adding a simple way of renaming multiple items at once
This commit is contained in:
parent
c05cad57d5
commit
6f812bbbaa
3 changed files with 48 additions and 31 deletions
|
@ -48,7 +48,7 @@ android {
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation 'com.simplemobiletools:commons:5.1.14'
|
implementation 'com.simplemobiletools:commons:5.1.15'
|
||||||
implementation 'com.theartofdev.edmodo:android-image-cropper:2.7.0'
|
implementation 'com.theartofdev.edmodo:android-image-cropper:2.7.0'
|
||||||
implementation 'androidx.multidex:multidex:2.0.0'
|
implementation 'androidx.multidex:multidex:2.0.0'
|
||||||
implementation 'it.sephiroth.android.exif:library:1.0.1'
|
implementation 'it.sephiroth.android.exif:library:1.0.1'
|
||||||
|
|
|
@ -10,6 +10,7 @@ import com.simplemobiletools.commons.adapters.MyRecyclerViewAdapter
|
||||||
import com.simplemobiletools.commons.dialogs.ConfirmationDialog
|
import com.simplemobiletools.commons.dialogs.ConfirmationDialog
|
||||||
import com.simplemobiletools.commons.dialogs.PropertiesDialog
|
import com.simplemobiletools.commons.dialogs.PropertiesDialog
|
||||||
import com.simplemobiletools.commons.dialogs.RenameItemDialog
|
import com.simplemobiletools.commons.dialogs.RenameItemDialog
|
||||||
|
import com.simplemobiletools.commons.dialogs.RenameItemsDialog
|
||||||
import com.simplemobiletools.commons.extensions.*
|
import com.simplemobiletools.commons.extensions.*
|
||||||
import com.simplemobiletools.commons.helpers.OTG_PATH
|
import com.simplemobiletools.commons.helpers.OTG_PATH
|
||||||
import com.simplemobiletools.commons.models.FileDirItem
|
import com.simplemobiletools.commons.models.FileDirItem
|
||||||
|
@ -68,7 +69,7 @@ class DirectoryAdapter(activity: BaseSimpleActivity, var dirs: ArrayList<Directo
|
||||||
|
|
||||||
val isOneItemSelected = isOneItemSelected()
|
val isOneItemSelected = isOneItemSelected()
|
||||||
menu.apply {
|
menu.apply {
|
||||||
findItem(R.id.cab_rename).isVisible = isOneItemSelected && !selectedPaths.contains(FAVORITES) && !selectedPaths.contains(RECYCLE_BIN)
|
findItem(R.id.cab_rename).isVisible = !selectedPaths.contains(FAVORITES) && !selectedPaths.contains(RECYCLE_BIN)
|
||||||
findItem(R.id.cab_change_cover_image).isVisible = isOneItemSelected
|
findItem(R.id.cab_change_cover_image).isVisible = isOneItemSelected
|
||||||
|
|
||||||
findItem(R.id.cab_empty_recycle_bin).isVisible = isOneItemSelected && selectedPaths.first() == RECYCLE_BIN
|
findItem(R.id.cab_empty_recycle_bin).isVisible = isOneItemSelected && selectedPaths.first() == RECYCLE_BIN
|
||||||
|
@ -141,6 +142,7 @@ class DirectoryAdapter(activity: BaseSimpleActivity, var dirs: ArrayList<Directo
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun renameDir() {
|
private fun renameDir() {
|
||||||
|
if (selectedKeys.size == 1) {
|
||||||
val firstDir = getFirstSelectedItem() ?: return
|
val firstDir = getFirstSelectedItem() ?: return
|
||||||
val sourcePath = firstDir.path
|
val sourcePath = firstDir.path
|
||||||
val dir = File(sourcePath)
|
val dir = File(sourcePath)
|
||||||
|
@ -163,6 +165,12 @@ class DirectoryAdapter(activity: BaseSimpleActivity, var dirs: ArrayList<Directo
|
||||||
}.start()
|
}.start()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
val paths = getSelectedPaths().filter { !activity.isAStorageRootFolder(it) } as ArrayList<String>
|
||||||
|
RenameItemsDialog(activity, paths) {
|
||||||
|
listener?.refreshItems()
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun toggleFoldersVisibility(hide: Boolean) {
|
private fun toggleFoldersVisibility(hide: Boolean) {
|
||||||
|
|
|
@ -13,6 +13,7 @@ import com.simplemobiletools.commons.activities.BaseSimpleActivity
|
||||||
import com.simplemobiletools.commons.adapters.MyRecyclerViewAdapter
|
import com.simplemobiletools.commons.adapters.MyRecyclerViewAdapter
|
||||||
import com.simplemobiletools.commons.dialogs.PropertiesDialog
|
import com.simplemobiletools.commons.dialogs.PropertiesDialog
|
||||||
import com.simplemobiletools.commons.dialogs.RenameItemDialog
|
import com.simplemobiletools.commons.dialogs.RenameItemDialog
|
||||||
|
import com.simplemobiletools.commons.dialogs.RenameItemsDialog
|
||||||
import com.simplemobiletools.commons.extensions.*
|
import com.simplemobiletools.commons.extensions.*
|
||||||
import com.simplemobiletools.commons.helpers.OTG_PATH
|
import com.simplemobiletools.commons.helpers.OTG_PATH
|
||||||
import com.simplemobiletools.commons.models.FileDirItem
|
import com.simplemobiletools.commons.models.FileDirItem
|
||||||
|
@ -111,7 +112,7 @@ class MediaAdapter(activity: BaseSimpleActivity, var media: MutableList<Thumbnai
|
||||||
val isOneItemSelected = isOneItemSelected()
|
val isOneItemSelected = isOneItemSelected()
|
||||||
val selectedPaths = selectedItems.map { it.path } as ArrayList<String>
|
val selectedPaths = selectedItems.map { it.path } as ArrayList<String>
|
||||||
menu.apply {
|
menu.apply {
|
||||||
findItem(R.id.cab_rename).isVisible = isOneItemSelected && selectedItems.firstOrNull()?.getIsInRecycleBin() == false
|
findItem(R.id.cab_rename).isVisible = selectedItems.firstOrNull()?.getIsInRecycleBin() == false
|
||||||
findItem(R.id.cab_open_with).isVisible = isOneItemSelected
|
findItem(R.id.cab_open_with).isVisible = isOneItemSelected
|
||||||
findItem(R.id.cab_confirm_selection).isVisible = isAGetIntent && allowMultiplePicks && selectedKeys.isNotEmpty()
|
findItem(R.id.cab_confirm_selection).isVisible = isAGetIntent && allowMultiplePicks && selectedKeys.isNotEmpty()
|
||||||
findItem(R.id.cab_restore_recycle_bin_files).isVisible = selectedPaths.all { it.startsWith(activity.filesDir.absolutePath) }
|
findItem(R.id.cab_restore_recycle_bin_files).isVisible = selectedPaths.all { it.startsWith(activity.filesDir.absolutePath) }
|
||||||
|
@ -195,6 +196,7 @@ class MediaAdapter(activity: BaseSimpleActivity, var media: MutableList<Thumbnai
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun renameFile() {
|
private fun renameFile() {
|
||||||
|
if (selectedKeys.size == 1) {
|
||||||
val oldPath = getFirstSelectedItemPath() ?: return
|
val oldPath = getFirstSelectedItemPath() ?: return
|
||||||
RenameItemDialog(activity, oldPath) {
|
RenameItemDialog(activity, oldPath) {
|
||||||
Thread {
|
Thread {
|
||||||
|
@ -207,6 +209,13 @@ class MediaAdapter(activity: BaseSimpleActivity, var media: MutableList<Thumbnai
|
||||||
}
|
}
|
||||||
}.start()
|
}.start()
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
RenameItemsDialog(activity, getSelectedPaths()) {
|
||||||
|
enableInstantLoad()
|
||||||
|
listener?.refreshItems()
|
||||||
|
finishActMode()
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun editFile() {
|
private fun editFile() {
|
||||||
|
|
Loading…
Reference in a new issue