Revision f39579c4

b/src/com/rackspace/cloud/servers/api/client/ServerManager.java
164 164
		
165 165
		Server server = null;
166 166
		CustomHttpClient httpclient = new CustomHttpClient(context);
167
		Log.d("info", "captin the url is " + Account.getAccount().getServerUrl() + "/servers/" + id + ".xml" + cacheBuster());
168 167
		HttpGet get = new HttpGet(Account.getAccount().getServerUrl() + "/servers/" + id + ".xml" + cacheBuster());
169 168
		get.addHeader("X-Auth-Token", Account.getAccount().getAuthToken());
170 169
		
b/src/com/rackspacecloud/android/ListAccountsActivity.java
61 61
	@Override
62 62
	protected void onSaveInstanceState(Bundle outState) {
63 63
		super.onSaveInstanceState(outState);
64
		Log.d("info", "captin the acounnt activity state has been saved");
65
		Log.d("info", "captin it is " + Boolean.toString(authenticating) + "that the app is authing");
66 64
		outState.putBoolean("authenticating", authenticating);
67 65
		//need to set authenticating back to true because it is set to false
68 66
		//in hideDialog()
......
96 94
	@Override
97 95
	protected void onStart(){
98 96
		super.onStart();
99
		Log.d("info", "captin onStop called");
100 97
		if(authenticating){
101 98
			showDialog();
102 99
		}
......
105 102
	@Override
106 103
	protected void onStop(){
107 104
		super.onStop();
108
		Log.d("info", "captin onStart called");
109 105
		if(authenticating){
110 106
			hideDialog();
111 107
			authenticating = true;
......
113 109
	}
114 110
		
115 111
	private void loadAccounts() {
116
		if(accounts != null)
117
			Log.d("loadAccounts", "captin the lenght is: " + accounts.size());
118 112
		//check and see if there are any in memory
119 113
		if(accounts == null){
120 114
			accounts = readAccounts();
......
123 117
		if(accounts == null){
124 118
			accounts = new ArrayList<Account>();
125 119
		}
126
		Log.d("loadAccounts2", "captin the lenght is: " + accounts.size());
127 120

  
128 121
		setAccountList();
129 122
	}
......
164 157
			in = new ObjectInputStream(fis);
165 158
			ArrayList<Account> file = (ArrayList<Account>)in.readObject();
166 159
			in.close();
167
			Log.d("captin", Boolean.toString(file == null));
168 160
			return file;
169 161
		} catch (FileNotFoundException e) {
170 162
			//showAlert("Error", "Could not load accounts.");
......
303 295
			acc.setApiKey(b.getString("apiKey"));
304 296
			acc.setUsername(b.getString("username"));
305 297
			acc.setAuthServer(b.getString("server"));
306
			Log.d("captin captin!", acc.getAuthServer());
307 298
			accounts.add(acc);
308 299
			writeAccounts();
309 300
			loadAccounts();
b/src/com/rackspacecloud/android/ViewServerActivity.java
23 23
import android.app.Activity;
24 24
import android.app.AlertDialog;
25 25
import android.app.Dialog;
26
import android.app.ProgressDialog;
27 26
import android.content.Context;
28 27
import android.content.DialogInterface;
29 28
import android.content.Intent;
30 29
import android.graphics.Color;
31 30
import android.os.AsyncTask;
32 31
import android.os.Bundle;
33
import android.util.Log;
34 32
import android.view.View;
35 33
import android.view.View.OnClickListener;
36 34
import android.widget.Button;
......
39 37
import android.widget.TextView;
40 38
import android.widget.Toast;
41 39

  
42
import com.rackspace.cloud.servers.api.client.Account;
43 40
import com.rackspace.cloud.servers.api.client.CloudServersException;
44 41
import com.rackspace.cloud.servers.api.client.Flavor;
45 42
import com.rackspace.cloud.servers.api.client.Image;
......
83 80
		super.onSaveInstanceState(outState);
84 81
		outState.putSerializable("server", server);
85 82
		if(pollServerTask != null && isPolling){
86
			Log.d("info", "captin cancelling the polling");
87 83
			pollServerTask.cancel(true);
88 84
		}
89 85
		outState.putBoolean("wasPolling", isPolling);
......
94 90
    		pollServerTask = new PollServerTask();
95 91
    		pollServerTask.execute((Void[]) null);
96 92
    	}
97
    	if (state != null && state.containsKey("server")) {
93
    	if (server == null && state != null && state.containsKey("server")) {
98 94
    		server = (Server) state.getSerializable("server");
99 95
    		//imageLoaded = state.getBoolean("imageLoaded");
100 96
    	}
97
    	canPoll = true;
101 98
        loadServerData();
102 99
        setupButtons();
103 100
        loadFlavors();
......
125 122
    public void onStop(){
126 123
    	super.onStop();
127 124
    	if(pollServerTask != null && isPolling){
128
    		Log.d("info", "captin in onStop cancelling");
129 125
    		pollServerTask.cancel(true);
130 126
    		isPolling = true;
131
			Log.d("info", "captin polling is true");
132 127
    	}
133 128
    	canPoll = false;
134 129
    	
......
143 138
    public void onStart(){
144 139
    	super.onStart();
145 140
    	if(isPolling){
146
    		Log.d("info", "captin in onStart starting");
147 141
    		pollServerTask = new PollServerTask();
148 142
    		pollServerTask.execute((Void[]) null);
149 143
    	}
......
314 308
    	});
315 309
    	
316 310
    }
317
    
318
    private void showAlert(String title, String message) {
319
		AlertDialog alert = new AlertDialog.Builder(ViewServerActivity.this).create();
320
		alert.setTitle(title);
321
		alert.setMessage(message);
322
		alert.setButton("OK", new DialogInterface.OnClickListener() {
323
	      public void onClick(DialogInterface dialog, int which) {
324
	        return;
325
	    } }); 
326
		alert.show();
327
    }
328
    
311
        
329 312
    private void showToast(String message) {
330 313
		Context context = getApplicationContext();
331 314
		int duration = Toast.LENGTH_SHORT;
......
354 337
		this.server = server;
355 338
	}
356 339

  
357
    @Override
358
    protected Dialog onCreateDialog(int id) {
359
        switch (id) {
360
        case R.id.view_server_soft_reboot_button:
361
            return new AlertDialog.Builder(ViewServerActivity.this)
362
        	.setIcon(R.drawable.alert_dialog_icon)
363
        	.setTitle("Soft Reboot")
364
        	.setMessage("Are you sure you want to perform a soft reboot?")
365
        	.setPositiveButton("Reboot Server", new DialogInterface.OnClickListener() {
366
        		public void onClick(DialogInterface dialog, int whichButton) {
367
        			// User clicked OK so do some stuff
368
        			new SoftRebootServerTask().execute((Void[]) null);
369
        		}
370
        	})
371
        	.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
372
        		public void onClick(DialogInterface dialog, int whichButton) {
373
        			// User clicked Cancel so do some stuff
374
        		}
375
        	})
376
        	.create();
377
        case R.id.view_server_hard_reboot_button:
378
            return new AlertDialog.Builder(ViewServerActivity.this)
379
        	.setIcon(R.drawable.alert_dialog_icon)
380
        	.setTitle("Hard Reboot")
381
        	.setMessage("Are you sure you want to perform a hard reboot?")
382
        	.setPositiveButton("Reboot Server", new DialogInterface.OnClickListener() {
383
        		public void onClick(DialogInterface dialog, int whichButton) {
384
        			// User clicked OK so do some stuff
385
        			new HardRebootServerTask().execute((Void[]) null);
386
        		}
387
        	})
388
        	.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
389
        		public void onClick(DialogInterface dialog, int whichButton) {
390
        			// User clicked Cancel so do some stuff
391
        		}
392
        	})
393
        	.create();
394
        case R.id.view_server_resize_button:
395
            return new AlertDialog.Builder(ViewServerActivity.this)
396
            .setItems(flavorNames, new ResizeClickListener())
397
        	.setIcon(R.drawable.alert_dialog_icon)
398
        	.setTitle("Resize Server")
399
        	.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
400
        		public void onClick(DialogInterface dialog, int whichButton) {
401
        			// User clicked Cancel so do some stuff
402
        		}
403
        	})
