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

Commit 13a5cc7

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

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
@@ -10,6 +10,7 @@
1010
import android.animation.Animator;
1111
import android.annotation.SuppressLint;
1212
import android.annotation.TargetApi;
13+
import android.app.Activity;
1314
import android.app.AlertDialog;
1415
import android.app.ProgressDialog;
1516
import android.app.SearchManager;
@@ -1441,4 +1442,44 @@ void switchRealm(final ProgressDialog progressDialog, final int position) {
14411442
progressDialog.dismiss();
14421443
}
14431444

1445+
1446+
@Override
1447+
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
1448+
if (requestCode == ADDREALM_REQUEST_CODE && resultCode == Activity.RESULT_OK) {
1449+
this.currentList.adapter.clear();
1450+
this.currentList.adapter.setHeaderShowing(true);
1451+
final String realmName = data.getStringExtra("realmName");
1452+
final String apiKey = data.getStringExtra("api_key");
1453+
final String email = data.getStringExtra("email");
1454+
final String serverURL = data.getStringExtra("serverURL");
1455+
notifications.logOut(new Runnable() {
1456+
@Override
1457+
public void run() {
1458+
if (event_poll != null) {
1459+
event_poll.abort();
1460+
event_poll = null;
1461+
}
1462+
statusUpdateHandler.removeMessages(0);
1463+
try {
1464+
unregisterReceiver(onGcmMessage);
1465+
} catch (IllegalArgumentException e) {
1466+
ZLog.logException(e);
1467+
}
1468+
1469+
app.clearConnectionState();
1470+
app.createNewRealm();
1471+
app.setEmail(email);
1472+
app.setServerURL(serverURL);
1473+
app.saveServerName(realmName);
1474+
app.setLoggedInApiKey(apiKey);
1475+
IntentFilter filter = new IntentFilter(GcmBroadcastReceiver.BROADCAST);
1476+
filter.setPriority(2);
1477+
registerReceiver(onGcmMessage, filter);
1478+
onRefresh();
1479+
}
1480+
});
1481+
1482+
}
1483+
this.currentList.adapter.setHeaderShowing(false);
1484+
}
14441485
}

0 commit comments

Comments
 (0)