Remove grid scaling in Overveiw

- Grid scaling has problem that scales task icon and menu, which makes it hard to control icon size and text size in the manula
- Replaced the whole concept with dedicated Task size calculation in grid layout
- Support different icon size in TaskView in grid and removed task_thumbnail_top_margin
- Removed grid progress in TaskViewSimulator as well
- Refactored how ClearAllButton scroll and translations are calcualted to align clear all properly in grid
- Make page center calculation aware of PagedView pivot and scaling

Bug: 174464863
Test: Manual on two screens
Change-Id: I47b13ef6e55c6e16c52ea04225f5bde02ed82fc2
This commit is contained in:
Alex Chau
2021-03-17 16:53:26 +00:00
parent 21aa7042c0
commit dedbc8ac36
15 changed files with 233 additions and 214 deletions
+7 -4
View File
@@ -152,8 +152,9 @@ public class DeviceProfile {
public float allAppsIconTextSizePx;
// Overview
public int overviewTaskThumbnailTopMarginPx;
public int overviewTaskMarginPx;
public int overviewTaskIconSizePx;
public int overviewTaskThumbnailTopMarginPx;
// Widgets
public final PointF appWidgetScale = new PointF(1.0f, 1.0f);
@@ -301,10 +302,12 @@ public class DeviceProfile {
: (hotseatBarTopPaddingPx + hotseatBarBottomPaddingPx
+ (isScalableGrid ? 0 : hotseatExtraVerticalSize)));
overviewTaskMarginPx = res.getDimensionPixelSize(R.dimen.overview_task_margin);
overviewTaskThumbnailTopMarginPx = res.getDimensionPixelSize(
R.dimen.task_thumbnail_icon_size) + 2 * overviewTaskMarginPx;
overviewTaskIconSizePx =
isTablet && FeatureFlags.ENABLE_OVERVIEW_GRID.get() ? res.getDimensionPixelSize(
R.dimen.task_thumbnail_icon_size_grid) : res.getDimensionPixelSize(
R.dimen.task_thumbnail_icon_size);
overviewTaskThumbnailTopMarginPx = overviewTaskIconSizePx + overviewTaskMarginPx * 2;
// Calculate all of the remaining variables.
extraSpace = updateAvailableDimensions(res);
+15 -8
View File
@@ -1512,17 +1512,16 @@ public abstract class PagedView<T extends View & PageIndicator> extends ViewGrou
return getDestinationPage(mOrientationHandler.getPrimaryScroll(this));
}
protected int getDestinationPage(int scaledScroll) {
return getPageNearestToCenterOfScreen(scaledScroll);
protected int getDestinationPage(int primaryScroll) {
return getPageNearestToCenterOfScreen(primaryScroll);
}
public int getPageNearestToCenterOfScreen() {
return getPageNearestToCenterOfScreen(mOrientationHandler.getPrimaryScroll(this));
}
private int getPageNearestToCenterOfScreen(int scaledScroll) {
int pageOrientationSize = mOrientationHandler.getMeasuredSize(this);
int screenCenter = scaledScroll + (pageOrientationSize / 2);
private int getPageNearestToCenterOfScreen(int primaryScroll) {
int screenCenter = getScreenCenter(primaryScroll);
int minDistanceFromScreenCenter = Integer.MAX_VALUE;
int minDistanceFromScreenCenterIndex = -1;
final int childCount = getChildCount();
@@ -1538,18 +1537,26 @@ public abstract class PagedView<T extends View & PageIndicator> extends ViewGrou
}
private int getDisplacementFromScreenCenter(int childIndex, int screenCenter) {
int childSize = getChildVisibleSize(childIndex);
int childSize = Math.round(getChildVisibleSize(childIndex));
int halfChildSize = (childSize / 2);
int childCenter = getChildOffset(childIndex) + halfChildSize;
return childCenter - screenCenter;
}
protected int getDisplacementFromScreenCenter(int childIndex) {
int pageOrientationSize = mOrientationHandler.getMeasuredSize(this);
int screenCenter = mOrientationHandler.getPrimaryScroll(this) + (pageOrientationSize / 2);
int primaryScroll = mOrientationHandler.getPrimaryScroll(this);
int screenCenter = getScreenCenter(primaryScroll);
return getDisplacementFromScreenCenter(childIndex, screenCenter);
}
private int getScreenCenter(int primaryScroll) {
float primaryScale = mOrientationHandler.getPrimaryScale(this);
float primaryPivot = mOrientationHandler.getPrimaryValue(getPivotX(), getPivotY());
int pageOrientationSize = mOrientationHandler.getMeasuredSize(this);
return Math.round(primaryScroll + (pageOrientationSize / 2f - primaryPivot) / primaryScale
+ primaryPivot);
}
protected void snapToDestination() {
snapToPage(getDestinationPage(), getPageSnapDuration());
}
@@ -77,6 +77,9 @@ public class Interpolators {
public static final Interpolator TOUCH_RESPONSE_INTERPOLATOR =
new PathInterpolator(0.3f, 0f, 0.1f, 1f);
public static final Interpolator TOUCH_RESPONSE_INTERPOLATOR_ACCEL_DEACCEL =
v -> ACCEL_DEACCEL.getInterpolation(TOUCH_RESPONSE_INTERPOLATOR.getInterpolation(v));
/**
* Inversion of ZOOM_OUT, compounded with an ease-out.
@@ -136,7 +136,7 @@ public class LandscapePagedViewHandler implements PagedOrientationHandler {
}
@Override
public int getClearAllScrollOffset(View view, boolean isRtl) {
public int getClearAllSidePadding(View view, boolean isRtl) {
return (isRtl ? view.getPaddingBottom() : - view.getPaddingTop()) / 2;
}
@@ -66,7 +66,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 getClearAllSidePadding(View view, boolean isRtl);
int getSecondaryDimension(View view);
FloatProperty<View> getPrimaryViewTranslate();
FloatProperty<View> getSecondaryViewTranslate();
@@ -132,7 +132,7 @@ public class PortraitPagedViewHandler implements PagedOrientationHandler {
}
@Override
public int getClearAllScrollOffset(View view, boolean isRtl) {
public int getClearAllSidePadding(View view, boolean isRtl) {
return (isRtl ? view.getPaddingRight() : - view.getPaddingLeft()) / 2;
}