Revision ecbad159

b/res/menu/view_container_object_list_context.xml
1
<?xml version="1.0" encoding="utf-8"?>
2
<menu xmlns:android="http://schemas.android.com/apk/res/android">
3
   <item android:icon="@drawable/add_button" android:title="Properties" android:id="@+id/properties_contextmenu"/>
4
   <item android:icon="@drawable/add_button" android:title="Move To Trash" android:id="@+id/totrash_contextmenu"/>
5
   <item android:icon="@drawable/add_button" android:title="restore" android:id="@+id/fromtrash_contextmenu"/>
6
   <item android:icon="@drawable/add_button" android:title="Delete" android:id="@+id/delete_contextmenu"/>
7
</menu>
b/src/com/rackspace/cloud/android/CloudListActivity.java
61 61
		app = (AndroidCloudApplication)this.getApplication();
62 62
		//So keyboard doesn't open till user clicks
63 63
		this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN); 
64
		registerForContextMenu(getListView());
64 65
	}
65 66
	
66 67
	@Override
b/src/com/rackspace/cloud/android/ContainerObjectDetails.java
125 125
	}
126 126

  
127 127
	public boolean isFolder(){
128
		return objects.getContentType().startsWith("application/folder");
128
		return objects.getContentType().startsWith("application/folder")||objects.getContentType().startsWith("application/directory");
129 129
	}
130 130
	@Override
131 131
	protected void onSaveInstanceState(Bundle outState) {
......
197 197
	}
198 198

  
199 199
	private void loadObjectData() {
200
		if(Container.MYSHARED.equals(objects.getContainerName())){
200
		if(Container.MYSHARED.equals(objects.getContainerName())||Container.MYSHARED.equals(containerNames)){
201 201
			isReadOnly = true;
202 202
			
203 203
		}
......
597 597
		super.onCreateOptionsMenu(menu);
598 598
		MenuInflater inflater = getMenuInflater();
599 599
		inflater.inflate(R.menu.container_object_list_menu, menu);
600
		menu.findItem(R.id.delete_object).setVisible(isReadOnly);
601
		menu.findItem(R.id.save).setVisible(isReadOnly);
600 602
		return true;
601 603
	}
602 604

  
b/src/com/rackspace/cloud/android/ContainerObjectsActivity.java
6 6
import java.net.URLEncoder;
7 7
import java.util.ArrayList;
8 8
import java.util.Arrays;
9
import java.util.Collections;
10 9
import java.util.List;
11 10

  
12 11
import org.apache.http.HttpResponse;
......
18 17
import android.content.DialogInterface;
19 18
import android.content.Intent;
20 19
import android.database.Cursor;
21
import android.hardware.Camera.PreviewCallback;
22 20
import android.net.Uri;
23 21
import android.os.AsyncTask;
24 22
import android.os.Bundle;
25 23
import android.util.Log;
24
import android.view.ContextMenu;
25
import android.view.ContextMenu.ContextMenuInfo;
26 26
import android.view.LayoutInflater;
27 27
import android.view.Menu;
28 28
import android.view.MenuInflater;
......
30 30
import android.view.View;
31 31
import android.view.ViewGroup;
32 32
import android.webkit.MimeTypeMap;
33
import android.widget.AdapterView;
33 34
import android.widget.ArrayAdapter;
34 35
import android.widget.EditText;
35 36
import android.widget.ImageView;
......
80 81
		} else {
81 82
			cdnEnabledIs = "false";
82 83
		}
84
		
83 85
		restoreState(savedInstanceState);
84 86
	}
85 87

  
......
394 396
			menu.findItem(R.id.add_folder).setVisible(false);
395 397
			menu.findItem(R.id.add_file).setVisible(false);
396 398
		}
399
		else if(Container.MYSHARED.equalsIgnoreCase(container.getName())){
400
			menu.findItem(R.id.delete_container).setVisible(false);
401
			menu.findItem(R.id.add_folder).setVisible(false);
402
			menu.findItem(R.id.add_file).setVisible(false);
403
		}
397 404
		return true;
398 405
	}
399

  
406
	@Override
407
	public void onCreateContextMenu(ContextMenu menu, View v,
408
			ContextMenuInfo menuInfo) {
409
		super.onCreateContextMenu(menu, v, menuInfo);
410
		MenuInflater inflater = getMenuInflater();
411
		inflater.inflate(R.menu.view_container_object_list_context, menu);
412
		menu.findItem(R.id.fromtrash_contextmenu).setVisible(false);
413
		if(Container.TRASH.equalsIgnoreCase(container.getName())){
414
			menu.findItem(R.id.delete_contextmenu).setVisible(false);
415
			menu.findItem(R.id.totrash_contextmenu).setVisible(false);
416
			menu.findItem(R.id.fromtrash_contextmenu).setVisible(true);
417
		}
418
		else if(Container.MYSHARED.equalsIgnoreCase(container.getName())){
419
			menu.findItem(R.id.delete_contextmenu).setVisible(false);
420
			menu.findItem(R.id.totrash_contextmenu).setVisible(false);
421
		}
422
	}
