mirror of
https://github.com/gedoor/legado.git
synced 2024-09-01 09:34:25 +08:00
优化
This commit is contained in:
parent
0500061d28
commit
8cbca1ae06
@ -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<VB : ViewBinding>(
|
||||
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<VB : ViewBinding>(
|
||||
} else {
|
||||
setTheme(R.style.AppTheme_Dark)
|
||||
}
|
||||
ATH.applyBackgroundTint(window.decorView)
|
||||
window.decorView.applyBackgroundTint(backgroundColor)
|
||||
}
|
||||
}
|
||||
if (imageBg) {
|
||||
|
@ -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
|
||||
|
@ -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() {
|
||||
|
Loading…
Reference in New Issue
Block a user