diff --git a/app/src/main/java/io/legado/app/base/BaseActivity.kt b/app/src/main/java/io/legado/app/base/BaseActivity.kt index 0fedc4c05..bb55a57c8 100644 --- a/app/src/main/java/io/legado/app/base/BaseActivity.kt +++ b/app/src/main/java/io/legado/app/base/BaseActivity.kt @@ -17,7 +17,6 @@ import io.legado.app.constant.AppConst import io.legado.app.constant.Theme import io.legado.app.help.AppConfig 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.backgroundColor import io.legado.app.lib.theme.primaryColor @@ -128,11 +127,11 @@ abstract class BaseActivity( Theme.Transparent -> setTheme(R.style.AppTheme_Transparent) Theme.Dark -> { setTheme(R.style.AppTheme_Dark) - ATH.applyBackgroundTint(window.decorView) + window.decorView.applyBackgroundTint(backgroundColor) } Theme.Light -> { setTheme(R.style.AppTheme_Light) - ATH.applyBackgroundTint(window.decorView) + window.decorView.applyBackgroundTint(backgroundColor) } else -> { if (ColorUtils.isColorLight(primaryColor)) { @@ -140,7 +139,7 @@ abstract class BaseActivity( } else { setTheme(R.style.AppTheme_Dark) } - ATH.applyBackgroundTint(window.decorView) + window.decorView.applyBackgroundTint(backgroundColor) } } if (imageBg) { diff --git a/app/src/main/java/io/legado/app/lib/theme/ATH.kt b/app/src/main/java/io/legado/app/lib/theme/ATH.kt index 279bb9b59..af30c14d3 100644 --- a/app/src/main/java/io/legado/app/lib/theme/ATH.kt +++ b/app/src/main/java/io/legado/app/lib/theme/ATH.kt @@ -8,7 +8,6 @@ import androidx.annotation.ColorInt import androidx.recyclerview.widget.RecyclerView import androidx.viewpager2.widget.ViewPager2 import com.google.android.material.bottomnavigation.BottomNavigationView -import io.legado.app.help.AppConfig import io.legado.app.utils.ColorUtils import io.legado.app.utils.dp import splitties.init.appCtx @@ -19,13 +18,6 @@ import splitties.init.appCtx @Suppress("unused", "MemberVisibilityCanBePrivate") 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) { view?.edgeEffectFactory = object : RecyclerView.EdgeEffectFactory() { 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?) { when (view) { is RecyclerView -> view.edgeEffectFactory = DEFAULT_EFFECT_FACTORY diff --git a/app/src/main/java/io/legado/app/utils/ViewExtensions.kt b/app/src/main/java/io/legado/app/utils/ViewExtensions.kt index d0c9af3f5..672a424b0 100644 --- a/app/src/main/java/io/legado/app/utils/ViewExtensions.kt +++ b/app/src/main/java/io/legado/app/utils/ViewExtensions.kt @@ -53,11 +53,15 @@ fun View.applyTint( TintHelper.setTintAuto(this, color, false, isDark) } -fun View.applyBackground( +fun View.applyBackgroundTint( @ColorInt color: Int, 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() {