aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/de/tzur
diff options
context:
space:
mode:
authorsteckbrief <steckbrief@chefmail.de>2015-01-20 22:42:53 +0100
committersteckbrief <steckbrief@chefmail.de>2015-01-20 22:42:53 +0100
commit46bbf1ce5f5d6adbf21674c0b6f38243cb8d9fc7 (patch)
treea9629270cb551f0a1e0d764ef3b31295fc2223b1 /src/main/java/de/tzur
parente8ca2a1ae3259c66991f69d62c470ca611ee4659 (diff)
- Avoiding accessing shared preferences to know if emoticons should be parsed for every single message
- Adding support to show online status in Conversations overview (configurable via the setting "send_button_status")
Diffstat (limited to 'src/main/java/de/tzur')
-rw-r--r--src/main/java/de/tzur/conversations/Settings.java55
1 files changed, 55 insertions, 0 deletions
diff --git a/src/main/java/de/tzur/conversations/Settings.java b/src/main/java/de/tzur/conversations/Settings.java
new file mode 100644
index 00000000..25079ea1
--- /dev/null
+++ b/src/main/java/de/tzur/conversations/Settings.java
@@ -0,0 +1,55 @@
+package de.tzur.conversations;
+
+import android.content.SharedPreferences;
+import android.util.Log;
+
+/**
+ * This class is used to provide access to settings which have to be accessed frequently.
+ * Every setting in this class has to be updated using @see SettingsActivity#onSharedPreferenceChanged.
+ */
+public final class Settings {
+
+ /**
+ * Initializes the settings provided via this static class.
+ * @param preferences the shared preferences of the app.
+ */
+ public static void initSettingsClassWithPreferences(SharedPreferences preferences) {
+ Log.d("SETTING", "Initializing settings");
+ String[] preferenceNames = { "parse_emoticons", "send_button_status" };
+ for (String name : preferenceNames) {
+ Settings.synchronizeSettingsClassWithPreferences(preferences, name);
+ }
+ }
+
+ /**
+ * Synchronizes the setting value in this class on settings update in SettingsActivity.
+ * @param preferences the shared preferences of the app.
+ * @param name the name of the setting to synchronize.
+ */
+ public static void synchronizeSettingsClassWithPreferences(SharedPreferences preferences, String name) {
+ Log.d("SETTING", "Synchronizing settings");
+ switch (name) {
+ case "parse_emoticons":
+ Settings.PARSE_EMOTICONS = preferences.getBoolean(name, Settings.PARSE_EMOTICONS);
+ break;
+ case "send_button_status":
+ Settings.SHOW_ONLINE_STATUS = preferences.getBoolean(name, Settings.SHOW_ONLINE_STATUS);
+ break;
+ }
+ }
+ /**
+ * Boolean if emoticons should be parsed to emoticons or not.
+ */
+ public static boolean PARSE_EMOTICONS = false;
+ /**
+ * Boolean if online status should be shown or not.
+ */
+ public static boolean SHOW_ONLINE_STATUS = false;
+
+ /**
+ * This is a utility class - private constructor avoids any instantiation.
+ */
+ private Settings() {
+ // Private constructor to avoid instantiation
+ }
+}