|
@@ -18,6 +18,8 @@
|
|
|
package com.owncloud.android.ui.fragment;
|
|
|
|
|
|
import java.io.File;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
|
|
|
import com.owncloud.android.AccountUtils;
|
|
|
import com.owncloud.android.R;
|
|
@@ -161,36 +163,65 @@ public class OCFileListFragment extends FragmentListView implements EditNameDial
|
|
|
inflater.inflate(R.menu.file_context_menu, menu);
|
|
|
AdapterContextMenuInfo info = (AdapterContextMenuInfo) menuInfo;
|
|
|
OCFile targetFile = (OCFile) mAdapter.getItem(info.position);
|
|
|
- MenuItem item = null;
|
|
|
- int[] ids = null;
|
|
|
+ List<Integer> toHide = new ArrayList<Integer>();
|
|
|
+ List<Integer> toDisable = new ArrayList<Integer>();
|
|
|
+
|
|
|
if (targetFile.isDirectory()) {
|
|
|
- int[] theIds = {R.id.open_file_item, R.id.download_file_item, R.id.cancel_download_item, R.id.cancel_upload_item};
|
|
|
- ids = theIds;
|
|
|
-
|
|
|
- } else if ( mContainerActivity.getFileDownloaderBinder().isDownloading(AccountUtils.getCurrentOwnCloudAccount(getActivity()), targetFile)) {
|
|
|
- int[] theIds = {R.id.open_file_item, R.id.download_file_item, R.id.cancel_upload_item};
|
|
|
- ids = theIds;
|
|
|
-
|
|
|
- } else if ( mContainerActivity.getFileUploaderBinder().isUploading(AccountUtils.getCurrentOwnCloudAccount(getActivity()), targetFile)) {
|
|
|
- int[] theIds = {R.id.open_file_item, R.id.download_file_item, R.id.cancel_download_item};
|
|
|
- ids = theIds;
|
|
|
-
|
|
|
- } else if ( targetFile.isDown()) {
|
|
|
- int[] theIds = {R.id.cancel_download_item, R.id.cancel_upload_item};
|
|
|
- ids = theIds;
|
|
|
+ // contextual menu for folders
|
|
|
+ toHide.add(R.id.open_file_item);
|
|
|
+ toHide.add(R.id.download_file_item);
|
|
|
+ toHide.add(R.id.cancel_download_item);
|
|
|
+ toHide.add(R.id.cancel_upload_item);
|
|
|
+ if ( mContainerActivity.getFileDownloaderBinder().isDownloading(AccountUtils.getCurrentOwnCloudAccount(getActivity()), targetFile) ||
|
|
|
+ mContainerActivity.getFileUploaderBinder().isUploading(AccountUtils.getCurrentOwnCloudAccount(getActivity()), targetFile) ) {
|
|
|
+ toDisable.add(R.id.rename_file_item);
|
|
|
+ toDisable.add(R.id.remove_file_item);
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
} else {
|
|
|
- int[] theIds = {R.id.open_file_item, R.id.cancel_download_item, R.id.cancel_upload_item};
|
|
|
- ids = theIds;
|
|
|
+ // contextual menu for regular files
|
|
|
+ if (targetFile.isDown()) {
|
|
|
+ toHide.add(R.id.cancel_download_item);
|
|
|
+ toHide.add(R.id.cancel_upload_item);
|
|
|
+ } else {
|
|
|
+ toHide.add(R.id.open_file_item);
|
|
|
+ }
|
|
|
+ if ( mContainerActivity.getFileDownloaderBinder().isDownloading(AccountUtils.getCurrentOwnCloudAccount(getActivity()), targetFile)) {
|
|
|
+ toHide.add(R.id.download_file_item);
|
|
|
+ toHide.add(R.id.cancel_upload_item);
|
|
|
+ toDisable.add(R.id.open_file_item);
|
|
|
+ toDisable.add(R.id.rename_file_item);
|
|
|
+ toDisable.add(R.id.remove_file_item);
|
|
|
+
|
|
|
+ } else if ( mContainerActivity.getFileUploaderBinder().isUploading(AccountUtils.getCurrentOwnCloudAccount(getActivity()), targetFile)) {
|
|
|
+ toHide.add(R.id.download_file_item);
|
|
|
+ toHide.add(R.id.cancel_download_item);
|
|
|
+ toDisable.add(R.id.open_file_item);
|
|
|
+ toDisable.add(R.id.rename_file_item);
|
|
|
+ toDisable.add(R.id.remove_file_item);
|
|
|
+
|
|
|
+ } else {
|
|
|
+ toHide.add(R.id.cancel_download_item);
|
|
|
+ toHide.add(R.id.cancel_upload_item);
|
|
|
+ }
|
|
|
}
|
|
|
-
|
|
|
- for (int i=0; i < ids.length; i++) {
|
|
|
- item = menu.findItem(ids[i]);
|
|
|
+
|
|
|
+ MenuItem item = null;
|
|
|
+ for (int i : toHide) {
|
|
|
+ item = menu.findItem(i);
|
|
|
if (item != null) {
|
|
|
item.setVisible(false);
|
|
|
item.setEnabled(false);
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ for (int i : toDisable) {
|
|
|
+ item = menu.findItem(i);
|
|
|
+ if (item != null) {
|
|
|
+ item.setEnabled(false);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
|