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

Commit 3c39be1f authored by Justin Weir's avatar Justin Weir Committed by Android (Google) Code Review
Browse files

Merge "Extract back handling from CentralSurfaces" into udc-qpr-dev

parents 4927ffbe 43766b71
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -118,6 +118,14 @@ public interface KeyguardViewController {
     */
    boolean isUnlockWithWallpaper();

    /**
     * @return Whether the bouncer over dream is showing. Note that the bouncer over dream is
     * handled independently of the rest of the notification panel. As a result, setting this state
     * via {@link CentralSurfaces#setBouncerShowing(boolean)} leads to unintended side effects from
     * states modified behind the dream.
     */
    boolean isBouncerShowingOverDream();

    /**
     * @return Whether subtle animation should be used for unlocking the device.
     */
+77 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2023 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.systemui.back.domain.interactor

import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.plugins.statusbar.StatusBarStateController
import com.android.systemui.shade.QuickSettingsController
import com.android.systemui.shade.ShadeController
import com.android.systemui.shade.ShadeViewController
import com.android.systemui.statusbar.StatusBarState
import com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager
import javax.inject.Inject

/** Handles requests to go back either from a button or gesture. */
@SysUISingleton
class BackActionInteractor
@Inject
constructor(
    private val statusBarStateController: StatusBarStateController,
    private val statusBarKeyguardViewManager: StatusBarKeyguardViewManager,
    private val shadeController: ShadeController
) {
    private lateinit var shadeViewController: ShadeViewController
    private lateinit var qsController: QuickSettingsController

    fun setup(qsController: QuickSettingsController, svController: ShadeViewController) {
        this.qsController = qsController
        this.shadeViewController = svController
    }

    fun shouldBackBeHandled(): Boolean {
        return statusBarStateController.state != StatusBarState.KEYGUARD &&
            statusBarStateController.state != StatusBarState.SHADE_LOCKED &&
            !statusBarKeyguardViewManager.isBouncerShowingOverDream
    }

    fun onBackRequested(): Boolean {
        if (statusBarKeyguardViewManager.canHandleBackPressed()) {
            statusBarKeyguardViewManager.onBackPressed()
            return true
        }
        if (qsController.isCustomizing) {
            qsController.closeQsCustomizer()
            return true
        }
        if (qsController.expanded) {
            shadeViewController.animateCollapseQs(false)
            return true
        }
        if (shadeViewController.closeUserSwitcherIfOpen()) {
            return true
        }
        if (shouldBackBeHandled()) {
            if (shadeViewController.canBeCollapsed()) {
                // this is the Shade dismiss animation, so make sure QQS closes when it ends.
                shadeViewController.onBackPressed()
                shadeController.animateCollapseShade()
            }
            return true
        }
        return false
    }
}
+8 −4
Original line number Diff line number Diff line
@@ -40,18 +40,19 @@ import com.android.keyguard.KeyguardMessageAreaController;
import com.android.keyguard.LockIconViewController;
import com.android.keyguard.dagger.KeyguardBouncerComponent;
import com.android.systemui.R;
import com.android.systemui.back.domain.interactor.BackActionInteractor;
import com.android.systemui.bouncer.domain.interactor.BouncerMessageInteractor;
import com.android.systemui.bouncer.ui.binder.KeyguardBouncerViewBinder;
import com.android.systemui.bouncer.ui.viewmodel.KeyguardBouncerViewModel;
import com.android.systemui.classifier.FalsingCollector;
import com.android.systemui.compose.ComposeFacade;
import com.android.systemui.dock.DockManager;
import com.android.systemui.flags.FeatureFlags;
import com.android.systemui.flags.Flags;
import com.android.systemui.keyguard.KeyguardUnlockAnimationController;
import com.android.systemui.bouncer.domain.interactor.BouncerMessageInteractor;
import com.android.systemui.keyguard.domain.interactor.KeyguardTransitionInteractor;
import com.android.systemui.keyguard.shared.model.TransitionState;
import com.android.systemui.keyguard.shared.model.TransitionStep;
import com.android.systemui.bouncer.ui.binder.KeyguardBouncerViewBinder;
import com.android.systemui.bouncer.ui.viewmodel.KeyguardBouncerViewModel;
import com.android.systemui.keyguard.ui.viewmodel.PrimaryBouncerToGoneTransitionViewModel;
import com.android.systemui.log.BouncerLogger;
import com.android.systemui.multishade.domain.interactor.MultiShadeInteractor;
@@ -111,6 +112,7 @@ public class NotificationShadeWindowViewController {
    private NotificationStackScrollLayout mStackScrollLayout;
    private PhoneStatusBarViewController mStatusBarViewController;
    private final CentralSurfaces mService;
    private final BackActionInteractor mBackActionInteractor;
    private final NotificationShadeWindowController mNotificationShadeWindowController;
    private DragDownHelper mDragDownHelper;
    private boolean mExpandingBelowNotch;
@@ -144,6 +146,7 @@ public class NotificationShadeWindowViewController {
            StatusBarWindowStateController statusBarWindowStateController,
            LockIconViewController lockIconViewController,
            CentralSurfaces centralSurfaces,
            BackActionInteractor backActionInteractor,
            NotificationShadeWindowController controller,
            Optional<UnfoldTransitionProgressProvider> unfoldTransitionProgressProvider,
            KeyguardUnlockAnimationController keyguardUnlockAnimationController,
@@ -173,6 +176,7 @@ public class NotificationShadeWindowViewController {
        mStatusBarKeyguardViewManager = statusBarKeyguardViewManager;
        mStatusBarWindowStateController = statusBarWindowStateController;
        mLockIconViewController = lockIconViewController;
        mBackActionInteractor = backActionInteractor;
        mLockIconViewController.init();
        mService = centralSurfaces;
        mNotificationShadeWindowController = controller;
@@ -443,7 +447,7 @@ public class NotificationShadeWindowViewController {
                switch (event.getKeyCode()) {
                    case KeyEvent.KEYCODE_BACK:
                        if (!down) {
                            mService.onBackPressed();
                            mBackActionInteractor.onBackRequested();
                        }
                        return true;
                    case KeyEvent.KEYCODE_MENU:
+0 −24
Original line number Diff line number Diff line
@@ -36,33 +36,12 @@ interface ShadeSurface : ShadeViewController {
        headsUpManager: HeadsUpManagerPhone
    )

    /**
     * Animate QS collapse by flinging it. If QS is expanded, it will collapse into QQS and stop. If
     * in split shade, it will collapse the whole shade.
     *
     * @param fullyCollapse Do not stop when QS becomes QQS. Fling until QS isn't visible anymore.
     */
    fun animateCollapseQs(fullyCollapse: Boolean)

    /** Returns whether the shade can be collapsed. */
    fun canBeCollapsed(): Boolean

    /** Cancels any pending collapses. */
    fun cancelPendingCollapse()

    /** Cancels the views current animation. */
    fun cancelAnimation()

    /**
     * Close the keyguard user switcher if it is open and capable of closing.
     *
     * Has no effect if user switcher isn't supported, if the user switcher is already closed, or if
     * the user switcher uses "simple" mode. The simple user switcher cannot be closed.
     *
     * @return true if the keyguard user switcher was open, and is now closed
     */
    fun closeUserSwitcherIfOpen(): Boolean

    /** Input focus transfer is about to happen. */
    fun startWaitingForExpandGesture()

@@ -116,9 +95,6 @@ interface ShadeSurface : ShadeViewController {
    /** Sets the view's alpha to max. */
    fun resetAlpha()

    /** Called when Back gesture has been committed (i.e. a back event has definitely occurred) */
    fun onBackPressed()

    /** Sets progress of the predictive back animation. */
    fun onBackProgressed(progressFraction: Float)

+24 −0
Original line number Diff line number Diff line
@@ -77,6 +77,17 @@ interface ShadeViewController {
    /** Collapses the shade with an animation duration in milliseconds. */
    fun collapseWithDuration(animationDuration: Int)

    /**
     * Animate QS collapse by flinging it. If QS is expanded, it will collapse into QQS and stop. If
     * in split shade, it will collapse the whole shade.
     *
     * @param fullyCollapse Do not stop when QS becomes QQS. Fling until QS isn't visible anymore.
     */
    fun animateCollapseQs(fullyCollapse: Boolean)

    /** Returns whether the shade can be collapsed. */
    fun canBeCollapsed(): Boolean

    /** Returns whether the shade is in the process of collapsing. */
    val isCollapsing: Boolean

@@ -126,6 +137,19 @@ interface ShadeViewController {
    /** Sets the amount of progress in the status bar launch animation. */
    fun applyLaunchAnimationProgress(linearProgress: Float)

    /**
     * Close the keyguard user switcher if it is open and capable of closing.
     *
     * Has no effect if user switcher isn't supported, if the user switcher is already closed, or if
     * the user switcher uses "simple" mode. The simple user switcher cannot be closed.
     *
     * @return true if the keyguard user switcher was open, and is now closed
     */
    fun closeUserSwitcherIfOpen(): Boolean

    /** Called when Back gesture has been committed (i.e. a back event has definitely occurred) */
    fun onBackPressed()

    /** Sets whether the status bar launch animation is currently running. */
    fun setIsLaunchAnimationRunning(running: Boolean)

Loading