From 37e0ad4ac3701035d165b84d4911f15eed3e9f58 Mon Sep 17 00:00:00 2001 From: Horis <821938089@qq.com> Date: Fri, 16 Sep 2022 21:12:46 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/ui/book/read/BaseReadBookActivity.kt | 6 +- .../io/legado/app/ui/book/read/ReadMenu.kt | 88 ++++++++++++------- 2 files changed, 62 insertions(+), 32 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/book/read/BaseReadBookActivity.kt b/app/src/main/java/io/legado/app/ui/book/read/BaseReadBookActivity.kt index 75ac8cdfb..df6d01744 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/BaseReadBookActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/BaseReadBookActivity.kt @@ -123,7 +123,11 @@ abstract class BaseReadBookActivity : if (toolBarHide) { setLightStatusBar(ReadBookConfig.durConfig.curStatusIconDark()) } else { - val statusBarColor = ThemeStore.statusBarColor(this, AppConfig.isTransparentStatusBar) + val statusBarColor = if (AppConfig.readBarStyleFollowPage && ReadBookConfig.durConfig.curBgType() == 0) { + ReadBookConfig.bgMeanColor + } else { + ThemeStore.statusBarColor(this, AppConfig.isTransparentStatusBar) + } setLightStatusBar(ColorUtils.isColorLight(statusBarColor)) } } diff --git a/app/src/main/java/io/legado/app/ui/book/read/ReadMenu.kt b/app/src/main/java/io/legado/app/ui/book/read/ReadMenu.kt index 8efb51994..bfecb2725 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/ReadMenu.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/ReadMenu.kt @@ -56,24 +56,23 @@ class ReadMenu @JvmOverloads constructor( private val menuBottomOut: Animation by lazy { loadAnimation(context, R.anim.anim_readbook_bottom_out) } - private val bgColor: Int - get() = if(AppConfig.readBarStyleFollowPage && ReadBookConfig.durConfig.curBgType() == 0){ - Color.parseColor(ReadBookConfig.durConfig.curBgStr()) - }else{ - context.bottomBackground - } - private val textColor: Int - get() = if(AppConfig.readBarStyleFollowPage && ReadBookConfig.durConfig.curBgType() == 0){ - ReadBookConfig.durConfig.curTextColor() - }else{ - context.getPrimaryTextColor(ColorUtils.isColorLight(bgColor)) - } + private val immersiveMenu: Boolean + get() = AppConfig.readBarStyleFollowPage && ReadBookConfig.durConfig.curBgType() == 0 + private var bgColor: Int = if (immersiveMenu) { + Color.parseColor(ReadBookConfig.durConfig.curBgStr()) + } else { + context.bottomBackground + } + private var textColor: Int = if (immersiveMenu) { + ReadBookConfig.durConfig.curTextColor() + } else { + context.getPrimaryTextColor(ColorUtils.isColorLight(bgColor)) + } - private val bottomBackgroundList: ColorStateList - get() = Selector.colorBuild() - .setDefaultColor(bgColor) - .setPressedColor(ColorUtils.darkenColor(bgColor)) - .create() + private var bottomBackgroundList: ColorStateList = Selector.colorBuild() + .setDefaultColor(bgColor) + .setPressedColor(ColorUtils.darkenColor(bgColor)) + .create() private var onMenuOutEnd: (() -> Unit)? = null private val showBrightnessView get() = context.getPrefBoolean( @@ -158,15 +157,22 @@ class ReadMenu @JvmOverloads constructor( fabNightTheme.setImageResource(R.drawable.ic_brightness) } initAnimation() - val bgColor = this@ReadMenu.bgColor - val textColor = this@ReadMenu.textColor - val bottomBackgroundList = this@ReadMenu.bottomBackgroundList - val lightTextColor = ColorUtils.withAlpha(ColorUtils.lightenColor(textColor),0.75f) - titleBar.setTextColor(textColor) - titleBar.setBackgroundColor(bgColor) - titleBar.setColorFilter(textColor) - tvChapterName.setTextColor(lightTextColor) - tvChapterUrl.setTextColor(lightTextColor) + if (immersiveMenu) { + val lightTextColor = ColorUtils.withAlpha(ColorUtils.lightenColor(textColor), 0.75f) + titleBar.setTextColor(textColor) + titleBar.setBackgroundColor(bgColor) + titleBar.setColorFilter(textColor) + tvChapterName.setTextColor(lightTextColor) + tvChapterUrl.setTextColor(lightTextColor) + } else { + val bgColor = context.primaryColor + val textColor = context.primaryTextColor + titleBar.setTextColor(textColor) + titleBar.setBackgroundColor(bgColor) + titleBar.setColorFilter(textColor) + tvChapterName.setTextColor(textColor) + tvChapterUrl.setTextColor(textColor) + } val brightnessBackground = GradientDrawable() brightnessBackground.cornerRadius = 5F.dpToPx() brightnessBackground.setColor(ColorUtils.adjustAlpha(bgColor, 0.5f)) @@ -195,19 +201,39 @@ class ReadMenu @JvmOverloads constructor( seekBrightness.post { seekBrightness.progress = AppConfig.readBrightness } - if(AppConfig.showReadTitleBarAddition){ + if (AppConfig.showReadTitleBarAddition) { titleBarAddition.visible() - }else{ + } else { titleBarAddition.gone() } } - fun reset(){ + fun reset() { + upColorConfig() initView() } - fun refreshMenuColorFilter(){ - binding.titleBar.setColorFilter(textColor) + fun refreshMenuColorFilter() { + if (immersiveMenu) { + binding.titleBar.setColorFilter(textColor) + } + } + + private fun upColorConfig() { + bgColor = if (immersiveMenu) { + Color.parseColor(ReadBookConfig.durConfig.curBgStr()) + } else { + context.bottomBackground + } + textColor = if (immersiveMenu) { + ReadBookConfig.durConfig.curTextColor() + } else { + context.getPrimaryTextColor(ColorUtils.isColorLight(bgColor)) + } + bottomBackgroundList = Selector.colorBuild() + .setDefaultColor(bgColor) + .setPressedColor(ColorUtils.darkenColor(bgColor)) + .create() } fun upBrightnessState() {