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

Commit 9cc76b5

Browse files
committed
Added SharedPreferences to store the realms
This GlobalSettings will store all the info about the saved realms.
1 parent 7a34200 commit 9cc76b5

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

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

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
package com.zulip.android;
22

33
import java.sql.SQLException;
4+
import java.util.ArrayList;
5+
import java.util.HashSet;
6+
import java.util.List;
47
import java.util.Map;
58
import java.util.Queue;
9+
import java.util.Set;
610
import java.util.concurrent.ConcurrentHashMap;
711
import java.util.concurrent.ConcurrentLinkedQueue;
812

@@ -57,6 +61,15 @@ public class ZulipApp extends Application {
5761
public static ZulipApp get() {
5862
return instance;
5963
}
64+
private final static String GLOBAL_SETTINGS = "HumbugActivity";
65+
private final static String SERVER_SETTINGS = "serverSettings";
66+
private final static String GLOBAL_SETTINGS_CURRENT = "currentRealm";
67+
private static final String GLOBAL_SETTINGS_REALMS = "REALMS";
68+
69+
public int currentRealm = 0;
70+
71+
public List<String> serverStringSet;
72+
private SharedPreferences globalSettings;
6073

6174
@Override
6275
public void onCreate() {
@@ -65,13 +78,11 @@ public void onCreate() {
6578

6679
// This used to be from HumbugActivity.getPreferences, so we keep that
6780
// file name.
68-
this.settings = getSharedPreferences("HumbugActivity",
69-
Context.MODE_PRIVATE);
7081

71-
max_message_id = settings.getInt("max_message_id", -1);
72-
eventQueueId = settings.getString("eventQueueId", null);
73-
lastEventId = settings.getInt("lastEventId", -1);
74-
pointer = settings.getInt("pointer", -1);
82+
globalSettings = getSharedPreferences(GLOBAL_SETTINGS, Context.MODE_PRIVATE);
83+
currentRealm = globalSettings.getInt(GLOBAL_SETTINGS_CURRENT, currentRealm);
84+
serverStringSet = new ArrayList<String>(globalSettings.getStringSet(GLOBAL_SETTINGS_REALMS, new HashSet<String>()));
85+
7586

7687
if (BuildHelper.shouldLogToCrashlytics()) {
7788
Crashlytics.start(this);

0 commit comments

Comments
 (0)