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

Commit 6e1ec01

Browse files
committed
Added SharedPreferences to store the realms
This GlobalSettings will store all the info about the saved realms.
1 parent 6ddd1f7 commit 6e1ec01

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

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

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
import java.io.IOException;
44
import java.sql.SQLException;
5+
import java.util.ArrayList;
6+
import java.util.List;
57
import java.util.Map;
68
import java.util.Queue;
79
import java.util.HashSet;
@@ -49,6 +51,16 @@ public class ZulipApp extends Application {
4951
Set<String> mutedTopics;
5052
private static final String MUTED_TOPIC_KEY = "mutedTopics";
5153

54+
private final static String GLOBAL_SETTINGS = "HumbugActivity";
55+
private final static String SERVER_SETTINGS = "serverSettings";
56+
private final static String GLOBAL_SETTINGS_CURRENT = "currentRealm";
57+
private static final String GLOBAL_SETTINGS_REALMS = "REALMS";
58+
59+
60+
public int currentRealm = 0;
61+
62+
public List<String> serverStringSet;
63+
private SharedPreferences globalSettings;
5264
/**
5365
* Handler to manage batching of unread messages
5466
*/
@@ -86,13 +98,10 @@ public void onCreate() {
8698

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

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);
96105

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

0 commit comments

Comments
 (0)