mirror of
https://github.com/topjohnwu/Magisk.git
synced 2024-11-24 02:25:28 +00:00
Fixed the searchView being collapsed after searching through it
Now they have their state synced with viewModel to allow continuity
This commit is contained in:
parent
7e5f2822ae
commit
b77c590910
@ -25,8 +25,22 @@ class MagiskHideFragment : MagiskFragment<HideViewModel, FragmentMagiskHideBindi
|
|||||||
override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
|
override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
|
||||||
inflater.inflate(R.menu.menu_magiskhide, menu)
|
inflater.inflate(R.menu.menu_magiskhide, menu)
|
||||||
menu.apply {
|
menu.apply {
|
||||||
(findItem(R.id.app_search).actionView as? SearchView)
|
val query = viewModel.query.value
|
||||||
?.setOnQueryTextListener(this@MagiskHideFragment)
|
val searchItem = menu.findItem(R.id.app_search)
|
||||||
|
val searchView = searchItem.actionView as? SearchView
|
||||||
|
|
||||||
|
searchView?.run {
|
||||||
|
setOnQueryTextListener(this@MagiskHideFragment)
|
||||||
|
setQuery(query, false)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (query.isNotBlank()) {
|
||||||
|
searchItem.expandActionView()
|
||||||
|
searchView?.isIconified = false
|
||||||
|
} else {
|
||||||
|
searchItem.collapseActionView()
|
||||||
|
searchView?.isIconified = true
|
||||||
|
}
|
||||||
|
|
||||||
val showSystem = Config.showSystemApp
|
val showSystem = Config.showSystemApp
|
||||||
|
|
||||||
|
@ -43,8 +43,23 @@ class ReposFragment : MagiskFragment<ModuleViewModel, FragmentReposBinding>(),
|
|||||||
|
|
||||||
override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
|
override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
|
||||||
inflater.inflate(R.menu.menu_repo, menu)
|
inflater.inflate(R.menu.menu_repo, menu)
|
||||||
(menu.findItem(R.id.repo_search).actionView as? SearchView)
|
|
||||||
?.setOnQueryTextListener(this)
|
val query = viewModel.query.value
|
||||||
|
val searchItem = menu.findItem(R.id.repo_search)
|
||||||
|
val searchView = searchItem.actionView as? SearchView
|
||||||
|
|
||||||
|
searchView?.run {
|
||||||
|
setOnQueryTextListener(this@ReposFragment)
|
||||||
|
setQuery(query, false)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (query.isNotBlank()) {
|
||||||
|
searchItem.expandActionView()
|
||||||
|
searchView?.isIconified = false
|
||||||
|
} else {
|
||||||
|
searchItem.collapseActionView()
|
||||||
|
searchView?.isIconified = true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||||
@ -84,7 +99,7 @@ class ReposFragment : MagiskFragment<ModuleViewModel, FragmentReposBinding>(),
|
|||||||
context.withExternalRW {
|
context.withExternalRW {
|
||||||
onSuccess {
|
onSuccess {
|
||||||
val intent = Intent(activity, ClassMap[DownloadModuleService::class.java])
|
val intent = Intent(activity, ClassMap[DownloadModuleService::class.java])
|
||||||
.putExtra("repo", item).putExtra("install", install)
|
.putExtra("repo", item).putExtra("install", install)
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||||
context.startForegroundService(intent)
|
context.startForegroundService(intent)
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user