Lawnchair: Make the grid actually reload

This commit is contained in:
Kshitij Gupta committed 2021-03-15 17:31:36 +05:30
1 parent 3fec1d33e5
commit b9ea94378e
2 files changed
+15

No files matched your search

@@ -2,6 +2,7 @@ package ch.deletescape.lawnchair.util.preferences
import android.content.Context
import android.content.SharedPreferences
import android.util.Log
import com.android.launcher3.LauncherAppState
import com.android.launcher3.Utilities
@@ -17,6 +18,10 @@ class LawnchairPreferences(val context: Context) {
LauncherAppState.getInstance(context).model.clearIconCache()
LauncherAppState.getInstance(context).model.forceReload()
}
WORKSPACE_ROWS, WORKSPACE_COLUMNS, ALL_APPS_COLUMNS, FOLDER_ROWS, FOLDER_COLUMNS, HOTSEAT_COLUMNS -> {
LauncherAppState.getInstance(context).invariantDeviceProfile.reInitGrid()
LauncherAppState.getInstance(context).model.forceReload()
}
}
}
@@ -140,6 +140,8 @@ public class InvariantDeviceProfile {
private ConfigMonitor mConfigMonitor;
private OverlayMonitor mOverlayMonitor;
private Context mContext;
@VisibleForTesting
public InvariantDeviceProfile() {}
@@ -162,10 +164,12 @@ public class InvariantDeviceProfile {
demoModeLayoutId = p.demoModeLayoutId;
mExtraAttrs = p.mExtraAttrs;
mOverlayMonitor = p.mOverlayMonitor;
mContext = p.mContext;
}
@TargetApi(23)
private InvariantDeviceProfile(Context context) {
mContext = context;
String gridName = getCurrentGridName(context);
String newGridName = initGrid(context, gridName);
if (!newGridName.equals(gridName)) {
@@ -185,6 +189,7 @@ public class InvariantDeviceProfile {
* This constructor should NOT have any monitors by design.
*/
public InvariantDeviceProfile(Context context, String gridName) {
mContext = context;
String newName = initGrid(context, gridName);
if (newName == null || !newName.equals(gridName)) {
throw new IllegalArgumentException("Unknown grid name");
@@ -195,6 +200,7 @@ public class InvariantDeviceProfile {
* This constructor should NOT have any monitors by design.
*/
public InvariantDeviceProfile(Context context, Display display) {
mContext = context;
// Ensure that the main device profile is initialized
InvariantDeviceProfile originalProfile = INSTANCE.get(context);
String gridName = getCurrentGridName(context);
@@ -322,6 +328,10 @@ public class InvariantDeviceProfile {
}
public void reInitGrid() {
initGrid(mContext, getCurrentGridName(mContext));
}
@Nullable
public TypedValue getAttrValue(int attr) {
return mExtraAttrs == null ? null : mExtraAttrs.get(attr);