diff options
author | Jorge Ruesga <jorge@ruesga.com> | 2013-05-01 00:49:36 +0200 |
---|---|---|
committer | Jorge Ruesga <jorge@ruesga.com> | 2013-05-01 00:49:36 +0200 |
commit | 47303b20c7fc028c1a7356607f82adafac4920dd (patch) | |
tree | ae453e0ceaaa267360e20c8ece050c66750f7577 /src | |
parent | 8663738c00f7d82362743e2f9b7cf41aa7f02be7 (diff) | |
download | packages_apps_trebuchet-47303b20c7fc028c1a7356607f82adafac4920dd.zip packages_apps_trebuchet-47303b20c7fc028c1a7356607f82adafac4920dd.tar.gz packages_apps_trebuchet-47303b20c7fc028c1a7356607f82adafac4920dd.tar.bz2 |
Trebuchet: Use preference provider to lock/unlock homescreen
mSharedPreferences uses "com.cyanogenmod.trebuchet.prefs", while the Preferences activity uses
"com.cyanogenmod.trebuchet_preferences". Use PreferenceProvider to sync lock/unlock homescreen.
Change-Id: Ib9312a9f8cffe3f009b8cd8d9b9789d459c1bd96
Signed-off-by: Jorge Ruesga <jorge@ruesga.com>
Diffstat (limited to 'src')
-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); } |