diff --git a/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsSlideInView.java b/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsSlideInView.java index 3b04602811..99937f841b 100644 --- a/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsSlideInView.java +++ b/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsSlideInView.java @@ -207,10 +207,10 @@ public class TaskbarAllAppsSlideInView extends AbstractSlideInView }; protected static final float TRANSLATION_SHIFT_CLOSED = 1f; protected static final float TRANSLATION_SHIFT_OPENED = 0f; - private static final float VIEW_NO_SCALE = 1f; private static final int DEFAULT_DURATION = 300; protected final T mActivityContext; @@ -129,9 +128,13 @@ public abstract class AbstractSlideInView protected @Nullable OnCloseListener mOnCloseBeginListener; protected List mOnCloseListeners = new ArrayList<>(); - protected final AnimatedFloat mSlideInViewScale = - new AnimatedFloat(this::onScaleProgressChanged, VIEW_NO_SCALE); - protected boolean mIsBackProgressing; + /** + * How far through a "user initiated dismissal" the UI is. e.g. Predictive back, swipe to home, + * 0 is regular state, 1 is fully dismissed. + */ + protected final AnimatedFloat mSwipeToDismissProgress = + new AnimatedFloat(this::onUserSwipeToDismissProgressChanged, 0f); + protected boolean mIsDismissInProgress; private @Nullable Drawable mContentBackground; private @Nullable View mContentBackgroundParentView; @@ -287,29 +290,30 @@ public abstract class AbstractSlideInView final float progress = backEvent.getProgress(); float deceleratedProgress = Interpolators.PREDICTIVE_BACK_DECELERATED_EASE.getInterpolation(progress); - mIsBackProgressing = progress > 0f; - mSlideInViewScale.updateValue(PREDICTIVE_BACK_MIN_SCALE - + (1 - PREDICTIVE_BACK_MIN_SCALE) * (1 - deceleratedProgress)); + mSwipeToDismissProgress.updateValue(deceleratedProgress); } - protected void onScaleProgressChanged() { - float scaleProgress = mSlideInViewScale.value; - SCALE_PROPERTY.set(this, scaleProgress); - setClipChildren(!mIsBackProgressing); - setClipToPadding(!mIsBackProgressing); - mContent.setClipChildren(!mIsBackProgressing); - mContent.setClipToPadding(!mIsBackProgressing); + protected void onUserSwipeToDismissProgressChanged() { + float progress = mSwipeToDismissProgress.value; + mIsDismissInProgress = progress > 0f; + + float scale = PREDICTIVE_BACK_MIN_SCALE + (1 - PREDICTIVE_BACK_MIN_SCALE) * (1f - progress); + SCALE_PROPERTY.set(this, scale); + setClipChildren(!mIsDismissInProgress); + setClipToPadding(!mIsDismissInProgress); + mContent.setClipChildren(!mIsDismissInProgress); + mContent.setClipToPadding(!mIsDismissInProgress); invalidate(); } @Override public void onBackCancelled() { super.onBackCancelled(); - animateSlideInViewToNoScale(); + animateSwipeToDismissProgressToStart(); } - protected void animateSlideInViewToNoScale() { - mSlideInViewScale.animateToValue(1f) + protected void animateSwipeToDismissProgressToStart() { + mSwipeToDismissProgress.animateToValue(0f) .setDuration(REVERT_SWIPE_ALL_APPS_TO_HOME_ANIMATION_DURATION_MS) .start(); } @@ -340,7 +344,7 @@ public abstract class AbstractSlideInView mContentBackgroundParentView.getTop() + (int) mContent.getTranslationY(), mContentBackgroundParentView.getRight(), mContentBackgroundParentView.getBottom() - + (mIsBackProgressing ? getBottomOffsetPx() : 0)); + + (mIsDismissInProgress ? getBottomOffsetPx() : 0)); mContentBackground.draw(canvas); } diff --git a/src/com/android/launcher3/views/WidgetsEduView.java b/src/com/android/launcher3/views/WidgetsEduView.java index 45ff9de503..53fbd8f33b 100644 --- a/src/com/android/launcher3/views/WidgetsEduView.java +++ b/src/com/android/launcher3/views/WidgetsEduView.java @@ -70,9 +70,9 @@ public class WidgetsEduView extends AbstractSlideInView implements } @Override - protected void onScaleProgressChanged() { - super.onScaleProgressChanged(); - setTranslationY(getMeasuredHeight() * (1 - mSlideInViewScale.value) / 2); + protected void onUserSwipeToDismissProgressChanged() { + super.onUserSwipeToDismissProgressChanged(); + setTranslationY(getMeasuredHeight() * (mSwipeToDismissProgress.value / 2)); } private void show() { diff --git a/src/com/android/launcher3/widget/WidgetsBottomSheet.java b/src/com/android/launcher3/widget/WidgetsBottomSheet.java index e6b9c9b7f9..f1b80e41d1 100644 --- a/src/com/android/launcher3/widget/WidgetsBottomSheet.java +++ b/src/com/android/launcher3/widget/WidgetsBottomSheet.java @@ -280,6 +280,6 @@ public class WidgetsBottomSheet extends BaseWidgetSheet { @Override public void addHintCloseAnim( float distanceToMove, Interpolator interpolator, PendingAnimation target) { - target.setInt(this, PADDING_BOTTOM, (int) (distanceToMove + mInsets.bottom), interpolator); + target.addAnimatedFloat(mSwipeToDismissProgress, 0f, 1f, interpolator); } } diff --git a/src/com/android/launcher3/widget/picker/WidgetsFullSheet.java b/src/com/android/launcher3/widget/picker/WidgetsFullSheet.java index 5cf8203b84..85375eec9d 100644 --- a/src/com/android/launcher3/widget/picker/WidgetsFullSheet.java +++ b/src/com/android/launcher3/widget/picker/WidgetsFullSheet.java @@ -17,7 +17,6 @@ package com.android.launcher3.widget.picker; import static com.android.launcher3.Flags.enableCategorizedWidgetSuggestions; import static com.android.launcher3.Flags.enableUnfoldedTwoPanePicker; -import static com.android.launcher3.LauncherAnimUtils.VIEW_TRANSLATE_Y; import static com.android.launcher3.LauncherPrefs.WIDGETS_EDUCATION_DIALOG_SEEN; import static com.android.launcher3.allapps.ActivityAllAppsContainerView.AdapterHolder.SEARCH; import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_WIDGETSTRAY_SEARCHED; @@ -814,8 +813,7 @@ public class WidgetsFullSheet extends BaseWidgetSheet @Override public void addHintCloseAnim( float distanceToMove, Interpolator interpolator, PendingAnimation target) { - target.setFloat(getRecyclerView(), VIEW_TRANSLATE_Y, -distanceToMove, interpolator); - target.setViewAlpha(getRecyclerView(), 0.5f, interpolator); + target.addAnimatedFloat(mSwipeToDismissProgress, 0f, 1f, interpolator); } @Override @@ -911,7 +909,7 @@ public class WidgetsFullSheet extends BaseWidgetSheet public void onBackInvoked() { if (mIsInSearchMode) { mSearchBar.reset(); - animateSlideInViewToNoScale(); + animateSwipeToDismissProgressToStart(); } else { super.onBackInvoked(); } diff --git a/src/com/android/launcher3/widget/picker/WidgetsTwoPaneSheet.java b/src/com/android/launcher3/widget/picker/WidgetsTwoPaneSheet.java index c60bca0b29..1bf813c89c 100644 --- a/src/com/android/launcher3/widget/picker/WidgetsTwoPaneSheet.java +++ b/src/com/android/launcher3/widget/picker/WidgetsTwoPaneSheet.java @@ -74,7 +74,7 @@ public class WidgetsTwoPaneSheet extends WidgetsFullSheet { private ScrollView mRightPaneScrollView; private WidgetsListTableViewHolderBinder mWidgetsListTableViewHolderBinder; - private boolean mOldIsBackSwipeProgressing; + private boolean mOldIsSwipeToDismissInProgress; private int mActivePage = -1; private PackageUserKey mSelectedHeader; @@ -154,14 +154,14 @@ public class WidgetsTwoPaneSheet extends WidgetsFullSheet { } @Override - protected void onScaleProgressChanged() { - super.onScaleProgressChanged(); - boolean isBackSwipeProgressing = mSlideInViewScale.value > 0; - if (isBackSwipeProgressing == mOldIsBackSwipeProgressing) { + protected void onUserSwipeToDismissProgressChanged() { + super.onUserSwipeToDismissProgressChanged(); + boolean isSwipeToDismissInProgress = mSwipeToDismissProgress.value > 0; + if (isSwipeToDismissInProgress == mOldIsSwipeToDismissInProgress) { return; } - mOldIsBackSwipeProgressing = isBackSwipeProgressing; - if (isBackSwipeProgressing) { + mOldIsSwipeToDismissInProgress = isSwipeToDismissInProgress; + if (isSwipeToDismissInProgress) { modifyAttributesOnViewTree(mPrimaryWidgetListView, (ViewParent) mContent, CLIP_CHILDREN_FALSE_MODIFIER); modifyAttributesOnViewTree(mRightPaneScrollView, (ViewParent) mContent,