mirror of
https://github.com/SimpleMobileTools/Simple-Gallery.git
synced 2024-12-24 15:30:57 +01:00
allow hiding/unhiding files from the fullscreen view too
This commit is contained in:
parent
2e8da56e2d
commit
49c66427a2
@ -164,6 +164,8 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
|
||||
findItem(R.id.menu_edit).isVisible = getCurrentMedium()!!.isImage() == true
|
||||
findItem(R.id.menu_rotate).isVisible = getCurrentMedium()!!.isImage() == true
|
||||
findItem(R.id.menu_save_as).isVisible = mRotationDegrees != 0f
|
||||
findItem(R.id.menu_hide).isVisible = !getCurrentMedium()!!.name.startsWith('.')
|
||||
findItem(R.id.menu_unhide).isVisible = getCurrentMedium()!!.name.startsWith('.')
|
||||
|
||||
findItem(R.id.menu_rotate).subMenu.apply {
|
||||
clearHeader()
|
||||
@ -185,6 +187,8 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
|
||||
R.id.menu_copy_to -> copyTo()
|
||||
R.id.menu_move_to -> moveTo()
|
||||
R.id.menu_open_with -> openWith(getCurrentFile())
|
||||
R.id.menu_hide -> toggleFileVisibility(true)
|
||||
R.id.menu_unhide -> toggleFileVisibility(false)
|
||||
R.id.menu_share -> shareMedium(getCurrentMedium()!!)
|
||||
R.id.menu_delete -> askConfirmDelete()
|
||||
R.id.menu_rename -> renameFile()
|
||||
@ -229,6 +233,20 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
|
||||
}
|
||||
}
|
||||
|
||||
private fun toggleFileVisibility(hide: Boolean) {
|
||||
toggleFileVisibility(getCurrentFile(), hide) {
|
||||
val newFileName = it.absolutePath.getFilenameFromPath()
|
||||
title = newFileName
|
||||
|
||||
getCurrentMedium()!!.apply {
|
||||
name = newFileName
|
||||
path = it.absolutePath
|
||||
mMedia[mPos] = this
|
||||
}
|
||||
invalidateOptionsMenu()
|
||||
}
|
||||
}
|
||||
|
||||
private fun saveImageAs() {
|
||||
val currPath = getCurrentPath()
|
||||
SaveAsDialog(this, currPath) {
|
||||
|
@ -13,7 +13,6 @@ import com.simplemobiletools.commons.dialogs.ConfirmationDialog
|
||||
import com.simplemobiletools.commons.dialogs.PropertiesDialog
|
||||
import com.simplemobiletools.commons.dialogs.RenameItemDialog
|
||||
import com.simplemobiletools.commons.extensions.beVisibleIf
|
||||
import com.simplemobiletools.commons.extensions.renameFile
|
||||
import com.simplemobiletools.gallery.R
|
||||
import com.simplemobiletools.gallery.activities.SimpleActivity
|
||||
import com.simplemobiletools.gallery.extensions.*
|
||||
@ -153,17 +152,7 @@ class MediaAdapter(val activity: SimpleActivity, var media: MutableList<Medium>,
|
||||
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.toggleFileVisibility(oldFile, hide) {}
|
||||
}
|
||||
activity.runOnUiThread {
|
||||
listener?.refreshItems()
|
||||
|
@ -237,6 +237,21 @@ fun SimpleActivity.removeNoMedia(path: String, callback: () -> Unit) {
|
||||
}
|
||||
}
|
||||
|
||||
fun SimpleActivity.toggleFileVisibility(oldFile: File, hide: Boolean, callback: (newFile: File) -> Unit) {
|
||||
val path = oldFile.parent
|
||||
var filename = oldFile.name
|
||||
if (hide) {
|
||||
filename = ".${filename.trimStart('.')}"
|
||||
} else {
|
||||
filename = filename.substring(1, filename.length)
|
||||
}
|
||||
val newFile = File(path, filename)
|
||||
renameFile(oldFile, newFile) {
|
||||
newFile.setLastModified(System.currentTimeMillis())
|
||||
callback(newFile)
|
||||
}
|
||||
}
|
||||
|
||||
fun Activity.getFileSignature(path: String) = StringSignature(File(path).lastModified().toString())
|
||||
|
||||
fun Activity.loadImage(path: String, target: MySquareImageView) {
|
||||
|
@ -10,7 +10,7 @@ import com.simplemobiletools.commons.helpers.SORT_DESCENDING
|
||||
import java.io.File
|
||||
import java.io.Serializable
|
||||
|
||||
data class Medium(val name: String, var path: String, val video: Boolean, val modified: Long, val taken: Long, val size: Long) : Serializable, Comparable<Medium> {
|
||||
data class Medium(var name: String, var path: String, val video: Boolean, val modified: Long, val taken: Long, val size: Long) : Serializable, Comparable<Medium> {
|
||||
companion object {
|
||||
private val serialVersionUID = -6553149366975455L
|
||||
var sorting: Int = 0
|
||||
|
@ -50,6 +50,14 @@
|
||||
android:id="@+id/menu_open_with"
|
||||
android:title="@string/open_with"
|
||||
app:showAsAction="never"/>
|
||||
<item
|
||||
android:id="@+id/menu_hide"
|
||||
android:title="@string/hide"
|
||||
app:showAsAction="never"/>
|
||||
<item
|
||||
android:id="@+id/menu_unhide"
|
||||
android:title="@string/unhide"
|
||||
app:showAsAction="never"/>
|
||||
<item
|
||||
android:id="@+id/menu_edit"
|
||||
android:icon="@drawable/ic_edit"
|
||||
|
Loading…
Reference in New Issue
Block a user