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
diff --git a/src/com/android/launcher3/PagedView.java b/src/com/android/launcher3/PagedView.java
index 65fde86..76885cc 100644
--- a/src/com/android/launcher3/PagedView.java
+++ b/src/com/android/launcher3/PagedView.java
@@ -1512,17 +1512,16 @@
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 @@
}
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());
}