浏览代码

prevent copy/move into encrypted folder --> M2

Signed-off-by: tobiaskaminsky <tobias@kaminsky.me>
tobiaskaminsky 7 年之前
父节点
当前提交
e3efbb1770

+ 7 - 0
src/main/java/com/owncloud/android/ui/activity/FolderPickerActivity.java

@@ -81,6 +81,7 @@ public class FolderPickerActivity extends FileActivity implements FileFragment.C
     private boolean mSyncInProgress = false;
 
     private boolean mSearchOnlyFolders = false;
+    private boolean mDoNotEnterEncryptedFolder = false;
 
     protected Button mCancelBtn;
     protected Button mChooseBtn;
@@ -106,10 +107,12 @@ public class FolderPickerActivity extends FileActivity implements FileFragment.C
                 case MOVE:
                     caption = getResources().getText(R.string.move_to).toString();
                     mSearchOnlyFolders = true;
+                    mDoNotEnterEncryptedFolder = true;
                     break;
                 case COPY:
                     caption = getResources().getText(R.string.copy_to).toString();
                     mSearchOnlyFolders = true;
+                    mDoNotEnterEncryptedFolder = true;
                     break;
                 default:
                     caption = ThemeUtils.getDefaultDisplayNameForRootFolder();
@@ -566,4 +569,8 @@ public class FolderPickerActivity extends FileActivity implements FileFragment.C
             }
         }
     }
+
+    public boolean isDoNotEnterEncryptedFolder() {
+        return mDoNotEnterEncryptedFolder;
+    }
 }

+ 14 - 5
src/main/java/com/owncloud/android/ui/fragment/OCFileListFragment.java

@@ -907,11 +907,20 @@ public class OCFileListFragment extends ExtendedListFragment implements OCFileLi
                     } else {
                         // update state and view of this fragment
                         searchFragment = false;
-                        listDirectory(file, MainApp.isOnlyOnDevice(), false);
-                        // then, notify parent activity to let it update its state and view
-                        mContainerActivity.onBrowsedDownTo(file);
-                        // save index and top position
-                        saveIndexAndTopPosition(position);
+
+                        if (mContainerActivity instanceof FolderPickerActivity &&
+                                ((FolderPickerActivity) mContainerActivity)
+                                        .isDoNotEnterEncryptedFolder()) {
+                            Snackbar.make(getListView(),
+                                    R.string.copy_move_to_encrypted_folder_not_supported,
+                                    Snackbar.LENGTH_LONG).show();
+                        } else {
+                            listDirectory(file, MainApp.isOnlyOnDevice(), false);
+                            // then, notify parent activity to let it update its state and view
+                            mContainerActivity.onBrowsedDownTo(file);
+                            // save index and top position
+                            saveIndexAndTopPosition(position);
+                        }
                     }
                 } else {
                     // update state and view of this fragment

+ 1 - 0
src/main/res/values/strings.xml

@@ -759,4 +759,5 @@
     <string name="end_to_end_encryption_unsuccessful">Storing keys was unsuccessful, please try it again!</string>
     <string name="end_to_end_encryption_dialog_close">Close</string>
     <string name="end_to_end_encryption_storing_keys">Storing keys</string>
+    <string name="copy_move_to_encrypted_folder_not_supported">Copy/move into encrypted folder currently not supported.</string>
 </resources>