From 42255d22a7bc08d4739c5521aaaedd5b90346d9c Mon Sep 17 00:00:00 2001 From: Tracy Zhou Date: Fri, 13 Mar 2020 00:38:11 -0700 Subject: [PATCH] Set default value of gridName to current grid name in GridOptionsProvider With grid preview, a grid name is passed in when requesting preview under different grid setting. With wallpaper preview, no such grid name will be passed in, and it should be set to the current. Bug: 145242344 Test: N/A Change-Id: I282cb5341b7f3756d41c4abd8d97f986abaa6d27 --- .../launcher3/uioverrides/PreviewSurfaceRenderer.java | 5 ++++- src/com/android/launcher3/InvariantDeviceProfile.java | 10 +++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/quickstep/src/com/android/launcher3/uioverrides/PreviewSurfaceRenderer.java b/quickstep/src/com/android/launcher3/uioverrides/PreviewSurfaceRenderer.java index 548223a8fe..c7cce0b563 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/PreviewSurfaceRenderer.java +++ b/quickstep/src/com/android/launcher3/uioverrides/PreviewSurfaceRenderer.java @@ -32,8 +32,11 @@ public class PreviewSurfaceRenderer { /** Handle a received surface view request. */ public static void render(Context context, Bundle bundle) { - final String gridName = bundle.getString("name"); + String gridName = bundle.getString("name"); bundle.remove("name"); + if (gridName == null) { + gridName = InvariantDeviceProfile.getCurrentGridName(context); + } final InvariantDeviceProfile idp = new InvariantDeviceProfile(context, gridName); MAIN_EXECUTOR.execute(() -> { diff --git a/src/com/android/launcher3/InvariantDeviceProfile.java b/src/com/android/launcher3/InvariantDeviceProfile.java index 2ad84b9f9c..7414a88586 100644 --- a/src/com/android/launcher3/InvariantDeviceProfile.java +++ b/src/com/android/launcher3/InvariantDeviceProfile.java @@ -162,9 +162,7 @@ public class InvariantDeviceProfile { "PreviewContext is passed into this IDP constructor"); } - String gridName = Utilities.getPrefs(context).getBoolean(GRID_OPTIONS_PREFERENCE_KEY, false) - ? Utilities.getPrefs(context).getString(KEY_IDP_GRID_NAME, null) - : null; + String gridName = getCurrentGridName(context); initGrid(context, gridName); mConfigMonitor = new ConfigMonitor(context, APPLY_CONFIG_AT_RUNTIME.get() ? this::onConfigChanged : this::killProcess); @@ -188,6 +186,12 @@ public class InvariantDeviceProfile { initGrid(context, null, new Info(display)); } + public static String getCurrentGridName(Context context) { + return Utilities.getPrefs(context).getBoolean(GRID_OPTIONS_PREFERENCE_KEY, false) + ? Utilities.getPrefs(context).getString(KEY_IDP_GRID_NAME, null) + : null; + } + /** * Retrieve system defined or RRO overriden icon shape. */