pull/1395/head
gedoor 3 years ago
parent 0500061d28
commit 8cbca1ae06
  1. 7
      app/src/main/java/io/legado/app/base/BaseActivity.kt
  2. 18
      app/src/main/java/io/legado/app/lib/theme/ATH.kt
  3. 8
      app/src/main/java/io/legado/app/utils/ViewExtensions.kt

@ -17,7 +17,6 @@ import io.legado.app.constant.AppConst
import io.legado.app.constant.Theme import io.legado.app.constant.Theme
import io.legado.app.help.AppConfig import io.legado.app.help.AppConfig
import io.legado.app.help.ThemeConfig import io.legado.app.help.ThemeConfig
import io.legado.app.lib.theme.ATH
import io.legado.app.lib.theme.ThemeStore import io.legado.app.lib.theme.ThemeStore
import io.legado.app.lib.theme.backgroundColor import io.legado.app.lib.theme.backgroundColor
import io.legado.app.lib.theme.primaryColor import io.legado.app.lib.theme.primaryColor
@ -128,11 +127,11 @@ abstract class BaseActivity<VB : ViewBinding>(
Theme.Transparent -> setTheme(R.style.AppTheme_Transparent) Theme.Transparent -> setTheme(R.style.AppTheme_Transparent)
Theme.Dark -> { Theme.Dark -> {
setTheme(R.style.AppTheme_Dark) setTheme(R.style.AppTheme_Dark)
ATH.applyBackgroundTint(window.decorView) window.decorView.applyBackgroundTint(backgroundColor)
} }
Theme.Light -> { Theme.Light -> {
setTheme(R.style.AppTheme_Light) setTheme(R.style.AppTheme_Light)
ATH.applyBackgroundTint(window.decorView) window.decorView.applyBackgroundTint(backgroundColor)
} }
else -> { else -> {
if (ColorUtils.isColorLight(primaryColor)) { if (ColorUtils.isColorLight(primaryColor)) {
@ -140,7 +139,7 @@ abstract class BaseActivity<VB : ViewBinding>(
} else { } else {
setTheme(R.style.AppTheme_Dark) setTheme(R.style.AppTheme_Dark)
} }
ATH.applyBackgroundTint(window.decorView) window.decorView.applyBackgroundTint(backgroundColor)
} }
} }
if (imageBg) { if (imageBg) {

@ -8,7 +8,6 @@ import androidx.annotation.ColorInt
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import androidx.viewpager2.widget.ViewPager2 import androidx.viewpager2.widget.ViewPager2
import com.google.android.material.bottomnavigation.BottomNavigationView import com.google.android.material.bottomnavigation.BottomNavigationView
import io.legado.app.help.AppConfig
import io.legado.app.utils.ColorUtils import io.legado.app.utils.ColorUtils
import io.legado.app.utils.dp import io.legado.app.utils.dp
import splitties.init.appCtx import splitties.init.appCtx
@ -19,13 +18,6 @@ import splitties.init.appCtx
@Suppress("unused", "MemberVisibilityCanBePrivate") @Suppress("unused", "MemberVisibilityCanBePrivate")
object ATH { object ATH {
fun setBackgroundTint(
view: View, @ColorInt color: Int,
isDark: Boolean = AppConfig.isNightTheme
) {
TintHelper.setTintAuto(view, color, true, isDark)
}
fun setEdgeEffectColor(view: RecyclerView?, @ColorInt color: Int) { fun setEdgeEffectColor(view: RecyclerView?, @ColorInt color: Int) {
view?.edgeEffectFactory = object : RecyclerView.EdgeEffectFactory() { view?.edgeEffectFactory = object : RecyclerView.EdgeEffectFactory() {
override fun createEdgeEffect(view: RecyclerView, direction: Int): EdgeEffect { override fun createEdgeEffect(view: RecyclerView, direction: Int): EdgeEffect {
@ -78,16 +70,6 @@ object ATH {
} }
} }
fun applyBackgroundTint(view: View?) {
view?.apply {
if (background == null) {
setBackgroundColor(context.backgroundColor)
} else {
setBackgroundTint(this, context.backgroundColor)
}
}
}
fun applyEdgeEffectColor(view: View?) { fun applyEdgeEffectColor(view: View?) {
when (view) { when (view) {
is RecyclerView -> view.edgeEffectFactory = DEFAULT_EFFECT_FACTORY is RecyclerView -> view.edgeEffectFactory = DEFAULT_EFFECT_FACTORY

@ -53,11 +53,15 @@ fun View.applyTint(
TintHelper.setTintAuto(this, color, false, isDark) TintHelper.setTintAuto(this, color, false, isDark)
} }
fun View.applyBackground( fun View.applyBackgroundTint(
@ColorInt color: Int, @ColorInt color: Int,
isDark: Boolean = AppConfig.isNightTheme isDark: Boolean = AppConfig.isNightTheme
) { ) {
TintHelper.setTintAuto(this, color, true, isDark) if (background == null) {
setBackgroundColor(color)
} else {
TintHelper.setTintAuto(this, color, true, isDark)
}
} }
fun View.gone() { fun View.gone() {

Loading…
Cancel
Save