阅读工具栏更多自定义
This commit is contained in:
@@ -124,5 +124,7 @@ object PreferKey {
|
|||||||
const val cNBBackground = "colorBottomBackgroundNight"
|
const val cNBBackground = "colorBottomBackgroundNight"
|
||||||
const val bgImageN = "backgroundImageNight"
|
const val bgImageN = "backgroundImageNight"
|
||||||
const val bgImageNBlurring = "backgroundImageNightBlurring"
|
const val bgImageNBlurring = "backgroundImageNightBlurring"
|
||||||
|
const val showReadTitleAddition = "showReadTitleAddition"
|
||||||
|
const val readBarStyleFollowPage = "readBarStyleFollowPage"
|
||||||
|
const val updateReadActionBar = "updateReadActionBar"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -342,5 +342,16 @@ object AppConfig : SharedPreferences.OnSharedPreferenceChangeListener {
|
|||||||
set(value) {
|
set(value) {
|
||||||
appCtx.putPrefInt(PreferKey.bitmapCacheSize, value)
|
appCtx.putPrefInt(PreferKey.bitmapCacheSize, value)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var showReadTitleBarAddition : Boolean
|
||||||
|
get() = appCtx.getPrefBoolean(PreferKey.showReadTitleAddition, true)
|
||||||
|
set(value) {
|
||||||
|
appCtx.putPrefBoolean(PreferKey.showReadTitleAddition, value)
|
||||||
|
}
|
||||||
|
var readBarStyleFollowPage : Boolean
|
||||||
|
get() = appCtx.getPrefBoolean(PreferKey.readBarStyleFollowPage, false)
|
||||||
|
set(value) {
|
||||||
|
appCtx.putPrefBoolean(PreferKey.readBarStyleFollowPage, value)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -229,6 +229,7 @@ class ReadBookActivity : BaseReadBookActivity(),
|
|||||||
setOnMenuItemClickListener(this@ReadBookActivity)
|
setOnMenuItemClickListener(this@ReadBookActivity)
|
||||||
}.show()
|
}.show()
|
||||||
}
|
}
|
||||||
|
binding.readMenu.refreshMenuColorFilter()
|
||||||
return super.onCompatCreateOptionsMenu(menu)
|
return super.onCompatCreateOptionsMenu(menu)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1216,6 +1217,7 @@ class ReadBookActivity : BaseReadBookActivity(),
|
|||||||
} else {
|
} else {
|
||||||
readView.upContent(resetPageOffset = false)
|
readView.upContent(resetPageOffset = false)
|
||||||
}
|
}
|
||||||
|
binding.readMenu.reset()
|
||||||
}
|
}
|
||||||
observeEvent<Int>(EventBus.ALOUD_STATE) {
|
observeEvent<Int>(EventBus.ALOUD_STATE) {
|
||||||
if (it == Status.STOP || it == Status.PAUSE) {
|
if (it == Status.STOP || it == Status.PAUSE) {
|
||||||
@@ -1253,6 +1255,9 @@ class ReadBookActivity : BaseReadBookActivity(),
|
|||||||
observeEvent<List<SearchResult>>(EventBus.SEARCH_RESULT) {
|
observeEvent<List<SearchResult>>(EventBus.SEARCH_RESULT) {
|
||||||
viewModel.searchResultList = it
|
viewModel.searchResultList = it
|
||||||
}
|
}
|
||||||
|
observeEvent<Boolean>(PreferKey.updateReadActionBar){
|
||||||
|
binding.readMenu.reset()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun upScreenTimeOut() {
|
private fun upScreenTimeOut() {
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package io.legado.app.ui.book.read
|
|||||||
import android.annotation.SuppressLint
|
import android.annotation.SuppressLint
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.res.ColorStateList
|
import android.content.res.ColorStateList
|
||||||
|
import android.graphics.Color
|
||||||
import android.graphics.drawable.GradientDrawable
|
import android.graphics.drawable.GradientDrawable
|
||||||
import android.util.AttributeSet
|
import android.util.AttributeSet
|
||||||
import android.view.Gravity
|
import android.view.Gravity
|
||||||
@@ -14,8 +15,7 @@ import android.view.animation.Animation
|
|||||||
import android.widget.FrameLayout
|
import android.widget.FrameLayout
|
||||||
import android.widget.SeekBar
|
import android.widget.SeekBar
|
||||||
import androidx.appcompat.widget.PopupMenu
|
import androidx.appcompat.widget.PopupMenu
|
||||||
import androidx.core.view.isGone
|
import androidx.core.view.*
|
||||||
import androidx.core.view.isVisible
|
|
||||||
import io.legado.app.R
|
import io.legado.app.R
|
||||||
import io.legado.app.constant.PreferKey
|
import io.legado.app.constant.PreferKey
|
||||||
import io.legado.app.databinding.ViewReadMenuBinding
|
import io.legado.app.databinding.ViewReadMenuBinding
|
||||||
@@ -55,12 +55,24 @@ class ReadMenu @JvmOverloads constructor(
|
|||||||
private val menuBottomOut: Animation by lazy {
|
private val menuBottomOut: Animation by lazy {
|
||||||
loadAnimation(context, R.anim.anim_readbook_bottom_out)
|
loadAnimation(context, R.anim.anim_readbook_bottom_out)
|
||||||
}
|
}
|
||||||
private val bgColor: Int = context.bottomBackground
|
private val bgColor: Int
|
||||||
private val textColor: Int = context.getPrimaryTextColor(ColorUtils.isColorLight(bgColor))
|
get() = if(AppConfig.readBarStyleFollowPage && ReadBookConfig.durConfig.curBgType() == 0){
|
||||||
private val bottomBackgroundList: ColorStateList = Selector.colorBuild()
|
Color.parseColor(ReadBookConfig.durConfig.curBgStr())
|
||||||
.setDefaultColor(bgColor)
|
}else{
|
||||||
.setPressedColor(ColorUtils.darkenColor(bgColor))
|
context.bottomBackground
|
||||||
.create()
|
}
|
||||||
|
private val textColor: Int
|
||||||
|
get() = if(AppConfig.readBarStyleFollowPage && ReadBookConfig.durConfig.curBgType() == 0){
|
||||||
|
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 onMenuOutEnd: (() -> Unit)? = null
|
private var onMenuOutEnd: (() -> Unit)? = null
|
||||||
private val showBrightnessView
|
private val showBrightnessView
|
||||||
get() = context.getPrefBoolean(
|
get() = context.getPrefBoolean(
|
||||||
@@ -145,6 +157,15 @@ class ReadMenu @JvmOverloads constructor(
|
|||||||
fabNightTheme.setImageResource(R.drawable.ic_brightness)
|
fabNightTheme.setImageResource(R.drawable.ic_brightness)
|
||||||
}
|
}
|
||||||
initAnimation()
|
initAnimation()
|
||||||
|
val bgColor = this@ReadMenu.bgColor
|
||||||
|
val textColor = this@ReadMenu.textColor
|
||||||
|
val bottomBackgroundList = this@ReadMenu.bottomBackgroundList
|
||||||
|
val lightTextColor = ColorUtils.lightenColor(textColor)
|
||||||
|
titleBar.setTextColor(textColor)
|
||||||
|
titleBar.setBackgroundColor(bgColor)
|
||||||
|
titleBar.setColorFilter(textColor)
|
||||||
|
tvChapterName.setTextColor(lightTextColor)
|
||||||
|
tvChapterUrl.setTextColor(lightTextColor)
|
||||||
val brightnessBackground = GradientDrawable()
|
val brightnessBackground = GradientDrawable()
|
||||||
brightnessBackground.cornerRadius = 5F.dpToPx()
|
brightnessBackground.cornerRadius = 5F.dpToPx()
|
||||||
brightnessBackground.setColor(ColorUtils.adjustAlpha(bgColor, 0.5f))
|
brightnessBackground.setColor(ColorUtils.adjustAlpha(bgColor, 0.5f))
|
||||||
@@ -173,6 +194,19 @@ class ReadMenu @JvmOverloads constructor(
|
|||||||
seekBrightness.post {
|
seekBrightness.post {
|
||||||
seekBrightness.progress = AppConfig.readBrightness
|
seekBrightness.progress = AppConfig.readBrightness
|
||||||
}
|
}
|
||||||
|
if(AppConfig.showReadTitleBarAddition){
|
||||||
|
titleBarAddition.visible()
|
||||||
|
}else{
|
||||||
|
titleBarAddition.gone()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun reset(){
|
||||||
|
initView()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun refreshMenuColorFilter(){
|
||||||
|
binding.titleBar.setColorFilter(textColor)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun upBrightnessState() {
|
fun upBrightnessState() {
|
||||||
|
|||||||
@@ -133,6 +133,10 @@ class MoreConfigDialog : DialogFragment() {
|
|||||||
ChapterProvider.upLayout()
|
ChapterProvider.upLayout()
|
||||||
ReadBook.loadContent(false)
|
ReadBook.loadContent(false)
|
||||||
}
|
}
|
||||||
|
PreferKey.showReadTitleAddition,
|
||||||
|
PreferKey.readBarStyleFollowPage -> {
|
||||||
|
postEvent(PreferKey.updateReadActionBar,true)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,12 +3,16 @@ package io.legado.app.ui.widget
|
|||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.res.ColorStateList
|
import android.content.res.ColorStateList
|
||||||
import android.graphics.Color
|
import android.graphics.Color
|
||||||
|
import android.graphics.PorterDuff
|
||||||
|
import android.graphics.PorterDuffColorFilter
|
||||||
import android.util.AttributeSet
|
import android.util.AttributeSet
|
||||||
import android.view.Menu
|
import android.view.Menu
|
||||||
import android.view.View
|
import android.view.View
|
||||||
|
import android.widget.ImageView
|
||||||
import androidx.annotation.ColorInt
|
import androidx.annotation.ColorInt
|
||||||
import androidx.annotation.StyleRes
|
import androidx.annotation.StyleRes
|
||||||
import androidx.appcompat.widget.Toolbar
|
import androidx.appcompat.widget.Toolbar
|
||||||
|
import androidx.core.view.children
|
||||||
import com.google.android.material.appbar.AppBarLayout
|
import com.google.android.material.appbar.AppBarLayout
|
||||||
import io.legado.app.R
|
import io.legado.app.R
|
||||||
import io.legado.app.lib.theme.elevation
|
import io.legado.app.lib.theme.elevation
|
||||||
@@ -192,6 +196,21 @@ class TitleBar @JvmOverloads constructor(
|
|||||||
toolbar.setSubtitleTextAppearance(context, resId)
|
toolbar.setSubtitleTextAppearance(context, resId)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun setTextColor(@ColorInt color: Int){
|
||||||
|
setTitleTextColor(color)
|
||||||
|
setSubTitleTextColor(color)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun setColorFilter(@ColorInt color: Int){
|
||||||
|
val colorFilter = PorterDuffColorFilter(color,PorterDuff.Mode.SRC_ATOP)
|
||||||
|
toolbar.children.firstOrNull { it is ImageView }?.background?.colorFilter = colorFilter
|
||||||
|
toolbar.navigationIcon?.colorFilter = colorFilter
|
||||||
|
toolbar.overflowIcon?.colorFilter = colorFilter
|
||||||
|
toolbar.menu.children.forEach{
|
||||||
|
it.icon?.colorFilter = colorFilter
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fun transparent() {
|
fun transparent() {
|
||||||
elevation = 0f
|
elevation = 0f
|
||||||
setBackgroundColor(Color.TRANSPARENT)
|
setBackgroundColor(Color.TRANSPARENT)
|
||||||
|
|||||||
@@ -22,6 +22,7 @@
|
|||||||
app:layout_constraintTop_toTopOf="parent">
|
app:layout_constraintTop_toTopOf="parent">
|
||||||
|
|
||||||
<androidx.constraintlayout.widget.ConstraintLayout
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
|
android:id="@+id/title_bar_addition"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content">
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
|
|||||||
@@ -1012,4 +1012,6 @@
|
|||||||
<string name="show_add_to_shelf_alert_summary">阅读未放入书架的书籍在返回时提示放入书架</string>
|
<string name="show_add_to_shelf_alert_summary">阅读未放入书架的书籍在返回时提示放入书架</string>
|
||||||
<string name="tag_explore_enabled">标志:发现已启用</string>
|
<string name="tag_explore_enabled">标志:发现已启用</string>
|
||||||
<string name="tag_explore_disabled">标志:发现已禁用</string>
|
<string name="tag_explore_disabled">标志:发现已禁用</string>
|
||||||
|
<string name="show_read_title_addition">show read title addition area</string>
|
||||||
|
<string name="read_bar_style_follow_page">read bar style follow page</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -1015,4 +1015,6 @@
|
|||||||
<string name="show_add_to_shelf_alert_summary">阅读未放入书架的书籍在返回时提示放入书架</string>
|
<string name="show_add_to_shelf_alert_summary">阅读未放入书架的书籍在返回时提示放入书架</string>
|
||||||
<string name="tag_explore_enabled">标志:发现已启用</string>
|
<string name="tag_explore_enabled">标志:发现已启用</string>
|
||||||
<string name="tag_explore_disabled">标志:发现已禁用</string>
|
<string name="tag_explore_disabled">标志:发现已禁用</string>
|
||||||
|
<string name="show_read_title_addition">show read title addition area</string>
|
||||||
|
<string name="read_bar_style_follow_page">read bar style follow page</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -1015,4 +1015,6 @@
|
|||||||
<string name="show_add_to_shelf_alert_summary">阅读未放入书架的书籍在返回时提示放入书架</string>
|
<string name="show_add_to_shelf_alert_summary">阅读未放入书架的书籍在返回时提示放入书架</string>
|
||||||
<string name="tag_explore_enabled">标志:发现已启用</string>
|
<string name="tag_explore_enabled">标志:发现已启用</string>
|
||||||
<string name="tag_explore_disabled">标志:发现已禁用</string>
|
<string name="tag_explore_disabled">标志:发现已禁用</string>
|
||||||
|
<string name="show_read_title_addition">show read title addition area</string>
|
||||||
|
<string name="read_bar_style_follow_page">read bar style follow page</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -1012,4 +1012,6 @@
|
|||||||
<string name="show_add_to_shelf_alert_summary">阅读未放入书架的书籍在返回时提示放入书架</string>
|
<string name="show_add_to_shelf_alert_summary">阅读未放入书架的书籍在返回时提示放入书架</string>
|
||||||
<string name="tag_explore_enabled">标志:发现已启用</string>
|
<string name="tag_explore_enabled">标志:发现已启用</string>
|
||||||
<string name="tag_explore_disabled">标志:发现已禁用</string>
|
<string name="tag_explore_disabled">标志:发现已禁用</string>
|
||||||
|
<string name="show_read_title_addition">展示顶部工具栏附加区域</string>
|
||||||
|
<string name="read_bar_style_follow_page">工具栏样式跟随页面</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -1014,4 +1014,6 @@
|
|||||||
<string name="show_add_to_shelf_alert_summary">阅读未放入书架的书籍在返回时提示放入书架</string>
|
<string name="show_add_to_shelf_alert_summary">阅读未放入书架的书籍在返回时提示放入书架</string>
|
||||||
<string name="tag_explore_enabled">标志:发现已启用</string>
|
<string name="tag_explore_enabled">标志:发现已启用</string>
|
||||||
<string name="tag_explore_disabled">标志:发现已禁用</string>
|
<string name="tag_explore_disabled">标志:发现已禁用</string>
|
||||||
|
<string name="show_read_title_addition">展示顶部工具栏附加区域</string>
|
||||||
|
<string name="read_bar_style_follow_page">工具栏样式跟随页面</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -1014,4 +1014,6 @@
|
|||||||
<string name="show_add_to_shelf_alert_summary">阅读未放入书架的书籍在返回时提示放入书架</string>
|
<string name="show_add_to_shelf_alert_summary">阅读未放入书架的书籍在返回时提示放入书架</string>
|
||||||
<string name="tag_explore_enabled">标志:发现已启用</string>
|
<string name="tag_explore_enabled">标志:发现已启用</string>
|
||||||
<string name="tag_explore_disabled">标志:发现已禁用</string>
|
<string name="tag_explore_disabled">标志:发现已禁用</string>
|
||||||
|
<string name="show_read_title_addition">展示顶部工具栏附加区域</string>
|
||||||
|
<string name="read_bar_style_follow_page">工具栏样式跟随页面</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -1015,4 +1015,6 @@
|
|||||||
<string name="show_add_to_shelf_alert_summary">阅读未放入书架的书籍在返回时提示放入书架</string>
|
<string name="show_add_to_shelf_alert_summary">阅读未放入书架的书籍在返回时提示放入书架</string>
|
||||||
<string name="tag_explore_enabled">标志:发现已启用</string>
|
<string name="tag_explore_enabled">标志:发现已启用</string>
|
||||||
<string name="tag_explore_disabled">标志:发现已禁用</string>
|
<string name="tag_explore_disabled">标志:发现已禁用</string>
|
||||||
|
<string name="show_read_title_addition">show read title addition area</string>
|
||||||
|
<string name="read_bar_style_follow_page">read bar style follow page</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -146,4 +146,13 @@
|
|||||||
app:iconSpaceReserved="false"
|
app:iconSpaceReserved="false"
|
||||||
app:isBottomBackground="true" />
|
app:isBottomBackground="true" />
|
||||||
|
|
||||||
|
<io.legado.app.lib.prefs.SwitchPreference
|
||||||
|
android:defaultValue="true"
|
||||||
|
android:key="showReadTitleAddition"
|
||||||
|
android:title="@string/show_read_title_addition"/>
|
||||||
|
|
||||||
|
<io.legado.app.lib.prefs.SwitchPreference
|
||||||
|
android:defaultValue="false"
|
||||||
|
android:key="readBarStyleFollowPage"
|
||||||
|
android:title="@string/read_bar_style_follow_page"/>
|
||||||
</androidx.preference.PreferenceScreen>
|
</androidx.preference.PreferenceScreen>
|
||||||
@@ -27,3 +27,5 @@ android.experimental.enableNewResourceShrinker.preciseShrinking=true
|
|||||||
android.nonTransitiveRClass=true
|
android.nonTransitiveRClass=true
|
||||||
#https://chromiumdash.appspot.com/releases?platform=Android
|
#https://chromiumdash.appspot.com/releases?platform=Android
|
||||||
CronetVersion=105.0.5195.79
|
CronetVersion=105.0.5195.79
|
||||||
|
|
||||||
|
android.injected.testOnly=false
|
||||||
Reference in New Issue
Block a user