2626import com .google .android .gms .common .GooglePlayServicesUtil ;
2727import com .zulip .android .ZulipAsyncPushTask .AsyncTaskCompleteListener ;
2828
29+ import org .json .JSONException ;
30+ import org .json .JSONObject ;
2931public class LoginActivity extends Activity implements View .OnClickListener ,
3032 OnConnectionFailedListener {
3133 private static final int REQUEST_ACCOUNT_PICKER = 2 ;
3234 private static final int REQUEST_CODE_RESOLVE_ERR = 9000 ;
3335
36+ public boolean startedFromAddRealm = false ;
3437 EditText serverUrlText ;
3538 EditText realmNameET ;
3639 LoginActivity that = this ; // self-ref
@@ -47,12 +50,21 @@ protected void onCreate(Bundle savedInstanceState) {
4750 setContentView (R .layout .login );
4851 realmNameET = (EditText ) findViewById (R .id .realmName );
4952 serverUrlText = (EditText ) findViewById (R .id .server );
53+ if (getIntent ().getBooleanExtra ("FROM_ADDREALM" , false )) {
54+ startedFromAddRealm = true ;
55+ ((TextView )findViewById (R .id .textView1 )).setText ("Add new Realm" );
56+ ((Button ) findViewById (R .id .login )).setText ("Add" );
57+ }
5058
5159 ((Button ) findViewById (R .id .login ))
5260 .setOnClickListener (new View .OnClickListener () {
5361 @ Override
5462 public void onClick (View v ) {
5563 connectionProgressDialog .show ();
64+ if (app .serverStringSet .contains (realmNameET .getText ().toString ())) {
65+ Toast .makeText (LoginActivity .this , R .string .realm_exists , Toast .LENGTH_SHORT ).show ();
66+ return ;
67+ }
5668 AsyncLogin alog = new AsyncLogin (that ,
5769 ((EditText ) findViewById (R .id .username ))
5870 .getText ().toString (),
0 commit comments