Revert "Revert "Migrate IDP_GRID_NAME usage to LauncherPrefs""
This reverts commit df11959779ca08a48308d9e390eb5b3fdb4bbf35.
Bug: 269569568
Test: In follow-up CL, everything works on device and manual and unit tests
verified original bug from this CL is not present.
Change-Id: I125bbbfd6442cd3fa1e88c9109de536b88981dc6
diff --git a/src/com/android/launcher3/InvariantDeviceProfile.java b/src/com/android/launcher3/InvariantDeviceProfile.java
index 604c1b8..2fb0fa6 100644
--- a/src/com/android/launcher3/InvariantDeviceProfile.java
+++ b/src/com/android/launcher3/InvariantDeviceProfile.java
@@ -16,6 +16,7 @@
package com.android.launcher3;
+import static com.android.launcher3.LauncherPrefs.GRID_NAME;
import static com.android.launcher3.Utilities.dpiFromPx;
import static com.android.launcher3.config.FeatureFlags.ENABLE_DEVICE_PROFILE_LOGGING;
import static com.android.launcher3.config.FeatureFlags.ENABLE_TWO_PANEL_HOME;
@@ -93,8 +94,6 @@
public static final int TYPE_MULTI_DISPLAY = 1;
public static final int TYPE_TABLET = 2;
- private static final String KEY_IDP_GRID_NAME = "idp_grid_name";
-
private static final float ICON_SIZE_DEFINED_IN_APP_DP = 48;
// Constants that affects the interpolation curve between statically defined device profile
@@ -207,8 +206,7 @@
String gridName = getCurrentGridName(context);
String newGridName = initGrid(context, gridName);
if (!newGridName.equals(gridName)) {
- LauncherPrefs.getPrefs(context).edit().putString(KEY_IDP_GRID_NAME, newGridName)
- .apply();
+ LauncherPrefs.get(context).put(GRID_NAME, newGridName);
}
new DeviceGridState(this).writeToPrefs(context);
@@ -316,7 +314,7 @@
}
public static String getCurrentGridName(Context context) {
- return LauncherPrefs.getPrefs(context).getString(KEY_IDP_GRID_NAME, null);
+ return LauncherPrefs.get(context).get(GRID_NAME);
}
private String initGrid(Context context, String gridName) {
@@ -458,9 +456,8 @@
public void setCurrentGrid(Context context, String gridName) {
- Context appContext = context.getApplicationContext();
- LauncherPrefs.getPrefs(appContext).edit().putString(KEY_IDP_GRID_NAME, gridName).apply();
- MAIN_EXECUTOR.execute(() -> onConfigChanged(appContext));
+ LauncherPrefs.get(context).put(GRID_NAME, gridName);
+ MAIN_EXECUTOR.execute(() -> onConfigChanged(context.getApplicationContext()));
}
private Object[] toModelState() {