404
        	.create();
405
        case R.id.view_server_delete_button:
406
            return new AlertDialog.Builder(ViewServerActivity.this)
407
        	.setIcon(R.drawable.alert_dialog_icon)
408
        	.setTitle("Delete Server")
409
        	.setMessage("Are you sure you want to delete this server?  This operation cannot be undone and all backups will be deleted.")
410
        	.setPositiveButton("Delete Server", new DialogInterface.OnClickListener() {
411
        		public void onClick(DialogInterface dialog, int whichButton) {
412
        			// User clicked OK so do some stuff
413
        			new DeleteServerTask().execute((Void[]) null);
414
        		}
415
        	})
416
        	.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
417
        		public void onClick(DialogInterface dialog, int whichButton) {
418
        			// User clicked Cancel so do some stuff
419
        		}
420
        	})
421
        	.create();          
422
         case R.id.view_server_rename_button:
423
        	final EditText input = new EditText(this);
424
        	input.setText(server.getName());
425
            return new AlertDialog.Builder(ViewServerActivity.this)
426
        	.setIcon(R.drawable.alert_dialog_icon)
427
            .setView(input)
428
        	.setTitle("Rename")
429
        	.setMessage("Enter new name for server: ")        	         
430
        	.setPositiveButton("Rename", new DialogInterface.OnClickListener() {
431
        		public void onClick(DialogInterface dialog, int whichButton) {
432
        			// User clicked OK so do some stuff
433
        			modifiedServerName = input.getText().toString();
434
        			new RenameServerTask().execute((Void[]) null);
435
        		}
436
        	})
