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

Commit 24b68453 authored by Beverly's avatar Beverly Committed by Beverly Tai
Browse files

Bring back lock icon w/ wallpaper color on LS

Current POR is to only hide the lock icon when udfps is enrolled

On the LS, change the color of the lock icon based on the wallpaper
color, else use textColorPrimary for the bouncer where the bouncer
is background is white.

Test: manual
Bug: 170228350
Change-Id: Iddedb3c7338f7a995e4787d1ec55bbee960b780d
parent 6f3ed806
Loading
Loading
Loading
Loading
+19 −0
Original line number Diff line number Diff line
@@ -289,6 +289,8 @@ public class KeyguardBouncer {
                    SysUiStatsLog.KEYGUARD_BOUNCER_STATE_CHANGED__STATE__HIDDEN);
            mDismissCallbackRegistry.notifyDismissCancelled();
        }
        mExpansion = EXPANSION_HIDDEN;
        dispatchExpansionChanged();
        mIsScrimmed = false;
        mFalsingCollector.onBouncerHidden();
        mCallback.onBouncerVisiblityChanged(false /* shown */);
@@ -377,6 +379,7 @@ public class KeyguardBouncer {
     */
    public void setExpansion(float fraction) {
        float oldExpansion = mExpansion;
        boolean expansionChanged = mExpansion != fraction;
        mExpansion = fraction;
        if (mKeyguardViewController != null && !mIsAnimatingAway) {
            mKeyguardViewController.setExpansion(fraction);
@@ -394,6 +397,10 @@ public class KeyguardBouncer {
                mKeyguardViewController.onStartingToHide();
            }
        }

        if (expansionChanged) {
            dispatchExpansionChanged();
        }
    }

    public boolean willDismissWithAction() {
@@ -518,6 +525,12 @@ public class KeyguardBouncer {
        }
    }

    private void dispatchExpansionChanged() {
        for (BouncerExpansionCallback callback : mExpansionCallbacks) {
            callback.onExpansionChanged(mExpansion);
        }
    }

    public void dump(PrintWriter pw) {
        pw.println("KeyguardBouncer");
        pw.println("  isShowing(): " + isShowing());
@@ -534,6 +547,12 @@ public class KeyguardBouncer {
        void onStartingToHide();
        void onStartingToShow();
        void onFullyHidden();

        /**
         * From 0f {@link KeyguardBouncer#EXPANSION_VISIBLE} when fully visible
         * to 1f {@link KeyguardBouncer#EXPANSION_HIDDEN} when fully hidden
         */
        default void onExpansionChanged(float bouncerHideAmount) {}
    }

    /** Create a {@link KeyguardBouncer} once a container and bouncer callback are available. */
+35 −11
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@ import static com.android.systemui.statusbar.phone.LockIcon.STATE_LOCKED;
import static com.android.systemui.statusbar.phone.LockIcon.STATE_LOCK_OPEN;
import static com.android.systemui.statusbar.phone.LockIcon.STATE_SCANNING_FACE;

import android.animation.ArgbEvaluator;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.content.res.TypedArray;
@@ -38,6 +39,7 @@ import com.android.internal.logging.nano.MetricsProto;
import com.android.internal.widget.LockPatternUtils;
import com.android.keyguard.KeyguardUpdateMonitor;
import com.android.keyguard.KeyguardUpdateMonitorCallback;
import com.android.settingslib.Utils;
import com.android.systemui.R;
import com.android.systemui.dagger.SysUISingleton;
import com.android.systemui.dagger.qualifiers.Main;
@@ -84,7 +86,7 @@ public class LockscreenLockIconController {
    private boolean mDocked;
    private boolean mWakeAndUnlockRunning;
    private boolean mShowingLaunchAffordance;
    private boolean mBouncerShowing;
    private float mBouncerHiddenAmount = KeyguardBouncer.EXPANSION_HIDDEN;
    private boolean mBouncerShowingScrimmed;
    private boolean mFingerprintUnlock;
    private int mStatusBarState = StatusBarState.SHADE;
@@ -104,6 +106,8 @@ public class LockscreenLockIconController {

            mSimLocked = mKeyguardUpdateMonitor.isSimPinSecure();
            mConfigurationListener.onThemeChanged();

            updateColor();
            update();
        }

@@ -348,7 +352,6 @@ public class LockscreenLockIconController {
     */
    public void attach(LockIcon lockIcon) {
        mLockIcon = lockIcon;
        updateColor();

        mLockIcon.setOnClickListener(this::handleClick);
        mLockIcon.setOnLongClickListener(this::handleLongClick);
@@ -408,20 +411,44 @@ public class LockscreenLockIconController {

    /** Sets whether the bouncer is showing. */
    public void setBouncerShowingScrimmed(boolean showing, boolean scrimmed) {
        mBouncerShowing = showing;
        mBouncerShowingScrimmed = scrimmed;
        update();
    }

    /**
     * Sets how hidden the bouncer is, where 0f is fully visible and 1f is fully hidden
     * See {@link KeyguardBouncer#EXPANSION_VISIBLE} and {@link KeyguardBouncer#EXPANSION_HIDDEN}.
     */
    public void setBouncerHideAmount(float hideAmount) {
        mBouncerHiddenAmount = hideAmount;
        updateColor();
    }

    private void updateColor() {
        if (mLockIcon == null) {
            return;
        }

        int iconColor = -1;
        if (mBouncerHiddenAmount == KeyguardBouncer.EXPANSION_VISIBLE) {
            TypedArray typedArray = mLockIcon.getContext().getTheme().obtainStyledAttributes(
                    null, new int[]{ android.R.attr.textColorPrimary }, 0, 0);
            iconColor = typedArray.getColor(0, Color.WHITE);
            typedArray.recycle();
        } else if (mBouncerHiddenAmount == KeyguardBouncer.EXPANSION_HIDDEN) {
            iconColor = Utils.getColorAttrDefaultColor(
                    mLockIcon.getContext(), com.android.systemui.R.attr.wallpaperTextColor);
        } else {
            // bouncer is transitioning
            TypedArray typedArray = mLockIcon.getContext().getTheme().obtainStyledAttributes(
                    null, new int[]{ android.R.attr.textColorPrimary }, 0, 0);
        int iconColor = typedArray.getColor(0, Color.WHITE);
            int bouncerIconColor = typedArray.getColor(0, Color.WHITE);
            typedArray.recycle();
            int keyguardIconColor = Utils.getColorAttrDefaultColor(
                    mLockIcon.getContext(), com.android.systemui.R.attr.wallpaperTextColor);
            iconColor = (int) new ArgbEvaluator().evaluate(
                    mBouncerHiddenAmount, bouncerIconColor, keyguardIconColor);
        }
        mLockIcon.updateColor(iconColor);
    }

@@ -520,10 +547,7 @@ public class LockscreenLockIconController {
            return changed;
        }
        boolean onAodOrDocked = mStatusBarStateController.isDozing() || mDocked;
        boolean onKeyguardWithoutBouncer = mStatusBarState == StatusBarState.KEYGUARD
                && !mBouncerShowing;
        boolean invisible = onAodOrDocked || mWakeAndUnlockRunning || mShowingLaunchAffordance
                || onKeyguardWithoutBouncer;
        boolean invisible = onAodOrDocked || mWakeAndUnlockRunning || mShowingLaunchAffordance;
        boolean fingerprintOrBypass = mFingerprintUnlock
                || mKeyguardBypassController.getBypassEnabled();
        if (fingerprintOrBypass && !mBouncerShowingScrimmed) {
+8 −0
Original line number Diff line number Diff line
@@ -3793,6 +3793,14 @@ public class StatusBar extends SystemUI implements DemoMode,
        }
    }

    /**
     * Sets how hidden the bouncer is, where 0f is fully visible and 1f is fully hidden
     * See {@link KeyguardBouncer#EXPANSION_VISIBLE} and {@link KeyguardBouncer#EXPANSION_HIDDEN}.
     */
    public void setBouncerHideAmount(float hideAmount) {
        mLockscreenLockIconController.setBouncerHideAmount(hideAmount);
    }

    /**
     * Collapses the notification shade if it is tracking or expanded.
     */
+5 −0
Original line number Diff line number Diff line
@@ -130,6 +130,11 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb
            updateStates();
            updateLockIcon();
        }

        @Override
        public void onExpansionChanged(float hideAmount) {
            mStatusBar.setBouncerHideAmount(hideAmount);
        }
    };
    private final DockManager.DockEventListener mDockEventListener =
            new DockManager.DockEventListener() {