Merge "Add support for changing status widget on security screen" into jb-mr1-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
7566abd305
@@ -3219,8 +3219,8 @@ public final class Settings {
|
||||
* Id of the time appwidget on the lockscreen, or -1 if none
|
||||
* @hide
|
||||
*/
|
||||
public static final String LOCK_SCREEN_CLOCK_APPWIDGET_ID =
|
||||
"lock_screen_clock_appwidget_id";
|
||||
public static final String LOCK_SCREEN_STATUS_APPWIDGET_ID =
|
||||
"lock_screen_status_appwidget_id";
|
||||
|
||||
/**
|
||||
* Id of the user-selected appwidget on the lockscreen, or -1 if none
|
||||
|
||||
@@ -1044,6 +1044,17 @@ public class LockPatternUtils {
|
||||
return new int[] { appWidgetId };
|
||||
}
|
||||
|
||||
public int getStatusWidget() {
|
||||
int appWidgetId = -1;
|
||||
String appWidgetIdString = Settings.Secure.getString(
|
||||
mContentResolver, Settings.Secure.LOCK_SCREEN_STATUS_APPWIDGET_ID);
|
||||
if (appWidgetIdString != null) {
|
||||
appWidgetId = (int) Integer.decode(appWidgetIdString);
|
||||
}
|
||||
|
||||
return appWidgetId;
|
||||
}
|
||||
|
||||
private long getLong(String secureSettingKey, long defaultValue) {
|
||||
try {
|
||||
return getLockSettings().getLong(secureSettingKey, defaultValue,
|
||||
|
||||
@@ -33,7 +33,6 @@ import android.content.res.Resources;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Rect;
|
||||
import android.os.Looper;
|
||||
import android.os.UserHandle;
|
||||
import android.os.UserManager;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.Log;
|
||||
@@ -42,6 +41,7 @@ import android.view.KeyEvent;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.WindowManager;
|
||||
import android.view.animation.AnimationUtils;
|
||||
import android.widget.RemoteViews.OnClickHandler;
|
||||
@@ -691,6 +691,23 @@ public class KeyguardHostView extends KeyguardViewBase {
|
||||
}
|
||||
inflateAndAddUserSelectorWidgetIfNecessary();
|
||||
|
||||
// Add status widget
|
||||
int statusWidgetId = mLockPatternUtils.getStatusWidget();
|
||||
if (statusWidgetId != -1) {
|
||||
addWidget(statusWidgetId);
|
||||
View newStatusWidget = mAppWidgetContainer.getChildAt(
|
||||
mAppWidgetContainer.getChildCount() - 1);
|
||||
|
||||
int oldStatusWidgetPosition = getWidgetPosition(R.id.keyguard_status_view);
|
||||
mAppWidgetContainer.removeViewAt(oldStatusWidgetPosition);
|
||||
|
||||
// Re-add new status widget at position of old one
|
||||
mAppWidgetContainer.removeView(newStatusWidget);
|
||||
newStatusWidget.setId(R.id.keyguard_status_view);
|
||||
mAppWidgetContainer.addView(newStatusWidget, oldStatusWidgetPosition);
|
||||
}
|
||||
|
||||
// Add user-selected widget
|
||||
final int[] widgets = mLockPatternUtils.getUserDefinedWidgets();
|
||||
for (int i = 0; i < widgets.length; i++) {
|
||||
if (widgets[i] != -1) {
|
||||
|
||||
Reference in New Issue
Block a user