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

Commit d1ea1214 authored by Lucas Dupin's avatar Lucas Dupin Committed by Android (Google) Code Review
Browse files

Merge "Bring back lock icon w/ wallpaper color on LS"

parents 1fa042b6 24b68453
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() {