pull/2368/head
kunfei 2 years ago
parent 63d61a6ffe
commit b1dd1f8002
  1. 26
      app/src/main/java/io/legado/app/lib/theme/MaterialValueHelper.kt
  2. 9
      app/src/main/java/io/legado/app/ui/book/read/ReadMenu.kt
  3. 17
      app/src/main/java/io/legado/app/ui/book/read/SearchMenu.kt
  4. 9
      app/src/main/java/io/legado/app/ui/book/read/config/AutoReadDialog.kt
  5. 11
      app/src/main/java/io/legado/app/ui/book/read/config/BgTextConfigDialog.kt
  6. 5
      app/src/main/java/io/legado/app/ui/book/toc/ChapterListFragment.kt
  7. 5
      app/src/main/java/io/legado/app/ui/widget/DetailSeekBar.kt
  8. 7
      app/src/main/java/io/legado/app/ui/widget/SelectActionBar.kt

@ -19,37 +19,27 @@ import io.legado.app.utils.dpToPx
@ColorInt @ColorInt
fun Context.getPrimaryTextColor(dark: Boolean): Int { fun Context.getPrimaryTextColor(dark: Boolean): Int {
return if (dark) { return if (dark) {
ContextCompat.getColor(this, androidx.appcompat.R.color.primary_text_default_material_light) ContextCompat.getColor(this, R.color.md_light_primary_text)
} else ContextCompat.getColor( } else {
this, ContextCompat.getColor(this, R.color.md_dark_primary_text)
androidx.appcompat.R.color.primary_text_default_material_dark }
)
} }
@ColorInt @ColorInt
fun Context.getSecondaryTextColor(dark: Boolean): Int { fun Context.getSecondaryTextColor(dark: Boolean): Int {
return if (dark) { return if (dark) {
ContextCompat.getColor( ContextCompat.getColor(this, R.color.md_light_secondary)
this,
androidx.appcompat.R.color.secondary_text_default_material_light
)
} else { } else {
ContextCompat.getColor( ContextCompat.getColor(this, R.color.md_dark_primary_text)
this,
androidx.appcompat.R.color.secondary_text_default_material_dark
)
} }
} }
@ColorInt @ColorInt
fun Context.getPrimaryDisabledTextColor(dark: Boolean): Int { fun Context.getPrimaryDisabledTextColor(dark: Boolean): Int {
return if (dark) { return if (dark) {
ContextCompat.getColor( ContextCompat.getColor(this, R.color.md_light_disabled)
this,
androidx.appcompat.R.color.primary_text_disabled_material_light
)
} else { } else {
ContextCompat.getColor(this, androidx.appcompat.R.color.primary_text_disabled_material_dark) ContextCompat.getColor(this, R.color.md_dark_disabled)
} }
} }

