Merge pull request #2404 from KryptKode/fix/rename_by_changing_case

fix renaming
This commit is contained in:
Tibor Kaputa 2022-04-10 12:14:04 +02:00 committed by GitHub
commit 631d7db3c0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 21 additions and 5 deletions

View file

@ -1166,6 +1166,13 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
private fun renameFile() { private fun renameFile() {
val oldPath = getCurrentPath() 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) { RenameItemDialog(this, oldPath) {
getCurrentMedia()[mPos].apply { getCurrentMedia()[mPos].apply {
path = it path = it

View file

@ -234,11 +234,19 @@ class MediaAdapter(
} }
private fun renameFile() { 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) { if (selectedKeys.size == 1) {
val oldPath = getFirstSelectedItemPath() ?: return RenameItemDialog(activity, firstPath) {
RenameItemDialog(activity, oldPath) {
ensureBackgroundThread { ensureBackgroundThread {
activity.updateDBMediaPath(oldPath, it) activity.updateDBMediaPath(firstPath, it)
activity.runOnUiThread { activity.runOnUiThread {
enableInstantLoad() enableInstantLoad()

View file

@ -1,6 +1,7 @@
package com.simplemobiletools.gallery.pro.dialogs package com.simplemobiletools.gallery.pro.dialogs
import android.view.KeyEvent import android.view.KeyEvent
import android.widget.Toast
import androidx.appcompat.app.AlertDialog import androidx.appcompat.app.AlertDialog
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import com.simplemobiletools.commons.activities.BaseSimpleActivity import com.simplemobiletools.commons.activities.BaseSimpleActivity
@ -111,8 +112,8 @@ 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() && path.isBasePath(activity)) { } else if (isRPlus() && activity.isAStorageRootFolder(path)) {
activity.toast(R.string.system_folder_restriction) activity.toast(R.string.copy_to_restricted_folder_message, Toast.LENGTH_LONG)
return@DirectoryAdapter return@DirectoryAdapter
} else { } else {
activity.handleLockedFolderOpening(path) { success -> activity.handleLockedFolderOpening(path) { success ->