diff --git a/app/build.gradle b/app/build.gradle
index d294a7fae..770b779f8 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -77,7 +77,7 @@ android {
}
dependencies {
- implementation 'com.github.SimpleMobileTools:Simple-Commons:b16cc87e63'
+ implementation 'com.github.SimpleMobileTools:Simple-Commons:69ac8d3f2f'
implementation 'com.theartofdev.edmodo:android-image-cropper:2.8.0'
implementation 'it.sephiroth.android.exif:library:1.0.1'
implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.24'
diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/EditActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/EditActivity.kt
index c668fbc07..92b553812 100644
--- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/EditActivity.kt
+++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/EditActivity.kt
@@ -28,6 +28,7 @@ import com.bumptech.glide.request.target.Target
import com.simplemobiletools.commons.dialogs.ColorPickerDialog
import com.simplemobiletools.commons.dialogs.ConfirmationDialog
import com.simplemobiletools.commons.extensions.*
+import com.simplemobiletools.commons.helpers.PERMISSION_WRITE_STORAGE
import com.simplemobiletools.commons.helpers.REAL_FILE_PATH
import com.simplemobiletools.commons.helpers.ensureBackgroundThread
import com.simplemobiletools.commons.helpers.isNougatPlus
@@ -101,7 +102,13 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener
return
}
- initEditActivity()
+ handlePermission(PERMISSION_WRITE_STORAGE){
+ if (!it) {
+ toast(R.string.no_storage_permissions)
+ finish()
+ }
+ initEditActivity()
+ }
}
override fun onResume() {
diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/dialogs/PickDirectoryDialog.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/dialogs/PickDirectoryDialog.kt
index 06a80e232..a207e0421 100644
--- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/dialogs/PickDirectoryDialog.kt
+++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/dialogs/PickDirectoryDialog.kt
@@ -112,7 +112,7 @@ class PickDirectoryDialog(
activity.toast(R.string.source_and_destination_same)
return@DirectoryAdapter
} else if (isRPlus() && path.isBasePath(activity)) {
- activity.toast(R.string.copy_to_restricted_folder_message)
+ activity.toast(R.string.system_folder_restriction)
return@DirectoryAdapter
} else {
activity.handleLockedFolderOpening(path) { success ->
diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/dialogs/SaveAsDialog.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/dialogs/SaveAsDialog.kt
index 71915fcf7..d0ccf7c6a 100644
--- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/dialogs/SaveAsDialog.kt
+++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/dialogs/SaveAsDialog.kt
@@ -5,7 +5,9 @@ import com.simplemobiletools.commons.activities.BaseSimpleActivity
import com.simplemobiletools.commons.dialogs.ConfirmationDialog
import com.simplemobiletools.commons.dialogs.FilePickerDialog
import com.simplemobiletools.commons.extensions.*
+import com.simplemobiletools.commons.helpers.isRPlus
import com.simplemobiletools.gallery.pro.R
+import java.io.File
import kotlinx.android.synthetic.main.dialog_save_as.view.*
class SaveAsDialog(
@@ -15,6 +17,9 @@ class SaveAsDialog(
init {
var realPath = path.getParentPath()
+ if (activity.isRestrictedWithSAFSdk30(realPath) && !activity.isInDownloadDir(realPath)) {
+ realPath = activity.getPicturesDirectoryPath(realPath)
+ }
val view = activity.layoutInflater.inflate(R.layout.dialog_save_as, null).apply {
save_as_path.text = "${activity.humanizePath(realPath).trimEnd('/')}/"
@@ -74,15 +79,36 @@ class SaveAsDialog(
if (activity.getDoesFilePathExist(newPath)) {
val title = String.format(activity.getString(R.string.file_already_exists_overwrite), newFilename)
ConfirmationDialog(activity, title) {
- callback(newPath)
- dismiss()
+ val newFile = File(newPath)
+ val isInDownloadDir = activity.isInDownloadDir(newPath)
+ val isInSubFolderInDownloadDir = activity.isInSubFolderInDownloadDir(newPath)
+ if (isRPlus() && isInDownloadDir && !isInSubFolderInDownloadDir && !newFile.canWrite()) {
+ val fileDirItem = arrayListOf(File(newPath).toFileDirItem(activity))
+ val fileUris = activity.getFileUrisFromFileDirItems(fileDirItem).second
+ activity.updateSDK30Uris(fileUris) { success ->
+ if (success) {
+ selectPath(this, newPath)
+ }
+ }
+ } else {
+ selectPath(this, newPath)
+ }
}
} else {
- callback(newPath)
- dismiss()
+ selectPath(this, newPath)
}
}
}
}
}
+
+ private fun selectPath(alertDialog: AlertDialog, newPath: String) {
+ activity.handleSAFDialogSdk30(newPath) {
+ if (!it) {
+ return@handleSAFDialogSdk30
+ }
+ callback(newPath)
+ alertDialog.dismiss()
+ }
+ }
}
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index eb4d5412d..351dea3f9 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -33,7 +33,6 @@
Set as default folder
Unset as default folder
Reorder folders by dragging
- The system does not allow copying to this folder.
Filter media
diff --git a/app/src/proprietary/kotlin/com/simplemobiletools/gallery/pro/activities/NewPhotoEditActivity.kt b/app/src/proprietary/kotlin/com/simplemobiletools/gallery/pro/activities/NewPhotoEditActivity.kt
index f40c61d48..d89571df6 100644
--- a/app/src/proprietary/kotlin/com/simplemobiletools/gallery/pro/activities/NewPhotoEditActivity.kt
+++ b/app/src/proprietary/kotlin/com/simplemobiletools/gallery/pro/activities/NewPhotoEditActivity.kt
@@ -13,6 +13,7 @@ import com.simplemobiletools.commons.helpers.PERMISSION_WRITE_STORAGE
import com.simplemobiletools.commons.helpers.REAL_FILE_PATH
import com.simplemobiletools.commons.helpers.ensureBackgroundThread
import com.simplemobiletools.commons.helpers.isNougatPlus
+import com.simplemobiletools.commons.helpers.isRPlus
import com.simplemobiletools.commons.models.FileDirItem
import com.simplemobiletools.gallery.pro.R
import com.simplemobiletools.gallery.pro.dialogs.SaveAsDialog
@@ -207,7 +208,7 @@ class NewPhotoEditActivity : SimpleActivity() {
// In case the user wants to overwrite the original file and it is on an SD card, delete it manually first. Else the system just appends (1)
private fun handleFileOverwriting(path: String, callback: () -> Unit) {
- if (getDoesFilePathExist(path) && isPathOnSD(path)) {
+ if (!isRPlus() && getDoesFilePathExist(path) && isPathOnSD(path)) {
val fileDirItem = FileDirItem(path, path.getFilenameFromPath())
tryDeleteFileDirItem(fileDirItem, false, true) { success ->
if (success) {
diff --git a/app/src/proprietary/kotlin/com/simplemobiletools/gallery/pro/activities/NewVideoEditActivity.kt b/app/src/proprietary/kotlin/com/simplemobiletools/gallery/pro/activities/NewVideoEditActivity.kt
index c48d6ecc8..11f7fa814 100644
--- a/app/src/proprietary/kotlin/com/simplemobiletools/gallery/pro/activities/NewVideoEditActivity.kt
+++ b/app/src/proprietary/kotlin/com/simplemobiletools/gallery/pro/activities/NewVideoEditActivity.kt
@@ -13,6 +13,7 @@ import com.simplemobiletools.commons.helpers.PERMISSION_WRITE_STORAGE
import com.simplemobiletools.commons.helpers.REAL_FILE_PATH
import com.simplemobiletools.commons.helpers.ensureBackgroundThread
import com.simplemobiletools.commons.helpers.isNougatPlus
+import com.simplemobiletools.commons.helpers.isRPlus
import com.simplemobiletools.commons.models.FileDirItem
import com.simplemobiletools.gallery.pro.R
import com.simplemobiletools.gallery.pro.dialogs.SaveAsDialog
@@ -198,7 +199,7 @@ class NewVideoEditActivity : SimpleActivity() {
// In case the user wants to overwrite the original file and it is on an SD card, delete it manually first. Else the system just appends (1)
private fun handleFileOverwriting(path: String, callback: () -> Unit) {
- if (getDoesFilePathExist(path) && isPathOnSD(path)) {
+ if (!isRPlus() && getDoesFilePathExist(path) && isPathOnSD(path)) {
val fileDirItem = FileDirItem(path, path.getFilenameFromPath())
tryDeleteFileDirItem(fileDirItem, false, true) { success ->
if (success) {