From 3fc6393741950ab62e2e3199c828292efc34b3be Mon Sep 17 00:00:00 2001 From: mawumag <70693636+mawumag@users.noreply.github.com> Date: Thu, 28 Dec 2023 10:50:27 +0100 Subject: [PATCH] Restore delete functionality for E2EE - fixes #11387 Added test for an encrypted file: - remove functionality *not* filtered - set/unset encryption, move/copy and rename filtered Signed-off-by: Marco Baggio <70693636+mawumag@users.noreply.github.com> --- .../com/owncloud/android/files/FileMenuFilterIT.kt | 14 ++++++++++++++ .../com/owncloud/android/files/FileMenuFilter.java | 7 +++++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/app/src/androidTest/java/com/owncloud/android/files/FileMenuFilterIT.kt b/app/src/androidTest/java/com/owncloud/android/files/FileMenuFilterIT.kt index 4e92898407b3..62fda42c73fe 100644 --- a/app/src/androidTest/java/com/owncloud/android/files/FileMenuFilterIT.kt +++ b/app/src/androidTest/java/com/owncloud/android/files/FileMenuFilterIT.kt @@ -189,6 +189,10 @@ class FileMenuFilterIT : AbstractIT() { mimeType = MimeType.DIRECTORY } + val encryptedFile = OCFile("/foo.md").apply { + isEncrypted = true + } + configureCapability(capability) launchActivity().use { @@ -227,6 +231,16 @@ class FileMenuFilterIT : AbstractIT() { assertTrue(toHide.contains(R.id.action_unset_encrypted)) assertFalse(toHide.contains(R.id.action_encrypted)) assertFalse(toHide.contains(R.id.action_remove_file)) + + // encrypted file + sut = filterFactory.newInstance(encryptedFile, mockComponentsGetter, true, user) + toHide = sut.getToHide(false) + + assertTrue(toHide.contains(R.id.action_unset_encrypted)) + assertTrue(toHide.contains(R.id.action_encrypted)) + assertTrue(toHide.contains(R.id.action_move_or_copy)) + assertTrue(toHide.contains(R.id.action_rename_file)) + assertFalse(toHide.contains(R.id.action_remove_file)) } } } diff --git a/app/src/main/java/com/owncloud/android/files/FileMenuFilter.java b/app/src/main/java/com/owncloud/android/files/FileMenuFilter.java index ecf266cc045c..4d6024c2b18a 100644 --- a/app/src/main/java/com/owncloud/android/files/FileMenuFilter.java +++ b/app/src/main/java/com/owncloud/android/files/FileMenuFilter.java @@ -339,8 +339,7 @@ private void filterSelectAll(List toHide, boolean inSingleFileFragment) } private void filterRemove(List toHide, boolean synchronizing) { - if (files.isEmpty() || synchronizing || containsLockedFile() - || containsEncryptedFolder() || containsEncryptedFile()) { + if (files.isEmpty() || synchronizing || containsLockedFile() || isEncryptedRoot()) { toHide.add(R.id.action_remove_file); } } @@ -566,4 +565,8 @@ private boolean isShared() { } return false; } + + private boolean isEncryptedRoot() { + return isEncryptedFolder() && !hasEncryptedParent(); + } }