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)}
""".trimIndent())
.setPositiveButton(R.string.yes) { _, _ ->
fileOperationService.wipeUris(urisToWipe) { errorMsg ->
fileOperationService.wipeUris(urisToWipe, rootFile) { errorMsg ->
runOnUiThread {
if (errorMsg == null){
rootFile?.delete()
Toast.makeText(this, R.string.wipe_successful, Toast.LENGTH_SHORT).show()
} else {
ColoredAlertDialogBuilder(this)

View File

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