Only allow folder to unset if not in e2e subtree

Signed-off-by: tobiasKaminsky <tobias@kaminsky.me>
This commit is contained in:
tobiasKaminsky 2022-06-14 07:39:22 +02:00
parent e8d2989295
commit d31ba4b3e6
No known key found for this signature in database
GPG key ID: 0E00D4D47D0C5AF7

View file

@ -319,8 +319,8 @@ public class FileMenuFilter {
}
private void filterUnsetEncrypted(List<Integer> toShow, List<Integer> toHide, boolean endToEndEncryptionEnabled) {
if (files.isEmpty() || !isSingleSelection() || isSingleFile() || !isEncryptedFolder()
|| !endToEndEncryptionEnabled) {
if (files.isEmpty() || !isSingleSelection() || isSingleFile() || !isEncryptedFolder() || hasEncryptedParent()
|| !endToEndEncryptionEnabled) {
toHide.add(R.id.action_unset_encrypted);
} else {
toShow.add(R.id.action_unset_encrypted);
@ -550,6 +550,13 @@ public class FileMenuFilter {
return files.iterator().next().isGroupFolder();
}
private boolean hasEncryptedParent() {
OCFile folder = files.iterator().next();
OCFile parent = componentsGetter.getStorageManager().getFileById(folder.getParentId());
return parent != null && parent.isEncrypted();
}
private boolean isSingleImage() {
return isSingleSelection() && MimeTypeUtil.isImage(files.iterator().next());
}