diff --git a/app/src/main/java/io/legado/app/ui/changesource/ChangeSourceDialog.kt b/app/src/main/java/io/legado/app/ui/changesource/ChangeSourceDialog.kt index 13007195a..f8bf69c21 100644 --- a/app/src/main/java/io/legado/app/ui/changesource/ChangeSourceDialog.kt +++ b/app/src/main/java/io/legado/app/ui/changesource/ChangeSourceDialog.kt @@ -20,8 +20,7 @@ class ChangeSourceDialog(val name: String, val author: String) : DialogFragment( override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) tool_bar.inflateMenu(R.menu.search_view) - tool_bar.title = name - tool_bar.subtitle = getString(R.string.author_show, author) + showTitle() initRecyclerView() initSearchView() } @@ -31,12 +30,25 @@ class ChangeSourceDialog(val name: String, val author: String) : DialogFragment( dialog?.window?.setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT) } + private fun showTitle() { + tool_bar.title = name + tool_bar.subtitle = getString(R.string.author_show, author) + } + private fun initRecyclerView() { recycler_view.layoutManager = LinearLayoutManager(context) } private fun initSearchView() { val searchView = tool_bar.menu.findItem(R.id.menu_search).actionView as SearchView + searchView.setOnCloseListener { + showTitle() + false + } + searchView.setOnSearchClickListener { + tool_bar.title = "" + tool_bar.subtitle = "" + } searchView.setOnQueryTextListener(object : SearchView.OnQueryTextListener { override fun onQueryTextSubmit(query: String?): Boolean { return false diff --git a/app/src/main/res/layout/dialog_change_source.xml b/app/src/main/res/layout/dialog_change_source.xml index e43f8cdae..cd6738e3c 100644 --- a/app/src/main/res/layout/dialog_change_source.xml +++ b/app/src/main/res/layout/dialog_change_source.xml @@ -9,6 +9,8 @@ android:id="@+id/tool_bar" android:layout_width="match_parent" android:layout_height="wrap_content" + android:background="@color/background" + android:elevation="5dp" app:displayHomeAsUp="false" app:fitStatusBar="false" app:layout_constraintTop_toTopOf="parent" />