handle picking restricted folders in PickDirectoryDialog

- users should not be able to pick restricted folders in PickDirectoryDialog when copying/moving files on SDK 30+
- show nice error message R.string.system_folder_restriction when user picks a restricted folder on SDK 30+
- restricted folders on SDK 30+ are: Android, Root of Internal and SDCard. The Download directory is writable
This commit is contained in:
darthpaul 2022-04-16 10:12:34 +01:00
parent e3a82a7507
commit bc5f0ce175

View file

@ -8,7 +8,6 @@ import com.simplemobiletools.commons.activities.BaseSimpleActivity
import com.simplemobiletools.commons.dialogs.FilePickerDialog import com.simplemobiletools.commons.dialogs.FilePickerDialog
import com.simplemobiletools.commons.extensions.* import com.simplemobiletools.commons.extensions.*
import com.simplemobiletools.commons.helpers.VIEW_TYPE_GRID import com.simplemobiletools.commons.helpers.VIEW_TYPE_GRID
import com.simplemobiletools.commons.helpers.isRPlus
import com.simplemobiletools.commons.views.MyGridLayoutManager import com.simplemobiletools.commons.views.MyGridLayoutManager
import com.simplemobiletools.gallery.pro.R import com.simplemobiletools.gallery.pro.R
import com.simplemobiletools.gallery.pro.adapters.DirectoryAdapter import com.simplemobiletools.gallery.pro.adapters.DirectoryAdapter
@ -112,7 +111,7 @@ class PickDirectoryDialog(
if (path.trimEnd('/') == sourcePath) { if (path.trimEnd('/') == sourcePath) {
activity.toast(R.string.source_and_destination_same) activity.toast(R.string.source_and_destination_same)
return@DirectoryAdapter return@DirectoryAdapter
} else if (isRPlus() && activity.isAStorageRootFolder(path)) { } else if (activity.isRestrictedWithSAFSdk30(path) && !activity.isInDownloadDir(path)) {
activity.toast(R.string.system_folder_restriction, Toast.LENGTH_LONG) activity.toast(R.string.system_folder_restriction, Toast.LENGTH_LONG)
return@DirectoryAdapter return@DirectoryAdapter
} else { } else {