Always request write permission when updating existing file on 30+

A casual file output stream was needed to fix the file size update issue
This commit is contained in:
Naveen 2023-02-01 03:14:29 +05:30
parent 89a8902bc4
commit 2131cb79d3
2 changed files with 11 additions and 9 deletions

View File

@ -873,11 +873,16 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener
ensureBackgroundThread {
val file = File(path)
val fileDirItem = FileDirItem(path, path.getFilenameFromPath())
getFileOutputStream(fileDirItem, true) {
if (it != null) {
saveBitmap(file, bitmap, it, showSavingToast)
} else {
toast(R.string.image_editing_failed)
try {
val out = FileOutputStream(file)
saveBitmap(file, bitmap, out, showSavingToast)
} catch (e: Exception) {
getFileOutputStream(fileDirItem, true) {
if (it != null) {
saveBitmap(file, bitmap, it, showSavingToast)
} else {
toast(R.string.image_editing_failed)
}
}
}
}

View File

@ -78,10 +78,7 @@ class SaveAsDialog(
if (activity.getDoesFilePathExist(newPath)) {
val title = String.format(activity.getString(R.string.file_already_exists_overwrite), newFilename)
ConfirmationDialog(activity, title) {
val newFile = File(newPath)
val isInDownloadDir = activity.isInDownloadDir(newPath)
val isInSubFolderInDownloadDir = activity.isInSubFolderInDownloadDir(newPath)
if ((isRPlus() && !isExternalStorageManager()) && isInDownloadDir && !isInSubFolderInDownloadDir && !newFile.canWrite()) {
if ((isRPlus() && !isExternalStorageManager())) {
val fileDirItem = arrayListOf(File(newPath).toFileDirItem(activity))
val fileUris = activity.getFileUrisFromFileDirItems(fileDirItem)
activity.updateSDK30Uris(fileUris) { success ->