Persist reordering/deleting widgets on keyguard
Also, clean up warnings from unused imports Change-Id: Id0ef12a584ffdaa8a4fb64ffe93d0dda0af398ec
This commit is contained in:
@@ -16,10 +16,6 @@
|
||||
|
||||
package com.android.internal.widget;
|
||||
|
||||
import com.android.internal.R;
|
||||
import com.android.internal.telephony.ITelephony;
|
||||
import com.google.android.collect.Lists;
|
||||
|
||||
import android.app.ActivityManagerNative;
|
||||
import android.app.admin.DevicePolicyManager;
|
||||
import android.content.ContentResolver;
|
||||
@@ -42,12 +38,13 @@ import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
|
||||
import org.apache.harmony.kernel.vm.StringUtils;
|
||||
import com.android.internal.R;
|
||||
import com.android.internal.telephony.ITelephony;
|
||||
import com.google.android.collect.Lists;
|
||||
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.security.SecureRandom;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -127,6 +124,11 @@ public class LockPatternUtils {
|
||||
*/
|
||||
public static final int FLAG_BIOMETRIC_WEAK_LIVELINESS = 0x1;
|
||||
|
||||
/**
|
||||
* Pseudo-appwidget id we use to represent the default clock status widget
|
||||
*/
|
||||
public static final int ID_DEFAULT_STATUS_WIDGET = -2;
|
||||
|
||||
protected final static String LOCKOUT_PERMANENT_KEY = "lockscreen.lockedoutpermanently";
|
||||
protected final static String LOCKOUT_ATTEMPT_DEADLINE = "lockscreen.lockoutattemptdeadline";
|
||||
protected final static String PATTERN_EVER_CHOSEN_KEY = "lockscreen.patterneverchosen";
|
||||
@@ -1052,7 +1054,7 @@ public class LockPatternUtils {
|
||||
mContentResolver, Settings.Secure.LOCK_SCREEN_APPWIDGET_IDS,
|
||||
UserHandle.USER_CURRENT);
|
||||
String delims = ",";
|
||||
if (appWidgetIdString != null) {
|
||||
if (appWidgetIdString != null && appWidgetIdString.length() > 0) {
|
||||
String[] appWidgetStringIds = appWidgetIdString.split(delims);
|
||||
int[] appWidgetIds = new int[appWidgetStringIds.length];
|
||||
for (int i = 0; i < appWidgetStringIds.length; i++) {
|
||||
@@ -1060,12 +1062,17 @@ public class LockPatternUtils {
|
||||
try {
|
||||
appWidgetIds[i] = Integer.decode(appWidget);
|
||||
} catch (NumberFormatException e) {
|
||||
Log.d(TAG, "Error when parsing widget id " + appWidget);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return appWidgetIds;
|
||||
}
|
||||
return new int[0];
|
||||
if (appWidgetIdString == null) {
|
||||
return new int[] { LockPatternUtils.ID_DEFAULT_STATUS_WIDGET };
|
||||
} else {
|
||||
return new int[0];
|
||||
}
|
||||
}
|
||||
|
||||
private static String combineStrings(int[] list, String separator) {
|
||||
@@ -1111,8 +1118,15 @@ public class LockPatternUtils {
|
||||
UserHandle.USER_CURRENT);
|
||||
}
|
||||
|
||||
public void addAppWidget(int widgetId, int index) {
|
||||
// TODO: log an error if this returns false
|
||||
public boolean addAppWidget(int widgetId, int index) {
|
||||
int[] widgets = getAppWidgets();
|
||||
if (widgets == null) {
|
||||
return false;
|
||||
}
|
||||
if (index < 0 || index >= widgets.length) {
|
||||
return false;
|
||||
}
|
||||
int[] newWidgets = new int[widgets.length + 1];
|
||||
for (int i = 0, j = 0; i < newWidgets.length; i++) {
|
||||
if (index == i) {
|
||||
@@ -1125,17 +1139,19 @@ public class LockPatternUtils {
|
||||
}
|
||||
}
|
||||
writeAppWidgets(newWidgets);
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean removeAppWidget(int widgetId, int index) {
|
||||
public boolean removeAppWidget(int widgetId) {
|
||||
int[] widgets = getAppWidgets();
|
||||
|
||||
int[] newWidgets = new int[widgets.length - 1];
|
||||
for (int i = 0, j = 0; i < widgets.length; i++) {
|
||||
if (index == i) {
|
||||
if (widgets[i] != widgetId) {
|
||||
return false;
|
||||
}
|
||||
if (widgets[i] == widgetId) {
|
||||
// continue...
|
||||
} else if (j >= newWidgets.length) {
|
||||
// we couldn't find the widget
|
||||
return false;
|
||||
} else {
|
||||
newWidgets[j] = widgets[i];
|
||||
j++;
|
||||
|
||||
@@ -23,7 +23,6 @@ import android.os.SystemClock;
|
||||
import android.telephony.TelephonyManager;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.widget.Button;
|
||||
|
||||
import com.android.internal.telephony.IccCardConstants.State;
|
||||
|
||||
@@ -17,41 +17,22 @@
|
||||
package com.android.internal.policy.impl.keyguard;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.HapticFeedbackConstants;
|
||||
import android.view.View;
|
||||
import android.view.ViewParent;
|
||||
|
||||
import com.android.internal.widget.LockPatternUtils;
|
||||
import java.util.List;
|
||||
|
||||
import android.app.admin.DevicePolicyManager;
|
||||
import android.content.res.Configuration;
|
||||
import android.graphics.Rect;
|
||||
|
||||
import com.android.internal.widget.PasswordEntryKeyboardView;
|
||||
|
||||
import android.os.CountDownTimer;
|
||||
import android.os.SystemClock;
|
||||
import android.text.Editable;
|
||||
import android.text.InputType;
|
||||
import android.text.SpannableStringBuilder;
|
||||
import android.text.TextWatcher;
|
||||
import android.text.method.DigitsKeyListener;
|
||||
import android.text.method.TextKeyListener;
|
||||
import android.text.style.TextAppearanceSpan;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.HapticFeedbackConstants;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.View;
|
||||
import android.view.inputmethod.EditorInfo;
|
||||
import android.view.inputmethod.InputMethodInfo;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
import android.view.inputmethod.InputMethodSubtype;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
import android.widget.TextView.OnEditorActionListener;
|
||||
|
||||
import com.android.internal.R;
|
||||
import com.android.internal.widget.LockPatternUtils;
|
||||
|
||||
/**
|
||||
* Base class for PIN and password unlock screens.
|
||||
|
||||
@@ -27,7 +27,6 @@ import android.graphics.PorterDuff;
|
||||
import android.graphics.PorterDuffXfermode;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.RectF;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
@@ -161,7 +161,7 @@ public class KeyguardHostView extends KeyguardViewBase {
|
||||
mAppWidgetContainer.setMinScale(0.5f);
|
||||
|
||||
addDefaultWidgets();
|
||||
maybePopulateWidgets();
|
||||
addWidgetsFromSettings();
|
||||
|
||||
mViewStateManager = new KeyguardViewStateManager();
|
||||
SlidingChallengeLayout slider =
|
||||
@@ -170,6 +170,7 @@ public class KeyguardHostView extends KeyguardViewBase {
|
||||
slider.setOnChallengeScrolledListener(mViewStateManager);
|
||||
}
|
||||
mAppWidgetContainer.setViewStateManager(mViewStateManager);
|
||||
mAppWidgetContainer.setLockPatternUtils(mLockPatternUtils);
|
||||
|
||||
mViewStateManager.setPagedView(mAppWidgetContainer);
|
||||
mViewStateManager.setChallengeLayout(slider != null ? slider :
|
||||
@@ -635,7 +636,9 @@ public class KeyguardHostView extends KeyguardViewBase {
|
||||
if (navigationText != null) {
|
||||
view.setSecurityMessageDisplay(new KeyguardNavigationManager(navigationText));
|
||||
} else {
|
||||
view.setSecurityMessageDisplay(mKeyguardStatusViewManager);
|
||||
if (mKeyguardStatusViewManager != null) {
|
||||
view.setSecurityMessageDisplay(mKeyguardStatusViewManager);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -826,7 +829,8 @@ public class KeyguardHostView extends KeyguardViewBase {
|
||||
AppWidgetHostView view = getAppWidgetHost().createView(mContext, appId, appWidgetInfo);
|
||||
addWidget(view, pageIndex);
|
||||
} else {
|
||||
Log.w(TAG, "AppWidgetInfo was null; not adding widget id " + appId);
|
||||
Log.w(TAG, "AppWidgetInfo for app widget id " + appId + " was null, deleting");
|
||||
mLockPatternUtils.removeAppWidget(appId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -876,8 +880,6 @@ public class KeyguardHostView extends KeyguardViewBase {
|
||||
|
||||
View addWidget = inflater.inflate(R.layout.keyguard_add_widget, null, true);
|
||||
mAppWidgetContainer.addWidget(addWidget);
|
||||
View statusWidget = inflater.inflate(R.layout.keyguard_status_view, null, true);
|
||||
mAppWidgetContainer.addWidget(statusWidget);
|
||||
if (mContext.getResources().getBoolean(R.bool.kg_enable_camera_default_widget)) {
|
||||
View cameraWidget =
|
||||
CameraWidgetFrame.create(mContext, mCameraWidgetCallbacks, mActivityLauncher);
|
||||
@@ -950,12 +952,15 @@ public class KeyguardHostView extends KeyguardViewBase {
|
||||
});
|
||||
}
|
||||
|
||||
mKeyguardStatusViewManager = ((KeyguardStatusView)
|
||||
findViewById(R.id.keyguard_status_view_face_palm)).getManager();
|
||||
KeyguardStatusView ksv = (KeyguardStatusView)
|
||||
findViewById(R.id.keyguard_status_view_face_palm);
|
||||
if (ksv != null) {
|
||||
mKeyguardStatusViewManager = ksv.getManager();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void maybePopulateWidgets() {
|
||||
private void addWidgetsFromSettings() {
|
||||
DevicePolicyManager dpm =
|
||||
(DevicePolicyManager) mContext.getSystemService(Context.DEVICE_POLICY_SERVICE);
|
||||
if (dpm != null) {
|
||||
@@ -980,7 +985,11 @@ public class KeyguardHostView extends KeyguardViewBase {
|
||||
Log.d(TAG, "Problem reading widgets");
|
||||
} else {
|
||||
for (int i = widgets.length -1; i >= 0; i--) {
|
||||
if (widgets[i] != -1) {
|
||||
if (widgets[i] == LockPatternUtils.ID_DEFAULT_STATUS_WIDGET) {
|
||||
LayoutInflater inflater = LayoutInflater.from(mContext);
|
||||
View statusWidget = inflater.inflate(R.layout.keyguard_status_view, null, true);
|
||||
mAppWidgetContainer.addWidget(statusWidget, addPageIndex + 1);
|
||||
} else {
|
||||
// We add the widgets from left to right, starting after the first page after
|
||||
// the add page. We count down, since the order will be persisted from right
|
||||
// to left, starting after camera.
|
||||
@@ -1064,7 +1073,17 @@ public class KeyguardHostView extends KeyguardViewBase {
|
||||
pageToShow = multiUserPosition;
|
||||
} else {
|
||||
final View statusView = findViewById(R.id.keyguard_status_view);
|
||||
pageToShow = mAppWidgetContainer.indexOfChild(statusView);
|
||||
int statusViewIndex = mAppWidgetContainer.indexOfChild(statusView);
|
||||
if (statusViewIndex == -1) {
|
||||
// TEMP code for default page
|
||||
if (mAppWidgetContainer.getChildCount() > 2) {
|
||||
pageToShow = mAppWidgetContainer.getChildCount() - 2;
|
||||
} else {
|
||||
pageToShow = 0;
|
||||
}
|
||||
} else {
|
||||
pageToShow = mAppWidgetContainer.indexOfChild(statusView);
|
||||
}
|
||||
}
|
||||
if (mTransportState == TRANSPORT_VISIBLE) {
|
||||
mTransportState = TRANSPORT_INVISIBLE;
|
||||
|
||||
@@ -26,7 +26,6 @@ import android.content.res.Resources;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
|
||||
@@ -20,14 +20,13 @@ import android.app.ActivityManagerNative;
|
||||
import android.content.Context;
|
||||
import android.content.pm.UserInfo;
|
||||
import android.os.RemoteException;
|
||||
import android.os.UserManager;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.Log;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.WindowManagerGlobal;
|
||||
import android.widget.FrameLayout;
|
||||
|
||||
import com.android.internal.R;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
@@ -17,37 +17,12 @@
|
||||
package com.android.internal.policy.impl.keyguard;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
import android.view.ViewParent;
|
||||
|
||||
import com.android.internal.widget.LockPatternUtils;
|
||||
import java.util.List;
|
||||
|
||||
import android.app.admin.DevicePolicyManager;
|
||||
import android.content.res.Configuration;
|
||||
import android.graphics.Rect;
|
||||
|
||||
import com.android.internal.widget.PasswordEntryKeyboardView;
|
||||
|
||||
import android.os.CountDownTimer;
|
||||
import android.os.SystemClock;
|
||||
import android.text.Editable;
|
||||
import android.text.InputType;
|
||||
import android.text.SpannableStringBuilder;
|
||||
import android.text.TextWatcher;
|
||||
import android.text.method.DigitsKeyListener;
|
||||
import android.text.method.TextKeyListener;
|
||||
import android.text.style.TextAppearanceSpan;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.inputmethod.EditorInfo;
|
||||
import android.view.inputmethod.InputMethodInfo;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
import android.view.inputmethod.InputMethodSubtype;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
import android.widget.TextView.OnEditorActionListener;
|
||||
|
||||
import com.android.internal.R;
|
||||
@@ -126,4 +101,4 @@ public class KeyguardPINView extends KeyguardAbsKeyInputView
|
||||
@Override
|
||||
public void showUsabilityHint() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,38 +16,26 @@
|
||||
|
||||
package com.android.internal.policy.impl.keyguard;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
|
||||
import com.android.internal.R;
|
||||
import com.android.internal.widget.LockPatternUtils;
|
||||
import java.util.List;
|
||||
|
||||
import android.app.admin.DevicePolicyManager;
|
||||
import android.content.Context;
|
||||
import android.content.res.Configuration;
|
||||
import android.graphics.Rect;
|
||||
|
||||
import com.android.internal.widget.PasswordEntryKeyboardView;
|
||||
|
||||
import android.os.CountDownTimer;
|
||||
import android.os.SystemClock;
|
||||
import android.text.Editable;
|
||||
import android.text.InputType;
|
||||
import android.text.TextWatcher;
|
||||
import android.text.method.DigitsKeyListener;
|
||||
import android.text.method.TextKeyListener;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.inputmethod.EditorInfo;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
import android.view.inputmethod.InputMethodInfo;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
import android.view.inputmethod.InputMethodSubtype;
|
||||
import android.widget.EditText;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
import android.widget.TextView.OnEditorActionListener;
|
||||
|
||||
import com.android.internal.R;
|
||||
import com.android.internal.widget.PasswordEntryKeyboardHelper;
|
||||
import com.android.internal.widget.PasswordEntryKeyboardView;
|
||||
|
||||
import java.util.List;
|
||||
/**
|
||||
* Displays an alphanumeric (latin-1) key entry for the user to enter
|
||||
* an unlock password
|
||||
|
||||
@@ -20,6 +20,8 @@ import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.widget.GridLayout;
|
||||
|
||||
import com.android.internal.widget.LockPatternUtils;
|
||||
|
||||
public class KeyguardStatusView extends GridLayout {
|
||||
@SuppressWarnings("unused")
|
||||
private KeyguardStatusViewManager mStatusViewManager;
|
||||
@@ -36,6 +38,10 @@ public class KeyguardStatusView extends GridLayout {
|
||||
super(context, attrs, defStyle);
|
||||
}
|
||||
|
||||
public int getAppWidgetId() {
|
||||
return LockPatternUtils.ID_DEFAULT_STATUS_WIDGET;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onFinishInflate() {
|
||||
super.onFinishInflate();
|
||||
|
||||
@@ -16,15 +16,6 @@
|
||||
|
||||
package com.android.internal.policy.impl.keyguard;
|
||||
|
||||
import com.android.internal.R;
|
||||
import com.android.internal.telephony.IccCardConstants;
|
||||
import com.android.internal.widget.DigitalClock;
|
||||
import com.android.internal.widget.LockPatternUtils;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import libcore.util.MutableInt;
|
||||
|
||||
import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
@@ -39,6 +30,10 @@ import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.android.internal.R;
|
||||
import com.android.internal.telephony.IccCardConstants;
|
||||
import com.android.internal.widget.LockPatternUtils;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import libcore.util.MutableInt;
|
||||
|
||||
@@ -16,17 +16,15 @@
|
||||
|
||||
package com.android.internal.policy.impl.keyguard;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
|
||||
import android.app.PendingIntent;
|
||||
import android.app.PendingIntent.CanceledException;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Bitmap;
|
||||
import android.media.AudioManager;
|
||||
import android.media.IRemoteControlDisplay;
|
||||
import android.media.MediaMetadataRetriever;
|
||||
import android.media.RemoteControlClient;
|
||||
import android.media.IRemoteControlDisplay;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
@@ -42,11 +40,12 @@ import android.util.Log;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.android.internal.R;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
/**
|
||||
* This is the widget responsible for showing music controls in keyguard.
|
||||
*/
|
||||
@@ -264,7 +263,7 @@ public class KeyguardTransportControlView extends KeyguardWidgetFrame implements
|
||||
@Override
|
||||
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
|
||||
int dim = Math.min(MAXDIM, Math.max(getWidth(), getHeight()));
|
||||
// int dim = Math.min(MAXDIM, Math.max(getWidth(), getHeight()));
|
||||
// Log.v(TAG, "setting max bitmap size: " + dim + "x" + dim);
|
||||
// mAudioManager.remoteControlDisplayUsesBitmapSize(mIRCD, dim, dim);
|
||||
}
|
||||
|
||||
@@ -46,7 +46,6 @@ import android.util.EventLog;
|
||||
import android.util.Log;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.WindowManager;
|
||||
import android.view.WindowManagerGlobal;
|
||||
import android.view.WindowManagerPolicy;
|
||||
|
||||
import com.android.internal.telephony.IccCardConstants;
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package com.android.internal.policy.impl.keyguard;
|
||||
|
||||
import android.appwidget.AppWidgetHostView;
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Canvas;
|
||||
@@ -26,8 +27,6 @@ import android.graphics.PorterDuffXfermode;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.Shader;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.PowerManager;
|
||||
import android.os.SystemClock;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
@@ -169,6 +168,15 @@ public class KeyguardWidgetFrame extends FrameLayout {
|
||||
return getChildAt(0);
|
||||
}
|
||||
|
||||
public int getContentAppWidgetId() {
|
||||
View content = getContent();
|
||||
if (content instanceof AppWidgetHostView) {
|
||||
return ((AppWidgetHostView) content).getAppWidgetId();
|
||||
} else {
|
||||
return ((KeyguardStatusView) content).getAppWidgetId();
|
||||
}
|
||||
}
|
||||
|
||||
private void drawGradientOverlay(Canvas c) {
|
||||
mGradientPaint.setShader(mForegroundGradient);
|
||||
mGradientPaint.setAlpha(mForegroundAlpha);
|
||||
|
||||
@@ -30,7 +30,7 @@ import android.view.animation.AccelerateInterpolator;
|
||||
import android.view.animation.DecelerateInterpolator;
|
||||
import android.widget.FrameLayout;
|
||||
|
||||
import com.android.internal.R;
|
||||
import com.android.internal.widget.LockPatternUtils;
|
||||
|
||||
public class KeyguardWidgetPager extends PagedView implements PagedView.PageSwitchListener,
|
||||
OnLongClickListener {
|
||||
@@ -44,6 +44,7 @@ public class KeyguardWidgetPager extends PagedView implements PagedView.PageSwit
|
||||
private AccelerateInterpolator mAlphaInterpolator = new AccelerateInterpolator(0.9f);
|
||||
private DecelerateInterpolator mLeftScreenAlphaInterpolator = new DecelerateInterpolator(4);
|
||||
private KeyguardViewStateManager mViewStateManager;
|
||||
private LockPatternUtils mLockPatternUtils;
|
||||
|
||||
// Related to the fading in / out background outlines
|
||||
private static final int CHILDREN_OUTLINE_FADE_OUT_DELAY = 0;
|
||||
@@ -81,6 +82,10 @@ public class KeyguardWidgetPager extends PagedView implements PagedView.PageSwit
|
||||
mViewStateManager = viewStateManager;
|
||||
}
|
||||
|
||||
public void setLockPatternUtils(LockPatternUtils l) {
|
||||
mLockPatternUtils = l;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPageSwitch(View newPage, int newPageIndex) {
|
||||
boolean showingStatusWidget = false;
|
||||
@@ -150,6 +155,21 @@ public class KeyguardWidgetPager extends PagedView implements PagedView.PageSwit
|
||||
addWidget(widget, -1);
|
||||
}
|
||||
|
||||
|
||||
public void onRemoveView(View v) {
|
||||
int appWidgetId = ((KeyguardWidgetFrame) v).getContentAppWidgetId();
|
||||
mLockPatternUtils.removeAppWidget(appWidgetId);
|
||||
}
|
||||
|
||||
public void onAddView(View v, int index) {
|
||||
int appWidgetId = ((KeyguardWidgetFrame) v).getContentAppWidgetId();
|
||||
getVisiblePages(mTempVisiblePagesRange);
|
||||
boundByReorderablePages(true, mTempVisiblePagesRange);
|
||||
// Subtract from the index to take into account pages before the reorderable
|
||||
// pages (e.g. the "add widget" page)
|
||||
mLockPatternUtils.addAppWidget(appWidgetId, index - mTempVisiblePagesRange[0]);
|
||||
}
|
||||
|
||||
/*
|
||||
* We wrap widgets in a special frame which handles drawing the over scroll foreground.
|
||||
*/
|
||||
@@ -305,7 +325,6 @@ public class KeyguardWidgetPager extends PagedView implements PagedView.PageSwit
|
||||
KeyguardWidgetFrame child = getWidgetPageAt(i);
|
||||
if (child != null) {
|
||||
float scrollProgress = getScrollProgress(screenCenter, child, i);
|
||||
float alpha = 1 - Math.abs(scrollProgress);
|
||||
// TODO: Set content alpha
|
||||
if (!isReordering(false)) {
|
||||
child.setBackgroundAlphaMultiplier(
|
||||
|
||||
@@ -24,7 +24,6 @@ import android.util.AttributeSet;
|
||||
import android.view.HapticFeedbackConstants;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.android.internal.R;
|
||||
|
||||
@@ -20,7 +20,6 @@ import android.animation.Animator;
|
||||
import android.animation.AnimatorListenerAdapter;
|
||||
import android.animation.AnimatorSet;
|
||||
import android.animation.ObjectAnimator;
|
||||
import android.animation.PropertyValuesHolder;
|
||||
import android.animation.TimeInterpolator;
|
||||
import android.animation.ValueAnimator;
|
||||
import android.animation.ValueAnimator.AnimatorUpdateListener;
|
||||
@@ -43,8 +42,6 @@ import android.view.View;
|
||||
import android.view.ViewConfiguration;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.ViewParent;
|
||||
import android.view.View.MeasureSpec;
|
||||
import android.view.ViewGroup.LayoutParams;
|
||||
import android.view.accessibility.AccessibilityEvent;
|
||||
import android.view.accessibility.AccessibilityManager;
|
||||
import android.view.accessibility.AccessibilityNodeInfo;
|
||||
@@ -61,7 +58,7 @@ import java.util.ArrayList;
|
||||
* An abstraction of the original Workspace which supports browsing through a
|
||||
* sequential list of "pages"
|
||||
*/
|
||||
public class PagedView extends ViewGroup implements ViewGroup.OnHierarchyChangeListener {
|
||||
public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarchyChangeListener {
|
||||
private static final String TAG = "WidgetPagedView";
|
||||
private static final boolean DEBUG = false;
|
||||
protected static final int INVALID_PAGE = -1;
|
||||
@@ -1400,7 +1397,9 @@ public class PagedView extends ViewGroup implements ViewGroup.OnHierarchyChangeL
|
||||
}
|
||||
|
||||
removeView(mDragView);
|
||||
onRemoveView(mDragView);
|
||||
addView(mDragView, pageUnderPointIndex);
|
||||
onAddView(mDragView, pageUnderPointIndex);
|
||||
mSidePageHoverIndex = -1;
|
||||
}
|
||||
};
|
||||
@@ -1511,6 +1510,10 @@ public class PagedView extends ViewGroup implements ViewGroup.OnHierarchyChangeL
|
||||
return true;
|
||||
}
|
||||
|
||||
//public abstract void onFlingToDelete(View v);
|
||||
public abstract void onRemoveView(View v);
|
||||
public abstract void onAddView(View v, int index);
|
||||
|
||||
private void resetTouchState() {
|
||||
releaseVelocityTracker();
|
||||
endReordering();
|
||||
@@ -2159,7 +2162,6 @@ public class PagedView extends ViewGroup implements ViewGroup.OnHierarchyChangeL
|
||||
};
|
||||
|
||||
public void onFlingToDelete(PointF vel) {
|
||||
final ViewConfiguration config = ViewConfiguration.get(getContext());
|
||||
final long startTime = AnimationUtils.currentAnimationTimeMillis();
|
||||
|
||||
// NOTE: Because it takes time for the first frame of animation to actually be
|
||||
@@ -2245,6 +2247,7 @@ public class PagedView extends ViewGroup implements ViewGroup.OnHierarchyChangeL
|
||||
}
|
||||
|
||||
removeView(dragView);
|
||||
onRemoveView(dragView);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user