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

Commit 034af89

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

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;
@@ -1513,4 +1514,44 @@ void switchRealm(final ProgressDialog progressDialog, final int position) {
15131514
progressDialog.dismiss();
15141515
}
15151516

1517+
1518+
@Override
1519+
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
1520+
if (requestCode == ADDREALM_REQUEST_CODE && resultCode == Activity.RESULT_OK) {
1521+
this.currentList.adapter.clear();
1522+
this.currentList.adapter.setHeaderShowing(true);
1523+
final String realmName = data.getStringExtra("realmName");
1524+
final String apiKey = data.getStringExtra("api_key");
1525+
final String email = data.getStringExtra("email");
1526+
final String serverURL = data.getStringExtra("serverURL");
1527+
notifications.logOut(new Runnable() {
1528+
@Override
1529+
public void run() {
1530+
if (event_poll != null) {
1531+
event_poll.abort();
1532+
event_poll = null;
1533+
}
1534+
statusUpdateHandler.removeMessages(0);
1535+
try {
1536+
unregisterReceiver(onGcmMessage);
1537+
} catch (IllegalArgumentException e) {
1538+
ZLog.logException(e);
1539+
}
1540+
1541+
app.clearConnectionState();
1542+
app.createNewRealm();
1543+
app.setEmail(email);
1544+
app.setServerURL(serverURL);
1545+
app.saveServerName(realmName);
1546+
app.setLoggedInApiKey(apiKey);
1547+
IntentFilter filter = new IntentFilter(GcmBroadcastReceiver.getGCMReceiverAction(getApplicationContext()));
1548+
filter.setPriority(2);
1549+
registerReceiver(onGcmMessage, filter);
1550+
onRefresh();
1551+
}
1552+
});
1553+
1554+
}
1555+
this.currentList.adapter.setHeaderShowing(false);
1556+
}
15161557
}

0 commit comments

Comments
 (0)