437
        	.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
438
        		public void onClick(DialogInterface dialog, int whichButton) {
439
        			// User clicked Cancel so do some stuff
440
        		}
441
        	})
442
        	.create();     
443
         case R.id.view_server_rebuild_button:
444
            return new AlertDialog.Builder(ViewServerActivity.this)
445
            .setItems(imageNames, new RebuildClickListener())
446
         	.setIcon(R.drawable.alert_dialog_icon)
447
         	.setTitle("Rebuild Server")
448
         	.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
449
         		public void onClick(DialogInterface dialog, int whichButton) {
450
         			// User clicked Cancel so do some stuff
451
         		}
452
         	})
453
         	.create();
454
        }
455
        return null;
456
    }
340
	@Override
341
	protected Dialog onCreateDialog(int id) {
342
		if(server == null){
343
			return new AlertDialog.Builder(ViewServerActivity.this)
344
			.setIcon(R.drawable.alert_dialog_icon)
345
			.setTitle("Error")
346
			.setMessage("Server is Busy")
347
			.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
348
				public void onClick(DialogInterface dialog, int whichButton) {
349
					// User clicked Cancel so do some stuff
350
				}
351
			})
352
			.create();
353
		}
354
		else{
355
			switch (id) {
356
			case R.id.view_server_soft_reboot_button:
357
				return new AlertDialog.Builder(ViewServerActivity.this)
358
				.setIcon(R.drawable.alert_dialog_icon)
359
				.setTitle("Soft Reboot")
360
				.setMessage("Are you sure you want to perform a soft reboot?")
361
				.setPositiveButton("Reboot Server", new DialogInterface.OnClickListener() {
362
					public void onClick(DialogInterface dialog, int whichButton) {
363
						// User clicked OK so do some stuff
364
						new SoftRebootServerTask().execute((Void[]) null);
365
					}
366
				})
367
				.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
368
					public void onClick(DialogInterface dialog, int whichButton) {
369
						// User clicked Cancel so do some stuff
370
					}
371
				})
372
				.create();
373
			case R.id.view_server_hard_reboot_button:
374
				return new AlertDialog.Builder(ViewServerActivity.this)
375
				.setIcon(R.drawable.alert_dialog_icon)
376
				.setTitle("Hard Reboot")
377
				.setMessage("Are you sure you want to perform a hard reboot?")
378
				.setPositiveButton("Reboot Server", new DialogInterface.OnClickListener() {
379
					public void onClick(DialogInterface dialog, int whichButton) {
380
						// User clicked OK so do some stuff
381
						new HardRebootServerTask().execute((Void[]) null);
382
					}
383
				})
384
				.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
385
					public void onClick(DialogInterface dialog, int whichButton) {
386
						// User clicked Cancel so do some stuff
387
					}
