diff options
| author | 2023-07-06 15:32:45 -0400 | |
|---|---|---|
| committer | 2023-07-07 14:13:39 +0000 | |
| commit | 09a9fc8b4868a09c0a54d3ec3a7bedb718caf274 (patch) | |
| tree | 991066c7d2a81ebf60bae7e9aa8283e1720a72b4 | |
| parent | 8a77a8462c572f1f58a68e439242dded6c9717f6 (diff) | |
Add empty implementation of ShadeController
Variants without shades want this, so there should be only one, and
it should be in the shade package to make updates not require topics.
Also adds some default methods to ShadeController to reduce the size
of ShadeControllerEmptyImpl and deemphasize ShadeController methods
that are too tied to implementation details of ShadeControllerImpl.
Test: presubmits are sufficient
Bug: 288867586
Change-Id: Ia7015378f85a8a68db049069b2d678b57c4390b1
3 files changed, 70 insertions, 29 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/shade/ShadeController.java b/packages/SystemUI/src/com/android/systemui/shade/ShadeController.java index 317d88585958..ebb98883c679 100644 --- a/packages/SystemUI/src/com/android/systemui/shade/ShadeController.java +++ b/packages/SystemUI/src/com/android/systemui/shade/ShadeController.java @@ -18,6 +18,7 @@ package com.android.systemui.shade; import android.view.MotionEvent; +import com.android.systemui.statusbar.CommandQueue; import com.android.systemui.statusbar.NotificationPresenter; import com.android.systemui.statusbar.StatusBarState; import com.android.systemui.statusbar.phone.CentralSurfaces; @@ -39,16 +40,24 @@ public interface ShadeController { void instantCollapseShade(); /** See {@link #animateCollapseShade(int, boolean, boolean, float)}. */ - void animateCollapseShade(); + default void animateCollapseShade() { + animateCollapseShade(CommandQueue.FLAG_EXCLUDE_NONE); + } /** See {@link #animateCollapseShade(int, boolean, boolean, float)}. */ - void animateCollapseShade(int flags); + default void animateCollapseShade(int flags) { + animateCollapseShade(flags, false, false, 1.0f); + } /** See {@link #animateCollapseShade(int, boolean, boolean, float)}. */ - void animateCollapseShadeForced(); + default void animateCollapseShadeForced() { + animateCollapseShade(CommandQueue.FLAG_EXCLUDE_NONE, true, false, 1.0f); + } /** See {@link #animateCollapseShade(int, boolean, boolean, float)}. */ - void animateCollapseShadeForcedDelayed(); + default void animateCollapseShadeForcedDelayed() { + animateCollapseShade(CommandQueue.FLAG_EXCLUDE_RECENTS_PANEL, true, true, 1.0f); + } /** * Collapse the shade animated, showing the bouncer when on {@link StatusBarState#KEYGUARD} or @@ -155,17 +164,17 @@ public interface ShadeController { void onLaunchAnimationEnd(boolean launchIsFullScreen); /** Sets the listener for when the visibility of the shade changes. */ - void setVisibilityListener(ShadeVisibilityListener listener); + default void setVisibilityListener(ShadeVisibilityListener listener) {}; /** */ - void setNotificationPresenter(NotificationPresenter presenter); + default void setNotificationPresenter(NotificationPresenter presenter) {}; /** */ - void setNotificationShadeWindowViewController( - NotificationShadeWindowViewController notificationShadeWindowViewController); + default void setNotificationShadeWindowViewController( + NotificationShadeWindowViewController notificationShadeWindowViewController) {}; /** */ - void setShadeViewController(ShadeViewController shadeViewController); + default void setShadeViewController(ShadeViewController shadeViewController) {}; /** Listens for shade visibility changes. */ interface ShadeVisibilityListener { diff --git a/packages/SystemUI/src/com/android/systemui/shade/ShadeControllerEmptyImpl.kt b/packages/SystemUI/src/com/android/systemui/shade/ShadeControllerEmptyImpl.kt new file mode 100644 index 000000000000..4d0500786ca3 --- /dev/null +++ b/packages/SystemUI/src/com/android/systemui/shade/ShadeControllerEmptyImpl.kt @@ -0,0 +1,52 @@ +package com.android.systemui.shade + +import android.view.MotionEvent +import com.android.systemui.dagger.SysUISingleton +import javax.inject.Inject + +/** Empty implementation of ShadeController for variants of Android without shades. */ +@SysUISingleton +open class ShadeControllerEmptyImpl @Inject constructor() : ShadeController { + override fun instantExpandShade() {} + override fun instantCollapseShade() {} + override fun animateCollapseShade( + flags: Int, + force: Boolean, + delayed: Boolean, + speedUpFactor: Float + ) {} + override fun animateExpandShade() {} + override fun animateExpandQs() {} + override fun postAnimateCollapseShade() {} + override fun postAnimateForceCollapseShade() {} + override fun postAnimateExpandQs() {} + override fun cancelExpansionAndCollapseShade() {} + override fun closeShadeIfOpen(): Boolean { + return false + } + override fun isKeyguard(): Boolean { + return false + } + override fun isShadeFullyOpen(): Boolean { + return false + } + override fun isExpandingOrCollapsing(): Boolean { + return false + } + override fun postOnShadeExpanded(action: Runnable?) {} + override fun addPostCollapseAction(action: Runnable?) {} + override fun runPostCollapseRunnables() {} + override fun collapseShade(): Boolean { + return false + } + override fun collapseShade(animate: Boolean) {} + override fun collapseOnMainThread() {} + override fun makeExpandedInvisible() {} + override fun makeExpandedVisible(force: Boolean) {} + override fun isExpandedVisible(): Boolean { + return false + } + override fun onStatusBarTouch(event: MotionEvent?) {} + override fun onLaunchAnimationCancelled(isLaunchForActivity: Boolean) {} + override fun onLaunchAnimationEnd(launchIsFullScreen: Boolean) {} +} diff --git a/packages/SystemUI/src/com/android/systemui/shade/ShadeControllerImpl.java b/packages/SystemUI/src/com/android/systemui/shade/ShadeControllerImpl.java index b92afac047fa..af74a8d7dca1 100644 --- a/packages/SystemUI/src/com/android/systemui/shade/ShadeControllerImpl.java +++ b/packages/SystemUI/src/com/android/systemui/shade/ShadeControllerImpl.java @@ -112,26 +112,6 @@ public final class ShadeControllerImpl implements ShadeController { } @Override - public void animateCollapseShade() { - animateCollapseShade(CommandQueue.FLAG_EXCLUDE_NONE); - } - - @Override - public void animateCollapseShade(int flags) { - animateCollapseShade(flags, false, false, 1.0f); - } - - @Override - public void animateCollapseShadeForced() { - animateCollapseShade(CommandQueue.FLAG_EXCLUDE_NONE, true, false, 1.0f); - } - - @Override - public void animateCollapseShadeForcedDelayed() { - animateCollapseShade(CommandQueue.FLAG_EXCLUDE_RECENTS_PANEL, true, true, 1.0f); - } - - @Override public void animateCollapseShade(int flags, boolean force, boolean delayed, float speedUpFactor) { if (!force && mStatusBarStateController.getState() != StatusBarState.SHADE) { |