try renaming files only if the permission has been granted
This commit is contained in:
parent
39350e0a86
commit
7266618cd2
1 changed files with 13 additions and 9 deletions
|
@ -798,16 +798,20 @@ fun BaseSimpleActivity.renameFile(oldPath: String, newPath: String, callback: ((
|
|||
} catch (exception: Exception) {
|
||||
if (isRPlus() && exception is java.nio.file.FileSystemException) {
|
||||
val fileUris = getFileUrisFromFileDirItems(arrayListOf(File(oldPath).toFileDirItem(this)))
|
||||
updateSDK30Uris(fileUris) {
|
||||
val values = ContentValues().apply {
|
||||
put(MediaStore.Images.Media.DISPLAY_NAME, newPath.getFilenameFromPath())
|
||||
}
|
||||
updateSDK30Uris(fileUris) { success ->
|
||||
if (success ) {
|
||||
val values = ContentValues().apply {
|
||||
put(MediaStore.Images.Media.DISPLAY_NAME, newPath.getFilenameFromPath())
|
||||
}
|
||||
|
||||
try {
|
||||
contentResolver.update(fileUris.first(), values, null, null)
|
||||
callback?.invoke(true)
|
||||
} catch (e: Exception) {
|
||||
showErrorToast(e)
|
||||
try {
|
||||
contentResolver.update(fileUris.first(), values, null, null)
|
||||
callback?.invoke(true)
|
||||
} catch (e: Exception) {
|
||||
showErrorToast(e)
|
||||
callback?.invoke(false)
|
||||
}
|
||||
} else {
|
||||
callback?.invoke(false)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue