pull/34/head
kunfei 5 years ago
parent 948f360ebb
commit 15cec309c2
  1. 4
      app/src/main/java/io/legado/app/lib/theme/ATH.kt
  2. 41
      app/src/main/java/io/legado/app/lib/theme/MaterialValueHelper.kt
  3. 25
      app/src/main/java/io/legado/app/ui/main/explore/ExploreFragment.kt
  4. 11
      app/src/main/res/drawable/ic_screen.xml
  5. 11
      app/src/main/res/menu/find_book.xml
  6. 1
      app/src/main/res/values/strings.xml

@ -130,8 +130,8 @@ object ATH {
fun setTint(
view: View,
@ColorInt color: Int, isDark:
Boolean = view.context.isNightTheme
@ColorInt color: Int,
isDark: Boolean = view.context.isNightTheme
) {
TintHelper.setTintAuto(view, color, false, isDark)
}

@ -42,39 +42,6 @@ fun Context.getSecondaryDisabledTextColor(dark: Boolean): Int {
} else ContextCompat.getColor(this, R.color.secondary_text_disabled_material_dark)
}
@SuppressLint("PrivateResource")
@ColorInt
fun Fragment.getPrimaryTextColor(dark: Boolean): Int {
return if (dark) {
ContextCompat.getColor(requireContext(), R.color.primary_text_default_material_light)
} else ContextCompat.getColor(requireContext(), R.color.primary_text_default_material_dark)
}
@SuppressLint("PrivateResource")
@ColorInt
fun Fragment.getSecondaryTextColor(dark: Boolean): Int {
return if (dark) {
ContextCompat.getColor(requireContext(), R.color.secondary_text_default_material_light)
} else ContextCompat.getColor(requireContext(), R.color.secondary_text_default_material_dark)
}
@SuppressLint("PrivateResource")
@ColorInt
fun Fragment.getPrimaryDisabledTextColor(dark: Boolean): Int {
return if (dark) {
ContextCompat.getColor(requireContext(), R.color.primary_text_disabled_material_light)
} else ContextCompat.getColor(requireContext(), R.color.primary_text_disabled_material_dark)
}
@SuppressLint("PrivateResource")
@ColorInt
fun Fragment.getSecondaryDisabledTextColor(dark: Boolean): Int {
return if (dark) {
ContextCompat.getColor(requireContext(), R.color.secondary_text_disabled_material_light)
} else ContextCompat.getColor(requireContext(), R.color.secondary_text_disabled_material_dark)
}
val Context.primaryColor: Int
get() = ThemeStore.primaryColor(this)
@ -112,16 +79,16 @@ val Fragment.backgroundColor: Int
get() = ThemeStore.backgroundColor(requireContext())
val Fragment.primaryTextColor: Int
get() = getPrimaryTextColor(isDarkTheme)
get() = requireContext().getPrimaryTextColor(isDarkTheme)
val Fragment.secondaryTextColor: Int
get() = getSecondaryTextColor(isDarkTheme)
get() = requireContext().getSecondaryTextColor(isDarkTheme)
val Fragment.primaryDisabledTextColor: Int
get() = getPrimaryDisabledTextColor(isDarkTheme)
get() = requireContext().getPrimaryDisabledTextColor(isDarkTheme)
val Fragment.secondaryDisabledTextColor: Int
get() = getSecondaryDisabledTextColor(isDarkTheme)
get() = requireContext().getSecondaryDisabledTextColor(isDarkTheme)
val Context.buttonDisabledColor: Int
get() = if (isDarkTheme) {

@ -3,6 +3,8 @@ 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
@ -10,13 +12,16 @@ import io.legado.app.R
import io.legado.app.base.VMBaseFragment
import io.legado.app.data.entities.BookSource
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_title_bar.*
class ExploreFragment : VMBaseFragment<ExploreViewModel>(R.layout.fragment_find_book),
ExploreAdapter.CallBack {
override val viewModel: ExploreViewModel
@ -24,6 +29,7 @@ class ExploreFragment : VMBaseFragment<ExploreViewModel>(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)
@ -32,7 +38,24 @@ class ExploreFragment : VMBaseFragment<ExploreViewModel>(R.layout.fragment_find_
}
override fun onCompatCreateOptionsMenu(menu: Menu) {
menuInflater.inflate(R.menu.find_book, 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<View>(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 initRecyclerView() {

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="1024"
android:viewportHeight="1024">
<path
android:fillColor="#FFFFFF"
android:pathData="M512 720.457143v-109.714286H201.216v109.714286H512z m0 204.8v-109.714286H201.216v109.714286H512zM324.754286 445.147429v40.886857h109.714285V429.348571a54.857143 54.857143 0 0 0-8.411428-29.110857L273.846857 157.257143h497.444572l-152.137143 242.980571a54.857143 54.857143 0 0 0-8.411429 29.110857v542.72h109.714286V445.074286l196.461714-313.636572A54.857143 54.857143 0 0 0 870.4 47.542857H174.811429a54.857143 54.857143 0 0 0-46.518858 83.968l196.388572 313.636572z" />
</vector>

@ -1,11 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="@+id/menu_search"
android:title="@string/search"
app:showAsAction="always" />
</menu>

@ -505,5 +505,6 @@
<string name="web_dav_url_s">输入你的服务器地址</string>
<string name="web_dav_account_s">输入你的WebDav账号</string>
<string name="rss_source">订阅源</string>
<string name="screen">筛选</string>
</resources>

Loading…
Cancel
Save