mirror of
https://github.com/libre-tube/LibreTube.git
synced 2024-12-15 06:40:30 +05:30
Merge pull request #3831 from SajalRG/fix-search-bar-collapse
Fix search bar collapse while search in progress
This commit is contained in:
commit
819205332c
@ -280,6 +280,22 @@ class MainActivity : BaseActivity() {
|
|||||||
return super.onPrepareOptionsMenu(menu)
|
return super.onPrepareOptionsMenu(menu)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun isSearchInProgress(): Boolean {
|
||||||
|
if (!::navController.isInitialized) return false
|
||||||
|
val id = navController.currentDestination?.id ?: return false
|
||||||
|
return id in listOf(R.id.searchFragment, R.id.searchResultFragment)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun invalidateMenu() {
|
||||||
|
// Don't invalidate menu when in search in progress
|
||||||
|
// this is a workaround as there is bug in android code
|
||||||
|
// details of bug: https://issuetracker.google.com/issues/244336571
|
||||||
|
if (isSearchInProgress()) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
super.invalidateMenu()
|
||||||
|
}
|
||||||
|
|
||||||
override fun onCreateOptionsMenu(menu: Menu): Boolean {
|
override fun onCreateOptionsMenu(menu: Menu): Boolean {
|
||||||
// Inflate the menu; this adds items to the action bar if it is present.
|
// Inflate the menu; this adds items to the action bar if it is present.
|
||||||
menuInflater.inflate(R.menu.action_bar, menu)
|
menuInflater.inflate(R.menu.action_bar, menu)
|
||||||
@ -354,9 +370,8 @@ class MainActivity : BaseActivity() {
|
|||||||
this@MainActivity.onBackPressedDispatcher.onBackPressed()
|
this@MainActivity.onBackPressedDispatcher.onBackPressed()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Suppress collapsing of search view here.
|
// Suppress collapsing of search when search in progress.
|
||||||
// It will close when search fragment will close, so its safe to return false here
|
return !isSearchInProgress()
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
return super.onCreateOptionsMenu(menu)
|
return super.onCreateOptionsMenu(menu)
|
||||||
|
Loading…
Reference in New Issue
Block a user