Index: blimp/client/core/android/java/src/org/chromium/blimp/core/common/PreferencesUtil.java |
diff --git a/blimp/client/core/android/java/src/org/chromium/blimp/core/common/PreferencesUtil.java b/blimp/client/core/android/java/src/org/chromium/blimp/core/common/PreferencesUtil.java |
new file mode 100644 |
index 0000000000000000000000000000000000000000..582eb3514f01d240f8bae2e512e2318b8177f552 |
--- /dev/null |
+++ b/blimp/client/core/android/java/src/org/chromium/blimp/core/common/PreferencesUtil.java |
@@ -0,0 +1,51 @@ |
+// Copyright 2016 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+package org.chromium.blimp.core.common; |
+ |
+import org.chromium.base.ContextUtils; |
+ |
+/** |
+ * Blimp preferences utilities. |
+ */ |
+public class PreferencesUtil { |
+ |
+ /** |
+ * Blimp switch preference key, also the key for this PreferenceFragment. |
+ */ |
+ public static final String PREF_BLIMP_SWITCH = "blimp_switch"; |
+ |
+ /** |
+ * Blimp assigner URL preference key. |
+ */ |
+ public static final String PREF_ASSIGNER_URL = "blimp_assigner_url"; |
+ |
+ private static final String DEFAULT_ASSIGNER_URL = |
+ "https://dev-blimp-pa.sandbox.googleapis.com/v1/assignment"; |
+ |
+ /** |
+ * Reads the last used assigner from shared preference. |
+ * @return The saved value of assigner preference, or the default development assigner URL |
+ * if we didn't find the shared preference. |
+ */ |
+ public static String getLastUsedAssigner() { |
+ return ContextUtils.getAppSharedPreferences().getString( |
+ PREF_ASSIGNER_URL, DEFAULT_ASSIGNER_URL); |
+ } |
+ |
+ /** |
+ * @return Value of Blimp switch preference. |
+ */ |
+ public static boolean isBlimpEnabled() { |
+ return ContextUtils.getAppSharedPreferences().getBoolean(PREF_BLIMP_SWITCH, false); |
+ } |
+ |
+ /** |
+ * Set the value of Blimp switch preference. |
+ */ |
+ public static void setBlimpEnabled(boolean enabled) { |
+ ContextUtils.getAppSharedPreferences().edit().putBoolean(PREF_BLIMP_SWITCH, enabled) |
+ .apply(); |
+ } |
+} |