Revision b2a2d2f1

b/res/layout/listaccountcell.xml
4 4
  android:layout_width="fill_parent"
5 5
  android:orientation="horizontal" android:layout_height="64dip">
6 6
    <ImageView android:id="@+id/account_type_icon" android:layout_gravity="center" android:layout_height="fill_parent" android:layout_width="wrap_content" android:maxHeight="30dp" android:maxWidth="30dp" android:layout_marginLeft="10dip"></ImageView>
7
    <TableLayout android:orientation="vertical" android:layout_height="fill_parent" android:layout_marginLeft="10dip" android:id="@+id/tableLayout1" android:layout_width="190dip">
7
    <TableLayout android:orientation="vertical" android:layout_height="fill_parent" android:layout_marginLeft="10dip" android:id="@+id/tableLayout1" android:layout_width="fill_parent" android:layout_marginRight="10dip">
8 8
        <TableRow android:layout_height="wrap_content" android:id="@+id/tableRow1" android:layout_width="wrap_content">
9
            <TextView android:textSize="24sp" android:textColor="#FFFFFF" android:layout_height="wrap_content" android:layout_width="wrap_content" android:layout_marginTop="5px" android:id="@+id/label"></TextView>
9
            <TextView android:textSize="24sp" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="#FFFFFF" android:layout_marginTop="5px" android:id="@+id/label"></TextView>
10 10
        </TableRow>
11 11
        <TableRow android:layout_height="wrap_content" android:id="@+id/tableRow2" android:layout_width="wrap_content">
12 12
            <TextView android:layout_height="wrap_content" android:layout_width="wrap_content" android:id="@+id/sublabel"></TextView>
b/res/layout/nonodescell.xml
1
<?xml version="1.0" encoding="utf-8"?>
2
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
3
    android:orientation="vertical"
4
    android:layout_width="fill_parent"
5
    android:layout_height="264dip"
6
    >
7
    
8
    <TextView android:layout_width="fill_parent"
9
        android:layout_height="wrap_content"
10
        android:layout_marginTop="125px"
11
        android:textColor="#FFFFFF"
12
        android:gravity="center"
13
        
14
        android:textSize="24sp" android:text="No Nodes" android:id="@+id/no_nodes_label"/>
15

  
16
    <TextView android:layout_width="fill_parent"
17
        android:layout_height="wrap_content"
18
        android:layout_marginTop="10px"
19
        android:textColor="#FFFFFF"
20
        android:gravity="center"
21
        android:textSize="12sp" android:text="Add an external node or create a Cloud Server." android:id="@+id/no_nodes_sublabel"/>
22
        
23
</LinearLayout>
b/res/values/style.xml
8 8
    <item name="android:windowTitleStyle">@null</item>
9 9
    <item name="android:windowAnimationStyle">@android:style/Animation.Dialog</item>
10 10
    <item name="android:windowSoftInputMode">stateUnspecified|adjustPan</item>
11
    <item name="android:backgroundDimEnabled">false</item>
12
    <item name="android:background">@android:color/black</item>
11
    <item name="android:backgroundDimEnabled">false</item> 
12
    <item name="android:background">@android:color/black</item> 
13 13
</style>
14 14
</resources>
b/src/com/rackspace/cloud/loadbalancer/api/client/LoadBalancerManager.java
46 46
	}
