diff options
author | Nebojsa Cvetkovic <nebkat@gmail.com> | 2013-11-25 16:58:53 +0000 |
---|---|---|
committer | Danesh M <daneshm90@gmail.com> | 2014-01-24 16:24:23 -0800 |
commit | 4fd7c82ec6cab6d160f72b0355f6c5fc399b1a43 (patch) | |
tree | 637afa03fb37b22d280ec6b22df5a47d278237cb /src/com/android/launcher3/settings/SettingsProvider.java | |
parent | 2af21d644dfdb5db0a0da751937566058c0cdfc4 (diff) | |
download | android_packages_apps_Trebuchet-4fd7c82ec6cab6d160f72b0355f6c5fc399b1a43.tar.gz android_packages_apps_Trebuchet-4fd7c82ec6cab6d160f72b0355f6c5fc399b1a43.tar.bz2 android_packages_apps_Trebuchet-4fd7c82ec6cab6d160f72b0355f6c5fc399b1a43.zip |
Workspace: Custom default screen
Change-Id: Ic90254f7758b9dbd4997a19474e455230355b772
Diffstat (limited to 'src/com/android/launcher3/settings/SettingsProvider.java')
-rw-r--r-- | src/com/android/launcher3/settings/SettingsProvider.java | 43 |
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)); } } |