diff options
author | Nebojsa Cvetkovic <nebkat@gmail.com> | 2013-11-20 21:26:10 +0000 |
---|---|---|
committer | Danesh M <daneshm90@gmail.com> | 2014-01-24 16:24:21 -0800 |
commit | 088187ee79416506852262535fca8963611fafbc (patch) | |
tree | 147e9bb6a183252cb49a765bb6df6c792fffe7f0 /src/com/android/launcher3/settings/SettingsProvider.java | |
parent | b5a2742f4196a2aa20217e64fd5bcccd19ad2a59 (diff) | |
download | android_packages_apps_Trebuchet-088187ee79416506852262535fca8963611fafbc.tar.gz android_packages_apps_Trebuchet-088187ee79416506852262535fca8963611fafbc.tar.bz2 android_packages_apps_Trebuchet-088187ee79416506852262535fca8963611fafbc.zip |
Settings: Initial
Change-Id: If8199313561dfba03a1aad0b49bb4036dcf586c9
Diffstat (limited to 'src/com/android/launcher3/settings/SettingsProvider.java')
-rw-r--r-- | src/com/android/launcher3/settings/SettingsProvider.java | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/src/com/android/launcher3/settings/SettingsProvider.java b/src/com/android/launcher3/settings/SettingsProvider.java new file mode 100644 index 000000000..30a7732b9 --- /dev/null +++ b/src/com/android/launcher3/settings/SettingsProvider.java @@ -0,0 +1,50 @@ +/* + * Copyright (C) 2013 The CyanogenMod Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +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"; + + private static Map<String, ?> sKeyValues; + + public static void load(Context context) { + SharedPreferences preferences = context.getSharedPreferences(SETTINGS_KEY, 0); + sKeyValues = preferences.getAll(); + } + + private static int getInt(String key, int def) { + return sKeyValues.containsKey(key) && sKeyValues.get(key) instanceof Integer ? + (Integer) sKeyValues.get(key) : def; + } + + private static boolean getBoolean(String key, boolean def) { + return sKeyValues.containsKey(key) && sKeyValues.get(key) instanceof Boolean ? + (Boolean) sKeyValues.get(key) : def; + } + + private static String getString(String key, String def) { + return sKeyValues.containsKey(key) && sKeyValues.get(key) instanceof String ? + (String) sKeyValues.get(key) : def; + } +} |