Align widget picker bottom swipe transition with predictive back.
Bug: 325930715 Test: widget picker tests Flag: NA Change-Id: I15319f0a264503ff34dd4cc0dc36a40531379e2b
This commit is contained in:
@@ -207,10 +207,10 @@ public class TaskbarAllAppsSlideInView extends AbstractSlideInView<TaskbarOverla
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onScaleProgressChanged() {
|
||||
super.onScaleProgressChanged();
|
||||
mAppsView.setClipChildren(!mIsBackProgressing);
|
||||
mAppsView.getAppsRecyclerViewContainer().setClipChildren(!mIsBackProgressing);
|
||||
protected void onUserSwipeToDismissProgressChanged() {
|
||||
super.onUserSwipeToDismissProgressChanged();
|
||||
mAppsView.setClipChildren(!mIsDismissInProgress);
|
||||
mAppsView.getAppsRecyclerViewContainer().setClipChildren(!mIsDismissInProgress);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -264,7 +264,7 @@ public class TaskbarAllAppsSlideInView extends AbstractSlideInView<TaskbarOverla
|
||||
if (mAllAppsCallbacks.handleSearchBackInvoked()) {
|
||||
// We need to scale back taskbar all apps if we navigate back within search inside all
|
||||
// apps
|
||||
animateSlideInViewToNoScale();
|
||||
animateSwipeToDismissProgressToStart();
|
||||
} else {
|
||||
super.onBackInvoked();
|
||||
}
|
||||
|
||||
@@ -82,7 +82,6 @@ public abstract class AbstractSlideInView<T extends Context & ActivityContext>
|
||||
};
|
||||
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<T extends Context & ActivityContext>
|
||||
protected @Nullable OnCloseListener mOnCloseBeginListener;
|
||||
protected List<OnCloseListener> 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<T extends Context & ActivityContext>
|
||||
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<T extends Context & ActivityContext>
|
||||
mContentBackgroundParentView.getTop() + (int) mContent.getTranslationY(),
|
||||
mContentBackgroundParentView.getRight(),
|
||||
mContentBackgroundParentView.getBottom()
|
||||
+ (mIsBackProgressing ? getBottomOffsetPx() : 0));
|
||||
+ (mIsDismissInProgress ? getBottomOffsetPx() : 0));
|
||||
mContentBackground.draw(canvas);
|
||||
}
|
||||
|
||||
|
||||
@@ -70,9 +70,9 @@ public class WidgetsEduView extends AbstractSlideInView<BaseActivity> 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() {
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user