388
				})
389
				.create();
390
			case R.id.view_server_resize_button:
391
				return new AlertDialog.Builder(ViewServerActivity.this)
392
				.setItems(flavorNames, new ResizeClickListener())
393
				.setIcon(R.drawable.alert_dialog_icon)
394
				.setTitle("Resize Server")
395
				.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
396
					public void onClick(DialogInterface dialog, int whichButton) {
397
						// User clicked Cancel so do some stuff
398
					}
399
				})
400
				.create();
401
			case R.id.view_server_delete_button:
402
				return new AlertDialog.Builder(ViewServerActivity.this)
403
				.setIcon(R.drawable.alert_dialog_icon)
404
				.setTitle("Delete Server")
405
				.setMessage("Are you sure you want to delete this server?  This operation cannot be undone and all backups will be deleted.")
406
				.setPositiveButton("Delete Server", new DialogInterface.OnClickListener() {
407
					public void onClick(DialogInterface dialog, int whichButton) {
408
						// User clicked OK so do some stuff
409
						new DeleteServerTask().execute((Void[]) null);
410
					}
411
				})
412
				.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
413
					public void onClick(DialogInterface dialog, int whichButton) {
414
						// User clicked Cancel so do some stuff
415
					}
416
				})
417
				.create();          
418
			case R.id.view_server_rename_button:
419
				final EditText input = new EditText(this);
420
				input.setText(server.getName());
421
				return new AlertDialog.Builder(ViewServerActivity.this)
422
				.setIcon(R.drawable.alert_dialog_icon)
423
				.setView(input)
424
				.setTitle("Rename")
425
				.setMessage("Enter new name for server: ")        	         
426
				.setPositiveButton("Rename", new DialogInterface.OnClickListener() {
427
					public void onClick(DialogInterface dialog, int whichButton) {
428
						// User clicked OK so do some stuff
429
						modifiedServerName = input.getText().toString();
430
						new RenameServerTask().execute((Void[]) null);
431
					}
432
				})
433
				.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
434
					public void onClick(DialogInterface dialog, int whichButton) {
435
						// User clicked Cancel so do some stuff
436
					}
437
				})
438
				.create();     
439
			case R.id.view_server_rebuild_button:
440
				return new AlertDialog.Builder(ViewServerActivity.this)
441
				.setItems(imageNames, new RebuildClickListener())
442
				.setIcon(R.drawable.alert_dialog_icon)
443
				.setTitle("Rebuild Server")
444
				.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
445
					public void onClick(DialogInterface dialog, int whichButton) {
446
						// User clicked Cancel so do some stuff
447
					}
448
				})
449
				.create();
450
			}
451
		}
452
		return new AlertDialog.Builder(ViewServerActivity.this)
453
		.setIcon(R.drawable.alert_dialog_icon)
454
		.setTitle("Error")
455
		.setMessage("Server is Busy")
456
		.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
457
			public void onClick(DialogInterface dialog, int whichButton) {
458
				// User clicked Cancel so do some stuff
459
			}
460
		})
461
		.create();
462
	}
457 463

  
458 464
    private class ResizeClickListener implements android.content.DialogInterface.OnClickListener {
459 465

  
......
511 517
		
512 518
		@Override 
513 519
		protected void onPreExecute(){
514
			Log.d("info", "captin The POLLING TASK HAS STARTED!");
515 520
			isPolling = true;
516 521
		}
517 522
		
518 523
		@Override
519 524
		protected Server doInBackground(Void... arg0) {
520
			Log.d("info", "captin can poll is " + canPoll);
521 525
			if(isCancelled() || !canPoll){
522 526
				return null;
523 527
			}
......
535 539
		protected void onPostExecute(Server result) {
536 540
			server = result;
537 541
			if(server != null){
538
				Log.d("info", "captin about to load data");
539 542
				loadServerData();
540 543
			}
541 544
			isPolling = false;
542
			Log.d("info", "captin polling is false");
543 545
		}
544 546
		
545 547
		@Override
546 548
		protected void onCancelled (){
547 549
			isPolling = false;
548
			Log.d("info", "captin polling is false and the poll has been canceled");
549 550
		}
550 551
		
551 552
    }

Also available in: Unified diff