add the file renaming functionality itself
This commit is contained in:
parent
40c4a9aec1
commit
2e8da56e2d
2 changed files with 25 additions and 6 deletions
|
@ -174,19 +174,18 @@ class DirectoryAdapter(val activity: SimpleActivity, val dirs: MutableList<Direc
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun toggleFoldersVisibility(hide: Boolean) {
|
private fun toggleFoldersVisibility(hide: Boolean) {
|
||||||
val paths = getSelectedPaths()
|
getSelectedPaths().forEach {
|
||||||
for (path in paths) {
|
|
||||||
if (hide) {
|
if (hide) {
|
||||||
if (config.wasHideFolderTooltipShown) {
|
if (config.wasHideFolderTooltipShown) {
|
||||||
hideFolder(path)
|
hideFolder(it)
|
||||||
} else {
|
} else {
|
||||||
config.wasHideFolderTooltipShown = true
|
config.wasHideFolderTooltipShown = true
|
||||||
ConfirmationDialog(activity, activity.getString(R.string.hide_folder_description)) {
|
ConfirmationDialog(activity, activity.getString(R.string.hide_folder_description)) {
|
||||||
hideFolder(path)
|
hideFolder(it)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
activity.removeNoMedia(path) {
|
activity.removeNoMedia(it) {
|
||||||
noMediaHandled()
|
noMediaHandled()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,7 @@ 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.extensions.beVisibleIf
|
import com.simplemobiletools.commons.extensions.beVisibleIf
|
||||||
|
import com.simplemobiletools.commons.extensions.renameFile
|
||||||
import com.simplemobiletools.gallery.R
|
import com.simplemobiletools.gallery.R
|
||||||
import com.simplemobiletools.gallery.activities.SimpleActivity
|
import com.simplemobiletools.gallery.activities.SimpleActivity
|
||||||
import com.simplemobiletools.gallery.extensions.*
|
import com.simplemobiletools.gallery.extensions.*
|
||||||
|
@ -149,7 +150,26 @@ class MediaAdapter(val activity: SimpleActivity, var media: MutableList<Medium>,
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun toggleFileVisibility(hide: Boolean) {
|
private fun toggleFileVisibility(hide: Boolean) {
|
||||||
|
Thread({
|
||||||
|
getSelectedMedia().forEach {
|
||||||
|
val oldFile = File(it.path)
|
||||||
|
val path = oldFile.parent
|
||||||
|
var filename = it.name
|
||||||
|
if (hide) {
|
||||||
|
filename = ".${filename.trimStart('.')}"
|
||||||
|
} else {
|
||||||
|
filename = filename.substring(1, filename.length)
|
||||||
|
}
|
||||||
|
val newFile = File(path, filename)
|
||||||
|
activity.renameFile(oldFile, newFile) {
|
||||||
|
newFile.setLastModified(System.currentTimeMillis())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
activity.runOnUiThread {
|
||||||
|
listener?.refreshItems()
|
||||||
|
actMode?.finish()
|
||||||
|
}
|
||||||
|
}).start()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun shareMedia() {
|
private fun shareMedia() {
|
||||||
|
|
Loading…
Reference in a new issue