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

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

Merge "[Bouncer] Move bouncer expansion callback out..." into tm-qpr-dev

parents e70c76e2 a3f1972f
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@ import com.android.systemui.dump.DumpManager
import com.android.systemui.flags.FeatureFlags
import com.android.systemui.flags.Flags
import com.android.systemui.keyguard.domain.interactor.AlternateBouncerInteractor
import com.android.systemui.keyguard.domain.interactor.PrimaryBouncerCallbackInteractor.PrimaryBouncerExpansionCallback
import com.android.systemui.keyguard.domain.interactor.PrimaryBouncerInteractor
import com.android.systemui.keyguard.shared.constants.KeyguardBouncerConstants
import com.android.systemui.lifecycle.repeatWhenAttached
@@ -41,7 +42,6 @@ import com.android.systemui.shade.ShadeExpansionStateManager
import com.android.systemui.statusbar.LockscreenShadeTransitionController
import com.android.systemui.statusbar.StatusBarState
import com.android.systemui.statusbar.notification.stack.StackStateAnimator
import com.android.systemui.statusbar.phone.KeyguardBouncer.PrimaryBouncerExpansionCallback
import com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager
import com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager.KeyguardViewManagerCallback
import com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager.LegacyAlternateBouncer
+4 −2
Original line number Diff line number Diff line
@@ -38,6 +38,7 @@ import com.android.systemui.dreams.complication.ComplicationHostViewController;
import com.android.systemui.dreams.dagger.DreamOverlayComponent;
import com.android.systemui.dreams.dagger.DreamOverlayModule;
import com.android.systemui.keyguard.domain.interactor.PrimaryBouncerCallbackInteractor;
import com.android.systemui.keyguard.domain.interactor.PrimaryBouncerCallbackInteractor.PrimaryBouncerExpansionCallback;
import com.android.systemui.statusbar.BlurUtils;
import com.android.systemui.statusbar.phone.KeyguardBouncer;
import com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager;
@@ -85,8 +86,9 @@ public class DreamOverlayContainerViewController extends ViewController<DreamOve

    private boolean mBouncerAnimating;

    private final KeyguardBouncer.PrimaryBouncerExpansionCallback mBouncerExpansionCallback =
            new KeyguardBouncer.PrimaryBouncerExpansionCallback() {
    private final PrimaryBouncerExpansionCallback
            mBouncerExpansionCallback =
            new PrimaryBouncerExpansionCallback() {

                @Override
                public void onStartingToShow() {
+45 −7
Original line number Diff line number Diff line
@@ -18,27 +18,29 @@ package com.android.systemui.keyguard.domain.interactor

import android.view.View
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.statusbar.phone.KeyguardBouncer
import com.android.systemui.keyguard.shared.constants.KeyguardBouncerConstants.EXPANSION_HIDDEN
import com.android.systemui.keyguard.shared.constants.KeyguardBouncerConstants.EXPANSION_VISIBLE
import com.android.systemui.util.ListenerSet
import javax.inject.Inject

/** Interactor to add and remove callbacks for the bouncer. */
@SysUISingleton
class PrimaryBouncerCallbackInteractor @Inject constructor() {
    private var resetCallbacks = ListenerSet<KeyguardBouncer.KeyguardResetCallback>()
    private var expansionCallbacks = ArrayList<KeyguardBouncer.PrimaryBouncerExpansionCallback>()
    private var resetCallbacks = ListenerSet<KeyguardResetCallback>()
    private var expansionCallbacks = ArrayList<PrimaryBouncerExpansionCallback>()

    /** Add a KeyguardResetCallback. */
    fun addKeyguardResetCallback(callback: KeyguardBouncer.KeyguardResetCallback) {
    fun addKeyguardResetCallback(callback: KeyguardResetCallback) {
        resetCallbacks.addIfAbsent(callback)
    }

    /** Remove a KeyguardResetCallback. */
    fun removeKeyguardResetCallback(callback: KeyguardBouncer.KeyguardResetCallback) {
    fun removeKeyguardResetCallback(callback: KeyguardResetCallback) {
        resetCallbacks.remove(callback)
    }

    /** Adds a callback to listen to bouncer expansion updates. */
    fun addBouncerExpansionCallback(callback: KeyguardBouncer.PrimaryBouncerExpansionCallback) {
    fun addBouncerExpansionCallback(callback: PrimaryBouncerExpansionCallback) {
        if (!expansionCallbacks.contains(callback)) {
            expansionCallbacks.add(callback)
        }
@@ -48,7 +50,7 @@ class PrimaryBouncerCallbackInteractor @Inject constructor() {
     * Removes a previously added callback. If the callback was never added, this method does
     * nothing.
     */
    fun removeBouncerExpansionCallback(callback: KeyguardBouncer.PrimaryBouncerExpansionCallback) {
    fun removeBouncerExpansionCallback(callback: PrimaryBouncerExpansionCallback) {
        expansionCallbacks.remove(callback)
    }

@@ -99,4 +101,40 @@ class PrimaryBouncerCallbackInteractor @Inject constructor() {
            callback.onKeyguardReset()
        }
    }

    /** Callback updated when the primary bouncer's show and hide states change. */
    interface PrimaryBouncerExpansionCallback {
        /**
         * Invoked when the bouncer expansion reaches [EXPANSION_VISIBLE]. This is NOT called each
         * time the bouncer is shown, but rather only when the fully shown amount has changed based
         * on the panel expansion. The bouncer's visibility can still change when the expansion
         * amount hasn't changed. See [PrimaryBouncerInteractor.isFullyShowing] for the checks for
         * the bouncer showing state.
         */
        fun onFullyShown() {}

        /** Invoked when the bouncer is starting to transition to a hidden state. */
        fun onStartingToHide() {}

        /** Invoked when the bouncer is starting to transition to a visible state. */
        fun onStartingToShow() {}

        /** Invoked when the bouncer expansion reaches [EXPANSION_HIDDEN]. */
        fun onFullyHidden() {}

        /**
         * From 0f [EXPANSION_VISIBLE] when fully visible to 1f [EXPANSION_HIDDEN] when fully hidden
         */
        fun onExpansionChanged(bouncerHideAmount: Float) {}

        /**
         * Invoked when visibility of KeyguardBouncer has changed. Note the bouncer expansion can be
         * [EXPANSION_VISIBLE], but the view's visibility can be [View.INVISIBLE].
         */
        fun onVisibilityChanged(isVisible: Boolean) {}
    }

    interface KeyguardResetCallback {
        fun onKeyguardReset()
    }
}
+2 −50
Original line number Diff line number Diff line
@@ -46,6 +46,8 @@ import com.android.systemui.DejankUtils;
import com.android.systemui.classifier.FalsingCollector;
import com.android.systemui.dagger.qualifiers.Main;
import com.android.systemui.keyguard.DismissCallbackRegistry;
import com.android.systemui.keyguard.domain.interactor.PrimaryBouncerCallbackInteractor.KeyguardResetCallback;
import com.android.systemui.keyguard.domain.interactor.PrimaryBouncerCallbackInteractor.PrimaryBouncerExpansionCallback;
import com.android.systemui.shared.system.SysUiStatsLog;
import com.android.systemui.statusbar.policy.KeyguardStateController;
import com.android.systemui.util.ListenerSet;
@@ -658,56 +660,6 @@ public class KeyguardBouncer {
        mExpansionCallbacks.remove(callback);
    }

    /**
     * Callback updated when the primary bouncer's show and hide states change.
     */
    public interface PrimaryBouncerExpansionCallback {
        /**
         * Invoked when the bouncer expansion reaches {@link KeyguardBouncer#EXPANSION_VISIBLE}.
         * This is NOT called each time the bouncer is shown, but rather only when the fully
         * shown amount has changed based on the panel expansion. The bouncer's visibility
         * can still change when the expansion amount hasn't changed.
         * See {@link KeyguardBouncer#isShowing()} for the checks for the bouncer showing state.
         */
        default void onFullyShown() {
        }

        /**
         * Invoked when the bouncer is starting to transition to a hidden state.
         */
        default void onStartingToHide() {
        }

        /**
         * Invoked when the bouncer is starting to transition to a visible state.
         */
        default void onStartingToShow() {
        }

        /**
         * Invoked when the bouncer expansion reaches {@link KeyguardBouncer#EXPANSION_HIDDEN}.
         */
        default 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) {}

        /**
         * Invoked when visibility of KeyguardBouncer has changed.
         * Note the bouncer expansion can be {@link KeyguardBouncer#EXPANSION_VISIBLE}, but the
         * view's visibility can be {@link View.INVISIBLE}.
         */
        default void onVisibilityChanged(boolean isVisible) {}
    }

    public interface KeyguardResetCallback {
        void onKeyguardReset();
    }

    /** Create a {@link KeyguardBouncer} once a container and bouncer callback are available. */
    public static class Factory {
        private final Context mContext;
+1 −1
Original line number Diff line number Diff line
@@ -62,6 +62,7 @@ import com.android.systemui.flags.Flags;
import com.android.systemui.keyguard.data.BouncerView;
import com.android.systemui.keyguard.domain.interactor.AlternateBouncerInteractor;
import com.android.systemui.keyguard.domain.interactor.PrimaryBouncerCallbackInteractor;
import com.android.systemui.keyguard.domain.interactor.PrimaryBouncerCallbackInteractor.PrimaryBouncerExpansionCallback;
import com.android.systemui.keyguard.domain.interactor.PrimaryBouncerInteractor;
import com.android.systemui.navigationbar.NavigationBarView;
import com.android.systemui.navigationbar.NavigationModeController;
@@ -78,7 +79,6 @@ import com.android.systemui.statusbar.NotificationShadeWindowController;
import com.android.systemui.statusbar.RemoteInputController;
import com.android.systemui.statusbar.StatusBarState;
import com.android.systemui.statusbar.SysuiStatusBarStateController;
import com.android.systemui.statusbar.phone.KeyguardBouncer.PrimaryBouncerExpansionCallback;
import com.android.systemui.statusbar.policy.ConfigurationController;
import com.android.systemui.statusbar.policy.KeyguardStateController;
import com.android.systemui.unfold.FoldAodAnimationController;
Loading