diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/adapters/MediaAdapter.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/adapters/MediaAdapter.kt index 124982dd4..e3686113e 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/adapters/MediaAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/adapters/MediaAdapter.kt @@ -311,12 +311,11 @@ class MediaAdapter( } } - private fun rotateSelection(degrees: Int) { + private fun handleRotate(paths: List, degrees: Int) { + var fileCnt = paths.size + rotatedImagePaths.clear() activity.toast(R.string.saving) ensureBackgroundThread { - val paths = getSelectedPaths().filter { it.isImageFast() } - var fileCnt = paths.size - rotatedImagePaths.clear() paths.forEach { rotatedImagePaths.add(it) activity.saveRotatedImageToFile(it, it, degrees, true) { @@ -332,6 +331,20 @@ class MediaAdapter( } } + private fun rotateSelection(degrees: Int) { + val paths = getSelectedPaths().filter { it.isImageFast() } + + if (paths.any { activity.needsStupidWritePermissions(it) }) { + activity.handleSAFDialog(paths.first { activity.needsStupidWritePermissions(it) }) { + if (it) { + handleRotate(paths, degrees) + } + } + } else { + handleRotate(paths, degrees) + } + } + private fun moveFilesTo() { activity.handleDeletePasswordProtection { copyMoveTo(false)