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
This commit is contained in:
Shan Huang
2022-09-19 23:34:55 +00:00
parent 1d073c9600
commit 28f630c97e
3 changed files with 16 additions and 0 deletions

View File

@@ -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) {}
}
}

View File

@@ -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 =

View File

@@ -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);
}
}