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

Commit 3cd6d0ee authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Lock Screen - Update layouts"

parents da8f20e6 10db54e0
Loading
Loading
Loading
Loading
+35 −0
Original line number Diff line number Diff line
@@ -104,6 +104,8 @@ public class KeyguardClockSwitch extends RelativeLayout {
    private boolean mSupportsDarkText;
    private int[] mColorPalette;

    private int mLockScreenMode = KeyguardUpdateMonitor.LOCK_SCREEN_MODE_NORMAL;

    public KeyguardClockSwitch(Context context, AttributeSet attrs) {
        super(context, attrs);

@@ -128,6 +130,35 @@ public class KeyguardClockSwitch extends RelativeLayout {
        return mClockPlugin != null;
    }

    /**
      * Update lock screen mode for testing different layouts
      */
    public void updateLockScreenMode(int mode) {
        mLockScreenMode = mode;
        RelativeLayout.LayoutParams statusAreaLP = (RelativeLayout.LayoutParams)
                mKeyguardStatusArea.getLayoutParams();
        RelativeLayout.LayoutParams clockLP = (RelativeLayout.LayoutParams)
                mSmallClockFrame.getLayoutParams();

        if (mode == KeyguardUpdateMonitor.LOCK_SCREEN_MODE_LAYOUT_1) {
            statusAreaLP.removeRule(RelativeLayout.BELOW);
            statusAreaLP.addRule(RelativeLayout.LEFT_OF, R.id.clock_view);
            statusAreaLP.addRule(RelativeLayout.ALIGN_PARENT_START);

            clockLP.addRule(RelativeLayout.ALIGN_PARENT_END);
            clockLP.width = ViewGroup.LayoutParams.WRAP_CONTENT;
        } else {
            statusAreaLP.removeRule(RelativeLayout.LEFT_OF);
            statusAreaLP.removeRule(RelativeLayout.ALIGN_PARENT_START);
            statusAreaLP.addRule(RelativeLayout.BELOW, R.id.clock_view);

            clockLP.removeRule(RelativeLayout.ALIGN_PARENT_END);
            clockLP.width = ViewGroup.LayoutParams.MATCH_PARENT;
        }

        requestLayout();
    }

    @Override
    protected void onFinishInflate() {
        super.onFinishInflate();
@@ -363,6 +394,10 @@ public class KeyguardClockSwitch extends RelativeLayout {
     * these cases.
     */
    void setKeyguardShowingHeader(boolean hasHeader) {
        if (mLockScreenMode != KeyguardUpdateMonitor.LOCK_SCREEN_MODE_NORMAL) {
            hasHeader = false;
        }

        if (mShowingHeader == hasHeader) {
            return;
        }
+9 −0
Original line number Diff line number Diff line
@@ -78,6 +78,11 @@ public class KeyguardStatusView extends GridLayout implements

    private KeyguardUpdateMonitorCallback mInfoCallback = new KeyguardUpdateMonitorCallback() {

        @Override
        public void onLockScreenModeChanged(int mode) {
            updateLockScreenMode(mode);
        }

        @Override
        public void onTimeChanged() {
            refreshTime();
@@ -255,6 +260,10 @@ public class KeyguardStatusView extends GridLayout implements
        mClockView.refresh();
    }

    private void updateLockScreenMode(int mode) {
        mClockView.updateLockScreenMode(mode);
    }

    private void updateTimeZone(TimeZone timeZone) {
        mClockView.onTimeZoneChanged(timeZone);
    }
+46 −0
Original line number Diff line number Diff line
@@ -180,6 +180,10 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
    private static final int MSG_USER_STOPPED = 340;
    private static final int MSG_USER_REMOVED = 341;
    private static final int MSG_KEYGUARD_GOING_AWAY = 342;
    private static final int MSG_LOCK_SCREEN_MODE = 343;

    public static final int LOCK_SCREEN_MODE_NORMAL = 0;
    public static final int LOCK_SCREEN_MODE_LAYOUT_1 = 1;

    /** Biometric authentication state: Not listening. */
    private static final int BIOMETRIC_STATE_STOPPED = 0;
@@ -263,6 +267,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
    private final ArrayList<WeakReference<KeyguardUpdateMonitorCallback>>
            mCallbacks = Lists.newArrayList();
    private ContentObserver mDeviceProvisionedObserver;
    private ContentObserver mLockScreenModeObserver;

    private boolean mSwitchingUser;

@@ -286,6 +291,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
    private boolean mLockIconPressed;
    private int mActiveMobileDataSubscription = SubscriptionManager.INVALID_SUBSCRIPTION_ID;
    private final Executor mBackgroundExecutor;
    private int mLockScreenMode;

    /**
     * Short delay before restarting fingerprint authentication after a successful try. This should
@@ -1694,6 +1700,9 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
                    case MSG_KEYGUARD_GOING_AWAY:
                        handleKeyguardGoingAway((boolean) msg.obj);
                        break;
                    case MSG_LOCK_SCREEN_MODE:
                        handleLockScreenMode();
                        break;
                    default:
                        super.handleMessage(msg);
                        break;
@@ -1828,6 +1837,23 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
                }
            }
        }

        updateLockScreenMode();
        mLockScreenModeObserver = new ContentObserver(mHandler) {
            @Override
            public void onChange(boolean selfChange) {
                updateLockScreenMode();
                mHandler.sendEmptyMessage(MSG_LOCK_SCREEN_MODE);
            }
        };
        mContext.getContentResolver().registerContentObserver(
                Settings.Global.getUriFor(Settings.Global.SHOW_NEW_LOCKSCREEN),
                false, mLockScreenModeObserver);
    }

    private void updateLockScreenMode() {
        mLockScreenMode = Settings.Global.getInt(mContext.getContentResolver(),
                Settings.Global.SHOW_NEW_LOCKSCREEN, 0);
    }

    private final UserSwitchObserver mUserSwitchObserver = new UserSwitchObserver() {
@@ -2349,6 +2375,20 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
        }
    }

    /**
     * Handle {@link #MSG_LOCK_SCREEN_MODE}
     */
    private void handleLockScreenMode() {
        Assert.isMainThread();
        if (DEBUG) Log.d(TAG, "handleLockScreenMode(" + mLockScreenMode + ")");
        for (int i = 0; i < mCallbacks.size(); i++) {
            KeyguardUpdateMonitorCallback cb = mCallbacks.get(i).get();
            if (cb != null) {
                cb.onLockScreenModeChanged(mLockScreenMode);
            }
        }
    }

    /**
     * Handle (@line #MSG_TIMEZONE_UPDATE}
     */
@@ -2668,6 +2708,8 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
        callback.onClockVisibilityChanged();
        callback.onKeyguardVisibilityChangedRaw(mKeyguardIsVisible);
        callback.onTelephonyCapable(mTelephonyCapable);
        callback.onLockScreenModeChanged(mLockScreenMode);

        for (Entry<Integer, SimData> data : mSimDatas.entrySet()) {
            final SimData state = data.getValue();
            callback.onSimStateChanged(state.subId, state.slotId, state.simState);
@@ -2959,6 +3001,10 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
            mContext.getContentResolver().unregisterContentObserver(mDeviceProvisionedObserver);
        }

        if (mLockScreenModeObserver != null) {
            mContext.getContentResolver().unregisterContentObserver(mLockScreenModeObserver);
        }

        try {
            ActivityManager.getService().unregisterUserSwitchObserver(mUserSwitchObserver);
        } catch (RemoteException e) {
+5 −0
Original line number Diff line number Diff line
@@ -317,4 +317,9 @@ public class KeyguardUpdateMonitorCallback {
     */
    public void onSecondaryLockscreenRequirementChanged(int userId) { }

    /**
     * Called to switch lock screen layout/clock layouts
     */
    public void onLockScreenModeChanged(int mode) { }

}
+13 −0
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@ import android.content.res.Resources;
import android.util.MathUtils;

import com.android.keyguard.KeyguardStatusView;
import com.android.keyguard.KeyguardUpdateMonitor;
import com.android.systemui.Interpolators;
import com.android.systemui.R;

@@ -122,6 +123,8 @@ public class KeyguardClockPositionAlgorithm {
     */
    private int mUnlockedStackScrollerPadding;

    private int mLockScreenMode;

    /**
     * Refreshes the dimension values.
     */
@@ -171,6 +174,13 @@ public class KeyguardClockPositionAlgorithm {
        result.clockX = (int) interpolate(0, burnInPreventionOffsetX(), mDarkAmount);
    }

    /**
      * Update lock screen mode for testing different layouts
      */
    public void onLockScreenModeChanged(int mode) {
        mLockScreenMode = mode;
    }

    public float getMinStackScrollerPadding() {
        return mBypassEnabled ? mUnlockedStackScrollerPadding
                : mMinTopMargin + mKeyguardStatusHeight + mClockNotificationsMargin;
@@ -185,6 +195,9 @@ public class KeyguardClockPositionAlgorithm {
    }

    private int getExpandedPreferredClockY() {
        if (mLockScreenMode != KeyguardUpdateMonitor.LOCK_SCREEN_MODE_NORMAL) {
            return mMinTopMargin;
        }
        return (mHasCustomClock && (!mHasVisibleNotifs || mBypassEnabled)) ? getPreferredClockY()
                : getExpandedClockPosition();
    }
Loading