Revision 2aaecc36 src/com/rackspacecloud/android/RackspaceCloudActivity.java
b/src/com/rackspacecloud/android/RackspaceCloudActivity.java | ||
---|---|---|
5 | 5 |
|
6 | 6 |
import android.app.Activity; |
7 | 7 |
import android.app.AlertDialog; |
8 |
import android.app.Dialog; |
|
8 | 9 |
import android.content.Context; |
9 | 10 |
import android.content.DialogInterface; |
10 | 11 |
import android.content.Intent; |
... | ... | |
12 | 13 |
import android.content.SharedPreferences.Editor; |
13 | 14 |
import android.os.AsyncTask; |
14 | 15 |
import android.os.Bundle; |
16 |
import android.util.Log; |
|
15 | 17 |
import android.view.KeyEvent; |
18 |
import android.view.Menu; |
|
19 |
import android.view.MenuItem; |
|
16 | 20 |
import android.view.View; |
17 | 21 |
import android.widget.Button; |
18 | 22 |
import android.widget.EditText; |
... | ... | |
33 | 37 |
private static final String OPT_USERNAME_DEF = ""; |
34 | 38 |
private static final String OPT_API_KEY = "apiKey"; |
35 | 39 |
private static final String OPT_API_KEY_DEF = ""; |
36 |
|
|
40 |
|
|
41 |
private static final int SHOW_PREFERENCES = 1; |
|
42 |
|
|
37 | 43 |
private Intent tabViewIntent; |
38 | 44 |
private boolean authenticating; |
39 | 45 |
|
... | ... | |
59 | 65 |
outState.putBoolean("authenticating", authenticating); |
60 | 66 |
} |
61 | 67 |
|
68 |
public boolean onCreateOptionsMenu(Menu menu) { |
|
69 |
menu.add(0, SHOW_PREFERENCES, 0, "Preferences"); |
|
70 |
return true; |
|
71 |
} |
|
72 |
|
|
73 |
public boolean onOptionsItemSelected(MenuItem item) { |
|
74 |
|
|
75 |
switch (item.getItemId()) { |
|
76 |
case SHOW_PREFERENCES: |
|
77 |
showPreferences(); |
|
78 |
break; |
|
79 |
} |
|
80 |
return true; |
|
81 |
} |
|
82 |
|
|
83 |
public void showPreferences() { |
|
84 |
Intent settingsActivity = new Intent(getBaseContext(), |
|
85 |
Preferences.class); |
|
86 |
startActivity(settingsActivity); |
|
87 |
} |
|
88 |
|
|
62 | 89 |
private void restoreState(Bundle state) { |
63 | 90 |
if (state != null && state.containsKey("authenticating") && state.getBoolean("authenticating")) { |
64 | 91 |
showActivityIndicators(); |
... | ... | |
97 | 124 |
} |
98 | 125 |
|
99 | 126 |
private void setLoginPreferences() { |
127 |
SharedPreferences prefs = getSharedPreferences( |
|
128 |
Preferences.SHARED_PREFERENCES_NAME, |
|
129 |
Context.MODE_PRIVATE); |
|
130 |
String resultType = prefs.getString( |
|
131 |
Preferences.PREF_KEY_RESULTS_TYPE, |
|
132 |
String.valueOf(Preferences.COUNTRY_US)); |
|
133 |
int resultTypeInt = Integer.parseInt(resultType); |
|
134 |
|
|
135 |
//Default Auth Server |
|
136 |
String authServer = Preferences.COUNTRY_US_AUTH_SERVER; |
|
137 |
if (resultTypeInt == Preferences.COUNTRY_UK) |
|
138 |
authServer = Preferences.COUNTRY_UK_AUTH_SERVER; |
|
139 |
|
|
100 | 140 |
String username = ((EditText) findViewById(R.id.login_username)).getText().toString(); |
101 | 141 |
String apiKey = ((EditText) findViewById(R.id.login_apikey)).getText().toString(); |
102 | 142 |
Account.setUsername(username); |
103 | 143 |
Account.setApiKey(apiKey); |
104 |
|
|
144 |
Account.setAuthServer(authServer); |
|
145 |
|
|
105 | 146 |
Editor e = this.getPreferences(Context.MODE_PRIVATE).edit(); |
106 | 147 |
e.putString(OPT_USERNAME, username); |
107 | 148 |
e.putString(OPT_API_KEY, apiKey); |
Also available in: Unified diff