|
@@ -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)
|
|
|
|
|
- set(value) {
|
|
|
|
|
- field = value
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ private val colorSurfaceContainer: Int
|
|
|
|
|
+ get() = context.themeColor(com.google.android.material.R.attr.colorSurfaceContainer)
|
|
|
|
|
|
|
|
- var colorSecondary: Int = context.themeColor(androidx.appcompat.R.attr.colorPrimary)
|
|
|
|
|
- set(value) {
|
|
|
|
|
- field = value
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ private val colorSecondary: Int
|
|
|
|
|
+ get() = context.themeColor(androidx.appcompat.R.attr.colorPrimary)
|
|
|
|
|
|
|
|
- var colorSecondaryContainer: Int = context.themeColor(com.google.android.material.R.attr.colorSecondaryContainer)
|
|
|
|
|
- set(value) {
|
|
|
|
|
- field = value
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ private val colorSecondaryContainer: Int
|
|
|
|
|
+ get() = context.themeColor(com.google.android.material.R.attr.colorSecondaryContainer)
|
|
|
|
|
|
|
|
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(ColorUtils.setAlphaComponent(bgColor, alpha))
|
|
|
|
|
- cdSlider.setCardBackgroundColor(ColorUtils.setAlphaComponent(bgColor, alpha))
|
|
|
|
|
|
|
+ titleBar.setBackgroundColor(alphaBgColor)
|
|
|
|
|
+ titleBar.toolbar.setBackgroundColor(alphaBgColor)
|
|
|
|
|
+ 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))
|
|
@@ -942,4 +925,4 @@ class ReadMenu @JvmOverloads constructor(
|
|
|
val onCheck: (() -> Unit)? = null,// 可选
|
|
val onCheck: (() -> Unit)? = null,// 可选
|
|
|
var state: Boolean = false // 动态
|
|
var state: Boolean = false // 动态
|
|
|
)
|
|
)
|
|
|
-}
|
|
|
|
|
|
|
+}
|