@ -4,6 +4,7 @@ import android.annotation.SuppressLint
import android.content.Context import android.content.Context
import android.content.res.ColorStateList import android.content.res.ColorStateList
import android.graphics.Color import android.graphics.Color
import android.graphics.PorterDuff
import android.graphics.drawable.GradientDrawable import android.graphics.drawable.GradientDrawable
import android.util.AttributeSet import android.util.AttributeSet
import android.view.Gravity import android.view.Gravity
@ -188,13 +189,13 @@ class ReadMenu @JvmOverloads constructor(
fabNightTheme.setColorFilter(textColor) fabNightTheme.setColorFilter(textColor)
tvPre.setTextColor(textColor) tvPre.setTextColor(textColor)
tvNext.setTextColor(textColor) tvNext.setTextColor(textColor)
ivCatalog.setColorFilter(textColor) ivCatalog.setColorFilter(textColor, PorterDuff.Mode.SRC_IN)
tvCatalog.setTextColor(textColor) tvCatalog.setTextColor(textColor)
ivReadAloud.setColorFilter(textColor) ivReadAloud.setColorFilter(textColor, PorterDuff.Mode.SRC_IN)
tvReadAloud.setTextColor(textColor) tvReadAloud.setTextColor(textColor)
ivFont.setColorFilter(textColor) ivFont.setColorFilter(textColor, PorterDuff.Mode.SRC_IN)
tvFont.setTextColor(textColor) tvFont.setTextColor(textColor)
ivSetting.setColorFilter(textColor) ivSetting.setColorFilter(textColor, PorterDuff.Mode.SRC_IN)
tvSetting.setTextColor(textColor) tvSetting.setTextColor(textColor)
vwBg.setOnClickListener(null) vwBg.setOnClickListener(null)
llBrightness.setOnClickListener(null) llBrightness.setOnClickListener(null)

@ -3,6 +3,7 @@ package io.legado.app.ui.book.read
import android.annotation.SuppressLint import android.annotation.SuppressLint
import android.content.Context import android.content.Context
import android.content.res.ColorStateList import android.content.res.ColorStateList
import android.graphics.PorterDuff
import android.util.AttributeSet import android.util.AttributeSet
import android.view.Gravity import android.view.Gravity
import android.view.LayoutInflater import android.view.LayoutInflater
@ -70,19 +71,17 @@ class SearchMenu @JvmOverloads constructor(
tvCurrentSearchInfo.setTextColor(bottomBackgroundList) tvCurrentSearchInfo.setTextColor(bottomBackgroundList)
llBottomBg.setBackgroundColor(bgColor) llBottomBg.setBackgroundColor(bgColor)
fabLeft.backgroundTintList = bottomBackgroundList fabLeft.backgroundTintList = bottomBackgroundList
fabLeft.setColorFilter(textColor) fabLeft.setColorFilter(textColor, PorterDuff.Mode.SRC_IN)
fabRight.backgroundTintList = bottomBackgroundList fabRight.backgroundTintList = bottomBackgroundList
fabRight.setColorFilter(textColor) fabRight.setColorFilter(textColor, PorterDuff.Mode.SRC_IN)
tvMainMenu.setTextColor(textColor) tvMainMenu.setTextColor(textColor)
tvSearchResults.setTextColor(textColor) tvSearchResults.setTextColor(textColor)
tvSearchExit.setTextColor(textColor) tvSearchExit.setTextColor(textColor)
//tvSetting.setTextColor(textColor) ivMainMenu.setColorFilter(textColor, PorterDuff.Mode.SRC_IN)
ivMainMenu.setColorFilter(textColor) ivSearchResults.setColorFilter(textColor, PorterDuff.Mode.SRC_IN)
ivSearchResults.setColorFilter(textColor) ivSearchExit.setColorFilter(textColor, PorterDuff.Mode.SRC_IN)
ivSearchExit.setColorFilter(textColor) ivSearchContentUp.setColorFilter(textColor, PorterDuff.Mode.SRC_IN)
//ivSetting.setColorFilter(textColor) ivSearchContentDown.setColorFilter(textColor, PorterDuff.Mode.SRC_IN)
ivSearchContentUp.setColorFilter(textColor)
ivSearchContentDown.setColorFilter(textColor)
tvCurrentSearchInfo.setTextColor(textColor) tvCurrentSearchInfo.setTextColor(textColor)
} }

