From 2e8da56e2daeed7c74e3be3838f8babc01afcd0f Mon Sep 17 00:00:00 2001 From: tibbi Date: Wed, 26 Apr 2017 20:54:47 +0200 Subject: [PATCH] add the file renaming functionality itself --- .../gallery/adapters/DirectoryAdapter.kt | 9 ++++---- .../gallery/adapters/MediaAdapter.kt | 22 ++++++++++++++++++- 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/DirectoryAdapter.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/DirectoryAdapter.kt index 07819dfa7..6c0ac3290 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/DirectoryAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/DirectoryAdapter.kt @@ -174,19 +174,18 @@ class DirectoryAdapter(val activity: SimpleActivity, val dirs: MutableList, } 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() {