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

Commit fd5dd22

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

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

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

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -597,6 +597,36 @@ public void openCompose(final MessageType type, String stream,
597597
dialog.show(fm, "fragment_compose");
598598
}
599599

600+
@Override
601+
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
602+
if (requestCode == ADDREALM_REQUEST_CODE && resultCode == Activity.RESULT_OK) {
603+
this.currentList.adapter.clear();
604+
this.currentList.showLoadIndicatorTop(true);
605+
final String realmName = data.getStringExtra("realmName");
606+
final String username = data.getStringExtra("username");
607+
final String server = data.getStringExtra("server");
608+
final String apiKey = data.getStringExtra("api_key");
609+
notifications.logOut(new Runnable() {
610+
public void run() {
611+
if (event_poll != null) {
612+
event_poll.abort();
613+
event_poll = null;
614+
}
615+
statusUpdateHandler.removeMessages(0);
616+
unregisterReceiver(onGcmMessage);
617+
app.createNewRealm();
618+
app.saveServer(server, realmName);
619+
app.clearConnectionState();
620+
app.setLoggedInApiKeyAndEmail(apiKey, username);
621+
IntentFilter filter = new IntentFilter(GcmBroadcastReceiver.BROADCAST);
622+
filter.setPriority(2);
623+
registerReceiver(onGcmMessage, filter);
624+
onRefresh();
625+
}
626+
});
627+
this.currentList.showLoadIndicatorTop(false);
628+
}
629+
}
600630
/**
601631
* Log the user out of the app, clearing our cache of their credentials.
602632
*/

0 commit comments

Comments
 (0)