423
	
424
	@Override
425
	public boolean onContextItemSelected(final MenuItem item) {
426
		final AdapterView.AdapterContextMenuInfo info;
427
		try {
428
		    info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();
429
		} catch (ClassCastException e) {
430
		    Log.e(LOG, "bad menuInfo", e);
431
		    return false;
432
		}
433
		long id = getListAdapter().getItemId(info.position);
434
		final ContainerObjects obj = (ContainerObjects) getListAdapter().getItem(info.position);
435
		
436
		switch (item.getItemId()) {
437
			case R.id.delete_contextmenu:
438
				/*if (currentPath.equals("")) {
439
					showDialog(deleteContainer);
440
				} else {
441
					showDialog(deleteFolder);
442
				}*///TODO
443
				return true;
444
			case R.id.totrash_contextmenu:
445
				/*if (currentPath.equals("")) {
446
					showDialog(deleteContainer);
447
				} else {
448
					showDialog(deleteFolder);
449
				}*///TODO
450
				return true;
451
			case R.id.fromtrash_contextmenu:
452
				/*if (currentPath.equals("")) {
453
					showDialog(deleteContainer);
454
				} else {
455
					showDialog(deleteFolder);
456
				}*///TODO
457
				return true;
458
			case R.id.properties_contextmenu:
459
				Intent viewIntent;
460
				viewIntent = new Intent(this, ContainerObjectDetails.class);
461
				viewIntent.putExtra("container", obj);
462
				viewIntent.putExtra("cdnUrl", container.getCdnUrl());
463
				viewIntent.putExtra("containerNames", container.getName());
464
				viewIntent.putExtra("isCdnEnabled", cdnEnabledIs);
465
				startActivityForResult(viewIntent, 55);
466
				return true;
467
			
468
		}
469
		return false;
470
		
471
	}
400 472
	@Override
