Revision 7b27f0dc src/com/rackspace/cloud/android/ContainerObjectsActivity.java
b/src/com/rackspace/cloud/android/ContainerObjectsActivity.java | ||
---|---|---|
55 | 55 |
|
56 | 56 |
private static final int deleteContainer = 0; |
57 | 57 |
private static final int deleteFolder = 1; |
58 |
|
|
58 |
private static final int deleteContext = 2; |
|
59 |
private static final int toTrashContext = 3; |
|
60 |
private static final int fromTrashContext = 4; |
|
61 |
private String currentSelectedPath=null; |
|
59 | 62 |
private ContainerObjects[] files; |
60 | 63 |
private static Container container; |
61 | 64 |
public String LOG = "viewFilesActivity"; |
... | ... | |
104 | 107 |
|
105 | 108 |
protected void restoreState(Bundle state) { |
106 | 109 |
super.restoreState(state); |
107 |
|
|
110 |
|
|
108 | 111 |
/* |
109 | 112 |
* need reference to the app so you can access curDirFiles as well as |
110 | 113 |
* processing status |
... | ... | |
200 | 203 |
* go to the current directory's parent and display that data |
201 | 204 |
*/ |
202 | 205 |
private void goUpDirectory() { |
206 |
if(currentSelectedPath != null){ |
|
207 |
currentSelectedPath=null; |
|
208 |
loadFiles(); |
|
209 |
return; |
|
210 |
} |
|
203 | 211 |
currentPath = currentPath.substring( |
204 | 212 |
0, |
205 | 213 |
currentPath.substring(0, currentPath.length() - 2).lastIndexOf( |
206 | 214 |
"/") + 1); |
207 |
if(container.getName().equalsIgnoreCase(Container.MYSHARED)){ |
|
208 |
loadCurrentDirectoryFiles(); |
|
209 |
displayCurrentFiles(); |
|
210 |
} |
|
211 |
else if(previousFiles!=null&&previousFiles.size()>0){ |
|
215 |
if(previousFiles!=null&&previousFiles.size()>0){ |
|
212 | 216 |
files = previousFiles.toArray(new ContainerObjects[]{}); |
213 | 217 |
previousFiles=null; |
214 | 218 |
loadCurrentDirectoryFiles(); |
... | ... | |
250 | 254 |
* determines if a file should be displayed in current directory |
251 | 255 |
*/ |
252 | 256 |
protected Boolean fileBelongsInDir(ContainerObjects obj) { |
253 |
String objPath = obj.getCName(); |
|
257 |
/*String objPath = obj.getCName();
|
|
254 | 258 |
|
255 | 259 |
if (!objPath.startsWith(currentPath)) { |
256 | 260 |
Log.i(LOG, "Path is:" + currentPath + " " + objPath + " " + false); |
... | ... | |
260 | 264 |
Log.i(LOG, "Path is:" + currentPath + " " + objPath + " " |
261 | 265 |
+ !objPath.contains("/")); |
262 | 266 |
return !objPath.contains("/"); |
263 |
} |
|
267 |
}*/ |
|
268 |
return true; |
|
264 | 269 |
} |
265 | 270 |
|
266 | 271 |
/* |
267 | 272 |
* loads all the files that are in the container into one array |
268 | 273 |
*/ |
269 |
private void setFileList(ArrayList<ContainerObjects> files) {
|
|
274 |
private void setFileList(List<ContainerObjects> files) { |
|
270 | 275 |
if (files == null) { |
271 | 276 |
files = new ArrayList<ContainerObjects>(); |
272 | 277 |
} |
... | ... | |
284 | 289 |
} |
285 | 290 |
|
286 | 291 |
protected void displayCurrentFiles() { |
292 |
setTitle(container.getName()+": /"+currentPath); |
|
287 | 293 |
if (app.getCurFiles().size() == 0) { |
288 | 294 |
displayNoFilesCell(); |
289 | 295 |
} else { |
... | ... | |
356 | 362 |
protected void onListItemClick(ListView l, View v, int position, long id) { |
357 | 363 |
if (app.getCurFiles() != null && app.getCurFiles().size() > 0) { |
358 | 364 |
Intent viewIntent; |
359 |
if (app.getCurFiles().get(position).getContentType() |
|
360 |
.startsWith("application/directory")) { |
|
365 |
if (app.getCurFiles().get(position).isFolder()) { |
|
361 | 366 |
currentPath = app.getCurFiles().get(position).getCName() + "/"; |
362 |
if(container.getName().equalsIgnoreCase(Container.MYSHARED)){ |
|
367 |
/*if(container.getName().equalsIgnoreCase(Container.MYSHARED)){
|
|
363 | 368 |
loadCurrentDirectoryFiles(); |
364 | 369 |
displayCurrentFiles(); |
365 | 370 |
} |
366 |
else{ |
|
371 |
else{*/
|
|
367 | 372 |
previousFiles = Arrays.asList(files); |
368 | 373 |
loadFiles(); |
369 |
} |
|
374 |
//}
|
|
370 | 375 |
//loadCurrentDirectoryFiles(); |
371 | 376 |
//displayCurrentFiles(); |
372 | 377 |
} |
... | ... | |
432 | 437 |
} |
433 | 438 |
long id = getListAdapter().getItemId(info.position); |
434 | 439 |
final ContainerObjects obj = (ContainerObjects) getListAdapter().getItem(info.position); |
435 |
|
|
440 |
currentSelectedPath = obj.getCName() + "/"; |
|
436 | 441 |
switch (item.getItemId()) { |
437 | 442 |
case R.id.delete_contextmenu: |
438 |
/*if (currentPath.equals("")) { |
|
439 |
showDialog(deleteContainer); |
|
440 |
} else { |
|
441 |
showDialog(deleteFolder); |
|
442 |
}*///TODO |
|
443 |
showDialog(deleteContext); |
|
443 | 444 |
return true; |
444 | 445 |
case R.id.totrash_contextmenu: |
445 |
/*if (currentPath.equals("")) { |
|
446 |
showDialog(deleteContainer); |
|
447 |
} else { |
|
448 |
showDialog(deleteFolder); |
|
449 |
}*///TODO |
|
446 |
showDialog(toTrashContext); |
|
450 | 447 |
return true; |
451 | 448 |
case R.id.fromtrash_contextmenu: |
452 |
/*if (currentPath.equals("")) { |
|
453 |
showDialog(deleteContainer); |
|
454 |
} else { |
|
455 |
showDialog(deleteFolder); |
|
456 |
}*///TODO |
|
449 |
showDialog(fromTrashContext); |
|
457 | 450 |
return true; |
458 | 451 |
case R.id.properties_contextmenu: |
459 | 452 |
Intent viewIntent; |
... | ... | |
466 | 459 |
return true; |
467 | 460 |
|
468 | 461 |
} |
462 |
currentSelectedPath=null; |
|
469 | 463 |
return false; |
470 | 464 |
|
471 | 465 |
} |
... | ... | |
585 | 579 |
// User clicked Cancel so do some stuff |
586 | 580 |
} |
587 | 581 |
}).create(); |
588 |
} else { |
|
589 |
return new AlertDialog.Builder(ContainerObjectsActivity.this) |
|
590 |
.setIcon(R.drawable.alert_dialog_icon) |
|
591 |
.setTitle("Delete Folder") |
|
592 |
.setMessage("Folder must be empty to delete") |
|
593 |
.setNegativeButton("OK", |
|
594 |
new DialogInterface.OnClickListener() { |
|
595 |
public void onClick(DialogInterface dialog, |
|
596 |
int whichButton) { |
|
597 |
// User clicked Cancel so do some stuff |
|
598 |
} |
|
599 |
}).create(); |
|
600 | 582 |
} |
583 |
case deleteContext: |
|
584 |
return new AlertDialog.Builder(ContainerObjectsActivity.this) |
|
585 |
.setIcon(R.drawable.alert_dialog_icon) |
|
586 |
.setTitle("Delete Object") |
|
587 |
.setMessage( |
|
588 |
"Are you sure you want to delete this Object?") |
|
589 |
.setPositiveButton("Delete Object", |
|
590 |
new DialogInterface.OnClickListener() { |
|
591 |
public void onClick(DialogInterface dialog, |
|
592 |
int whichButton) { |
|
593 |
// User clicked OK so do some stuff |
|
594 |
new DeleteObjectTask().execute(container.getName(), currentSelectedPath); |
|
595 |
} |
|
596 |
}) |
|
597 |
.setNegativeButton("Cancel", |
|
598 |
new DialogInterface.OnClickListener() { |
|
599 |
public void onClick(DialogInterface dialog, |
|
600 |
int whichButton) { |
|
601 |
currentSelectedPath=null; |
|
602 |
// User clicked Cancel so do some stuff |
|
603 |
} |
|
604 |
}).create(); |
|
601 | 605 |
case R.id.add_folder: |
602 | 606 |
final EditText input = new EditText(this); |
603 | 607 |
return new AlertDialog.Builder(ContainerObjectsActivity.this) |
... | ... | |
669 | 673 |
|
670 | 674 |
ImageView objectImage = (ImageView) row |
671 | 675 |
.findViewById(R.id.file_type_image); |
672 |
if (file.getContentType().startsWith("application/directory")||file.getContentType().startsWith("application/folder")) {
|
|
676 |
if (file.isFolder()) {
|
|
673 | 677 |
objectImage.setImageResource(R.drawable.folder); |
674 | 678 |
} else { |
675 | 679 |
objectImage.setImageResource(R.drawable.file); |
... | ... | |
693 | 697 |
} |
694 | 698 |
|
695 | 699 |
private class LoadFilesTask extends |
696 |
AsyncTask<String, Void, ArrayList<ContainerObjects>> {
|
|
700 |
AsyncTask<String, Void, List<ContainerObjects>> { |
|
697 | 701 |
|
698 | 702 |
private CloudServersException exception; |
699 | 703 |
|
... | ... | |
703 | 707 |
} |
704 | 708 |
|
705 | 709 |
@Override |
706 |
protected ArrayList<ContainerObjects> doInBackground(String... path) {
|
|
707 |
ArrayList<ContainerObjects> files = null;
|
|
710 |
protected List<ContainerObjects> doInBackground(String... path) { |
|
711 |
List<ContainerObjects> files = null; |
|
708 | 712 |
try { |
709 | 713 |
if (container.getName().equals(Container.MYSHARED)) { |
710 | 714 |
files = (new ContainerObjectManager(getContext())) |
711 |
.createListMyShared(true, container.getName(),
|
|
715 |
.createListMyShared( container.getName(), |
|
712 | 716 |
new ContainerManager(getContext()) |
713 |
.createList(true)); |
|
717 |
.createList(true),path[0]);
|
|
714 | 718 |
} else if (container.getName().equals(Container.OTHERS)) { |
715 | 719 |
|
716 | 720 |
} else { |
717 | 721 |
if (container.getOtherUser() == null) |
718 | 722 |
files = (new ContainerObjectManager(getContext())) |
719 |
.createList(true, container.getName(),path[0]);
|
|
723 |
.createList(container.getName(), path[0]);
|
|
720 | 724 |
else |
721 | 725 |
files = (new ContainerObjectManager(getContext())) |
722 |
.createOtherList(true, container.getName(), |
|
723 |
container.getOtherUser()); |
|
726 |
.createOtherList(container.getName(), container.getOtherUser()); |
|
724 | 727 |
} |
725 | 728 |
} catch (CloudServersException e) { |
726 | 729 |
exception = e; |
... | ... | |
730 | 733 |
} |
731 | 734 |
|
732 | 735 |
@Override |
733 |
protected void onPostExecute(ArrayList<ContainerObjects> result) {
|
|
736 |
protected void onPostExecute(List<ContainerObjects> result) { |
|
734 | 737 |
loadingFiles = false; |
735 | 738 |
hideDialog(); |
736 | 739 |
if (exception != null) { |
... | ... | |
850 | 853 |
private class DeleteObjectTask extends AsyncTask<String, Void, HttpBundle> { |
851 | 854 |
|
852 | 855 |
private CloudServersException exception; |
853 |
|
|
856 |
public boolean isInFile=false; |
|
854 | 857 |
@Override |
855 | 858 |
protected void onPreExecute() { |
856 | 859 |
showDialog(); |
... | ... | |
1014 | 1017 |
@Override |
1015 | 1018 |
protected void onPostExecute(Void arg1) { |
1016 | 1019 |
hideDialog(); |
1017 |
removeFromList(currentPath); |
|
1020 |
if(currentSelectedPath==null) |
|
1021 |
removeFromList(currentPath); |
|
1018 | 1022 |
previousFiles=null; |
1019 | 1023 |
goUpDirectory(); |
1020 | 1024 |
} |
Also available in: Unified diff