diff --git a/app/src/main/java/io/legado/app/ui/main/explore/ExploreFragment.kt b/app/src/main/java/io/legado/app/ui/main/explore/ExploreFragment.kt index 4041ca5f4..8ac9c93bd 100644 --- a/app/src/main/java/io/legado/app/ui/main/explore/ExploreFragment.kt +++ b/app/src/main/java/io/legado/app/ui/main/explore/ExploreFragment.kt @@ -1,10 +1,7 @@ package io.legado.app.ui.main.explore import android.os.Bundle -import android.view.Menu import android.view.View -import androidx.appcompat.widget.AppCompatImageView -import androidx.appcompat.widget.SearchView import androidx.lifecycle.Observer import androidx.recyclerview.widget.LinearLayoutManager import io.legado.app.App @@ -15,10 +12,10 @@ import io.legado.app.lib.theme.ATH import io.legado.app.lib.theme.primaryTextColor import io.legado.app.ui.book.source.edit.SourceEditActivity import io.legado.app.ui.explore.ExploreShowActivity -import io.legado.app.utils.getCompatDrawable import io.legado.app.utils.getViewModel import io.legado.app.utils.startActivity import kotlinx.android.synthetic.main.fragment_find_book.* +import kotlinx.android.synthetic.main.view_search.* import kotlinx.android.synthetic.main.view_title_bar.* @@ -29,33 +26,20 @@ class ExploreFragment : VMBaseFragment(R.layout.fragment_find_ private lateinit var adapter: ExploreAdapter private lateinit var linearLayoutManager: LinearLayoutManager - private var searchView: SearchView? = null override fun onViewCreated(view: View, savedInstanceState: Bundle?) { setSupportToolbar(toolbar) + initSearchView() initRecyclerView() initData() } - override fun onCompatCreateOptionsMenu(menu: Menu) { - menuInflater.inflate(R.menu.search_view, menu) - val search = menu.findItem(R.id.menu_search) - searchView = search.actionView as SearchView - val bottom = - searchView?.findViewById(androidx.appcompat.R.id.search_button) as? AppCompatImageView - bottom?.setImageDrawable(getCompatDrawable(R.drawable.ic_screen)) - ATH.setTint(searchView!!, primaryTextColor) - searchView?.maxWidth = resources.displayMetrics.widthPixels - searchView?.onActionViewCollapsed() - searchView?.setOnQueryTextListener(object : SearchView.OnQueryTextListener { - override fun onQueryTextSubmit(query: String): Boolean { - return false - } - - override fun onQueryTextChange(newText: String): Boolean { - return false - } - }) + private fun initSearchView() { + ATH.setTint(search_view, primaryTextColor) + search_view.onActionViewExpanded() + search_view.isSubmitButtonEnabled = true + search_view.queryHint = getString(R.string.screen_find) + search_view.clearFocus() } private fun initRecyclerView() { diff --git a/app/src/main/res/layout/fragment_find_book.xml b/app/src/main/res/layout/fragment_find_book.xml index 4ea053240..8609db403 100644 --- a/app/src/main/res/layout/fragment_find_book.xml +++ b/app/src/main/res/layout/fragment_find_book.xml @@ -1,15 +1,16 @@ + android:layout_height="match_parent" + android:orientation="vertical"> diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 3cda2ca88..a143f2e50 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -506,5 +506,6 @@ 输入你的WebDav账号 订阅源 筛选 + 筛选发现