@ -1,6 +1,7 @@
package io.legado.app.ui.book.read.config package io.legado.app.ui.book.read.config
import android.content.DialogInterface import android.content.DialogInterface
import android.graphics.PorterDuff
import android.os.Bundle import android.os.Bundle
import android.view.Gravity import android.view.Gravity
import android.view.View import android.view.View
@ -55,13 +56,13 @@ class AutoReadDialog : BaseDialogFragment(R.layout.dialog_auto_read) {
root.setBackgroundColor(bg) root.setBackgroundColor(bg)
tvReadSpeedTitle.setTextColor(textColor) tvReadSpeedTitle.setTextColor(textColor)
tvReadSpeed.setTextColor(textColor) tvReadSpeed.setTextColor(textColor)
ivCatalog.setColorFilter(textColor) ivCatalog.setColorFilter(textColor, PorterDuff.Mode.SRC_IN)
tvCatalog.setTextColor(textColor) tvCatalog.setTextColor(textColor)
ivMainMenu.setColorFilter(textColor) ivMainMenu.setColorFilter(textColor, PorterDuff.Mode.SRC_IN)
tvMainMenu.setTextColor(textColor) tvMainMenu.setTextColor(textColor)
ivAutoPageStop.setColorFilter(textColor) ivAutoPageStop.setColorFilter(textColor, PorterDuff.Mode.SRC_IN)
tvAutoPageStop.setTextColor(textColor) tvAutoPageStop.setTextColor(textColor)
ivSetting.setColorFilter(textColor) ivSetting.setColorFilter(textColor, PorterDuff.Mode.SRC_IN)
tvSetting.setTextColor(textColor) tvSetting.setTextColor(textColor)
initOnChange() initOnChange()
initData() initData()

@ -3,6 +3,7 @@ package io.legado.app.ui.book.read.config
import android.annotation.SuppressLint import android.annotation.SuppressLint
import android.content.DialogInterface import android.content.DialogInterface
import android.graphics.Color import android.graphics.Color
import android.graphics.PorterDuff
import android.net.Uri import android.net.Uri
import android.os.Bundle import android.os.Bundle
import android.view.Gravity import android.view.Gravity
@ -105,12 +106,12 @@ class BgTextConfigDialog : BaseDialogFragment(R.layout.dialog_read_bg_text) {
rootView.setBackgroundColor(bg) rootView.setBackgroundColor(bg)
tvNameTitle.setTextColor(primaryTextColor) tvNameTitle.setTextColor(primaryTextColor)
tvName.setTextColor(secondaryTextColor) tvName.setTextColor(secondaryTextColor)
ivEdit.setColorFilter(secondaryTextColor) ivEdit.setColorFilter(secondaryTextColor, PorterDuff.Mode.SRC_IN)
tvRestore.setTextColor(primaryTextColor) tvRestore.setTextColor(primaryTextColor)
swDarkStatusIcon.setTextColor(primaryTextColor) swDarkStatusIcon.setTextColor(primaryTextColor)
ivImport.setColorFilter(primaryTextColor) ivImport.setColorFilter(primaryTextColor, PorterDuff.Mode.SRC_IN)
ivExport.setColorFilter(primaryTextColor) ivExport.setColorFilter(primaryTextColor, PorterDuff.Mode.SRC_IN)
ivDelete.setColorFilter(primaryTextColor) ivDelete.setColorFilter(primaryTextColor, PorterDuff.Mode.SRC_IN)
tvBgAlpha.setTextColor(primaryTextColor) tvBgAlpha.setTextColor(primaryTextColor)
tvBgImage.setTextColor(primaryTextColor) tvBgImage.setTextColor(primaryTextColor)
recyclerView.adapter = adapter recyclerView.adapter = adapter
@ -119,7 +120,7 @@ class BgTextConfigDialog : BaseDialogFragment(R.layout.dialog_read_bg_text) {
tvName.setTextColor(secondaryTextColor) tvName.setTextColor(secondaryTextColor)
tvName.text = getString(R.string.select_image) tvName.text = getString(R.string.select_image)
ivBg.setImageResource(R.drawable.ic_image) ivBg.setImageResource(R.drawable.ic_image)
ivBg.setColorFilter(primaryTextColor) ivBg.setColorFilter(primaryTextColor, PorterDuff.Mode.SRC_IN)
root.setOnClickListener { root.setOnClickListener {
selectBgImage.launch() selectBgImage.launch()
} }

@ -3,6 +3,7 @@ package io.legado.app.ui.book.toc
import android.annotation.SuppressLint import android.annotation.SuppressLint
import android.app.Activity.RESULT_OK import android.app.Activity.RESULT_OK
import android.content.Intent import android.content.Intent
import android.graphics.PorterDuff
import android.os.Bundle import android.os.Bundle
import android.view.View import android.view.View
import androidx.fragment.app.activityViewModels import androidx.fragment.app.activityViewModels
@ -44,8 +45,8 @@ class ChapterListFragment : VMBaseFragment<TocViewModel>(R.layout.fragment_chapt
val btc = requireContext().getPrimaryTextColor(ColorUtils.isColorLight(bbg)) val btc = requireContext().getPrimaryTextColor(ColorUtils.isColorLight(bbg))
llChapterBaseInfo.setBackgroundColor(bbg) llChapterBaseInfo.setBackgroundColor(bbg)
tvCurrentChapterInfo.setTextColor(btc) tvCurrentChapterInfo.setTextColor(btc)
ivChapterTop.setColorFilter(btc) ivChapterTop.setColorFilter(btc, PorterDuff.Mode.SRC_IN)
ivChapterBottom.setColorFilter(btc) ivChapterBottom.setColorFilter(btc, PorterDuff.Mode.SRC_IN)
initRecyclerView() initRecyclerView()
initView() initView()
viewModel.bookData.observe(this@ChapterListFragment) { viewModel.bookData.observe(this@ChapterListFragment) {

@ -1,6 +1,7 @@
package io.legado.app.ui.widget package io.legado.app.ui.widget
import android.content.Context import android.content.Context
import android.graphics.PorterDuff
import android.util.AttributeSet import android.util.AttributeSet
import android.view.LayoutInflater import android.view.LayoutInflater
import android.widget.FrameLayout import android.widget.FrameLayout
@ -47,8 +48,8 @@ class DetailSeekBar @JvmOverloads constructor(
val isLight = ColorUtils.isColorLight(context.bottomBackground) val isLight = ColorUtils.isColorLight(context.bottomBackground)
val textColor = context.getPrimaryTextColor(isLight) val textColor = context.getPrimaryTextColor(isLight)
binding.tvSeekTitle.setTextColor(textColor) binding.tvSeekTitle.setTextColor(textColor)
binding.ivSeekPlus.setColorFilter(textColor) binding.ivSeekPlus.setColorFilter(textColor, PorterDuff.Mode.SRC_IN)
binding.ivSeekReduce.setColorFilter(textColor) binding.ivSeekReduce.setColorFilter(textColor, PorterDuff.Mode.SRC_IN)
binding.tvSeekValue.setTextColor(textColor) binding.tvSeekValue.setTextColor(textColor)
} }
binding.ivSeekPlus.setOnClickListener { binding.ivSeekPlus.setOnClickListener {

@ -1,6 +1,7 @@
package io.legado.app.ui.widget package io.legado.app.ui.widget
import android.content.Context import android.content.Context
import android.graphics.PorterDuff
import android.util.AttributeSet import android.util.AttributeSet
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.Menu import android.view.Menu
@ -35,7 +36,7 @@ class SelectActionBar @JvmOverloads constructor(
elevation = context.elevation elevation = context.elevation
binding.cbSelectedAll.setTextColor(primaryTextColor) binding.cbSelectedAll.setTextColor(primaryTextColor)
TintHelper.setTint(binding.cbSelectedAll, context.accentColor, !bgIsLight) TintHelper.setTint(binding.cbSelectedAll, context.accentColor, !bgIsLight)
binding.ivMenuMore.setColorFilter(disabledColor) binding.ivMenuMore.setColorFilter(disabledColor, PorterDuff.Mode.SRC_IN)
binding.cbSelectedAll.setOnCheckedChangeListener { buttonView, isChecked -> binding.cbSelectedAll.setOnCheckedChangeListener { buttonView, isChecked ->
if (buttonView.isPressed) { if (buttonView.isPressed) {
callBack?.selectAll(isChecked) callBack?.selectAll(isChecked)
@ -101,9 +102,9 @@ class SelectActionBar @JvmOverloads constructor(
btnSelectActionMain.isEnabled = isClickable btnSelectActionMain.isEnabled = isClickable
btnSelectActionMain.isClickable = isClickable btnSelectActionMain.isClickable = isClickable
if (isClickable) { if (isClickable) {
ivMenuMore.setColorFilter(primaryTextColor) ivMenuMore.setColorFilter(primaryTextColor, PorterDuff.Mode.SRC_IN)
} else { } else {
ivMenuMore.setColorFilter(disabledColor) ivMenuMore.setColorFilter(disabledColor, PorterDuff.Mode.SRC_IN)
} }
ivMenuMore.isEnabled = isClickable ivMenuMore.isEnabled = isClickable
ivMenuMore.isClickable = isClickable ivMenuMore.isClickable = isClickable

Loading…
Cancel
Save