Use appropriate start padding for clear all button

This still shows up a bit strange with
notched phones because we are using
RecentsView padding to give ClearAll the
right amount of spacing. However, we're only
adding padding to the left and right and not
the top/bottom.
That's captured here: b/154436527

Fixes: 150389833
Test: Tested landscape/portrait/seascape
launcher, w/ RTL as well

Change-Id: I49defd58048e609a1f7a821abb97374bcbb94b9f
This commit is contained in:
Vinit Nayak committed 2020-04-27 22:44:05 -07:00
1 parent 2f04a9d271
commit 48ea9e9502
5 files changed
+24 -1

No files matched your search

@@ -56,7 +56,8 @@ public class ClearAllButton extends Button implements PageCallbacks {
@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
super.onLayout(changed, left, top, right, bottom);
mScrollOffset = mIsRtl ? mParent.getPaddingRight() / 2 : - mParent.getPaddingLeft() / 2;
PagedOrientationHandler orientationHandler = mParent.getPagedOrientationHandler();
mScrollOffset = orientationHandler.getClearAllScrollOffset(mParent, mIsRtl);
}
@Override
@@ -125,6 +125,11 @@ public class LandscapePagedViewHandler implements PagedOrientationHandler {
return rect.height();
}
@Override
public int getClearAllScrollOffset(View view, boolean isRtl) {
return (isRtl ? view.getPaddingBottom() : - view.getPaddingTop()) / 2;
}
@Override
public int getSecondaryDimension(View view) {
return view.getWidth();
@@ -62,6 +62,7 @@ public interface PagedOrientationHandler {
float getPrimaryVelocity(VelocityTracker velocityTracker, int pointerId);
int getMeasuredSize(View view);
float getPrimarySize(RectF rect);
int getClearAllScrollOffset(View view, boolean isRtl);
int getSecondaryDimension(View view);
FloatProperty<View> getPrimaryViewTranslate();
FloatProperty<View> getSecondaryViewTranslate();
@@ -122,6 +122,11 @@ public class PortraitPagedViewHandler implements PagedOrientationHandler {
return rect.width();
}
@Override
public int getClearAllScrollOffset(View view, boolean isRtl) {
return (isRtl ? view.getPaddingRight() : - view.getPaddingLeft()) / 2;
}
@Override
public int getSecondaryDimension(View view) {
return view.getHeight();
@@ -75,4 +75,15 @@ public class SeascapePagedViewHandler extends LandscapePagedViewHandler {
public float getTaskMenuY(float y, View thumbnailView) {
return y + thumbnailView.getMeasuredHeight();
}
@Override
public int getClearAllScrollOffset(View view, boolean isRtl) {
return (isRtl ? view.getPaddingTop() : - view.getPaddingBottom()) / 2;
}
@Override
public void setPrimaryAndResetSecondaryTranslate(View view, float translation) {
view.setTranslationX(0);
view.setTranslationY(-translation);
}
}