Fix workspace scale calculation
- Based on workspace page instead of workspace (takes padding into
account)
- Checks that width != 0 so we don't divide by 0
Bug: 79526164
Change-Id: I25d92a04550aa34abab7e9e1f93c93dbccd61752
diff --git a/quickstep/src/com/android/launcher3/uioverrides/OverviewState.java b/quickstep/src/com/android/launcher3/uioverrides/OverviewState.java
index 4029b82..ac940ea 100644
--- a/quickstep/src/com/android/launcher3/uioverrides/OverviewState.java
+++ b/quickstep/src/com/android/launcher3/uioverrides/OverviewState.java
@@ -50,8 +50,11 @@
public float[] getWorkspaceScaleAndTranslation(Launcher launcher) {
RecentsView recentsView = launcher.getOverviewPanel();
Workspace workspace = launcher.getWorkspace();
+ View workspacePage = workspace.getPageAt(workspace.getCurrentPage());
+ float workspacePageWidth = workspacePage != null && workspacePage.getWidth() != 0
+ ? workspacePage.getWidth() : launcher.getDeviceProfile().availableWidthPx;
recentsView.getTaskSize(sTempRect);
- float scale = (float) sTempRect.width() / workspace.getWidth();
+ float scale = (float) sTempRect.width() / workspacePageWidth;
float parallaxFactor = 0.4f;
return new float[]{scale, 0, -getDefaultSwipeHeight(launcher) * parallaxFactor};
}