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

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

Merge "[bc25] Refactor ShadeInteractor for Dual Shade Overlays." into main

parents da2ccf22 60985a39
Loading
Loading
Loading
Loading
+20 −0
Original line number Diff line number Diff line
@@ -87,6 +87,26 @@ class ShadeModeInteractorImplTest : SysuiTestCase() {
            assertThat(shadeMode).isEqualTo(ShadeMode.Dual)
        }

    @Test
    @EnableFlags(DualShade.FLAG_NAME)
    fun isDualShade_flagEnabled_true() =
        testScope.runTest {
            // Initiate collection.
            val shadeMode by collectLastValue(underTest.shadeMode)

            assertThat(underTest.isDualShade).isTrue()
        }

    @Test
    @DisableFlags(DualShade.FLAG_NAME)
    fun isDualShade_flagDisabled_false() =
        testScope.runTest {
            // Initiate collection.
            val shadeMode by collectLastValue(underTest.shadeMode)

            assertThat(underTest.isDualShade).isFalse()
        }

    @Test
    fun getTopEdgeSplitFraction_narrowScreen_splitInHalf() =
        testScope.runTest {
+7 −10
Original line number Diff line number Diff line
@@ -101,10 +101,10 @@ import com.android.systemui.navigationbar.views.buttons.KeyButtonView;
import com.android.systemui.recents.OverviewProxyService.OverviewProxyListener;
import com.android.systemui.scene.domain.interactor.SceneInteractor;
import com.android.systemui.scene.shared.flag.SceneContainerFlag;
import com.android.systemui.scene.shared.model.SceneFamilies;
import com.android.systemui.settings.DisplayTracker;
import com.android.systemui.settings.UserTracker;
import com.android.systemui.shade.ShadeViewController;
import com.android.systemui.shade.domain.interactor.ShadeInteractor;
import com.android.systemui.shared.recents.IOverviewProxy;
import com.android.systemui.shared.recents.ISystemUiProxy;
import com.android.systemui.shared.system.QuickStepContract;
@@ -158,6 +158,7 @@ public class OverviewProxyService implements CallbackController<OverviewProxyLis
    private final ScreenPinningRequest mScreenPinningRequest;
    private final NotificationShadeWindowController mStatusBarWinController;
    private final Provider<SceneInteractor> mSceneInteractor;
    private final Provider<ShadeInteractor> mShadeInteractor;

    private final KeyboardTouchpadEduStatsInteractor mKeyboardTouchpadEduStatsInteractor;

@@ -246,11 +247,8 @@ public class OverviewProxyService implements CallbackController<OverviewProxyLis
                            }
                        } else if (action == ACTION_UP) {
                            // Gesture was too short to be picked up by scene container touch
                            // handling; programmatically start the transition to shade scene.
                            mSceneInteractor.get().changeScene(
                                    SceneFamilies.NotifShade,
                                    "short launcher swipe"
                            );
                            // handling; programmatically start the transition to the shade.
                            mShadeInteractor.get().expandNotificationShade("short launcher swipe");
                        }
                    }
                    event.recycle();
@@ -267,10 +265,7 @@ public class OverviewProxyService implements CallbackController<OverviewProxyLis
                        mSceneInteractor.get().onRemoteUserInputStarted(
                                "trackpad swipe");
                    } else if (action == ACTION_UP) {
                        mSceneInteractor.get().changeScene(
                                SceneFamilies.NotifShade,
                                "short trackpad swipe"
                        );
                        mShadeInteractor.get().expandNotificationShade("short trackpad swipe");
                    }
                    mStatusBarWinController.getWindowRootView().dispatchTouchEvent(event);
                } else {
@@ -652,6 +647,7 @@ public class OverviewProxyService implements CallbackController<OverviewProxyLis
            NotificationShadeWindowController statusBarWinController,
            SysUiState sysUiState,
            Provider<SceneInteractor> sceneInteractor,
            Provider<ShadeInteractor> shadeInteractor,
            UserTracker userTracker,
            UserManager userManager,
            WakefulnessLifecycle wakefulnessLifecycle,
@@ -688,6 +684,7 @@ public class OverviewProxyService implements CallbackController<OverviewProxyLis
        mScreenPinningRequest = screenPinningRequest;
        mStatusBarWinController = statusBarWinController;
        mSceneInteractor = sceneInteractor;
        mShadeInteractor = shadeInteractor;
        mUserTracker = userTracker;
        mConnectionBackoffAttempts = 0;
        mRecentsComponentName = ComponentName.unflattenFromString(context.getString(
+5 −14
Original line number Diff line number Diff line
@@ -91,17 +91,14 @@ constructor(
    }

    override fun instantCollapseShade() {
        sceneInteractor.snapToScene(
            SceneFamilies.Home,
            "hide shade",
        )
        sceneInteractor.snapToScene(SceneFamilies.Home, "hide shade")
    }

    override fun animateCollapseShade(
        flags: Int,
        force: Boolean,
        delayed: Boolean,
        speedUpFactor: Float
        speedUpFactor: Float,
    ) {
        if (!force && !shadeInteractor.isAnyExpanded.value) {
            runPostCollapseActions()
@@ -147,7 +144,7 @@ constructor(
        if (shadeInteractor.isAnyExpanded.value) {
            commandQueue.animateCollapsePanels(
                CommandQueue.FLAG_EXCLUDE_RECENTS_PANEL,
                true /* force */
                true, /* force */
            )
            assistManagerLazy.get().hideAssist()
        }
@@ -172,17 +169,11 @@ constructor(
    }

    override fun expandToNotifications() {
        sceneInteractor.changeScene(
            SceneFamilies.NotifShade,
            "ShadeController.animateExpandShade",
        )
        shadeInteractor.expandNotificationShade("ShadeController.animateExpandShade")
    }

    override fun expandToQs() {
        sceneInteractor.changeScene(
            SceneFamilies.QuickSettings,
            "ShadeController.animateExpandQs",
        )
        shadeInteractor.expandQuickSettingsShade("ShadeController.animateExpandQs")
    }

    override fun setVisibilityListener(listener: ShadeVisibilityListener) {
+12 −0
Original line number Diff line number Diff line
@@ -140,6 +140,18 @@ interface BaseShadeInteractor {
     * animating.
     */
    val isUserInteractingWithQs: Flow<Boolean>

    /**
     * Triggers the expansion (opening) of the notification shade. If the notification shade is
     * already open, this has no effect.
     */
    fun expandNotificationShade(loggingReason: String)

    /**
     * Triggers the expansion (opening) of the quick settings shade. If the quick settings shade is
     * already open, this has no effect.
     */
    fun expandQuickSettingsShade(loggingReason: String)
}

fun createAnyExpansionFlow(
+4 −0
Original line number Diff line number Diff line
@@ -49,4 +49,8 @@ class ShadeInteractorEmptyImpl @Inject constructor() : ShadeInteractor {
    override val isShadeLayoutWide: StateFlow<Boolean> = inactiveFlowBoolean

    override fun getTopEdgeSplitFraction(): Float = 0.5f

    override fun expandNotificationShade(loggingReason: String) {}

    override fun expandQuickSettingsShade(loggingReason: String) {}
}
Loading