401 473
	/*
402 474
	 * option performed for delete depends on if you are at the top of a
b/src/com/rackspace/cloud/android/ListContainerActivity.java
2 2

  
3 3
import java.util.ArrayList;
4 4

  
5
import android.app.Activity;
6
import android.app.ActivityGroup;
5 7
import android.app.AlertDialog;
6 8
import android.content.Context;
7 9
import android.content.DialogInterface;
......
20 22
import android.widget.ListView;
21 23
import android.widget.TextView;
22 24

  
23
import com.rackspace.cloud.android.R;
24 25
import com.rackspace.cloud.files.api.client.Container;
25 26
import com.rackspace.cloud.files.api.client.ContainerManager;
26 27
import com.rackspace.cloud.servers.api.client.CloudServersException;
......
84 85

  
85 86
	protected void onListItemClick(ListView l, View v, int position, long id) {
86 87
		if (containers != null && containers.length > 0) {
87
			Intent viewIntent = new Intent(this, ContainerObjectsActivity.class);
88
			Intent viewIntent = new Intent(this.getContext(), ContainerObjectsActivity.class);
88 89
			viewIntent.putExtra("container", containers[position]);
90
			//replaceContentView(".ContainerObjectsActivity",viewIntent);
89 91
			startActivityForResult(viewIntent, 55);
92
			
90 93
		}
91 94
	}
95
	
96
	public void replaceContentView(String id, Intent newIntent) {
97
		//Log.i("LOG",context.getClass()+"");
98
		//Log.i("LOG", ((Activity)getApplicationContext()).getParent().getClass()+" "+(((Activity)getApplicationContext()).getParent() instanceof ActivityGroup));
99
		 
100
	    View view = ((ActivityGroup)((Activity)ListContainerActivity.this).getParent()).getLocalActivityManager()
101
	            .startActivity(id,
102
	                    newIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP))
103
	            .getDecorView();
104
	    ((Activity) ListContainerActivity.this).setContentView(view);
105

  
106
	}
92 107

  
93 108
	protected void loadContainers() {
94 109
		displayLoadingCell();
......
269 284
		super.onCreateOptionsMenu(menu);
270 285
		MenuInflater inflater = getMenuInflater();
271 286
		inflater.inflate(R.menu.container_list_menu, menu);
287
		menu.findItem(R.id.add_container).setVisible(false);
272 288
		return true;
273 289
	}
274 290

  
b/src/com/rackspace/cloud/android/PithosGroupsActivity.java
223 223

  
224 224
	
225 225
	private void showNew(){
226
		final CharSequence[] items = {"New Group"};
227
		AlertDialog.Builder builder = new AlertDialog.Builder(PithosGroupsActivity.this);
228
		builder.setTitle("Create ...");
229
		builder.setItems(items, new DialogInterface.OnClickListener() {
230
		    public void onClick(DialogInterface dialog, int item) {
231
		        switch(item){
232
		        case 0:
233
		        	final AlertDialog.Builder alert = new AlertDialog.Builder(PithosGroupsActivity.this);
234
		        	alert.setTitle("New Group");
235
		    		final EditText input = new EditText(PithosGroupsActivity.this);
236
		    		alert.setView(input);
237
		    		alert.setPositiveButton("Create", new DialogInterface.OnClickListener() {
238
		    			public void onClick(DialogInterface dialog, int whichButton) {
239
		    				String value = input.getText().toString().trim();
240
		    				Map<String,String> headers = new HashMap<String,String>();
241
		    				headers.put("X-Account-Group-"+value, Account.getAccount().getUsername()+",");
242
		    				HttpBundle bundel;
243
							try {
244
								bundel = new ContainerObjectManager(getApplicationContext()).updateObject(null, null, null, "application/json", headers);
245
								refresh();
246
							} catch (CloudServersException e) {
247
								// TODO Auto-generated catch block
248
								e.printStackTrace();
249
							}
250
		    				((GroupsListView) findViewById(R.id.groupsListView)).getGroupsAdapter().notifyDataSetChanged();
251
		    				
252
		    			}
253
		    		});
254

  
255
		    		alert.setNegativeButton("Cancel",
256
		    				new DialogInterface.OnClickListener() {
257
		    					public void onClick(DialogInterface dialog, int whichButton) {
258
		    						dialog.cancel();
259
		    					}
260
		    				});
261
		    		alert.show();
262
		        	break;
263
		        default:
264
		        	break;
265
		        }
266
		    }
226
		final AlertDialog.Builder alert = new AlertDialog.Builder(PithosGroupsActivity.this);
227
		alert.setTitle("New Group");
228
		final EditText input = new EditText(PithosGroupsActivity.this);
229
		alert.setView(input);
230
		alert.setPositiveButton("Create", new DialogInterface.OnClickListener() {
231
			public void onClick(DialogInterface dialog, int whichButton) {
232
				String value = input.getText().toString().trim();
233
				Map<String,String> headers = new HashMap<String,String>();
234
				headers.put("X-Account-Group-"+value, Account.getAccount().getUsername()+",");
235
				HttpBundle bundel;
236
				try {
237
					bundel = new ContainerObjectManager(getApplicationContext()).updateObject(null, null, null, "application/json", headers);
238
					refresh();
239
				} catch (CloudServersException e) {
240
					// TODO Auto-generated catch block
241
					e.printStackTrace();
242
				}
243
				((GroupsListView) findViewById(R.id.groupsListView)).getGroupsAdapter().notifyDataSetChanged();
244
				
245
			}
246
		});
247
			
248
		alert.setNegativeButton("Cancel",
249
				new DialogInterface.OnClickListener() {
250
			public void onClick(DialogInterface dialog, int whichButton) {
251
				dialog.cancel();
252
			}
267 253
		});
268
		AlertDialog alert = builder.create();
269 254
		alert.show();
255
		        	
270 256
	}
271 257
	
272 258
	protected void refresh(){
b/src/com/rackspace/cloud/android/PithosMySharedActivity.java
1 1
package com.rackspace.cloud.android;
2 2

  
3 3
import java.util.ArrayList;
4
import java.util.List;
4 5

  
5 6
import android.util.Log;
6 7

  
......
36 37
			app.setCurFiles(curFiles);
37 38
		}
38 39
	}
39

  
40
	List<String> dirPaths=new ArrayList<String>();
40 41
	/*
41 42
	 * determines if a file should be displayed in current 
42 43
	 * directory
......
44 45
	protected Boolean fileBelongsInDir(ContainerObjects obj){
45 46
		String objPath = obj.getCName();
46 47
		String currentPath = getCurrentPath();
48
		
47 49
		if(!objPath.startsWith(currentPath)){
48 50
			Log.i(LOG,"Path is:"+currentPath+" "+objPath+" "+false);
49 51
			return false;

Also available in: Unified diff