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

Commit 2e2cf00

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

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
@@ -1,6 +1,8 @@
11
package com.zulip.android;
22

33
import java.sql.SQLException;
4+
import java.util.ArrayList;
5+
import java.util.List;
46
import java.util.Map;
57
import java.util.Queue;
68
import java.util.HashSet;
@@ -46,6 +48,16 @@ public class ZulipApp extends Application {
4648
Set<String> mutedTopics;
4749
private static final String MUTED_TOPIC_KEY = "mutedTopics";
4850

51+
private final static String GLOBAL_SETTINGS = "HumbugActivity";
52+
private final static String SERVER_SETTINGS = "serverSettings";
53+
private final static String GLOBAL_SETTINGS_CURRENT = "currentRealm";
54+
private static final String GLOBAL_SETTINGS_REALMS = "REALMS";
55+
56+
57+
public int currentRealm = 0;
58+
59+
public List<String> serverStringSet;
60+
private SharedPreferences globalSettings;
4961
/**
5062
* Handler to manage batching of unread messages
5163
*/
@@ -83,13 +95,10 @@ public void onCreate() {
8395

8496
// This used to be from HumbugActivity.getPreferences, so we keep that
8597
// file name.
86-
this.settings = getSharedPreferences("HumbugActivity",
87-
Context.MODE_PRIVATE);
98+
globalSettings = getSharedPreferences(GLOBAL_SETTINGS, Context.MODE_PRIVATE);
99+
currentRealm = globalSettings.getInt(GLOBAL_SETTINGS_CURRENT, currentRealm);
100+
serverStringSet = new ArrayList<String>(globalSettings.getStringSet(GLOBAL_SETTINGS_REALMS, new HashSet<String>()));
88101

89-
max_message_id = settings.getInt("max_message_id", -1);
90-
eventQueueId = settings.getString("eventQueueId", null);
91-
lastEventId = settings.getInt("lastEventId", -1);
92-
pointer = settings.getInt("pointer", -1);
93102

94103
if (BuildHelper.shouldLogToCrashlytics()) {
95104
Crashlytics.start(this);

0 commit comments

Comments
 (0)