Skip to content
This repository was archived by the owner on Jul 25, 2024. It is now read-only.

Commit 2f825c9

Browse files
committed
Added SharedPreferences to store the realms
This GlobalSettings will store all the info about the saved realms.
1 parent cf69947 commit 2f825c9

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

app/src/main/java/com/zulip/android/ZulipApp.java

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,16 @@ public class ZulipApp extends Application {
4949
Set<String> mutedTopics;
5050
private static final String MUTED_TOPIC_KEY = "mutedTopics";
5151

52+
private final static String GLOBAL_SETTINGS = "HumbugActivity";
53+
private final static String SERVER_SETTINGS = "serverSettings";
54+
private final static String GLOBAL_SETTINGS_CURRENT = "currentRealm";
55+
private static final String GLOBAL_SETTINGS_REALMS = "REALMS";
56+
57+
58+
public int currentRealm = 0;
59+
60+
public HashSet serverStringSet;
61+
private SharedPreferences globalSettings;
5262
/**
5363
* Handler to manage batching of unread messages
5464
*/
@@ -86,13 +96,10 @@ public void onCreate() {
8696

8797
// This used to be from HumbugActivity.getPreferences, so we keep that
8898
// file name.
89-
this.settings = getSharedPreferences("HumbugActivity",
90-
Context.MODE_PRIVATE);
99+
globalSettings = getSharedPreferences(GLOBAL_SETTINGS, Context.MODE_PRIVATE);
100+
currentRealm = globalSettings.getInt(GLOBAL_SETTINGS_CURRENT, currentRealm);
101+
serverStringSet = new HashSet<String>(globalSettings.getStringSet(GLOBAL_SETTINGS_REALMS, new HashSet<String>()));
91102

92-
max_message_id = settings.getInt("max_message_id", -1);
93-
eventQueueId = settings.getString("eventQueueId", null);
94-
lastEventId = settings.getInt("lastEventId", -1);
95-
pointer = settings.getInt("pointer", -1);
96103

97104
if (BuildHelper.shouldLogToCrashlytics()) {
98105
// TODO(lfaraone): figure out what to do about crash reporting

0 commit comments

Comments
 (0)