Revert "Migrate IDP_GRID_NAME usage to LauncherPrefs"

This reverts commit 6f9a57186c.

Reason for revert: A Bug where only device preferences were being used, not the main shared preference file.

Bug: 269569568
Test: Verified this on device.
Change-Id: I8422b2d7073537bd46c3a91033bd2281bbd306b7
This commit is contained in:
Stefan Andonian
2023-02-21 18:10:08 +00:00
parent 6f9a57186c
commit df11959779
3 changed files with 34 additions and 33 deletions

View File

@@ -16,7 +16,6 @@
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;
@@ -94,6 +93,8 @@ public class InvariantDeviceProfile {
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
@@ -205,7 +206,8 @@ public class InvariantDeviceProfile {
String gridName = getCurrentGridName(context);
String newGridName = initGrid(context, gridName);
if (!newGridName.equals(gridName)) {
LauncherPrefs.get(context).put(GRID_NAME, newGridName);
LauncherPrefs.getPrefs(context).edit().putString(KEY_IDP_GRID_NAME, newGridName)
.apply();
}
new DeviceGridState(this).writeToPrefs(context);
@@ -313,7 +315,7 @@ public class InvariantDeviceProfile {
}
public static String getCurrentGridName(Context context) {
return LauncherPrefs.get(context).get(GRID_NAME);
return LauncherPrefs.getPrefs(context).getString(KEY_IDP_GRID_NAME, null);
}
private String initGrid(Context context, String gridName) {
@@ -453,8 +455,9 @@ public class InvariantDeviceProfile {
public void setCurrentGrid(Context context, String gridName) {
LauncherPrefs.get(context).put(GRID_NAME, gridName);
MAIN_EXECUTOR.execute(() -> onConfigChanged(context.getApplicationContext()));
Context appContext = context.getApplicationContext();
LauncherPrefs.getPrefs(appContext).edit().putString(KEY_IDP_GRID_NAME, gridName).apply();
MAIN_EXECUTOR.execute(() -> onConfigChanged(appContext));
}
private Object[] toModelState() {