From 28f630c97e3350d8cedea6b4c8ceef55b7791f03 Mon Sep 17 00:00:00 2001 From: Shan Huang Date: Mon, 19 Sep 2022 23:34:55 +0000 Subject: [PATCH] Add setTriggerBack interface to BackCallback. This allows the back arrow to report back trigger state to BackAnimation as the gesture is going on. The trigger state might be included in the future back progress API. Bug: b/238475284 Test: Manual for now, because the current back arrow doesn't have tests unfortunately, and will be deprecated soon. We should add tests when we productionize the arrow prototype. Change-Id: Idcbc2244d942788cd18a07ece252b0e7b6ef849a --- .../systemui/plugins/NavigationEdgeBackPlugin.java | 8 ++++++++ .../navigationbar/gestural/EdgeBackGestureHandler.java | 7 +++++++ .../navigationbar/gestural/NavigationBarEdgePanel.java | 1 + 3 files changed, 16 insertions(+) diff --git a/packages/SystemUI/plugin/src/com/android/systemui/plugins/NavigationEdgeBackPlugin.java b/packages/SystemUI/plugin/src/com/android/systemui/plugins/NavigationEdgeBackPlugin.java index 12372593b62f1..506ccf3c24377 100644 --- a/packages/SystemUI/plugin/src/com/android/systemui/plugins/NavigationEdgeBackPlugin.java +++ b/packages/SystemUI/plugin/src/com/android/systemui/plugins/NavigationEdgeBackPlugin.java @@ -61,5 +61,13 @@ public interface NavigationEdgeBackPlugin extends Plugin { /** Indicates that the gesture was cancelled and the system should not go back. */ void cancelBack(); + + /** + * Indicates if back will be triggered if committed in current state. + * + * @param triggerBack if back will be triggered in current state. + */ + // TODO(b/247883311): Remove default impl once SwipeBackGestureHandler overrides this. + default void setTriggerBack(boolean triggerBack) {} } } diff --git a/packages/SystemUI/src/com/android/systemui/navigationbar/gestural/EdgeBackGestureHandler.java b/packages/SystemUI/src/com/android/systemui/navigationbar/gestural/EdgeBackGestureHandler.java index 7c4c64c200898..35e7edb2ed970 100644 --- a/packages/SystemUI/src/com/android/systemui/navigationbar/gestural/EdgeBackGestureHandler.java +++ b/packages/SystemUI/src/com/android/systemui/navigationbar/gestural/EdgeBackGestureHandler.java @@ -303,6 +303,13 @@ public class EdgeBackGestureHandler extends CurrentUserTracker mOverviewProxyService.notifyBackAction(false, (int) mDownPoint.x, (int) mDownPoint.y, false /* isButton */, !mIsOnLeftEdge); } + + @Override + public void setTriggerBack(boolean triggerBack) { + if (mBackAnimation != null) { + mBackAnimation.setTriggerBack(triggerBack); + } + } }; private final SysUiState.SysUiStateCallback mSysUiStateCallback = diff --git a/packages/SystemUI/src/com/android/systemui/navigationbar/gestural/NavigationBarEdgePanel.java b/packages/SystemUI/src/com/android/systemui/navigationbar/gestural/NavigationBarEdgePanel.java index 122852f7d07ab..24efc762b39b6 100644 --- a/packages/SystemUI/src/com/android/systemui/navigationbar/gestural/NavigationBarEdgePanel.java +++ b/packages/SystemUI/src/com/android/systemui/navigationbar/gestural/NavigationBarEdgePanel.java @@ -880,6 +880,7 @@ public class NavigationBarEdgePanel extends View implements NavigationEdgeBackPl // Whenever the trigger back state changes the existing translation animation should be // cancelled mTranslationAnimation.cancel(); + mBackCallback.setTriggerBack(mTriggerBack); } }