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

Commit a6c43b2

Browse files
committed
Save settings for the new realm settings.
Reset, Abort current connections and estabilish new connections and settings.
1 parent e3e7499 commit a6c43b2

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

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

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

1010
import android.annotation.SuppressLint;
1111
import android.annotation.TargetApi;
12+
import android.app.Activity;
1213
import android.app.AlertDialog;
1314
import android.app.ProgressDialog;
1415
import android.app.SearchManager;
@@ -1248,4 +1249,44 @@ void switchRealm(final ProgressDialog progressDialog, final int position) {
12481249
progressDialog.dismiss();
12491250
}
12501251

1252+
1253+
@Override
1254+
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
1255+
if (requestCode == ADDREALM_REQUEST_CODE && resultCode == Activity.RESULT_OK) {
1256+
this.currentList.adapter.clear();
1257+
this.currentList.showLoadIndicatorTop(true);
1258+
final String realmName = data.getStringExtra("realmName");
1259+
final String apiKey = data.getStringExtra("api_key");
1260+
final String email = data.getStringExtra("email");
1261+
final String serverURL = data.getStringExtra("serverURL");
1262+
notifications.logOut(new Runnable() {
1263+
@Override
1264+
public void run() {
1265+
if (event_poll != null) {
1266+
event_poll.abort();
1267+
event_poll = null;
1268+
}
1269+
statusUpdateHandler.removeMessages(0);
1270+
try {
1271+
unregisterReceiver(onGcmMessage);
1272+
} catch (IllegalArgumentException e) {
1273+
ZLog.logException(e);
1274+
}
1275+
1276+
app.clearConnectionState();
1277+
app.createNewRealm();
1278+
app.setEmail(email);
1279+
app.setServerURL(serverURL);
1280+
app.saveServerName(realmName);
1281+
app.setLoggedInApiKey(apiKey);
1282+
IntentFilter filter = new IntentFilter(GcmBroadcastReceiver.BROADCAST);
1283+
filter.setPriority(2);
1284+
registerReceiver(onGcmMessage, filter);
1285+
onRefresh();
1286+
}
1287+
});
1288+
1289+
}
1290+
this.currentList.showLoadIndicatorTop(false);
1291+
}
12511292
}

0 commit comments

Comments
 (0)