add a menu button for toggling filename visibility at search activity

This commit is contained in:
tibbi 2019-07-09 22:39:51 +02:00
parent 60a7c341b0
commit 924b72d6ff
2 changed files with 18 additions and 0 deletions

View file

@ -54,6 +54,14 @@ class SearchActivity : SimpleActivity(), MediaOperationsListener {
return true
}
override fun onOptionsItemSelected(item: MenuItem): Boolean {
when (item.itemId) {
R.id.toggle_filename -> toggleFilenameVisibility()
else -> return super.onOptionsItemSelected(item)
}
return true
}
private fun setupSearch(menu: Menu) {
val searchManager = getSystemService(Context.SEARCH_SERVICE) as SearchManager
mSearchMenuItem = menu.findItem(R.id.search)
@ -135,6 +143,11 @@ class SearchActivity : SimpleActivity(), MediaOperationsListener {
private fun getMediaAdapter() = media_grid.adapter as? MediaAdapter
private fun toggleFilenameVisibility() {
config.displayFileNames = !config.displayFileNames
getMediaAdapter()?.updateDisplayFilenames(config.displayFileNames)
}
private fun itemClicked(path: String) {
val isVideo = path.isVideoFast()
if (isVideo) {

View file

@ -7,4 +7,9 @@
android:title="@string/search"
app:actionViewClass="androidx.appcompat.widget.SearchView"
app:showAsAction="collapseActionView|always"/>
<item
android:id="@+id/toggle_filename"
android:icon="@drawable/ic_label"
android:title="@string/toggle_filename"
app:showAsAction="always"/>
</menu>