@@ -69,12 +69,26 @@ public void onClick(View v) {
6969 ((EditText ) findViewById (R .id .username ))
7070 .getText ().toString (),
7171 ((EditText ) findViewById (R .id .password ))
72- .getText ().toString ());
72+ .getText ().toString (), serverUrlText . getText (). toString (), startedFromAddRealm , realmNameET . getText (). toString () );
7373 // Remove the CPD when done
7474 alog .setCallback (new AsyncTaskCompleteListener () {
7575 @ Override
7676 public void onTaskComplete (String result ) {
7777 connectionProgressDialog .dismiss ();
78+ if (startedFromAddRealm ){
79+ try {
80+ JSONObject jsonObject = new JSONObject (result );
81+ Intent intent = new Intent (LoginActivity .this , ZulipActivity .class );
82+ intent .putExtra ("username" , ((EditText ) findViewById (R .id .username )).getText ().toString ());
83+ intent .putExtra ("realmName" , ((EditText ) findViewById (R .id .realmName )).getText ().toString ());
84+ intent .putExtra ("server" , serverUrlText .getText ().toString ());
85+ intent .putExtra ("api_key" , jsonObject .getString ("api_key" ));
86+ setResult (Activity .RESULT_OK , intent );
87+ finish ();
88+ } catch (JSONException e ) {
89+ e .printStackTrace ();
90+ }
91+ }
7892 }
7993
8094 @ Override
@@ -182,7 +196,7 @@ public void authWithGapps() {
182196 this .app .getEmail (), scope );
183197 // Send token to the server to exchange for an API key
184198 final AsyncLogin loginTask = new AsyncLogin (that ,
185- "google-oauth2-token" , token );
199+ "google-oauth2-token" , token , serverUrlText . getText (). toString (), startedFromAddRealm , realmNameET . getText (). toString () );
186200 loginTask .setCallback (new AsyncTaskCompleteListener () {
187201 @ Override
188202 public void onTaskComplete (String result ) {
0 commit comments