Revision 0edf6b39 src/com/rackspacecloud/android/ViewServerActivity.java
b/src/com/rackspacecloud/android/ViewServerActivity.java | ||
---|---|---|
52 | 52 |
* @author Mike Mayo - mike.mayo@rackspace.com - twitter.com/greenisus |
53 | 53 |
* |
54 | 54 |
*/ |
55 |
public class ViewServerActivity extends Activity { |
|
55 |
public class ViewServerActivity extends GaActivity {
|
|
56 | 56 |
|
57 | 57 |
private Server server; |
58 | 58 |
private boolean ipAddressesLoaded; // to prevent polling from loading tons of duplicates |
... | ... | |
69 | 69 |
private PollServerTask pollServerTask; |
70 | 70 |
private boolean canPoll; |
71 | 71 |
private boolean noAskForConfirm; |
72 |
|
|
72 |
|
|
73 | 73 |
/** Called when the activity is first created. */ |
74 | 74 |
@Override |
75 | 75 |
public void onCreate(Bundle savedInstanceState) { |
76 | 76 |
super.onCreate(savedInstanceState); |
77 |
trackPageView(PAGE_SERVER); |
|
77 | 78 |
server = (Server) this.getIntent().getExtras().get("server"); |
78 | 79 |
context = getApplicationContext(); |
79 | 80 |
setContentView(R.layout.viewserver); |
... | ... | |
109 | 110 |
loadFlavors(); |
110 | 111 |
loadImages(); |
111 | 112 |
} |
113 |
|
|
114 |
|
|
112 | 115 |
/* |
113 | 116 |
private void loadImage() { |
114 | 117 |
// hate to do this, but devices run out of memory after a few rotations |
... | ... | |
178 | 181 |
startActivity(viewIntent); |
179 | 182 |
} |
180 | 183 |
} |
181 |
|
|
184 |
|
|
182 | 185 |
// show status and possibly the progress, with polling |
183 | 186 |
if (!"ACTIVE".equals(server.getStatus())) { |
184 | 187 |
status.setText(server.getStatus() + " - " + server.getProgress() + "%"); |
... | ... | |
316 | 319 |
|
317 | 320 |
setupButton(R.id.view_server_ping_button, new OnClickListener() { |
318 | 321 |
public void onClick(View v) { |
319 |
Intent viewIntent = new Intent(v.getContext(), PingServerActivity.class);
|
|
322 |
trackEvent(CATEGORY_SERVER, EVENT_PING, "", -1);
|
|
320 | 323 |
|
321 | 324 |
//ping the first public ip |
325 |
Intent viewIntent = new Intent(v.getContext(), PingServerActivity.class); |
|
322 | 326 |
viewIntent.putExtra("ipAddress", server.getPublicIpAddresses()[0]); |
323 | 327 |
startActivity(viewIntent); |
324 | 328 |
|
... | ... | |
348 | 352 |
public void setServer(Server server) { |
349 | 353 |
this.server = server; |
350 | 354 |
} |
351 |
|
|
355 |
|
|
352 | 356 |
//setup menu for when menu button is pressed |
353 | 357 |
public boolean onCreateOptionsMenu(Menu menu) { |
354 | 358 |
super.onCreateOptionsMenu(menu); |
... | ... | |
356 | 360 |
inflater.inflate(R.menu.view_server_activity_menu, menu); |
357 | 361 |
return true; |
358 | 362 |
} |
359 |
|
|
360 |
@Override
|
|
361 |
//in options menu, when add account is selected go to add account activity
|
|
362 |
public boolean onOptionsItemSelected(MenuItem item) {
|
|
363 |
switch (item.getItemId()) {
|
|
364 |
case R.id.refresh_server:
|
|
365 |
loadServerData();
|
|
366 |
return true;
|
|
367 |
}
|
|
368 |
return false;
|
|
369 |
}
|
|
363 |
|
|
364 |
@Override
|
|
365 |
//in options menu, when add account is selected go to add account activity
|
|
366 |
public boolean onOptionsItemSelected(MenuItem item) {
|
|
367 |
switch (item.getItemId()) {
|
|
368 |
case R.id.refresh_server:
|
|
369 |
loadServerData();
|
|
370 |
return true;
|
|
371 |
}
|
|
372 |
return false;
|
|
373 |
}
|
|
370 | 374 |
|
371 | 375 |
private void startServerError(String message, HttpBundle bundle){ |
372 | 376 |
Intent viewIntent = new Intent(getApplicationContext(), ServerErrorActivity.class); |
... | ... | |
399 | 403 |
.setMessage("Are you sure you want to perform a soft reboot?") |
400 | 404 |
.setPositiveButton("Reboot Server", new DialogInterface.OnClickListener() { |
401 | 405 |
public void onClick(DialogInterface dialog, int whichButton) { |
402 |
// User clicked OK so do some stuff
|
|
406 |
trackEvent(CATEGORY_SERVER, EVENT_REBOOT, "", -1);
|
|
403 | 407 |
new SoftRebootServerTask().execute((Void[]) null); |
404 | 408 |
} |
405 | 409 |
}) |
... | ... | |
416 | 420 |
.setMessage("Are you sure you want to perform a hard reboot?") |
417 | 421 |
.setPositiveButton("Reboot Server", new DialogInterface.OnClickListener() { |
418 | 422 |
public void onClick(DialogInterface dialog, int whichButton) { |
419 |
// User clicked OK so do some stuff
|
|
423 |
trackEvent(CATEGORY_SERVER, EVENT_REBOOT, "", -1);
|
|
420 | 424 |
new HardRebootServerTask().execute((Void[]) null); |
421 | 425 |
} |
422 | 426 |
}) |
... | ... | |
444 | 448 |
.setMessage("Are you sure you want to delete this server? This operation cannot be undone and all backups will be deleted.") |
445 | 449 |
.setPositiveButton("Delete Server", new DialogInterface.OnClickListener() { |
446 | 450 |
public void onClick(DialogInterface dialog, int whichButton) { |
447 |
// User clicked OK so do some stuff
|
|
451 |
trackEvent(CATEGORY_SERVER, EVENT_DELETE, "", -1);
|
|
448 | 452 |
new DeleteServerTask().execute((Void[]) null); |
449 | 453 |
} |
450 | 454 |
}) |
... | ... | |
464 | 468 |
.setMessage("Enter new name for server: ") |
465 | 469 |
.setPositiveButton("Rename", new DialogInterface.OnClickListener() { |
466 | 470 |
public void onClick(DialogInterface dialog, int whichButton) { |
467 |
// User clicked OK so do some stuff
|
|
471 |
trackEvent(CATEGORY_SERVER, EVENT_RENAME, "", -1);
|
|
468 | 472 |
modifiedServerName = input.getText().toString(); |
469 | 473 |
new RenameServerTask().execute((Void[]) null); |
470 | 474 |
} |
... | ... | |
503 | 507 |
private class ResizeClickListener implements android.content.DialogInterface.OnClickListener { |
504 | 508 |
|
505 | 509 |
public void onClick(DialogInterface dialog, int which) { |
506 |
//need to add one because server flavors state at index 1
|
|
510 |
trackEvent(CATEGORY_SERVER, EVENT_RESIZE, "", -1);
|
|
507 | 511 |
selectedFlavorId = which + 1 + ""; |
508 | 512 |
new ResizeServerTask().execute((Void[]) null); |
509 | 513 |
} |
... | ... | |
513 | 517 |
private class RebuildClickListener implements android.content.DialogInterface.OnClickListener { |
514 | 518 |
|
515 | 519 |
public void onClick(DialogInterface dialog, int which) { |
520 |
trackEvent(CATEGORY_SERVER, EVENT_REBUILD, "", -1); |
|
516 | 521 |
selectedImageId = images[which].getId() + ""; |
517 | 522 |
new RebuildServerTask().execute((Void[]) null); |
518 | 523 |
} |
Also available in: Unified diff