Revision 00fc84e9 src/com/rackspacecloud/android/PasswordServerActivity.java
b/src/com/rackspacecloud/android/PasswordServerActivity.java | ||
---|---|---|
16 | 16 |
import com.rackspace.cloud.servers.api.client.ServerManager; |
17 | 17 |
import com.rackspace.cloud.servers.api.client.http.HttpBundle; |
18 | 18 |
|
19 |
public class PasswordServerActivity extends GaActivity implements |
|
20 |
OnClickListener { |
|
21 |
|
|
19 |
public class PasswordServerActivity extends CloudActivity implements OnClickListener{ |
|
20 |
|
|
22 | 21 |
private Server server; |
23 | 22 |
private String modifiedPassword; |
24 |
|
|
23 |
|
|
25 | 24 |
public void onCreate(Bundle savedInstanceState) { |
26 | 25 |
super.onCreate(savedInstanceState); |
27 | 26 |
trackPageView(GoogleAnalytics.PAGE_PASSCODE); |
... | ... | |
38 | 37 |
Button update = (Button) findViewById(R.id.password_change_button); |
39 | 38 |
update.setOnClickListener(this); |
40 | 39 |
} |
41 |
|
|
40 |
|
|
42 | 41 |
@Override |
43 | 42 |
public void onClick(View v) { |
44 | 43 |
String password = ((EditText)findViewById(R.id.password_edittext)).getText().toString(); |
... | ... | |
46 | 45 |
if(password.equals(confirm)){ |
47 | 46 |
trackEvent(GoogleAnalytics.CATEGORY_SERVER, GoogleAnalytics.EVENT_PASSWORD, "", -1); |
48 | 47 |
modifiedPassword = password; |
49 |
new PasswordServerTask().execute((Void[]) null); |
|
50 |
} else { |
|
51 |
showToast("The password and confirmation do not match"); |
|
48 |
new PasswordServerTask().execute((Void[]) null); |
|
52 | 49 |
} |
53 |
} |
|
54 | 50 |
else{ |
55 | 51 |
showToast("The password and confirmation do not match"); |
56 | 52 |
} |
... | ... | |
60 | 56 |
|
61 | 57 |
private CloudServersException exception; |
62 | 58 |
|
63 |
protected void onPreExecute() {
|
|
59 |
protected void onPreExecute(){ |
|
64 | 60 |
showToast("Change root password process has begun"); |
65 | 61 |
} |
66 |
|
|
62 |
|
|
67 | 63 |
@Override |
68 | 64 |
protected HttpBundle doInBackground(Void... arg0) { |
69 | 65 |
HttpBundle bundle = null; |
70 | 66 |
try { |
71 |
bundle = (new ServerManager()).changePassword(server, |
|
72 |
modifiedPassword, getApplicationContext()); |
|
67 |
bundle = (new ServerManager()).changePassword(server, modifiedPassword, getApplicationContext()); |
|
73 | 68 |
} catch (CloudServersException e) { |
74 | 69 |
exception = e; |
75 | 70 |
} |
... | ... | |
80 | 75 |
protected void onPostExecute(HttpBundle bundle) { |
81 | 76 |
HttpResponse response = bundle.getResponse(); |
82 | 77 |
if (response != null) { |
83 |
int statusCode = response.getStatusLine().getStatusCode(); |
|
84 |
if (statusCode == 204) {
|
|
78 |
int statusCode = response.getStatusLine().getStatusCode();
|
|
79 |
if(statusCode == 204){
|
|
85 | 80 |
String mustMatch = "The server's root password has successfully been changed."; |
86 |
Toast passwordError = Toast.makeText( |
|
87 |
getApplicationContext(), mustMatch, |
|
88 |
Toast.LENGTH_SHORT); |
|
81 |
Toast passwordError = Toast.makeText(getApplicationContext(), mustMatch, Toast.LENGTH_SHORT); |
|
89 | 82 |
passwordError.show(); |
90 | 83 |
finish(); |
91 | 84 |
} |
... | ... | |
103 | 96 |
} |
104 | 97 |
} |
105 | 98 |
|
99 |
|
|
106 | 100 |
} |
107 | 101 |
} |
Also available in: Unified diff