This repository was archived by the owner on Jul 25, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +26
-4
lines changed
app/src/main/java/com/zulip/android Expand file tree Collapse file tree 2 files changed +26
-4
lines changed Original file line number Diff line number Diff line change @@ -375,6 +375,19 @@ public boolean isTopicMute(int id, String subject) {
375375 return mutedTopics .contains (id + subject );
376376 }
377377
378+ public void saveServerName (String serverName ) {
379+ String username =null ;
380+ try {
381+ username = you .getEmail ();
382+ } catch (Exception e ) {
383+ //SQL Exception can occur if name is not updated!
384+ ZLog .logException (e );
385+ }
386+ Editor globalEditor = this .globalSettings .edit ();
387+ serverStringSet .add ((username != null ) ? serverName + " - " + username : serverName );
388+ globalEditor .putStringSet (GLOBAL_SETTINGS_REALMS , new HashSet <String >(serverStringSet ));
389+ globalEditor .apply ();
390+ }
378391 public void createNewRealm () {
379392 SharedPreferences .Editor editor = this .globalSettings .edit ();
380393 currentRealm = serverStringSet .size ();
Original file line number Diff line number Diff line change @@ -58,10 +58,19 @@ protected void onPostExecute(String result) {
5858 JSONObject obj = new JSONObject (result );
5959
6060 if (obj .getString ("result" ).equals ("success" )) {
61- this .app .setLoggedInApiKey (obj .getString ("api_key" ));
62- if (devServer ) ((DevAuthActivity ) activity ).openHome ();
63- else ((LoginActivity ) activity ).openHome ();
64- callback .onTaskComplete (result , obj );
61+ if (startedFromAddRealm ) {
62+ loginThroughAddRealm (obj );
63+ callback .onTaskComplete (result , obj );
64+ } else {
65+ this .app .setServerURL (serverURL );
66+ this .app .setLoggedInApiKey (obj .getString ("api_key" ));
67+ ZulipApp .get ().saveServerName (realmName );
68+ if (context instanceof LoginActivity ) {
69+ ((LoginActivity ) this .context ).openHome ();
70+ } else if (context instanceof DevAuthActivity ) {
71+ ((DevAuthActivity ) this .context ).openHome ();
72+ }
73+ }
6574 return ;
6675 }
6776 } catch (JSONException e ) {
You can’t perform that action at this time.
0 commit comments