47 47

  
48 48
	public LoadBalancer getLoadBalancerById(long id) throws LoadBalancersException {
49
		Log.d("info", "the id is " + id);
50 49
		LoadBalancer loadBalancer = null;
51 50
		//First try DFW
52 51
		try{
......
72 71
		if(loadBalancer == null){
73 72
			try{
74 73
				loadBalancer = getLoadBalancerById(id, Account.getLoadBalancerLONUrl());
75
				loadBalancer.setRegion("ORD");
74
				loadBalancer.setRegion("LON");
76 75
			}
77 76
			catch(LoadBalancersException lbe){
78 77
				throw lbe;
b/src/com/rackspacecloud/android/AddNodesActivity.java
194 194
	private void displayNoServersCell() {
195 195
		String a[] = new String[1];
196 196
		a[0] = "No Nodes";
197
		setListAdapter(new ArrayAdapter<String>(this, R.layout.noserverscell, R.id.no_servers_label, a));
197
		setListAdapter(new ArrayAdapter<String>(this, R.layout.nonodescell, R.id.no_nodes_label, a));
198 198
		getListView().setTextFilterEnabled(true);
199 199
		getListView().setDividerHeight(0); // hide the dividers so it won't look like a list row
200 200
		getListView().setItemsCanFocus(false);
b/src/com/rackspacecloud/android/CloudActivity.java
80 80
		
81 81
	}
82 82
	
83
	@Override
84
	protected void onStart(){
85
		super.onStart();
86
		if(isLoading){
87
			showDialog();
88
		}
89
	}
90
	
91
	@Override
92
	protected void onStop(){
93
		super.onStop();
94
		if(isLoading){
95
			hideDialog();
96
			isLoading = true;
97
		}
98
	}
99
	
83 100
	protected final void showAlert(String title, String message) {
84 101
		try {
85 102
			AlertDialog alert = new AlertDialog.Builder(this).create();
......
152 169
		if(pDialog == null || !pDialog.isShowing()){
153 170
			isLoading = true;
154 171
			pDialog = new ProgressDialog(this);
172
			pDialog.setProgressStyle(R.style.NewDialog);
155 173

  
156 174
			/*
157 175
			 * if back is pressed while dialog is showing it will 
......
163 181
					finish();
164 182
				}
165 183
			});
166

  
167 184
			pDialog.getWindow().addFlags(WindowManager.LayoutParams.FLAG_BLUR_BEHIND);
168 185
			pDialog.show();
169 186
			pDialog.setContentView(new ProgressBar(this), new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
b/src/com/rackspacecloud/android/CloudListActivity.java
33 33

  
34 34
public class CloudListActivity extends GaListActivity{
35 35

  
36
	protected Context context;
36
	private Context context;
37 37
	private boolean isLoading;
38 38
	private ProgressDialog pDialog;
39 39
	
......
145 145
		if(pDialog == null || !pDialog.isShowing()){
146 146
			isLoading = true;
147 147
			pDialog = new ProgressDialog(this);
148

  
148
			pDialog.setProgressStyle(R.style.NewDialog);
149
			
149 150
			/*
150 151
			 * if back is pressed while dialog is showing it will 
151 152
			 * still finish the activity
b/src/com/rackspacecloud/android/ContainerObjectDetails.java
5 5
import java.io.FileNotFoundException;
6 6
import java.io.FileOutputStream;
7 7
import java.io.IOException;
8
import java.io.StringReader;
9

  
10
import javax.xml.parsers.FactoryConfigurationError;
11
import javax.xml.parsers.ParserConfigurationException;
12
import javax.xml.parsers.SAXParser;
13
import javax.xml.parsers.SAXParserFactory;
14 8

  
15 9
import org.apache.http.HttpEntity;
16 10
import org.apache.http.HttpResponse;
17
import org.apache.http.client.ClientProtocolException;
18
import org.apache.http.impl.client.BasicResponseHandler;
19 11
import org.apache.http.util.EntityUtils;
20
import org.xml.sax.InputSource;
21
import org.xml.sax.SAXException;
22
import org.xml.sax.XMLReader;
23 12

  
24 13
import android.app.Activity;
25 14
import android.app.AlertDialog;
26 15
import android.app.Dialog;
27
import android.app.ProgressDialog;
28
import android.content.Context;
29 16
import android.content.DialogInterface;
30 17
import android.content.Intent;
31 18
import android.net.Uri;
32 19
import android.os.AsyncTask;
33 20
import android.os.Bundle;
34 21
import android.os.Environment;
35
import android.util.Log;
36 22
import android.view.Menu;
37 23
import android.view.MenuInflater;
38 24
import android.view.MenuItem;
......
45 31
import com.rackspace.cloud.files.api.client.ContainerObjects;
46 32
import com.rackspace.cloud.servers.api.client.CloudServersException;
47 33
import com.rackspace.cloud.servers.api.client.http.HttpBundle;
48
import com.rackspace.cloud.servers.api.client.parsers.CloudServersFaultXMLParser;
49 34

  
50 35
/** 
51 36
 * 
......
53 38
 *
54 39
 */
55 40

  
56
//doesn't extend cloud activity because of the complex
57
//dialog management needed for the listeners
58
public class ContainerObjectDetails extends GaActivity {
41
public class ContainerObjectDetails extends CloudActivity {
59 42

  
60 43
	private static final int deleteObject = 0;
61 44
	private final String DOWNLOAD_DIRECTORY = "/RackspaceCloud";
......
71 54
	private double kiloBytes;
72 55
	public Button previewButton;
73 56
	public Button downloadButton;
74
	public Context context;
75
	private boolean displayDialog;
76
	private ProgressDialog dialog;
77 57
	private Boolean isDownloaded;
78 58
	private AndroidCloudApplication app;
79 59
	private DeleteObjectListenerTask deleteObjTask;
......
84 64
	public void onCreate(Bundle savedInstanceState) {
85 65
		super.onCreate(savedInstanceState);
86 66
		trackPageView(PAGE_STORAGE_OBJECT);
87
		
88
		context = getApplicationContext();
89 67

  
90 68
		objects = (ContainerObjects) this.getIntent().getExtras().get("container");
91 69
		containerNames =  (String) this.getIntent().getExtras().get("containerNames");
92 70
		cdnURL = (String) this.getIntent().getExtras().get("cdnUrl");
93 71
		cdnEnabled = (String) this.getIntent().getExtras().get("isCdnEnabled");
94 72

  
95

  
96 73
		setContentView(R.layout.viewobject);       
97 74
		restoreState(savedInstanceState);
98

  
99 75
	}
100 76

  
101 77
	@Override
......
103 79
		super.onSaveInstanceState(outState);
104 80
		outState.putSerializable("container", objects);
105 81
		outState.putBoolean("isDownloaded", isDownloaded);
106
		outState.putBoolean("displayDialog", displayDialog);
107
		
108
		if(displayDialog){
109
			hideDialog();
110
			displayDialog = true;
111
		}
112 82
	}
113 83

  
114
	private void restoreState(Bundle state) {
115
		
84
	protected void restoreState(Bundle state) {
85
		super.restoreState(state);
116 86
		/*
117 87
		 * need reference to the app so you can access curDirFiles
118 88
		 * as well as processing status
119 89
		 */
120 90
		app = (AndroidCloudApplication)this.getApplication();
121 91

  
122
		if (state != null && state.containsKey("displayDialog") && state.getBoolean("displayDialog")) {
123
    		showDialog();
124
    	} else {
125
    		hideDialog();
126
    	}
127
		
128 92
		if (state != null && state.containsKey("container")) {
129 93
			objects = (ContainerObjects) state.getSerializable("container");
130 94
		}
......
162 126
			downloadObjTask.execute();
163 127
		}
164 128
	}
165
	
166
	@Override
167
	protected void onStart(){
168
		super.onStart();
169
		if(displayDialog){
170
			showDialog();
171
		}
172
	}
173 129

  
174
	
175 130
	@Override
176 131
	protected void onStop(){
177 132
		super.onStop();
178 133

  
179
		if(displayDialog){
180
			hideDialog();
181
			displayDialog = true;
182
		}
183

  
184 134
		/*
185 135
		 * Need to stop running listener task
186 136
		 * if we exit
......
221 171
		//Last Modification date
222 172
		String strDate = objects.getLastMod();
223 173
		strDate = strDate.substring(0, strDate.indexOf('T'));
224
		/*
225
		SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.ssssss");
226
		Date dateStr = null;
227
		try {
228
			dateStr = formatter.parse(strDate);
229
		} catch (ParseException e1) {
230
			e1.printStackTrace();
231
		}
232
		String formattedDate = formatter.format(dateStr);
233 174

  
234
		Date date1 = null;
235
		try {
236
			date1 = formatter.parse(formattedDate);
237
		} catch (ParseException e) {
238
			e.printStackTrace();
239
		}      
240
		formatter = new SimpleDateFormat("MMM-dd-yyyy");
241
		formattedDate = formatter.format(date1);
242
		*/
243 175
		TextView lastmod = (TextView) findViewById(R.id.view_file_modification);
244 176
		lastmod.setText(strDate);    	  
245 177

  
......
272 204
		}
273 205
	}
274 206

  
275
	private void showAlert(String title, String message) {
276
		AlertDialog alert = new AlertDialog.Builder(this).create();
277
		alert.setTitle(title);
278
		alert.setMessage(message);
279
		alert.setButton("OK", new DialogInterface.OnClickListener() {
280
			public void onClick(DialogInterface dialog, int which) {
281
				return;
282
			} }); 
283
		alert.show();
284
	}
285 207
	//Create the Menu options
286 208
	@Override 
287 209
	public boolean onCreateOptionsMenu(Menu menu) {
......
433 355

  
434 356
	//Task's
435 357

  
436
	private CloudServersException parseCloudServersException(HttpResponse response) {
437
		CloudServersException cse = new CloudServersException();
438
		try {
439
			BasicResponseHandler responseHandler = new BasicResponseHandler();
440
			String body = responseHandler.handleResponse(response);
441
			CloudServersFaultXMLParser parser = new CloudServersFaultXMLParser();
442
			SAXParser saxParser = SAXParserFactory.newInstance().newSAXParser();
443
			XMLReader xmlReader = saxParser.getXMLReader();
444
			xmlReader.setContentHandler(parser);
445
			xmlReader.parse(new InputSource(new StringReader(body)));		    	
446
			cse = parser.getException();		    	
447
		} catch (ClientProtocolException e) {
448
			cse = new CloudServersException();
449
			cse.setMessage(e.getLocalizedMessage());
450
		} catch (IOException e) {
451
			cse = new CloudServersException();
452
			cse.setMessage(e.getLocalizedMessage());
453
		} catch (ParserConfigurationException e) {
454
			cse = new CloudServersException();
455
			cse.setMessage(e.getLocalizedMessage());
456
		} catch (SAXException e) {
457
			cse = new CloudServersException();
458
			cse.setMessage(e.getLocalizedMessage());
459
		} catch (FactoryConfigurationError e) {
460
			cse = new CloudServersException();
461
			cse.setMessage(e.getLocalizedMessage());
462
		}
463
		return cse;
464
	}
465

  
466
	private void startFileError(String message, HttpBundle bundle){
467
		Intent viewIntent = new Intent(getApplicationContext(), ServerErrorActivity.class);
468
		viewIntent.putExtra("errorMessage", message);
469
		viewIntent.putExtra("response", bundle.getResponseText());
470
		viewIntent.putExtra("request", bundle.getCurlRequest());
471
		startActivity(viewIntent);
472
	}
473
	
474
	private void showDialog() {
475
		if(dialog == null || !dialog.isShowing()){
476
			displayDialog = true;
477
			dialog = ProgressDialog.show(ContainerObjectDetails.this, "", "Loading...", true);
478
		}
479
    }
480
    
481
    private void hideDialog() {
482
    	if(dialog != null){
483
    		dialog.dismiss();
484
    	}
485
    	displayDialog = false;
486
    }
487

  
488 358
	private class ContainerObjectDeleteTask extends AsyncTask<Void, Void, HttpBundle> {
489 359

  
490 360
		private CloudServersException exception;
491 361

  
492 362
		protected void onPreExecute(){
493
			//dialog = ProgressDialog.show(ContainerObjectDetails.this, "", "Deleting...", true);
494 363
			showDialog();
495 364
			app.setDeleteingObject(true);
496 365
			deleteObjTask = new DeleteObjectListenerTask();
......
501 370
		protected HttpBundle doInBackground(Void... arg0) {
502 371
			HttpBundle bundle = null;	
503 372
			try {
504
				bundle = (new ContainerObjectManager(context)).deleteObject(containerNames, objects.getCName() );
373
				bundle = (new ContainerObjectManager(getContext())).deleteObject(containerNames, objects.getCName() );
505 374
			} catch (CloudServersException e) {
506 375
				exception = e;
507 376
			}
......
511 380

  
512 381
		@Override
513 382
		protected void onPostExecute(HttpBundle bundle) {
514
			//dialog.dismiss();
515 383
			app.setDeleteingObject(false);
516 384
			hideDialog();
517 385
			HttpResponse response = bundle.getResponse();
518 386
			if (response != null) {
519 387
				int statusCode = response.getStatusLine().getStatusCode();
520 388
				if (statusCode == 204) {
521
					//handled by listner
389
					//handled by listener
522 390
				} else {
523 391
					CloudServersException cse = parseCloudServersException(response);
524 392
					if ("".equals(cse.getMessage())) {
525
						startFileError("There was a problem deleting your File.", bundle);
393
						showError("There was a problem deleting your File.", bundle);
526 394
					} else {
527
						startFileError("There was a problem deleting your file: " + cse.getMessage(), bundle);
395
						showError("There was a problem deleting your file: " + cse.getMessage(), bundle);
528 396
					}
529 397
				}
530 398
			} else if (exception != null) {
531
				startFileError("There was a problem deleting your file: " + exception.getMessage(), bundle);				
399
				showError("There was a problem deleting your file: " + exception.getMessage(), bundle);				
532 400
			}			
533 401
		}
534 402
	}
......
549 417
		protected HttpBundle doInBackground(Void... arg0) {
550 418
			HttpBundle bundle = null;	
551 419
			try {
552
				bundle = (new ContainerObjectManager(context)).getObject(containerNames, objects.getCName());
420
				bundle = (new ContainerObjectManager(getContext())).getObject(containerNames, objects.getCName());
553 421
			} catch (CloudServersException e) {
554 422
				exception = e;
555 423
			}
......
567 435
					setResult(Activity.RESULT_OK);
568 436
					HttpEntity entity = response.getEntity();
569 437
					app.setDownloadedEntity(entity);
570
					/*
571
					try {
572
						if(writeFile(EntityUtils.toByteArray(entity))){
573
							downloadButton.setText("Open File");
574
							isDownloaded = true;
575
						}
576
						else{
577
							showAlert("Error", "There was a problem downloading your file.");
578
						}
579

  
580
					} catch (IOException e) {
581
						showAlert("Error", "There was a problem downloading your file.");
582
						e.printStackTrace();
583
					}
584
					*/
585

  
586 438
				} else {
587 439
					CloudServersException cse = parseCloudServersException(response);
588 440
					if ("".equals(cse.getMessage())) {
589
						startFileError("There was a problem downloading your File.", bundle);
441
						showError("There was a problem downloading your File.", bundle);
590 442
					} else {
591
						startFileError("There was a problem downloading your file: " + cse.getMessage(), bundle);
443
						showError("There was a problem downloading your file: " + cse.getMessage(), bundle);
592 444
					}
593 445
				}
594 446
			} else if (exception != null) {
595
				startFileError("There was a problem downloading your file: " + exception.getMessage(), bundle);				
447
				showError("There was a problem downloading your file: " + exception.getMessage(), bundle);				
596 448
			}			
597 449
		}
598 450
	}
......
649 501
		protected void onPostExecute(Void arg1) {
650 502
			hideDialog();
651 503
			try {
652
				Log.d("info", "captin starting to write");
653 504
				if(writeFile(EntityUtils.toByteArray(app.getDownloadedEntity()))){
654 505
					downloadButton.setText("Open File");
655 506
					isDownloaded = true;
656
					Log.d("info", "captin wrote");
657 507
				}
658 508
				else{
659 509
					showAlert("Error", "There was a problem downloading your file.");
b/src/com/rackspacecloud/android/ContainerObjectsActivity.java
1 1
package com.rackspacecloud.android;
2 2

  
3
import java.io.IOException;
4
import java.io.StringReader;
5 3
import java.util.ArrayList;
6 4
import java.util.Arrays;
7 5

  
8
import javax.xml.parsers.FactoryConfigurationError;
9
import javax.xml.parsers.ParserConfigurationException;
10
import javax.xml.parsers.SAXParser;
11
import javax.xml.parsers.SAXParserFactory;
12

  
13 6
import org.apache.http.HttpResponse;
14
import org.apache.http.client.ClientProtocolException;
15
import org.apache.http.impl.client.BasicResponseHandler;
16
import org.xml.sax.InputSource;
17
import org.xml.sax.SAXException;
18
import org.xml.sax.XMLReader;
19 7

  
20 8
import android.app.Activity;
21 9
import android.app.AlertDialog;
22 10
import android.app.Dialog;
23
import android.app.ProgressDialog;
24
import android.content.Context;
25 11
import android.content.DialogInterface;
26 12
import android.content.Intent;
27 13
import android.os.AsyncTask;
28 14
import android.os.Bundle;
29
import android.util.Log;
30 15
import android.view.LayoutInflater;
31 16
import android.view.Menu;
32 17
import android.view.MenuInflater;
33
import android.view.MenuItem;
18
import android.view.MenuItem; 
34 19
import android.view.View;
35 20
import android.view.ViewGroup;
36 21
import android.widget.ArrayAdapter;
......
44 29
import com.rackspace.cloud.files.api.client.ContainerObjects;
45 30
import com.rackspace.cloud.servers.api.client.CloudServersException;
46 31
import com.rackspace.cloud.servers.api.client.http.HttpBundle;
47
import com.rackspace.cloud.servers.api.client.parsers.CloudServersFaultXMLParser;
48 32

  
49 33
/**
50 34
 * 
......
52 36
 * 
53 37
 */
54 38

  
55
//doesn't extend cloud activity because of the complex
56
//dialog management needed for the listeners
57
public class ContainerObjectsActivity extends GaListActivity {
39
public class ContainerObjectsActivity extends CloudListActivity {
58 40

  
59 41
	private static final int deleteContainer = 0;
60 42
	private static final int deleteFolder = 1;
......
67 49
	public Object kiloBytes;
68 50
	public int bConver = 1048576;
69 51
	public int kbConver = 1024;
70
	private Context context;
71
	private String currentPath;
72 52
	private boolean loadingFiles;
73
	private boolean displayDialog;
74
	private ProgressDialog dialog;
53
	private String currentPath;
75 54
	private AndroidCloudApplication app;
76 55
	private AddObjectListenerTask task;
77 56
	private DeleteObjectListenerTask deleteObjTask;
......
82 61
		super.onCreate(savedInstanceState);
83 62
		trackPageView(PAGE_FOLDER);
84 63
		container = (Container) this.getIntent().getExtras().get("container");
85
		Log.v(LOG, "CDNEnabled:" + container.isCdnEnabled());
86
		context = getApplicationContext();
87 64
		if (container.isCdnEnabled() == true) {
88 65
			cdnEnabledIs = "true";
89 66
		} else {
......
102 79
		//current path represents where you have "navigated" to
103 80
		outState.putString("path", currentPath);
104 81
		
105
		//stores state if you are loading or not 
106 82
		outState.putBoolean("loadingFiles", loadingFiles);
107
		
108
		//stores whether dialog is showing or not
109
		outState.putBoolean("displayDialog", displayDialog);
110
		
111
		//need to set authenticating back to true because it is set to false
112
		//in hideDialog()
113
		if(displayDialog){
114
			hideDialog();
115
			displayDialog = true;
116
		}
117 83
	}
118 84

  
119 85

  
120 86

  
121
	private void restoreState(Bundle state) {
122
		
87
	protected void restoreState(Bundle state) {
88
		super.restoreState(state);
123 89
		
124 90
		/*
125 91
		 * need reference to the app so you can access curDirFiles
126 92
		 * as well as processing status
127 93
		 */
128 94
		app = (AndroidCloudApplication)this.getApplication();
129

  
130
		if (state != null && state.containsKey("displayDialog") && state.getBoolean("displayDialog")) {
131
    		showDialog();
132
    	} else {
133
    		hideDialog();
134
    	}
135 95
		
136 96
		if(state != null){
137 97
			if(state.containsKey("path")){
......
187 147
	}
188 148
	
189 149
	@Override
190
	protected void onStart(){
191
		super.onStart();
192
		if(displayDialog){
193
			showDialog();
194
		}
195
	}
196

  
197
	
198
	@Override
199 150
	protected void onStop(){
200 151
		super.onStop();
201 152

  
202
		if(displayDialog){
203
			hideDialog();
204
			displayDialog = true;
205
		}
206

  
207 153
		/*
208 154
		 * Need to stop running listener task
209 155
		 * if we exit
......
343 289
		getListView().setItemsCanFocus(false);
344 290
	}
345 291

  
346

  
347
	private void showAlert(String title, String message) {
348
		// Can't create handler inside thread that has not called
349
		// Looper.prepare()
350
		// Looper.prepare();
351
		try {
352
			AlertDialog alert = new AlertDialog.Builder(this).create();
353
			alert.setTitle(title);
354
			alert.setMessage(message);
355
			alert.setButton("OK", new DialogInterface.OnClickListener() {
356
				public void onClick(DialogInterface dialog, int which) {
357
					return;
358
				}
359
			});
360
			alert.show();
361
		} catch (Exception e) {
362
			e.printStackTrace();
363
		}
364
	}
365

  
366 292
	/* just get the last part of the filename
367 293
	 * so the entire file path does not show
368 294
	 */
......
579 505
		
580 506
	}
581 507

  
582
	private CloudServersException parseCloudServersException(
583
			HttpResponse response) {
584
		CloudServersException cse = new CloudServersException();
585
		try {
586
			BasicResponseHandler responseHandler = new BasicResponseHandler();
587
			String body = responseHandler.handleResponse(response);
588
			CloudServersFaultXMLParser parser = new CloudServersFaultXMLParser();
589
			SAXParser saxParser = SAXParserFactory.newInstance().newSAXParser();
590
			XMLReader xmlReader = saxParser.getXMLReader();
591
			xmlReader.setContentHandler(parser);
592
			xmlReader.parse(new InputSource(new StringReader(body)));
593
			cse = parser.getException();
594
		} catch (ClientProtocolException e) {
595
			cse = new CloudServersException();
596
			cse.setMessage(e.getLocalizedMessage());
597
		} catch (IOException e) {
598
			cse = new CloudServersException();
599
			cse.setMessage(e.getLocalizedMessage());
600
		} catch (ParserConfigurationException e) {
601
			cse = new CloudServersException();
602
			cse.setMessage(e.getLocalizedMessage());
603
		} catch (SAXException e) {
604
			cse = new CloudServersException();
605
			cse.setMessage(e.getLocalizedMessage());
606
		} catch (FactoryConfigurationError e) {
607
			cse = new CloudServersException();
608
			cse.setMessage(e.getLocalizedMessage());
609
		}
610
		return cse;
611
	}
612

  
613
	private void startFileError(String message, HttpBundle bundle){
614
		Intent viewIntent = new Intent(getApplicationContext(), ServerErrorActivity.class);
615
		viewIntent.putExtra("errorMessage", message);
616
		viewIntent.putExtra("response", bundle.getResponseText());
617
		viewIntent.putExtra("request", bundle.getCurlRequest());
618
		startActivity(viewIntent);
619
	}
620
	
621
	private void showDialog() {
622
		if(dialog == null || !dialog.isShowing()){
623
			displayDialog = true;
624
			dialog = ProgressDialog.show(ContainerObjectsActivity.this, "", "Loading...", true);
625
		}
626
    }
627
    
628
    private void hideDialog() {
629
    	if(dialog != null){
630
    		dialog.dismiss();
631
    	}
632
    	displayDialog = false;
633
    }
634

  
635 508
	class FileAdapter extends ArrayAdapter<ContainerObjects> {
636 509
		FileAdapter() {
637 510
			super(ContainerObjectsActivity.this,
......
669 542
	AsyncTask<String, Void, ArrayList<ContainerObjects>> {
670 543

  
671 544
		private CloudServersException exception;
545
		
672 546
		protected void onPreExecute(){
673 547
			showDialog();
674
			loadingFiles = true; 
548
			loadingFiles = true;
675 549
		}
676 550

  
677 551
		@Override
678 552
		protected ArrayList<ContainerObjects> doInBackground(String... path) {
679 553
			ArrayList<ContainerObjects> files = null;
680 554
			try {
681
				files = (new ContainerObjectManager(context)).createList(true,
555
				files = (new ContainerObjectManager(getContext())).createList(true,
682 556
						container.getName());
683 557
			} catch (CloudServersException e) {
684 558
				exception = e;
......
689 563

  
690 564
		@Override
691 565
		protected void onPostExecute(ArrayList<ContainerObjects> result) {
566
			loadingFiles = false;
692 567
			hideDialog();
693 568
			if (exception != null) {
694 569
				showAlert("Error", exception.getMessage());
695 570
			}
696

  
697 571
			setFileList(result);
698 572
			loadCurrentDirectoryFiles();
699 573
			displayCurrentFiles();
700
			loadingFiles = false;
701 574
		}
702 575

  
703 576
	}
......
720 593
			HttpBundle bundle = null;
721 594
			try {
722 595
				
723
				bundle = (new ContainerObjectManager(context)).addObject(container.getName(), currentPath, data[0], data[1]);
596
				bundle = (new ContainerObjectManager(getContext())).addObject(container.getName(), currentPath, data[0], data[1]);
724 597
			} catch (CloudServersException e) {
725 598
				exception = e;
726 599
			}
......
730 603
		@Override
731 604
		protected void onPostExecute(HttpBundle bundle) {
732 605
			app.setAddingObject(false);
606
			hideDialog();
733 607
			HttpResponse response = bundle.getResponse();
734 608
			if (response != null) {
735 609
				int statusCode = response.getStatusLine().getStatusCode();
......
737 611
					setResult(Activity.RESULT_OK);
738 612
					//loading the new files is done by ListenerTask
739 613
				} else {
740
					hideDialog();
741 614
					CloudServersException cse = parseCloudServersException(response);
742 615
					if ("".equals(cse.getMessage())) {
743
						startFileError("There was a problem deleting your folder.", bundle);
616
						showError("There was a problem deleting your folder.", bundle);
744 617
					} else {
745
						startFileError("There was a problem deleting your folder: "
618
						showError("There was a problem deleting your folder: "
746 619
								+ cse.getMessage(), bundle);
747 620
					}
748 621
				}
749 622
			} else if (exception != null) {
750
				hideDialog();
751
				startFileError("There was a problem deleting your folder: "
623
				showError("There was a problem deleting your folder: "
752 624
						+ exception.getMessage(), bundle);
753 625
			}
754 626
		}
......
772 644
			HttpBundle bundle = null;
773 645
			try {
774 646
				//subtring because the current directory contains a "/" at the end of the string
775
				bundle = (new ContainerObjectManager(context)).deleteObject(container.getName(), currentPath.substring(0, currentPath.length()-1));
647
				bundle = (new ContainerObjectManager(getContext())).deleteObject(container.getName(), currentPath.substring(0, currentPath.length()-1));
776 648
			} catch (CloudServersException e) {
777 649
				exception = e;
778 650
			}
......
782 654
		@Override
783 655
		protected void onPostExecute(HttpBundle bundle) {
784 656
			app.setDeleteingObject(false);
657
			hideDialog();
785 658
			HttpResponse response = bundle.getResponse();
786 659
			if (response != null) {
787 660
				int statusCode = response.getStatusLine().getStatusCode();
788 661
				if (statusCode == 409) {
789
					hideDialog();
790 662
					showAlert("Error",
791 663
					"Folder must be empty in order to delete");
792 664
				}
793 665
				if (statusCode == 204) {
794 666
					setResult(Activity.RESULT_OK);
795 667
				} else {
796
					hideDialog();
797 668
					CloudServersException cse = parseCloudServersException(response);
798 669
					if ("".equals(cse.getMessage())) {
799
						startFileError("There was a problem deleting your folder.", bundle);
670
						showError("There was a problem deleting your folder.", bundle);
800 671
					} else {
801
						startFileError("There was a problem deleting your folder: "
672
						showError("There was a problem deleting your folder: "
802 673
								+ cse.getMessage(), bundle);
803 674
					}
804 675
				}
805 676
			} else if (exception != null) {
806
				hideDialog();
807
				startFileError("There was a problem deleting your folder: "
677
				showError("There was a problem deleting your folder: "
808 678
						+ exception.getMessage(), bundle);
809 679
			}
810 680
		}
......
816 686
		private CloudServersException exception;
817 687

  
818 688
		@Override
819
		protected void onPreExecute(){
689
		protected void onPreExecute(){ 
820 690
			showDialog();
821 691
			app.setDeletingContainer(true);
822 692
			deleteContainerTask = new DeleteContainerListenerTask();
......
827 697
		protected HttpBundle doInBackground(String... object) {
828 698
			HttpBundle bundle = null;
829 699
			try {
830
				
831
				bundle = (new ContainerManager(context)).delete(container.getName());
700
				bundle = (new ContainerManager(getContext())).delete(container.getName());
832 701
			} catch (CloudServersException e) {
833 702
				exception = e;
834 703
			}
......
843 712
			if (response != null) {
844 713
				int statusCode = response.getStatusLine().getStatusCode();
845 714
				if (statusCode == 409) {
846
					startFileError("Container must be empty in order to delete", bundle);
715
					showError("Container must be empty in order to delete", bundle);
847 716
				}
848 717
				if (statusCode == 204) {
849 718
					setResult(Activity.RESULT_OK);
......
851 720
				} else {
852 721
					CloudServersException cse = parseCloudServersException(response);
853 722
					if ("".equals(cse.getMessage())) {
854
						startFileError("There was a problem deleting your container.", bundle);
723
						showError("There was a problem deleting your container.", bundle);
855 724
					} else {
856
						startFileError("There was a problem deleting your container: "
725
						showError("There was a problem deleting your container: "
857 726
								+ cse.getMessage(), bundle);
858 727
					}
859 728
				}
860 729
			} else if (exception != null) {
861
				startFileError("There was a problem deleting your server: "
730
				showError("There was a problem deleting your server: "
862 731
						+ exception.getMessage(), bundle);
863 732
			}
864 733
		}
......
891 760
		 */
892 761
		@Override
893 762
		protected void onPostExecute(Void arg1) {
763
			hideDialog();
894 764
			loadFiles();
895 765
		}
896 766
	}
b/src/com/rackspacecloud/android/GaActivity.java
5 5
import android.app.Activity;
6 6
import android.os.Build;
7 7
import android.os.Bundle;
8
import android.util.Log;
9 8

  
10 9
public class GaActivity extends Activity {
11 10
	
......
49 48
	
50 49
	public void startTracker(){
51 50
		if(!"google_sdk".equals(Build.PRODUCT) && !"sdk".equals(Build.PRODUCT)){
52
			Log.d("tracker", "Creating Tracker");
53 51
			tracker = GoogleAnalyticsTracker.getInstance();
54 52
			tracker.start(Config.WEB_PROPERTY_ID, 20, this);
55 53
		}
56
		else{
57
			Log.d("tracker", "Not Creating Tracker");
58
		}
59 54
	}
60 55
	
61 56
	public void trackPageView(String page){
62 57
		if(tracker != null){
63
			Log.d("tracker", "Tracking pageview: " + page);
64 58
			tracker.trackPageView(page);
65 59
		}
66 60
	}
......
75 69

  
76 70
	public void trackEvent(String category, String action, String label, int value){
77 71
		if(tracker != null){
78
			Log.d("tracker", "Tracking event: " + category + " " + action);
79 72
			tracker.trackEvent(category, action, label, value);
80 73
		}
81 74
	}
b/src/com/rackspacecloud/android/GaListActivity.java
5 5
import android.app.ListActivity;
6 6
import android.os.Build;
7 7
import android.os.Bundle;
8
import android.util.Log;
9 8

  
10 9
public class GaListActivity extends ListActivity {
11 10

  
......
49 48
	
50 49
	public void startTracker(){
51 50
		if(!"google_sdk".equals(Build.PRODUCT) && !"sdk".equals(Build.PRODUCT)){
52
			Log.d("tracker", "Creating Tracker");
53 51
			tracker = GoogleAnalyticsTracker.getInstance();
54 52
			tracker.start(Config.WEB_PROPERTY_ID, 20, this);
55 53
		}
56
		else{
57
			Log.d("tracker", "Not Creating Tracker");
58
		}
59 54
	}
60 55

  
61 56
	public void trackPageView(String page){
62 57
		if(tracker != null){
63
			Log.d("tracker", "Tracking pageview: " + page);
64 58
			tracker.trackPageView(page);
65 59
		}
66 60
	}
......
75 69

  
76 70
	public void trackEvent(String category, String action, String label, int value){
77 71
		if(tracker != null){
78
			Log.d("tracker", "Tracking event: " + category + " " + action);
79 72
			tracker.trackEvent(category, action, label, value);
80 73
		}
81 74
	}
b/src/com/rackspacecloud/android/ListAccountsActivity.java
38 38
import android.view.MenuInflater;
39 39
import android.view.MenuItem;
40 40
import android.view.View;
41
import android.view.WindowManager;
41 42
import android.view.View.OnClickListener;
43
import android.view.ViewGroup.LayoutParams;
42 44
import android.view.ViewGroup;
43 45
import android.widget.AdapterView.AdapterContextMenuInfo;
44 46
import android.widget.ArrayAdapter;
......
46 48
import android.widget.EditText;
47 49
import android.widget.ImageView;
48 50
import android.widget.ListView;
51
import android.widget.ProgressBar;
49 52
import android.widget.TextView;
50 53
import android.widget.Toast;
51 54

  
......
55 58
	private final int PASSWORD_PROMPT = 123;
56 59
	private final String FILENAME = "accounts.data";
57 60
	private static final String PAGE_ROOT = "/Root";
58

  
61
	
59 62
	private boolean authenticating;
60 63
	private ArrayList<Account> accounts;
61 64
	private Intent tabViewIntent;
......
405 408
		app.setIsLoggingIn(true);
406 409
		authenticating = true;
407 410
		if(dialog == null || !dialog.isShowing()){
408
			dialog = ProgressDialog.show(ListAccountsActivity.this, "", "Authenticating...", true);
409
			dialog.setCancelable(true);
411
			dialog = new ProgressDialog(this);
412
			dialog.setProgressStyle(R.style.NewDialog);
410 413
			dialog.setOnCancelListener(new OnCancelListener() {
411 414

  
412 415
				@Override
......
415 418
					hideDialog();
416 419
				}
417 420
			});
421
			dialog.getWindow().addFlags(WindowManager.LayoutParams.FLAG_BLUR_BEHIND);
422
			dialog.show();
423
			dialog.setContentView(new ProgressBar(this), new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
418 424
		}
425

  
426
		
419 427
	}
420 428

  
421 429
	private void hideDialog() {
b/src/com/rackspacecloud/android/SharedVipActivity.java
169 169
		protected ArrayList<LoadBalancer> doInBackground(Void... arg0) {
170 170
			ArrayList<LoadBalancer> loadBalancers = null;
171 171
			try {
172
				loadBalancers = (new LoadBalancerManager(context)).createList();
172
				loadBalancers = (new LoadBalancerManager(getContext())).createList();
173 173
			} catch (LoadBalancersException e) {
174 174
				exception = e;
175 175
			}

Also available in: Unified diff