Revision d88d3ae1 src/com/rackspacecloud/android/AddAccountActivity.java

b/src/com/rackspacecloud/android/AddAccountActivity.java
20 20
	
21 21
	EditText usernameText;
22 22
	EditText apiKeyText;
23
	EditText customServer;
23 24
	Spinner providerSpinner;
24 25
	String authServer;
25 26
	boolean isHidden;
......
29 30
        setContentView(R.layout.createaccount);
30 31
        usernameText = (EditText) findViewById(R.id.username);
31 32
        apiKeyText = (EditText) findViewById(R.id.addaccount_apikey);
33
        customServer = (EditText) findViewById(R.id.custom_auth_server_edit);
32 34
        ((Button) findViewById(R.id.submit_new_account)).setOnClickListener(this);
33 35
        isHidden = true;
36
        customServer.setEnabled(false);
34 37
        if(savedInstanceState != null)
35 38
        	isHidden = savedInstanceState.containsKey("isHidden") && savedInstanceState.getBoolean("isHidden");
36 39
        setUpApiText(savedInstanceState);
......
78 81
		//set the auth server default to us
79 82
		authServer = "https://auth.api.rackspacecloud.com/v1.0";
80 83
		providerSpinner = (Spinner) findViewById(R.id.provider_spinner);
81
		String[] providers = {"Rackspace Cloud (US)", "Rackspace Cloud (UK)"};
84
		String[] providers = {"Rackspace Cloud (US)", "Rackspace Cloud (UK)", "Custom"};
82 85
		ArrayAdapter<String> imageAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, providers);
83 86
		imageAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
84 87
		providerSpinner.setAdapter(imageAdapter);
85 88
		providerSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener(){
86 89
		    public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) {
87 90
		    	if(pos == 0){
88
					authServer = "https://auth.api.rackspacecloud.com/v1.0";
91
					authServer = Preferences.COUNTRY_US_AUTH_SERVER;
92
			        customServer.setEnabled(false);
89 93
				}
90 94
				else if(pos == 1){
91
					authServer = "https://lon.auth.api.rackspacecloud.com/v1.0";
95
					authServer = Preferences.COUNTRY_UK_AUTH_SERVER;
96
			        customServer.setEnabled(false);
97
				}
98
				else{
99
			        customServer.setEnabled(true);
92 100
				}
93 101
		    }
94 102
		    public void onNothingSelected(AdapterView<?> parent) {
......
97 105
	}
98 106
	
99 107
	public void onClick(View arg0) {
100
		
108

  
101 109
		if (hasValidInput()) {
102 110
			//showActivityIndicators();
103 111
			Intent result = new Intent();
104 112
			Bundle b = new Bundle();
105 113
			b.putString("username", usernameText.getText().toString());
106 114
			b.putString("apiKey", apiKeyText.getText().toString());
107
			b.putString("server", authServer);
115
			b.putString("server", getAuthServer());
108 116
			result.putExtra("accountInfo", b);
109 117
			setResult(RESULT_OK, result);
110 118
			finish();
......
114 122
		
115 123
	}
116 124
	
125
	private String getAuthServer(){
126
		if(customServer.isEnabled()){
127
			authServer = customServer.getText().toString();
128
		}
129
		return authServer;
130
	}
131
	
117 132
	private void showAlert(String title, String message) {
118 133
    	try {
119 134
		AlertDialog alert = new AlertDialog.Builder(this).create();

Also available in: Unified diff