summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher3/settings/SettingsProvider.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/android/launcher3/settings/SettingsProvider.java')
-rw-r--r--src/com/android/launcher3/settings/SettingsProvider.java43
1 files changed, 22 insertions, 21 deletions
diff --git a/src/com/android/launcher3/settings/SettingsProvider.java b/src/com/android/launcher3/settings/SettingsProvider.java
index fdf2757df..96da0e0a6 100644
--- a/src/com/android/launcher3/settings/SettingsProvider.java
+++ b/src/com/android/launcher3/settings/SettingsProvider.java
@@ -19,46 +19,47 @@ package com.android.launcher3.settings;
import android.content.Context;
import android.content.SharedPreferences;
-import java.util.Map;
-
public final class SettingsProvider {
public static final String SETTINGS_KEY = "com.android.launcher3_preferences";
public static final String SETTINGS_CHANGED = "settings_changed";
+ public static final String SETTINGS_UI_HOMESCREEN_DEFAULT_SCREEN_ID = "ui_homescreen_default_screen_id";
public static final String SETTINGS_UI_HOMESCREEN_SEARCH = "ui_homescreen_search";
- private static Map<String, ?> sKeyValues;
+ public static SharedPreferences get(Context context) {
+ return context.getSharedPreferences(SETTINGS_KEY, 0);
+ }
+
+ public static int getIntCustomDefault(Context context, String key, int def) {
+ return get(context).getInt(key, def);
+ }
- public static void load(Context context) {
- SharedPreferences preferences = context.getSharedPreferences(SETTINGS_KEY, 0);
- sKeyValues = preferences.getAll();
+ public static int getInt(Context context, String key, int resource) {
+ return getIntCustomDefault(context, key, context.getResources().getInteger(resource));
}
- public static int getInt(String key, int def) {
- return sKeyValues.containsKey(key) && sKeyValues.get(key) instanceof Integer ?
- (Integer) sKeyValues.get(key) : def;
+ public static long getLongCustomDefault(Context context, String key, long def) {
+ return get(context).getLong(key, def);
}
- public static int getInt(String key, Context context, int resource) {
- return getInt(key, context.getResources().getInteger(resource));
+ public static long getLong(Context context, String key, int resource) {
+ return getLongCustomDefault(context, key, context.getResources().getInteger(resource));
}
- public static boolean getBoolean(String key, boolean def) {
- return sKeyValues.containsKey(key) && sKeyValues.get(key) instanceof Boolean ?
- (Boolean) sKeyValues.get(key) : def;
+ public static boolean getBooleanCustomDefault(Context context, String key, boolean def) {
+ return get(context).getBoolean(key, def);
}
- public static boolean getBoolean(String key, Context context, int resource) {
- return getBoolean(key, context.getResources().getBoolean(resource));
+ public static boolean getBoolean(Context context, String key, int resource) {
+ return getBooleanCustomDefault(context, key, context.getResources().getBoolean(resource));
}
- public static String getString(String key, String def) {
- return sKeyValues.containsKey(key) && sKeyValues.get(key) instanceof String ?
- (String) sKeyValues.get(key) : def;
+ public static String getStringCustomDefault(Context context, String key, String def) {
+ return get(context).getString(key, def);
}
- public static String getString(String key, Context context, int resource) {
- return getString(key, context.getResources().getString(resource));
+ public static String getString(Context context, String key, int resource) {
+ return getStringCustomDefault(context, key, context.getResources().getString(resource));
}
}