From 0c4e11b4797b21e432ef7ded46983adba0426821 Mon Sep 17 00:00:00 2001 From: Alex Chau Date: Fri, 8 Jul 2022 18:41:36 +0100 Subject: [PATCH] Make workspace and hotseat scale down in widgets picker - Also centralized workspace content scale percentage to DeviceProfile Test: manual Fix: 231699666 Change-Id: I3f8dcb9921e0cd93ad391d51120b189005ad07df --- quickstep/res/values/dimens.xml | 1 - .../launcher3/QuickstepTransitionManager.java | 6 ++---- .../uioverrides/states/AllAppsState.java | 7 +++---- res/values/dimens.xml | 3 +++ src/com/android/launcher3/DeviceProfile.java | 2 ++ src/com/android/launcher3/Launcher.java | 16 +++++++++++++++- src/com/android/launcher3/LauncherAnimUtils.java | 6 +++--- 7 files changed, 28 insertions(+), 13 deletions(-) diff --git a/quickstep/res/values/dimens.xml b/quickstep/res/values/dimens.xml index 0fd3c4a3db..17a48a7f14 100644 --- a/quickstep/res/values/dimens.xml +++ b/quickstep/res/values/dimens.xml @@ -66,7 +66,6 @@ 0.5dp - 0.97 115dp 100dp diff --git a/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java b/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java index b20752d630..bb79c1ba10 100644 --- a/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java +++ b/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java @@ -200,7 +200,6 @@ public class QuickstepTransitionManager implements OnDeviceProfileChangeListener final Handler mHandler; - private final float mContentScale; private final float mClosingWindowTransY; private final float mMaxShadowRadius; @@ -245,7 +244,6 @@ public class QuickstepTransitionManager implements OnDeviceProfileChangeListener mBackAnimationController = new LauncherBackAnimationController(mLauncher, this); Resources res = mLauncher.getResources(); - mContentScale = res.getFloat(R.dimen.content_scale); mClosingWindowTransY = res.getDimensionPixelSize(R.dimen.closing_window_trans_y); mMaxShadowRadius = res.getDimensionPixelSize(R.dimen.max_shadow_radius); @@ -483,8 +481,8 @@ public class QuickstepTransitionManager implements OnDeviceProfileChangeListener : new float[]{0, 1}; float[] scales = isAppOpening - ? new float[]{1, mContentScale} - : new float[]{mContentScale, 1}; + ? new float[]{1, mDeviceProfile.workspaceContentScale} + : new float[]{mDeviceProfile.workspaceContentScale, 1}; // Pause expensive view updates as they can lead to layer thrashing and skipped frames. mLauncher.pauseExpensiveViewUpdates(); diff --git a/quickstep/src/com/android/launcher3/uioverrides/states/AllAppsState.java b/quickstep/src/com/android/launcher3/uioverrides/states/AllAppsState.java index a74774c62b..9f2efc4962 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/states/AllAppsState.java +++ b/quickstep/src/com/android/launcher3/uioverrides/states/AllAppsState.java @@ -31,8 +31,6 @@ import com.android.launcher3.util.Themes; */ public class AllAppsState extends LauncherState { - private static final float WORKSPACE_SCALE_FACTOR = 0.97f; - private static final int STATE_FLAGS = FLAG_WORKSPACE_INACCESSIBLE | FLAG_CLOSE_POPUPS | FLAG_HOTSEAT_INACCESSIBLE; @@ -60,7 +58,8 @@ public class AllAppsState extends LauncherState { @Override public ScaleAndTranslation getWorkspaceScaleAndTranslation(Launcher launcher) { - return new ScaleAndTranslation(WORKSPACE_SCALE_FACTOR, NO_OFFSET, NO_OFFSET); + return new ScaleAndTranslation(launcher.getDeviceProfile().workspaceContentScale, NO_OFFSET, + NO_OFFSET); } @Override @@ -71,7 +70,7 @@ public class AllAppsState extends LauncherState { ScaleAndTranslation overviewScaleAndTranslation = LauncherState.OVERVIEW .getWorkspaceScaleAndTranslation(launcher); return new ScaleAndTranslation( - WORKSPACE_SCALE_FACTOR, + launcher.getDeviceProfile().workspaceContentScale, overviewScaleAndTranslation.translationX, overviewScaleAndTranslation.translationY); } diff --git a/res/values/dimens.xml b/res/values/dimens.xml index 5e33de8012..a3a30e1a72 100644 --- a/res/values/dimens.xml +++ b/res/values/dimens.xml @@ -413,4 +413,7 @@ 4dp 16dp 2dp + + + 0.97 diff --git a/src/com/android/launcher3/DeviceProfile.java b/src/com/android/launcher3/DeviceProfile.java index 1bc269d9c3..673ab54c7b 100644 --- a/src/com/android/launcher3/DeviceProfile.java +++ b/src/com/android/launcher3/DeviceProfile.java @@ -107,6 +107,7 @@ public class DeviceProfile { public Rect cellLayoutPaddingPx = new Rect(); public final int edgeMarginPx; + public final float workspaceContentScale; public float workspaceSpringLoadShrunkTop; public float workspaceSpringLoadShrunkBottom; public final int workspaceSpringLoadedBottomSpace; @@ -298,6 +299,7 @@ public class DeviceProfile { } edgeMarginPx = res.getDimensionPixelSize(R.dimen.dynamic_grid_edge_margin); + workspaceContentScale = res.getFloat(R.dimen.workspace_content_scale); desiredWorkspaceHorizontalMarginPx = getHorizontalMarginPx(inv, res); desiredWorkspaceHorizontalMarginOriginalPx = desiredWorkspaceHorizontalMarginPx; diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java index 5081f4f7c6..1632090588 100644 --- a/src/com/android/launcher3/Launcher.java +++ b/src/com/android/launcher3/Launcher.java @@ -30,7 +30,10 @@ import static com.android.launcher3.AbstractFloatingView.TYPE_ICON_SURFACE; import static com.android.launcher3.AbstractFloatingView.TYPE_REBIND_SAFE; import static com.android.launcher3.AbstractFloatingView.TYPE_SNACKBAR; import static com.android.launcher3.AbstractFloatingView.getTopOpenViewWithType; +import static com.android.launcher3.LauncherAnimUtils.HOTSEAT_SCALE_PROPERTY_FACTORY; +import static com.android.launcher3.LauncherAnimUtils.SCALE_INDEX_WIDGET_TRANSITION; import static com.android.launcher3.LauncherAnimUtils.SPRING_LOADED_EXIT_DELAY; +import static com.android.launcher3.LauncherAnimUtils.WORKSPACE_SCALE_PROPERTY_FACTORY; import static com.android.launcher3.LauncherSettings.Favorites.ITEM_TYPE_APPLICATION; import static com.android.launcher3.LauncherState.ALL_APPS; import static com.android.launcher3.LauncherState.FLAG_MULTI_PAGE; @@ -96,6 +99,7 @@ import android.os.Trace; import android.os.UserHandle; import android.text.TextUtils; import android.text.method.TextKeyListener; +import android.util.FloatProperty; import android.util.Log; import android.util.SparseArray; import android.view.KeyEvent; @@ -301,6 +305,11 @@ public class Launcher extends StatefulActivity public static final int DISPLAY_WORKSPACE_TRACE_COOKIE = 0; public static final int DISPLAY_ALL_APPS_TRACE_COOKIE = 1; + private static final FloatProperty> WORKSPACE_WIDGET_SCALE = + WORKSPACE_SCALE_PROPERTY_FACTORY.get(SCALE_INDEX_WIDGET_TRANSITION); + private static final FloatProperty HOTSEAT_WIDGET_SCALE = + HOTSEAT_SCALE_PROPERTY_FACTORY.get(SCALE_INDEX_WIDGET_TRANSITION); + private Configuration mOldConfig; @Thunk @@ -3225,7 +3234,12 @@ public class Launcher extends StatefulActivity * @param progress Transition progress from 0 to 1; where 0 => home and 1 => widgets. */ public void onWidgetsTransition(float progress) { - // No-Op + if (mDeviceProfile.isTablet) { + float scale = + Utilities.comp(Utilities.comp(mDeviceProfile.workspaceContentScale) * progress); + WORKSPACE_WIDGET_SCALE.set(getWorkspace(), scale); + HOTSEAT_WIDGET_SCALE.set(getHotseat(), scale); + } } private static class NonConfigInstance { diff --git a/src/com/android/launcher3/LauncherAnimUtils.java b/src/com/android/launcher3/LauncherAnimUtils.java index 0c7c3110c4..b858d1a13a 100644 --- a/src/com/android/launcher3/LauncherAnimUtils.java +++ b/src/com/android/launcher3/LauncherAnimUtils.java @@ -81,9 +81,9 @@ public class LauncherAnimUtils { new MultiScalePropertyFactory("hotseat_scale_property"); public static final int SCALE_INDEX_UNFOLD_ANIMATION = 1; - public static final int SCALE_INDEX_UNLOCK_ANIMATION = 2; - public static final int SCALE_INDEX_WORKSPACE_STATE = 3; - public static final int SCALE_INDEX_REVEAL_ANIM = 4; + public static final int SCALE_INDEX_WORKSPACE_STATE = 2; + public static final int SCALE_INDEX_REVEAL_ANIM = 3; + public static final int SCALE_INDEX_WIDGET_TRANSITION = 4; /** Increase the duration if we prevented the fling, as we are going against a high velocity. */ public static int blockedFlingDurationFactor(float velocity) {