diff --git a/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsSlideInView.java b/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsSlideInView.java index 6ceec3e5bc..8e05686558 100644 --- a/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsSlideInView.java +++ b/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsSlideInView.java @@ -206,13 +206,6 @@ public class TaskbarAllAppsSlideInView extends AbstractSlideInView return true; } + @Override + @RequiresApi(Build.VERSION_CODES.UPSIDE_DOWN_CAKE) + public void onBackStarted(BackEvent backEvent) { + super.onBackStarted(backEvent); + mViewToAnimateInSwipeToDismiss = shouldAnimateContentViewInBackSwipe() ? mContent : this; + } + @Override @RequiresApi(Build.VERSION_CODES.UPSIDE_DOWN_CAKE) public void onBackProgressed(BackEvent backEvent) { @@ -295,6 +302,18 @@ public abstract class AbstractSlideInView mSwipeToDismissProgress.updateValue(deceleratedProgress); } + /** + * During predictive back swipe, the default behavior is to scale {@link AbstractSlideInView} + * during back swipe. This method allow subclass to scale {@link #mContent}, typically to exit + * search mode. + * + *

Note that this method can be expensive, and should only be called from + * {@link #onBackStarted(BackEvent)}, not from {@link #onBackProgressed(BackEvent)}. + */ + protected boolean shouldAnimateContentViewInBackSwipe() { + return false; + } + protected void onUserSwipeToDismissProgressChanged() { float progress = mSwipeToDismissProgress.value; mIsDismissInProgress = progress > 0f; diff --git a/src/com/android/launcher3/widget/picker/WidgetsFullSheet.java b/src/com/android/launcher3/widget/picker/WidgetsFullSheet.java index eca4f2fa21..28eeb10a80 100644 --- a/src/com/android/launcher3/widget/picker/WidgetsFullSheet.java +++ b/src/com/android/launcher3/widget/picker/WidgetsFullSheet.java @@ -46,7 +46,6 @@ import android.view.animation.Interpolator; import android.widget.Button; import android.widget.LinearLayout; import android.widget.TextView; -import android.window.BackEvent; import androidx.annotation.NonNull; import androidx.annotation.Nullable; @@ -903,22 +902,23 @@ public class WidgetsFullSheet extends BaseWidgetSheet return isFoldUnFold || useDifferentLayoutOnOrientationChange; } + /** + * In widget search mode, we should scale down content inside widget bottom sheet, rather + * than the whole bottom sheet, to indicate we will navigate back within the widget + * bottom sheet. + */ @Override - public void onBackStarted(BackEvent backEvent) { - super.onBackStarted(backEvent); - // In widget search mode, we should scale down content inside widget bottom sheet, rather - // than the whole bottom sheet, to indicate we will navigate back within the widget - // bottom sheet. - if (mIsInSearchMode) { - mViewToAnimateInSwipeToDismiss = mContent; - } + public boolean shouldAnimateContentViewInBackSwipe() { + return mIsInSearchMode; } @Override public void onBackInvoked() { if (mIsInSearchMode) { mSearchBar.reset(); - animateSwipeToDismissProgressToStart(); + // Posting animation to next frame will let widget sheet finish updating UI first, and + // make animation smoother. + post(this::animateSwipeToDismissProgressToStart); } else { super.onBackInvoked(); }