Delete root directory from background service when wiping

This commit is contained in:
Matéo Duparc 2021-08-28 11:18:51 +02:00
parent faeab5d3f6
commit 6f49cec157
Signed by: hardcoresushi
GPG Key ID: 007F84120107191E
2 changed files with 5 additions and 3 deletions

View File

@ -131,10 +131,9 @@ class ExplorerActivity : BaseExplorerActivity() {
${getString(R.string.ask_for_wipe)} ${getString(R.string.ask_for_wipe)}
""".trimIndent()) """.trimIndent())
.setPositiveButton(R.string.yes) { _, _ -> .setPositiveButton(R.string.yes) { _, _ ->
fileOperationService.wipeUris(urisToWipe) { errorMsg -> fileOperationService.wipeUris(urisToWipe, rootFile) { errorMsg ->
runOnUiThread { runOnUiThread {
if (errorMsg == null){ if (errorMsg == null){
rootFile?.delete()
Toast.makeText(this, R.string.wipe_successful, Toast.LENGTH_SHORT).show() Toast.makeText(this, R.string.wipe_successful, Toast.LENGTH_SHORT).show()
} else { } else {
ColoredAlertDialogBuilder(this) ColoredAlertDialogBuilder(this)

View File

@ -307,7 +307,7 @@ class FileOperationService : Service() {
}.start() }.start()
} }
fun wipeUris(uris: List<Uri>, callback: (String?) -> Unit){ fun wipeUris(uris: List<Uri>, rootFile: DocumentFile? = null, callback: (String?) -> Unit){
Thread { Thread {
val notification = showNotification(R.string.file_op_wiping_msg, uris.size) val notification = showNotification(R.string.file_op_wiping_msg, uris.size)
var errorMsg: String? = null var errorMsg: String? = null
@ -323,6 +323,9 @@ class FileOperationService : Service() {
break break
} }
} }
if (errorMsg == null) {
rootFile?.delete()
}
cancelNotification(notification) cancelNotification(notification)
callback(errorMsg) callback(errorMsg)
}.start() }.start()