舍弃原来的主题系统
This commit is contained in:
@@ -6,6 +6,7 @@ import android.content.DialogInterface
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.core.view.isVisible
|
||||
import androidx.fragment.app.viewModels
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import io.legato.kazusa.R
|
||||
@@ -70,9 +71,9 @@ class AddToBookshelfDialog() : BaseDialogFragment(R.layout.dialog_add_to_bookshe
|
||||
}
|
||||
viewModel.loadStateLiveData.observe(this) {
|
||||
if (it) {
|
||||
binding.rotateLoading.visible()
|
||||
binding.rotateLoading.isVisible = true
|
||||
} else {
|
||||
binding.rotateLoading.gone()
|
||||
binding.rotateLoading.isVisible = true
|
||||
}
|
||||
}
|
||||
viewModel.loadErrorLiveData.observe(this) {
|
||||
|
||||
@@ -9,6 +9,7 @@ import android.widget.ImageButton
|
||||
import androidx.appcompat.widget.SearchView
|
||||
import androidx.appcompat.widget.Toolbar
|
||||
import androidx.core.os.bundleOf
|
||||
import androidx.core.view.isVisible
|
||||
import androidx.fragment.app.viewModels
|
||||
import androidx.lifecycle.Lifecycle.State.STARTED
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
@@ -215,7 +216,7 @@ class ChangeBookSourceDialog() : BaseBottomSheetDialogFragment(R.layout.dialog_b
|
||||
|
||||
private fun initLiveData() {
|
||||
viewModel.searchStateData.observe(viewLifecycleOwner) {
|
||||
//binding.refreshProgressBar.isAutoLoading = it
|
||||
binding.refreshProgressBar.isVisible = it
|
||||
if (it) {
|
||||
startStopMenuItem?.let { item ->
|
||||
item.setIcon(R.drawable.ic_stop_black_24dp)
|
||||
@@ -227,7 +228,7 @@ class ChangeBookSourceDialog() : BaseBottomSheetDialogFragment(R.layout.dialog_b
|
||||
item.setTitle(R.string.refresh)
|
||||
}
|
||||
}
|
||||
binding.toolBar.menu.applyTint(requireContext())
|
||||
//binding.toolBar.menu.applyTint(requireContext())
|
||||
}
|
||||
lifecycleScope.launch {
|
||||
repeatOnLifecycle(STARTED) {
|
||||
|
||||
@@ -11,6 +11,7 @@ import io.legato.kazusa.lib.theme.ThemeUtils
|
||||
//import io.legado.app.lib.theme.accentColor
|
||||
import io.legato.kazusa.utils.getCompatColor
|
||||
import io.legato.kazusa.utils.gone
|
||||
import io.legato.kazusa.utils.themeColor
|
||||
import io.legato.kazusa.utils.visible
|
||||
|
||||
class ChangeChapterTocAdapter(context: Context, val callback: Callback) :
|
||||
@@ -30,11 +31,13 @@ class ChangeChapterTocAdapter(context: Context, val callback: Callback) :
|
||||
) {
|
||||
binding.run {
|
||||
val isDur = durChapterIndex == item.index
|
||||
|
||||
if (isDur) {
|
||||
//tvChapterName.setTextColor(context.accentColor)
|
||||
tvChapterName.setTextColor(context.themeColor(com.google.android.material.R.attr.colorPrimary))
|
||||
} else {
|
||||
tvChapterName.setTextColor(context.getCompatColor(R.color.primaryText))
|
||||
tvChapterName.setTextColor(context.themeColor(com.google.android.material.R.attr.colorOnSurface))
|
||||
}
|
||||
|
||||
tvChapterName.text = item.title
|
||||
if (item.isVolume) {
|
||||
//卷名,如第一卷 突出显示
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package io.legato.kazusa.ui.book.read.page
|
||||
|
||||
import android.content.Context
|
||||
import android.graphics.Canvas
|
||||
import android.graphics.Paint
|
||||
import android.os.SystemClock
|
||||
@@ -10,11 +11,13 @@ import io.legato.kazusa.lib.theme.ThemeStore
|
||||
import io.legato.kazusa.ui.book.read.page.entities.PageDirection
|
||||
import io.legato.kazusa.utils.canvasrecorder.CanvasRecorderFactory
|
||||
import io.legato.kazusa.utils.canvasrecorder.recordIfNeeded
|
||||
import io.legato.kazusa.utils.themeColor
|
||||
|
||||
/**
|
||||
* 自动翻页
|
||||
*/
|
||||
class AutoPager(private val readView: ReadView) {
|
||||
class AutoPager(
|
||||
private val readView: ReadView) {
|
||||
private var progress = 0
|
||||
var isRunning = false
|
||||
private set
|
||||
@@ -28,7 +31,7 @@ class AutoPager(private val readView: ReadView) {
|
||||
|
||||
fun start() {
|
||||
isRunning = true
|
||||
paint.color = ThemeStore.accentColor
|
||||
paint.color = readView.context.themeColor(com.google.android.material.R.attr.colorPrimary)
|
||||
lastTimeMillis = SystemClock.uptimeMillis()
|
||||
readView.curPage.upSelectAble(false)
|
||||
readView.invalidate()
|
||||
|
||||
@@ -19,6 +19,7 @@ import io.legato.kazusa.ui.book.read.page.provider.ChapterProvider
|
||||
import io.legato.kazusa.utils.canvasrecorder.CanvasRecorderFactory
|
||||
import io.legato.kazusa.utils.canvasrecorder.recordIfNeededThenDraw
|
||||
import io.legato.kazusa.utils.dpToPx
|
||||
import io.legato.kazusa.utils.themeColor
|
||||
|
||||
/**
|
||||
* 行信息
|
||||
@@ -173,7 +174,7 @@ data class TextLine(
|
||||
ChapterProvider.contentPaint
|
||||
}
|
||||
val textColor = if (isReadAloud) {
|
||||
ThemeStore.accentColor
|
||||
view.context.themeColor(com.google.android.material.R.attr.colorPrimary)
|
||||
} else {
|
||||
ReadBookConfig.textColor
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import io.legato.kazusa.ui.book.read.page.ContentTextView
|
||||
import io.legato.kazusa.ui.book.read.page.entities.TextLine
|
||||
import io.legato.kazusa.ui.book.read.page.entities.TextLine.Companion.emptyTextLine
|
||||
import io.legato.kazusa.ui.book.read.page.provider.ChapterProvider
|
||||
import io.legato.kazusa.utils.themeColor
|
||||
|
||||
/**
|
||||
* 文字列
|
||||
@@ -49,7 +50,7 @@ data class TextColumn(
|
||||
ChapterProvider.contentPaint
|
||||
}
|
||||
val textColor = if (textLine.isReadAloud || isSearchResult) {
|
||||
ThemeStore.accentColor
|
||||
view.context.themeColor(com.google.android.material.R.attr.colorPrimary)
|
||||
} else {
|
||||
ReadBookConfig.textColor
|
||||
}
|
||||
|
||||
@@ -9,13 +9,14 @@ import io.legato.kazusa.databinding.ItemSearchListBinding
|
||||
//import io.legado.app.lib.theme.accentColor
|
||||
import io.legato.kazusa.utils.getCompatColor
|
||||
import io.legato.kazusa.utils.hexString
|
||||
import io.legato.kazusa.utils.themeColor
|
||||
|
||||
|
||||
class SearchContentAdapter(context: Context, val callback: Callback) :
|
||||
RecyclerAdapter<SearchResult, ItemSearchListBinding>(context) {
|
||||
|
||||
val textColor = context.getCompatColor(R.color.primaryText).hexString.substring(2)
|
||||
//val accentColor = context.accentColor.hexString.substring(2)
|
||||
val textColor = context.themeColor(com.google.android.material.R.attr.colorOnSurface).hexString.substring(2)
|
||||
val accentColor = context.themeColor(com.google.android.material.R.attr.colorPrimary).hexString.substring(2)
|
||||
|
||||
override fun getViewBinding(parent: ViewGroup): ItemSearchListBinding {
|
||||
return ItemSearchListBinding.inflate(inflater, parent, false)
|
||||
@@ -30,7 +31,7 @@ class SearchContentAdapter(context: Context, val callback: Callback) :
|
||||
binding.run {
|
||||
val isDur = callback.durChapterIndex() == item.chapterIndex
|
||||
if (payloads.isEmpty()) {
|
||||
//tvSearchResult.text = item.getHtmlCompat(textColor, accentColor)
|
||||
tvSearchResult.text = item.getHtmlCompat(textColor, accentColor)
|
||||
tvSearchResult.paint.isFakeBoldText = isDur
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ import io.legato.kazusa.help.glide.ImageLoader
|
||||
import io.legato.kazusa.help.glide.OkHttpModelLoader
|
||||
import io.legato.kazusa.utils.getCompatColor
|
||||
import io.legato.kazusa.utils.gone
|
||||
import io.legato.kazusa.utils.themeColor
|
||||
import io.legato.kazusa.utils.visible
|
||||
|
||||
|
||||
@@ -73,9 +74,9 @@ class RssArticlesAdapter(context: Context, callBack: CallBack) :
|
||||
}.into(imageView)
|
||||
}
|
||||
if (item.read) {
|
||||
tvTitle.setTextColor(context.getCompatColor(R.color.tv_text_summary))
|
||||
tvTitle.setTextColor(context.themeColor(com.google.android.material.R.attr.colorOnSurfaceVariant))
|
||||
} else {
|
||||
tvTitle.setTextColor(context.getCompatColor(R.color.primaryText))
|
||||
tvTitle.setTextColor(context.themeColor(com.google.android.material.R.attr.colorOnSurface))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ import io.legato.kazusa.help.glide.ImageLoader
|
||||
import io.legato.kazusa.help.glide.OkHttpModelLoader
|
||||
import io.legato.kazusa.utils.getCompatColor
|
||||
import io.legato.kazusa.utils.gone
|
||||
import io.legato.kazusa.utils.themeColor
|
||||
import io.legato.kazusa.utils.visible
|
||||
|
||||
|
||||
@@ -73,9 +74,9 @@ class RssArticlesAdapter2(context: Context, callBack: CallBack) :
|
||||
}.into(imageView)
|
||||
}
|
||||
if (item.read) {
|
||||
tvTitle.setTextColor(context.getCompatColor(R.color.tv_text_summary))
|
||||
tvTitle.setTextColor(context.themeColor(com.google.android.material.R.attr.colorOnSurfaceVariant))
|
||||
} else {
|
||||
tvTitle.setTextColor(context.getCompatColor(R.color.primaryText))
|
||||
tvTitle.setTextColor(context.themeColor(com.google.android.material.R.attr.colorOnSurface))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,13 +59,15 @@ class DetailSeekBar @JvmOverloads constructor(
|
||||
// binding.tvSeekValue.setTextColor(textColor)
|
||||
}
|
||||
binding.ivSeekPlus.setOnClickListener {
|
||||
binding.slider.value = binding.slider.value + 1
|
||||
onChanged?.invoke(binding.slider.value.toInt())
|
||||
val newValue = (binding.slider.value + 1).coerceAtMost(binding.slider.valueTo)
|
||||
binding.slider.value = newValue
|
||||
onChanged?.invoke(newValue.toInt())
|
||||
}
|
||||
|
||||
binding.ivSeekReduce.setOnClickListener {
|
||||
binding.slider.value = binding.slider.value - 1
|
||||
onChanged?.invoke(binding.slider.value.toInt())
|
||||
val newValue = (binding.slider.value - 1).coerceAtLeast(binding.slider.valueFrom)
|
||||
binding.slider.value = newValue
|
||||
onChanged?.invoke(newValue.toInt())
|
||||
}
|
||||
|
||||
binding.slider.addOnChangeListener { _, value, fromUser ->
|
||||
|
||||
@@ -23,6 +23,8 @@ import io.legato.kazusa.utils.spToPx
|
||||
import kotlin.math.min
|
||||
import kotlin.math.pow
|
||||
import androidx.core.graphics.createBitmap
|
||||
import io.legato.kazusa.utils.themeColor
|
||||
import androidx.core.content.withStyledAttributes
|
||||
|
||||
@Suppress("unused", "MemberVisibilityCanBePrivate")
|
||||
class CircleImageView @JvmOverloads constructor(
|
||||
@@ -117,35 +119,35 @@ class CircleImageView @JvmOverloads constructor(
|
||||
|
||||
private var text: String? = null
|
||||
|
||||
private var textColor = context.getCompatColor(R.color.primaryText)
|
||||
private var textColor = context.themeColor(com.google.android.material.R.attr.colorOnSurface)
|
||||
private var textBold = false
|
||||
var isInView = false
|
||||
|
||||
init {
|
||||
val a = context.obtainStyledAttributes(attrs, R.styleable.CircleImageView)
|
||||
mBorderWidth =
|
||||
a.getDimensionPixelSize(
|
||||
R.styleable.CircleImageView_civ_border_width,
|
||||
DEFAULT_BORDER_WIDTH
|
||||
)
|
||||
mBorderColor =
|
||||
a.getColor(R.styleable.CircleImageView_civ_border_color, DEFAULT_BORDER_COLOR)
|
||||
mBorderOverlay =
|
||||
a.getBoolean(R.styleable.CircleImageView_civ_border_overlay, DEFAULT_BORDER_OVERLAY)
|
||||
mCircleBackgroundColor =
|
||||
a.getColor(
|
||||
R.styleable.CircleImageView_civ_circle_background_color,
|
||||
DEFAULT_CIRCLE_BACKGROUND_COLOR
|
||||
)
|
||||
text = a.getString(R.styleable.CircleImageView_text)
|
||||
contentDescription = text
|
||||
if (a.hasValue(R.styleable.CircleImageView_textColor)) {
|
||||
textColor = a.getColor(
|
||||
R.styleable.CircleImageView_textColor,
|
||||
context.getCompatColor(R.color.primaryText)
|
||||
)
|
||||
context.withStyledAttributes(attrs, R.styleable.CircleImageView) {
|
||||
mBorderWidth =
|
||||
getDimensionPixelSize(
|
||||
R.styleable.CircleImageView_civ_border_width,
|
||||
DEFAULT_BORDER_WIDTH
|
||||
)
|
||||
mBorderColor =
|
||||
getColor(R.styleable.CircleImageView_civ_border_color, DEFAULT_BORDER_COLOR)
|
||||
mBorderOverlay =
|
||||
getBoolean(R.styleable.CircleImageView_civ_border_overlay, DEFAULT_BORDER_OVERLAY)
|
||||
mCircleBackgroundColor =
|
||||
getColor(
|
||||
R.styleable.CircleImageView_civ_circle_background_color,
|
||||
DEFAULT_CIRCLE_BACKGROUND_COLOR
|
||||
)
|
||||
text = getString(R.styleable.CircleImageView_text)
|
||||
contentDescription = text
|
||||
if (hasValue(R.styleable.CircleImageView_textColor)) {
|
||||
textColor = getColor(
|
||||
R.styleable.CircleImageView_textColor,
|
||||
context.themeColor(com.google.android.material.R.attr.colorOnSurface)
|
||||
)
|
||||
}
|
||||
}
|
||||
a.recycle()
|
||||
|
||||
mReady = true
|
||||
|
||||
|
||||
@@ -29,6 +29,7 @@ import android.os.BatteryManager
|
||||
import android.os.Build
|
||||
import android.os.Process
|
||||
import android.provider.Settings
|
||||
import android.util.TypedValue
|
||||
import androidx.annotation.ColorRes
|
||||
import androidx.annotation.DrawableRes
|
||||
import androidx.core.content.ContextCompat
|
||||
@@ -417,3 +418,8 @@ val Context.isDebuggable: Boolean
|
||||
|
||||
val Context.dataStore by preferencesDataStore(name = "settings")
|
||||
|
||||
fun Context.themeColor(attr: Int): Int {
|
||||
val typedValue = TypedValue()
|
||||
theme.resolveAttribute(attr, typedValue, true)
|
||||
return ContextCompat.getColor(this, typedValue.resourceId)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user