add a main screen menu item for toggling recycle bin visibility

This commit is contained in:
tibbi 2019-02-21 16:53:00 +01:00
parent 8bcff133cc
commit 72582a049b
2 changed files with 26 additions and 0 deletions

View file

@ -43,6 +43,7 @@ import com.simplemobiletools.gallery.pro.models.Medium
import kotlinx.android.synthetic.main.activity_main.* import kotlinx.android.synthetic.main.activity_main.*
import java.io.* import java.io.*
import java.util.* import java.util.*
import kotlin.collections.ArrayList
class MainActivity : SimpleActivity(), DirectoryOperationsListener { class MainActivity : SimpleActivity(), DirectoryOperationsListener {
private val PICK_MEDIA = 2 private val PICK_MEDIA = 2
@ -264,9 +265,12 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener {
menuInflater.inflate(R.menu.menu_main_intent, menu) menuInflater.inflate(R.menu.menu_main_intent, menu)
} else { } else {
menuInflater.inflate(R.menu.menu_main, menu) menuInflater.inflate(R.menu.menu_main, menu)
val useBin = config.useRecycleBin
menu.apply { menu.apply {
findItem(R.id.increase_column_count).isVisible = config.viewTypeFolders == VIEW_TYPE_GRID && config.dirColumnCnt < MAX_COLUMN_COUNT findItem(R.id.increase_column_count).isVisible = config.viewTypeFolders == VIEW_TYPE_GRID && config.dirColumnCnt < MAX_COLUMN_COUNT
findItem(R.id.reduce_column_count).isVisible = config.viewTypeFolders == VIEW_TYPE_GRID && config.dirColumnCnt > 1 findItem(R.id.reduce_column_count).isVisible = config.viewTypeFolders == VIEW_TYPE_GRID && config.dirColumnCnt > 1
findItem(R.id.hide_the_recycle_bin).isVisible = useBin && config.showRecycleBinAtFolders
findItem(R.id.show_the_recycle_bin).isVisible = useBin && !config.showRecycleBinAtFolders
setupSearch(this) setupSearch(this)
} }
} }
@ -287,6 +291,8 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener {
R.id.temporarily_show_hidden -> tryToggleTemporarilyShowHidden() R.id.temporarily_show_hidden -> tryToggleTemporarilyShowHidden()
R.id.stop_showing_hidden -> tryToggleTemporarilyShowHidden() R.id.stop_showing_hidden -> tryToggleTemporarilyShowHidden()
R.id.create_new_folder -> createNewFolder() R.id.create_new_folder -> createNewFolder()
R.id.show_the_recycle_bin -> toggleRecycleBin(true)
R.id.hide_the_recycle_bin -> toggleRecycleBin(false)
R.id.increase_column_count -> increaseColumnCount() R.id.increase_column_count -> increaseColumnCount()
R.id.reduce_column_count -> reduceColumnCount() R.id.reduce_column_count -> reduceColumnCount()
R.id.settings -> launchSettings() R.id.settings -> launchSettings()
@ -612,6 +618,18 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener {
mZoomListener = null mZoomListener = null
} }
private fun toggleRecycleBin(show: Boolean) {
config.showRecycleBinAtFolders = show
invalidateOptionsMenu()
Thread {
var dirs = getCurrentlyDisplayedDirs()
if (!show) {
dirs = dirs.filter { it.path != RECYCLE_BIN } as ArrayList<Directory>
}
gotDirectories(dirs)
}.start()
}
private fun createNewFolder() { private fun createNewFolder() {
FilePickerDialog(this, internalStoragePath, false, config.shouldShowHidden, false, true) { FilePickerDialog(this, internalStoragePath, false, config.shouldShowHidden, false, true) {
CreateNewFolderDialog(this, it) { CreateNewFolderDialog(this, it) {

View file

@ -38,6 +38,14 @@
android:id="@+id/stop_showing_hidden" android:id="@+id/stop_showing_hidden"
android:title="@string/stop_showing_hidden" android:title="@string/stop_showing_hidden"
app:showAsAction="never"/> app:showAsAction="never"/>
<item
android:id="@+id/show_the_recycle_bin"
android:title="@string/show_the_recycle_bin"
app:showAsAction="never"/>
<item
android:id="@+id/hide_the_recycle_bin"
android:title="@string/hide_the_recycle_bin"
app:showAsAction="never"/>
<item <item
android:id="@+id/create_new_folder" android:id="@+id/create_new_folder"
android:title="@string/create_new_folder" android:title="@string/create_new_folder"