Using edgeEffect for overscroll in all-apps and widget tray

Bug: 183966408
Test: Manual
Change-Id: Iea1b67504fc59fc7ce2ec657bf8ac7e3d8bfff1c
This commit is contained in:
Sunny Goyal
2021-03-29 12:26:05 -07:00
parent 78f5a8c6ab
commit c5797893e7
3 changed files with 78 additions and 134 deletions

View File

@@ -77,7 +77,7 @@ import com.android.launcher3.workprofile.PersonalWorkSlidingTabStrip.OnActivePag
public class AllAppsContainerView extends SpringRelativeLayout implements DragSource,
Insettable, OnDeviceProfileChangeListener, OnActivePageChangedListener {
private static final float FLING_VELOCITY_MULTIPLIER = 135f;
private static final float FLING_VELOCITY_MULTIPLIER = 1000 * .8f;
// Starts the springs after at least 55% of the animation has passed.
private static final float FLING_ANIMATION_THRESHOLD = 0.55f;
private static final int ALPHA_CHANNEL_COUNT = 2;
@@ -140,12 +140,7 @@ public class AllAppsContainerView extends SpringRelativeLayout implements DragSo
mAllAppsStore.addUpdateListener(this::onAppsUpdated);
addSpringView(R.id.all_apps_header);
addSpringView(R.id.apps_list_view);
addSpringView(R.id.all_apps_tabs_view_pager);
mMultiValueAlpha = new MultiValueAlpha(this, ALPHA_CHANNEL_COUNT);
}
/**
@@ -169,14 +164,6 @@ public class AllAppsContainerView extends SpringRelativeLayout implements DragSo
return mWorkModeSwitch;
}
@Override
protected void setDampedScrollShift(float shift) {
// Bound the shift amount to avoid content from drawing on top (Y-val) of the QSB.
float maxShift = getSearchView().getHeight() / 2f;
super.setDampedScrollShift(Utilities.boundToRange(shift, -maxShift, maxShift));
}
@Override
public void onDeviceProfileChanged(DeviceProfile dp) {
for (AdapterHolder holder : mAH) {
@@ -407,12 +394,6 @@ public class AllAppsContainerView extends SpringRelativeLayout implements DragSo
}
}
@Override
public int getCanvasClipTopForOverscroll() {
// Do not clip if the QSB is attached to the spring, otherwise the QSB will get clipped.
return mSpringViews.get(getSearchView().getId()) ? 0 : mHeader.getTop();
}
private void rebindAdapters(boolean showTabs) {
rebindAdapters(showTabs, false /* force */);
}
@@ -639,11 +620,8 @@ public class AllAppsContainerView extends SpringRelativeLayout implements DragSo
public void onAnimationUpdate(ValueAnimator valueAnimator) {
if (shouldSpring
&& valueAnimator.getAnimatedFraction() >= FLING_ANIMATION_THRESHOLD) {
int searchViewId = getSearchView().getId();
addSpringView(searchViewId);
finishWithShiftAndVelocity(1, velocity * FLING_VELOCITY_MULTIPLIER,
(anim, canceled, value, velocity) -> removeSpringView(searchViewId));
absorbSwipeUpVelocity(Math.abs(
Math.round(velocity * FLING_VELOCITY_MULTIPLIER)));
shouldSpring = false;
}
}