Merge remote-tracking branch 'origin/master'

pull/2457/head
kunfei 2 years ago
commit 264d74b343
  1. 10
      app/src/main/java/io/legado/app/ui/book/search/SearchActivity.kt
  2. 9
      app/src/main/res/layout/activity_book_search.xml

@ -109,7 +109,6 @@ class SearchActivity : VMBaseActivity<ActivityBookSearchBinding, SearchViewModel
override fun onCompatCreateOptionsMenu(menu: Menu): Boolean { override fun onCompatCreateOptionsMenu(menu: Menu): Boolean {
menuInflater.inflate(R.menu.book_search, menu) menuInflater.inflate(R.menu.book_search, menu)
this.menu = menu this.menu = menu
upSearchScopeMenu()
precisionSearchMenuItem = menu.findItem(R.id.menu_precision_search) precisionSearchMenuItem = menu.findItem(R.id.menu_precision_search)
precisionSearchMenuItem?.isChecked = getPrefBoolean(PreferKey.precisionSearch) precisionSearchMenuItem?.isChecked = getPrefBoolean(PreferKey.precisionSearch)
return super.onCompatCreateOptionsMenu(menu) return super.onCompatCreateOptionsMenu(menu)
@ -220,7 +219,7 @@ class SearchActivity : VMBaseActivity<ActivityBookSearchBinding, SearchViewModel
private fun initData() { private fun initData() {
viewModel.searchScope.stateLiveData.observe(this) { viewModel.searchScope.stateLiveData.observe(this) {
upSearchScopeMenu() upSearchScope()
} }
viewModel.isSearchLiveData.observe(this) { viewModel.isSearchLiveData.observe(this) {
if (it) { if (it) {
@ -237,9 +236,8 @@ class SearchActivity : VMBaseActivity<ActivityBookSearchBinding, SearchViewModel
} }
} }
private fun upSearchScopeMenu() { private fun upSearchScope() {
menu?.findItem(R.id.menu_search_scope)?.title = binding.tvSearchScope.text = viewModel.searchScope.display
"${getString(R.string.search_scope)}-${viewModel.searchScope.display}"
} }
/** /**
@ -249,7 +247,7 @@ class SearchActivity : VMBaseActivity<ActivityBookSearchBinding, SearchViewModel
val searchScope = intent?.getStringExtra("searchScope") val searchScope = intent?.getStringExtra("searchScope")
searchScope?.let { searchScope?.let {
viewModel.searchScope.update(searchScope) viewModel.searchScope.update(searchScope)
upSearchScopeMenu() upSearchScope()
} }
val key = intent?.getStringExtra("key") val key = intent?.getStringExtra("key")
if (key.isNullOrBlank()) { if (key.isNullOrBlank()) {

@ -48,6 +48,15 @@
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toBottomOf="@id/title_bar"> app:layout_constraintTop_toBottomOf="@id/title_bar">
<TextView
android:id="@+id/tv_searchScope"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="6dp"
android:text="@string/all_source"
android:singleLine="true"
android:gravity="center" />
<TextView <TextView
android:id="@+id/tv_book_show" android:id="@+id/tv_book_show"
android:layout_width="match_parent" android:layout_width="match_parent"

Loading…
Cancel
Save