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

Commit 86c0be7

Browse files
committed
Save settings for the new realm settings.
Reset, Abort current connections and estabilish new connections and settings.
1 parent 3dddd56 commit 86c0be7

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

app/src/main/java/com/zulip/android/activities/ZulipActivity.java

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99

1010
import android.annotation.SuppressLint;
1111
import android.annotation.TargetApi;
12+
import android.app.Activity;
1213
import android.app.AlertDialog;
14+
import android.app.ProgressDialog;
1315
import android.app.SearchManager;
1416
import android.content.BroadcastReceiver;
1517
import android.content.Context;
@@ -1095,4 +1097,44 @@ void switchRealm(final ProgressDialog progressDialog, final int position) {
10951097
progressDialog.dismiss();
10961098
}
10971099

1100+
1101+
@Override
1102+
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
1103+
if (requestCode == ADDREALM_REQUEST_CODE && resultCode == Activity.RESULT_OK) {
1104+
this.currentList.adapter.clear();
1105+
this.currentList.showLoadIndicatorTop(true);
1106+
final String realmName = data.getStringExtra("realmName");
1107+
final String apiKey = data.getStringExtra("api_key");
1108+
final String email = data.getStringExtra("email");
1109+
final String serverURL = data.getStringExtra("serverURL");
1110+
notifications.logOut(new Runnable() {
1111+
@Override
1112+
public void run() {
1113+
if (event_poll != null) {
1114+
event_poll.abort();
1115+
event_poll = null;
1116+
}
1117+
statusUpdateHandler.removeMessages(0);
1118+
try {
1119+
unregisterReceiver(onGcmMessage);
1120+
} catch (IllegalArgumentException e) {
1121+
ZLog.logException(e);
1122+
}
1123+
1124+
app.clearConnectionState();
1125+
app.createNewRealm();
1126+
app.setEmail(email);
1127+
app.setServerURL(serverURL);
1128+
app.saveServerName(realmName);
1129+
app.setLoggedInApiKey(apiKey);
1130+
IntentFilter filter = new IntentFilter(GcmBroadcastReceiver.BROADCAST);
1131+
filter.setPriority(2);
1132+
registerReceiver(onGcmMessage, filter);
1133+
onRefresh();
1134+
}
1135+
});
1136+
1137+
}
1138+
this.currentList.showLoadIndicatorTop(false);
1139+
}
10981140
}

0 commit comments

Comments
 (0)