From 3c0c7ed5be11ff4116ed57124cda781c2b664079 Mon Sep 17 00:00:00 2001 From: Naveen Date: Sun, 12 Mar 2023 21:48:51 +0530 Subject: [PATCH 1/2] Delete hidden files using casual method --- .../com/simplemobiletools/commons/extensions/Activity.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/commons/src/main/kotlin/com/simplemobiletools/commons/extensions/Activity.kt b/commons/src/main/kotlin/com/simplemobiletools/commons/extensions/Activity.kt index ce2355fcc..1ec9c8093 100644 --- a/commons/src/main/kotlin/com/simplemobiletools/commons/extensions/Activity.kt +++ b/commons/src/main/kotlin/com/simplemobiletools/commons/extensions/Activity.kt @@ -713,7 +713,8 @@ fun BaseSimpleActivity.deleteFilesBg(files: List, allowDeleteFolder } val recycleBinPath = firstFile.isRecycleBinPath(this) - if (canManageMedia() && !recycleBinPath) { + val containsNoMedia = firstFile.path.doesThisOrParentHaveNoMedia(HashMap(), null) + if (canManageMedia() && !recycleBinPath && !containsNoMedia) { val fileUris = getFileUrisFromFileDirItems(files) deleteSDK30Uris(fileUris) { success -> From 71ef4cece62372415c165a7f50d6f7f2b7577fbe Mon Sep 17 00:00:00 2001 From: Naveen Date: Mon, 13 Mar 2023 11:56:48 +0530 Subject: [PATCH 2/2] Avoid calling `doesThisOrParentHaveNoMedia` unnecessarily --- .../com/simplemobiletools/commons/extensions/Activity.kt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/commons/src/main/kotlin/com/simplemobiletools/commons/extensions/Activity.kt b/commons/src/main/kotlin/com/simplemobiletools/commons/extensions/Activity.kt index 1ec9c8093..b836bc44f 100644 --- a/commons/src/main/kotlin/com/simplemobiletools/commons/extensions/Activity.kt +++ b/commons/src/main/kotlin/com/simplemobiletools/commons/extensions/Activity.kt @@ -702,19 +702,19 @@ fun BaseSimpleActivity.deleteFilesBg(files: List, allowDeleteFolder } val firstFile = files.first() - handleSAFDialog(firstFile.path) { + val firstFilePath = firstFile.path + handleSAFDialog(firstFilePath) { if (!it) { return@handleSAFDialog } - checkManageMediaOrHandleSAFDialogSdk30(firstFile.path) { + checkManageMediaOrHandleSAFDialogSdk30(firstFilePath) { if (!it) { return@checkManageMediaOrHandleSAFDialogSdk30 } val recycleBinPath = firstFile.isRecycleBinPath(this) - val containsNoMedia = firstFile.path.doesThisOrParentHaveNoMedia(HashMap(), null) - if (canManageMedia() && !recycleBinPath && !containsNoMedia) { + if (canManageMedia() && !recycleBinPath && !firstFilePath.doesThisOrParentHaveNoMedia(HashMap(), null)) { val fileUris = getFileUrisFromFileDirItems(files) deleteSDK30Uris(fileUris) { success ->