summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJorge Ruesga <jorge@ruesga.com>2013-04-30 15:53:31 -0700
committerGerrit Code Review <gerrit@cyanogenmod.org>2013-04-30 15:53:31 -0700
commit1b594e97521683bce2535f308085100c17f7e89a (patch)
tree75f14f3422c53ba3196382c9242f06715c48d227
parent27e7ba45147e560ba077ab7e5c28b8bcdbdc18b0 (diff)
parent47303b20c7fc028c1a7356607f82adafac4920dd (diff)
downloadpackages_apps_trebuchet-1b594e97521683bce2535f308085100c17f7e89a.tar.gz
packages_apps_trebuchet-1b594e97521683bce2535f308085100c17f7e89a.tar.bz2
packages_apps_trebuchet-1b594e97521683bce2535f308085100c17f7e89a.zip
Merge "Trebuchet: Use preference provider to lock/unlock homescreen" into cm-10.1
-rw-r--r--src/com/cyanogenmod/trebuchet/Launcher.java4
-rw-r--r--src/com/cyanogenmod/trebuchet/preference/PreferencesProvider.java18
2 files changed, 16 insertions, 6 deletions
diff --git a/src/com/cyanogenmod/trebuchet/Launcher.java b/src/com/cyanogenmod/trebuchet/Launcher.java
index c82c8fe2..ed8ae087 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 c4039ffa..17887328 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);
}