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

Commit 6b59087d authored by Justin Weir's avatar Justin Weir
Browse files

Move shade code out of CentralSurfaces

Bug: 249277686
Test: manual
Test: run an fix affected tests
Change-Id: I5024e060f3fdbf4d5b213170bff150867038758a
parent 771907f9
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -133,6 +133,9 @@ public interface ActivityStarter {
            boolean willAnimateOnKeyguard,
            @Nullable String customMessage);

    /** Whether we should animate an activity launch. */
    boolean shouldAnimateLaunch(boolean isActivityIntent);

    interface Callback {
        void onActivityStarted(int resultCode);
    }
+8 −2
Original line number Diff line number Diff line
@@ -115,6 +115,9 @@ public interface ShadeController {
     */
    void collapseShade(boolean animate);

    /** Calls #collapseShade if already on the main thread. If not, posts a call to it. */
    void collapseOnMainThread();

    /** Makes shade expanded but not visible. */
    void makeExpandedInvisible();

@@ -127,8 +130,11 @@ public interface ShadeController {
    /** Handle status bar touch event. */
    void onStatusBarTouch(MotionEvent event);

    /** Called when the shade finishes collapsing. */
    void onClosingFinished();
    /** Called when a launch animation was cancelled. */
    void onLaunchAnimationCancelled(boolean isLaunchForActivity);

    /** Called when a launch animation ends. */
    void onLaunchAnimationEnd(boolean launchIsFullScreen);

    /** Sets the listener for when the visibility of the shade changes. */
    void setVisibilityListener(ShadeVisibilityListener listener);
+37 −2
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package com.android.systemui.shade;

import android.content.ComponentCallbacks2;
import android.os.Looper;
import android.util.Log;
import android.view.MotionEvent;
import android.view.ViewTreeObserver;
@@ -25,6 +26,7 @@ import android.view.WindowManagerGlobal;

import com.android.systemui.assist.AssistManager;
import com.android.systemui.dagger.SysUISingleton;
import com.android.systemui.dagger.qualifiers.Main;
import com.android.systemui.plugins.statusbar.StatusBarStateController;
import com.android.systemui.statusbar.CommandQueue;
import com.android.systemui.statusbar.NotificationPresenter;
@@ -38,6 +40,7 @@ import com.android.systemui.statusbar.window.StatusBarWindowController;
import dagger.Lazy;

import java.util.ArrayList;
import java.util.concurrent.Executor;

import javax.inject.Inject;

@@ -51,6 +54,7 @@ public final class ShadeControllerImpl implements ShadeController {
    private final int mDisplayId;

    private final CommandQueue mCommandQueue;
    private final Executor mMainExecutor;
    private final KeyguardStateController mKeyguardStateController;
    private final NotificationShadeWindowController mNotificationShadeWindowController;
    private final StatusBarStateController mStatusBarStateController;
@@ -72,6 +76,7 @@ public final class ShadeControllerImpl implements ShadeController {
    @Inject
    public ShadeControllerImpl(
            CommandQueue commandQueue,
            @Main Executor mainExecutor,
            KeyguardStateController keyguardStateController,
            StatusBarStateController statusBarStateController,
            StatusBarKeyguardViewManager statusBarKeyguardViewManager,
@@ -82,6 +87,7 @@ public final class ShadeControllerImpl implements ShadeController {
            Lazy<NotificationGutsManager> gutsManager
    ) {
        mCommandQueue = commandQueue;
        mMainExecutor = mainExecutor;
        mStatusBarStateController = statusBarStateController;
        mStatusBarWindowController = statusBarWindowController;
        mGutsManager = gutsManager;
@@ -226,6 +232,15 @@ public final class ShadeControllerImpl implements ShadeController {
        }
    }

    @Override
    public void collapseOnMainThread() {
        if (Looper.getMainLooper().isCurrentThread()) {
            collapseShade();
        } else {
            mMainExecutor.execute(this::collapseShade);
        }
    }

    @Override
    public void onStatusBarTouch(MotionEvent event) {
        if (event.getAction() == MotionEvent.ACTION_UP) {
@@ -235,8 +250,7 @@ public final class ShadeControllerImpl implements ShadeController {
        }
    }

    @Override
    public void onClosingFinished() {
    private void onClosingFinished() {
        runPostCollapseRunnables();
        if (!mPresenter.isPresenterFullyCollapsed()) {
            // if we set it not to be focusable when collapsing, we have to undo it when we aborted
@@ -245,6 +259,27 @@ public final class ShadeControllerImpl implements ShadeController {
        }
    }

    @Override
    public void onLaunchAnimationCancelled(boolean isLaunchForActivity) {
        if (mPresenter.isPresenterFullyCollapsed()
                && !mPresenter.isCollapsing()
                && isLaunchForActivity) {
            onClosingFinished();
        } else {
            collapseShade(true /* animate */);
        }
    }

    @Override
    public void onLaunchAnimationEnd(boolean launchIsFullScreen) {
        if (!mPresenter.isCollapsing()) {
            onClosingFinished();
        }
        if (launchIsFullScreen) {
            instantCollapseShade();
        }
    }

    @Override
    public void instantCollapseShade() {
        mNotificationPanelViewController.instantCollapse();
+35 −5
Original line number Diff line number Diff line
@@ -388,6 +388,35 @@ constructor(
        mainExecutor.executeDelayed(runnable, delay.toLong())
    }

    /**
     * Whether we should animate an activity launch.
     *
     * Note: This method must be called *before* dismissing the keyguard.
     */
    private fun shouldAnimateLaunch(
        isActivityIntent: Boolean,
        showOverLockscreen: Boolean,
    ): Boolean {
        // TODO(b/184121838): Support launch animations when occluded.
        if (keyguardStateController.isOccluded) {
            return false
        }

        // Always animate if we are not showing the keyguard or if we animate over the lockscreen
        // (without unlocking it).
        if (showOverLockscreen || !keyguardStateController.isShowing) {
            return true
        }

        // We don't animate non-activity launches as they can break the animation.
        // TODO(b/184121838): Support non activity launches on the lockscreen.
        return isActivityIntent
    }

    override fun shouldAnimateLaunch(isActivityIntent: Boolean): Boolean {
        return shouldAnimateLaunch(isActivityIntent, false)
    }

    /**
     * Encapsulates the activity logic for activity starter.
     *
@@ -419,7 +448,7 @@ constructor(
            val animate =
                animationController != null &&
                    !willLaunchResolverActivity &&
                    centralSurfaces?.shouldAnimateLaunch(true /* isActivityIntent */) == true
                    shouldAnimateLaunch(isActivityIntent = true)
            val animController =
                wrapAnimationController(
                    animationController = animationController,
@@ -538,7 +567,7 @@ constructor(
            val animate =
                !willLaunchResolverActivity &&
                    animationController != null &&
                    centralSurfaces?.shouldAnimateLaunch(intent.isActivity) == true
                    shouldAnimateLaunch(intent.isActivity)

            // If we animate, don't collapse the shade and defer the keyguard dismiss (in case we
            // run the animation on the keyguard). The animation will take care of (instantly)
@@ -595,7 +624,7 @@ constructor(
                        Log.w(TAG, "Sending intent failed: $e")
                        if (!collapse) {
                            // executeRunnableDismissingKeyguard did not collapse for us already.
                            centralSurfaces?.collapsePanelOnMainThread()
                            shadeControllerLazy.get().collapseOnMainThread()
                        }
                        // TODO: Dismiss Keyguard.
                    }
@@ -637,7 +666,7 @@ constructor(

            val animate =
                animationController != null &&
                    centralSurfaces?.shouldAnimateLaunch(
                    shouldAnimateLaunch(
                        /* isActivityIntent= */ true,
                        showOverLockscreenWhenLocked
                    ) == true
@@ -867,7 +896,8 @@ constructor(
                if (dismissShade) {
                    return StatusBarLaunchAnimatorController(
                        animationController,
                        it,
                        it.shadeViewController,
                        shadeControllerLazy.get(),
                        notifShadeWindowControllerLazy.get(),
                        isLaunchForActivity
                    )
+0 −11
Original line number Diff line number Diff line
@@ -191,8 +191,6 @@ public interface CentralSurfaces extends Dumpable, LifecycleOwner {

    void animateExpandSettingsPanel(@Nullable String subpanel);

    void collapsePanelOnMainThread();

    void togglePanel();

    void start();
@@ -230,15 +228,6 @@ public interface CentralSurfaces extends Dumpable, LifecycleOwner {

    boolean isOccluded();

    //TODO: These can / should probably be moved to NotificationPresenter or ShadeController
    void onLaunchAnimationCancelled(boolean isLaunchForActivity);

    void onLaunchAnimationEnd(boolean launchIsFullScreen);

    boolean shouldAnimateLaunch(boolean isActivityIntent, boolean showOverLockscreen);

    boolean shouldAnimateLaunch(boolean isActivityIntent);

    boolean isDeviceInVrMode();

    NotificationPresenter getPresenter();
Loading