Просмотр исходного кода

FileMenuFilter: don't show move, remove or rename options when file is locked

Signed-off-by: Álvaro Brey Vilas <alvaro.brey@nextcloud.com>
Álvaro Brey Vilas 3 лет назад
Родитель
Сommit
f8ad9ae413
1 измененных файлов с 23 добавлено и 6 удалено
  1. 23 6
      app/src/main/java/com/owncloud/android/files/FileMenuFilter.java

+ 23 - 6
app/src/main/java/com/owncloud/android/files/FileMenuFilter.java

@@ -204,7 +204,8 @@ public class FileMenuFilter {
         filterEdit(toShow, toHide, capability);
         filterDownload(toShow, toHide, synchronizing);
         filterRename(toShow, toHide, synchronizing);
-        filterMoveCopy(toShow, toHide, synchronizing);
+        filterCopy(toShow, toHide, synchronizing);
+        filterMove(toShow, toHide, synchronizing);
         filterRemove(toShow, toHide, synchronizing);
         filterSelectAll(toShow, toHide, inSingleFileFragment);
         filterDeselectAll(toShow, toHide, inSingleFileFragment);
@@ -452,25 +453,32 @@ public class FileMenuFilter {
     }
 
     private void filterRemove(List<Integer> toShow, List<Integer> toHide, boolean synchronizing) {
-        if (files.isEmpty() || synchronizing || containsEncryptedFolder()) {
+        if (files.isEmpty() || synchronizing || containsEncryptedFolder() || containsLockedFile()) {
             toHide.add(R.id.action_remove_file);
         } else {
             toShow.add(R.id.action_remove_file);
         }
     }
 
-    private void filterMoveCopy(List<Integer> toShow, List<Integer> toHide, boolean synchronizing) {
-        if (files.isEmpty() || synchronizing || containsEncryptedFile() || containsEncryptedFolder()) {
+    private void filterMove(List<Integer> toShow, List<Integer> toHide, boolean synchronizing) {
+        if (files.isEmpty() || synchronizing || containsEncryptedFile() || containsEncryptedFolder() || containsLockedFile()) {
             toHide.add(R.id.action_move);
-            toHide.add(R.id.action_copy);
         } else {
             toShow.add(R.id.action_move);
+        }
+    }
+
+    private void filterCopy(List<Integer> toShow, List<Integer> toHide, boolean synchronizing) {
+        if (files.isEmpty() || synchronizing || containsEncryptedFile() || containsEncryptedFolder()) {
+            toHide.add(R.id.action_copy);
+        } else {
             toShow.add(R.id.action_copy);
         }
     }
 
+
     private void filterRename(Collection<Integer> toShow, Collection<Integer> toHide, boolean synchronizing) {
-        if (!isSingleSelection() || synchronizing || containsEncryptedFile() || containsEncryptedFolder()) {
+        if (!isSingleSelection() || synchronizing || containsEncryptedFile() || containsEncryptedFolder() || containsLockedFile()) {
             toHide.add(R.id.action_rename_file);
         } else {
             toShow.add(R.id.action_rename_file);
@@ -589,6 +597,15 @@ public class FileMenuFilter {
         return false;
     }
 
+    private boolean containsLockedFile() {
+        for (OCFile file : files) {
+            if (file.isLocked()) {
+                return true;
+            }
+        }
+        return false;
+    }
+
     private boolean containsEncryptedFolder() {
         for (OCFile file : files) {
             if (file.isFolder() && file.isEncrypted()) {