Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7566abd3 authored by Michael Jurka's avatar Michael Jurka Committed by Android (Google) Code Review
Browse files

Merge "Add support for changing status widget on security screen" into jb-mr1-dev

parents c9cc62b9 20c41d53
Loading
Loading
Loading
Loading
+2 −2
Original line number Original line Diff line number Diff line
@@ -3219,8 +3219,8 @@ public final class Settings {
         * Id of the time appwidget on the lockscreen, or -1 if none
         * Id of the time appwidget on the lockscreen, or -1 if none
         * @hide
         * @hide
         */
         */
        public static final String LOCK_SCREEN_CLOCK_APPWIDGET_ID =
        public static final String LOCK_SCREEN_STATUS_APPWIDGET_ID =
            "lock_screen_clock_appwidget_id";
            "lock_screen_status_appwidget_id";


        /**
        /**
         * Id of the user-selected appwidget on the lockscreen, or -1 if none
         * Id of the user-selected appwidget on the lockscreen, or -1 if none
+11 −0
Original line number Original line Diff line number Diff line
@@ -1044,6 +1044,17 @@ public class LockPatternUtils {
        return new int[] { appWidgetId };
        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) {
    private long getLong(String secureSettingKey, long defaultValue) {
        try {
        try {
            return getLockSettings().getLong(secureSettingKey, defaultValue,
            return getLockSettings().getLong(secureSettingKey, defaultValue,
+18 −1
Original line number Original line Diff line number Diff line
@@ -33,7 +33,6 @@ import android.content.res.Resources;
import android.graphics.Canvas;
import android.graphics.Canvas;
import android.graphics.Rect;
import android.graphics.Rect;
import android.os.Looper;
import android.os.Looper;
import android.os.UserHandle;
import android.os.UserManager;
import android.os.UserManager;
import android.util.AttributeSet;
import android.util.AttributeSet;
import android.util.Log;
import android.util.Log;
@@ -42,6 +41,7 @@ import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.MotionEvent;
import android.view.View;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.view.WindowManager;
import android.view.animation.AnimationUtils;
import android.view.animation.AnimationUtils;
import android.widget.RemoteViews.OnClickHandler;
import android.widget.RemoteViews.OnClickHandler;
@@ -691,6 +691,23 @@ public class KeyguardHostView extends KeyguardViewBase {
        }
        }
        inflateAndAddUserSelectorWidgetIfNecessary();
        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();
        final int[] widgets = mLockPatternUtils.getUserDefinedWidgets();
        for (int i = 0; i < widgets.length; i++) {
        for (int i = 0; i < widgets.length; i++) {
            if (widgets[i] != -1) {
            if (widgets[i] != -1) {