Merge "Prevent edit state workspace scale from hiding next pages." into tm-dev am: de5d9718ed
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Launcher3/+/17730701
Change-Id: I57a8af052e5ae512c8685d0c492d286f8e84008b
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
diff --git a/src/com/android/launcher3/DeviceProfile.java b/src/com/android/launcher3/DeviceProfile.java
index 5a59de5..33bb0a5 100644
--- a/src/com/android/launcher3/DeviceProfile.java
+++ b/src/com/android/launcher3/DeviceProfile.java
@@ -928,6 +928,13 @@
return workspaceSpringLoadShrunkBottom;
}
+ /**
+ * Gets the minimum visible amount of the next workspace page when in the spring-loaded state.
+ */
+ public float getWorkspaceSpringLoadedMinimumNextPageVisible() {
+ return getCellSize().x / 2f;
+ }
+
public int getWorkspaceWidth() {
return getWorkspaceWidth(getTotalWorkspacePadding());
}
diff --git a/src/com/android/launcher3/states/SpringLoadedState.java b/src/com/android/launcher3/states/SpringLoadedState.java
index 52356ce..7e9d56d 100644
--- a/src/com/android/launcher3/states/SpringLoadedState.java
+++ b/src/com/android/launcher3/states/SpringLoadedState.java
@@ -53,7 +53,15 @@
float shrunkTop = grid.getWorkspaceSpringLoadShrunkTop();
float shrunkBottom = grid.getWorkspaceSpringLoadShrunkBottom();
- float scale = (shrunkBottom - shrunkTop) / ws.getNormalChildHeight();
+ float scale = Math.min((shrunkBottom - shrunkTop) / ws.getNormalChildHeight(), 1f);
+
+ // Reduce scale if next pages would not be visible after scaling the workspace
+ float scaledWorkspaceWidth = ws.getWidth() * scale;
+ float maxAvailableWidth =
+ ws.getWidth() - (2 * grid.getWorkspaceSpringLoadedMinimumNextPageVisible());
+ if (scaledWorkspaceWidth > maxAvailableWidth) {
+ scale *= maxAvailableWidth / scaledWorkspaceWidth;
+ }
float halfHeight = ws.getHeight() / 2;
float myCenter = ws.getTop() + halfHeight;