Merge pull request #765
* 深浅色切换问题 * 代码优化 * Merge branch 'HapeLee:main' into darkmode-fix * toolbar 反色修复 * 代码优化
This commit is contained in:
@@ -320,12 +320,6 @@ class ReadBookActivity : BaseReadBookActivity(),
|
|||||||
|
|
||||||
upScreenTimeOut()
|
upScreenTimeOut()
|
||||||
ReadBook.register(this)
|
ReadBook.register(this)
|
||||||
binding.readMenu.colorSurfaceContainer =
|
|
||||||
themeColor(com.google.android.material.R.attr.colorSurfaceContainer)
|
|
||||||
binding.readMenu.colorSecondary =
|
|
||||||
themeColor(androidx.appcompat.R.attr.colorPrimary)
|
|
||||||
binding.readMenu.colorSecondaryContainer =
|
|
||||||
themeColor(com.google.android.material.R.attr.colorSecondaryContainer)
|
|
||||||
binding.cursorLeft.setOnTouchListener(this)
|
binding.cursorLeft.setOnTouchListener(this)
|
||||||
binding.cursorRight.setOnTouchListener(this)
|
binding.cursorRight.setOnTouchListener(this)
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import android.content.Context
|
|||||||
import android.content.res.ColorStateList
|
import android.content.res.ColorStateList
|
||||||
import android.content.res.Configuration
|
import android.content.res.Configuration
|
||||||
import android.graphics.drawable.GradientDrawable
|
import android.graphics.drawable.GradientDrawable
|
||||||
|
import android.graphics.drawable.RippleDrawable
|
||||||
import android.util.AttributeSet
|
import android.util.AttributeSet
|
||||||
import android.view.Gravity
|
import android.view.Gravity
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
@@ -94,20 +95,14 @@ class ReadMenu @JvmOverloads constructor(
|
|||||||
fillAfter = true
|
fillAfter = true
|
||||||
}
|
}
|
||||||
|
|
||||||
var colorSurfaceContainer: Int = context.themeColor(com.google.android.material.R.attr.colorSurfaceContainer)
|
private val colorSurfaceContainer: Int
|
||||||
set(value) {
|
get() = context.themeColor(com.google.android.material.R.attr.colorSurfaceContainer)
|
||||||
field = value
|
|
||||||
}
|
|
||||||
|
|
||||||
var colorSecondary: Int = context.themeColor(androidx.appcompat.R.attr.colorPrimary)
|
private val colorSecondary: Int
|
||||||
set(value) {
|
get() = context.themeColor(androidx.appcompat.R.attr.colorPrimary)
|
||||||
field = value
|
|
||||||
}
|
|
||||||
|
|
||||||
var colorSecondaryContainer: Int = context.themeColor(com.google.android.material.R.attr.colorSecondaryContainer)
|
private val colorSecondaryContainer: Int
|
||||||
set(value) {
|
get() = context.themeColor(com.google.android.material.R.attr.colorSecondaryContainer)
|
||||||
field = value
|
|
||||||
}
|
|
||||||
|
|
||||||
private val bgColor: Int
|
private val bgColor: Int
|
||||||
get() = when (AppConfig.readBarStyle) {
|
get() = when (AppConfig.readBarStyle) {
|
||||||
@@ -210,6 +205,10 @@ class ReadMenu @JvmOverloads constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun initView() = binding.run {
|
private fun initView() = binding.run {
|
||||||
|
val bgColor = this@ReadMenu.bgColor
|
||||||
|
val acColor = this@ReadMenu.acColor
|
||||||
|
val bgcColor = this@ReadMenu.bgcColor
|
||||||
|
val alphaBgColor = ColorUtils.setAlphaComponent(bgColor, (AppConfig.menuAlpha / 100f * 255).toInt())
|
||||||
initAnimation()
|
initAnimation()
|
||||||
updateSliderVisibility()
|
updateSliderVisibility()
|
||||||
val brightnessBackground = GradientDrawable()
|
val brightnessBackground = GradientDrawable()
|
||||||
@@ -233,9 +232,12 @@ class ReadMenu @JvmOverloads constructor(
|
|||||||
val allButtons = getUserButtons()
|
val allButtons = getUserButtons()
|
||||||
renderButtons(binding.bottomView, allButtons)
|
renderButtons(binding.bottomView, allButtons)
|
||||||
}
|
}
|
||||||
val alpha = (AppConfig.menuAlpha / 100f * 255).toInt()
|
titleBar.setBackgroundColor(alphaBgColor)
|
||||||
titleBar.setBackgroundColor(ColorUtils.setAlphaComponent(bgColor, alpha))
|
titleBar.toolbar.setBackgroundColor(alphaBgColor)
|
||||||
cdSlider.setCardBackgroundColor(ColorUtils.setAlphaComponent(bgColor, alpha))
|
bottomView.setBackgroundColor(alphaBgColor)
|
||||||
|
(tvPre.background as? RippleDrawable)?.setColor(ColorStateList.valueOf(bgcColor))
|
||||||
|
(tvNext.background as? RippleDrawable)?.setColor(ColorStateList.valueOf(bgcColor))
|
||||||
|
cdSlider.setCardBackgroundColor(alphaBgColor)
|
||||||
seekReadPage.trackInactiveTintList = ColorStateList.valueOf(bgcColor)
|
seekReadPage.trackInactiveTintList = ColorStateList.valueOf(bgcColor)
|
||||||
seekReadPage.trackActiveTintList = ColorStateList.valueOf(acColor)
|
seekReadPage.trackActiveTintList = ColorStateList.valueOf(acColor)
|
||||||
seekReadPage.thumbTintList = ColorStateList.valueOf(acColor)
|
seekReadPage.thumbTintList = ColorStateList.valueOf(acColor)
|
||||||
@@ -258,12 +260,12 @@ class ReadMenu @JvmOverloads constructor(
|
|||||||
if (resources.configuration.orientation == Configuration.ORIENTATION_LANDSCAPE) {
|
if (resources.configuration.orientation == Configuration.ORIENTATION_LANDSCAPE) {
|
||||||
binding.bottomMenu.applyNavigationBarPadding()
|
binding.bottomMenu.applyNavigationBarPadding()
|
||||||
} else {
|
} else {
|
||||||
bottomView.setBackgroundColor(ColorUtils.setAlphaComponent(bgColor, alpha))
|
|
||||||
binding.bottomView.applyNavigationBarPadding()
|
binding.bottomView.applyNavigationBarPadding()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun updateToolBarColor(){
|
fun updateToolBarColor() {
|
||||||
|
val acColor = this@ReadMenu.acColor
|
||||||
binding.titleBar.toolbar.navigationIcon?.setTint(acColor)
|
binding.titleBar.toolbar.navigationIcon?.setTint(acColor)
|
||||||
binding.titleBar.toolbar.apply {
|
binding.titleBar.toolbar.apply {
|
||||||
setTitleTextColor(acColor)
|
setTitleTextColor(acColor)
|
||||||
@@ -276,8 +278,8 @@ class ReadMenu @JvmOverloads constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun reset() {
|
fun reset() {
|
||||||
upColorConfig()
|
|
||||||
initView()
|
initView()
|
||||||
|
updateToolBarColor()
|
||||||
upBookView()
|
upBookView()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -287,25 +289,6 @@ class ReadMenu @JvmOverloads constructor(
|
|||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun upColorConfig() {
|
|
||||||
// bgColor = if (immersiveMenu) {
|
|
||||||
// kotlin.runCatching {
|
|
||||||
// Color.parseColor(ReadBookConfig.durConfig.curBgStr())
|
|
||||||
// }.getOrDefault(context.bottomBackground)
|
|
||||||
// } 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() {
|
fun upBrightnessState() {
|
||||||
if (brightnessAuto()) {
|
if (brightnessAuto()) {
|
||||||
binding.ivBrightnessAuto.setColorFilter(context.themeColor(androidx.appcompat.R.attr.colorPrimary))
|
binding.ivBrightnessAuto.setColorFilter(context.themeColor(androidx.appcompat.R.attr.colorPrimary))
|
||||||
|
|||||||
Reference in New Issue
Block a user