diff options
-rw-r--r-- | src/com/cyanogenmod/trebuchet/Launcher.java | 4 | ||||
-rw-r--r-- | src/com/cyanogenmod/trebuchet/preference/PreferencesProvider.java | 18 |
2 files changed, 16 insertions, 6 deletions
diff --git a/src/com/cyanogenmod/trebuchet/Launcher.java b/src/com/cyanogenmod/trebuchet/Launcher.java index c82c8fe..ed8ae08 100644 --- a/src/com/cyanogenmod/trebuchet/Launcher.java +++ b/src/com/cyanogenmod/trebuchet/Launcher.java @@ -1835,9 +1835,7 @@ public final class Launcher extends Activity return true; case MENU_LOCK_WORKSPACE: mLockWorkspace = !mLockWorkspace; - SharedPreferences.Editor editor = mSharedPrefs.edit(); - editor.putBoolean("ui_general_lock_workspace", mLockWorkspace); - editor.commit(); + PreferencesProvider.Interface.General.setLockWorkspace(this, mLockWorkspace); return true; } diff --git a/src/com/cyanogenmod/trebuchet/preference/PreferencesProvider.java b/src/com/cyanogenmod/trebuchet/preference/PreferencesProvider.java index c4039ff..1788732 100644 --- a/src/com/cyanogenmod/trebuchet/preference/PreferencesProvider.java +++ b/src/com/cyanogenmod/trebuchet/preference/PreferencesProvider.java @@ -18,8 +18,8 @@ package com.cyanogenmod.trebuchet.preference; import android.content.Context; import android.content.SharedPreferences; +import android.content.SharedPreferences.Editor; -import com.cyanogenmod.trebuchet.LauncherApplication; import com.cyanogenmod.trebuchet.Workspace; import com.cyanogenmod.trebuchet.AppsCustomizePagedView; @@ -30,11 +30,12 @@ public final class PreferencesProvider { public static final String PREFERENCES_CHANGED = "preferences_changed"; - private static Map<String, ?> sKeyValues; + private static Map<String, Object> sKeyValues; + @SuppressWarnings("unchecked") public static void load(Context context) { SharedPreferences preferences = context.getSharedPreferences(PREFERENCES_KEY, 0); - sKeyValues = preferences.getAll(); + sKeyValues = (Map<String, Object>)preferences.getAll(); } private static int getInt(String key, int def) { @@ -47,6 +48,14 @@ public final class PreferencesProvider { (Boolean) sKeyValues.get(key) : def; } + private static void setBoolean(Context ctx, String key, boolean value) { + SharedPreferences preferences = ctx.getSharedPreferences(PREFERENCES_KEY, 0); + Editor editor = preferences.edit(); + editor.putBoolean(key, value); + editor.apply(); // For better performance + sKeyValues.put(key, Boolean.valueOf(value)); + } + private static String getString(String key, String def) { return sKeyValues.containsKey(key) && sKeyValues.get(key) instanceof String ? (String) sKeyValues.get(key) : def; @@ -207,6 +216,9 @@ public final class PreferencesProvider { public static boolean getLockWorkspace(boolean def) { return getBoolean("ui_general_lock_workspace", def); } + public static void setLockWorkspace(Context ctx, boolean value) { + setBoolean(ctx, "ui_general_lock_workspace", value); + } public static boolean getFullscreenMode() { return getBoolean("ui_general_fullscreen", false); } |