diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/ViewPagerActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/ViewPagerActivity.kt index 6a29622b3..c58a5c480 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/ViewPagerActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/ViewPagerActivity.kt @@ -1166,6 +1166,13 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View private fun renameFile() { val oldPath = getCurrentPath() + + val isSDOrOtgRootFolder = isAStorageRootFolder(oldPath.getParentPath()) && !oldPath.startsWith(internalStoragePath) + if (isRPlus() && isSDOrOtgRootFolder) { + toast(R.string.rename_in_sd_card_system_restriction, Toast.LENGTH_LONG) + return + } + RenameItemDialog(this, oldPath) { getCurrentMedia()[mPos].apply { path = it 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 9b07dca42..e9c7193ac 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 @@ -234,11 +234,19 @@ class MediaAdapter( } private fun renameFile() { + val firstPath = getFirstSelectedItemPath() ?: return + + val isSDOrOtgRootFolder = activity.isAStorageRootFolder(firstPath.getParentPath()) && !firstPath.startsWith(activity.internalStoragePath) + if (isRPlus() && isSDOrOtgRootFolder) { + activity.toast(R.string.rename_in_sd_card_system_restriction, Toast.LENGTH_LONG) + finishActMode() + return + } + if (selectedKeys.size == 1) { - val oldPath = getFirstSelectedItemPath() ?: return - RenameItemDialog(activity, oldPath) { + RenameItemDialog(activity, firstPath) { ensureBackgroundThread { - activity.updateDBMediaPath(oldPath, it) + activity.updateDBMediaPath(firstPath, it) activity.runOnUiThread { enableInstantLoad() 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 a207e0421..69f22ff76 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 @@ -1,6 +1,7 @@ package com.simplemobiletools.gallery.pro.dialogs import android.view.KeyEvent +import android.widget.Toast import androidx.appcompat.app.AlertDialog import androidx.recyclerview.widget.RecyclerView import com.simplemobiletools.commons.activities.BaseSimpleActivity @@ -111,8 +112,8 @@ class PickDirectoryDialog( if (path.trimEnd('/') == sourcePath) { activity.toast(R.string.source_and_destination_same) return@DirectoryAdapter - } else if (isRPlus() && path.isBasePath(activity)) { - activity.toast(R.string.system_folder_restriction) + } else if (isRPlus() && activity.isAStorageRootFolder(path)) { + activity.toast(R.string.copy_to_restricted_folder_message, Toast.LENGTH_LONG) return@DirectoryAdapter } else { activity.handleLockedFolderOpening(path) { success ->