更新界面
This commit is contained in:
@@ -1,21 +1,19 @@
|
||||
package io.legato.kazusa.ui.book.changecover
|
||||
|
||||
//import io.legado.app.lib.theme.primaryColor
|
||||
import android.os.Bundle
|
||||
import android.view.MenuItem
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.appcompat.widget.Toolbar
|
||||
import androidx.core.view.isVisible
|
||||
import androidx.fragment.app.viewModels
|
||||
import androidx.lifecycle.Lifecycle.State.STARTED
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import androidx.lifecycle.repeatOnLifecycle
|
||||
import androidx.recyclerview.widget.GridLayoutManager
|
||||
import io.legato.kazusa.R
|
||||
import io.legato.kazusa.base.BaseDialogFragment
|
||||
import io.legato.kazusa.base.BaseBottomSheetDialogFragment
|
||||
import io.legato.kazusa.databinding.DialogChangeCoverBinding
|
||||
//import io.legado.app.lib.theme.primaryColor
|
||||
import io.legato.kazusa.utils.applyTint
|
||||
import io.legato.kazusa.utils.setLayout
|
||||
import io.legato.kazusa.utils.viewbindingdelegate.viewBinding
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.flow.conflate
|
||||
@@ -24,7 +22,7 @@ import kotlinx.coroutines.launch
|
||||
/**
|
||||
* 换封面
|
||||
*/
|
||||
class ChangeCoverDialog() : BaseDialogFragment(R.layout.dialog_change_cover),
|
||||
class ChangeCoverDialog() : BaseBottomSheetDialogFragment(R.layout.dialog_change_cover),
|
||||
Toolbar.OnMenuItemClickListener,
|
||||
CoverAdapter.CallBack {
|
||||
|
||||
@@ -43,11 +41,6 @@ class ChangeCoverDialog() : BaseDialogFragment(R.layout.dialog_change_cover),
|
||||
private val startStopMenuItem: MenuItem?
|
||||
get() = binding.toolBar.menu.findItem(R.id.menu_start_stop)
|
||||
|
||||
override fun onStart() {
|
||||
super.onStart()
|
||||
setLayout(1f, ViewGroup.LayoutParams.MATCH_PARENT)
|
||||
}
|
||||
|
||||
override fun onFragmentCreated(view: View, savedInstanceState: Bundle?) {
|
||||
//binding.toolBar.setBackgroundColor(primaryColor)
|
||||
binding.toolBar.setTitle(R.string.change_cover_source)
|
||||
@@ -82,7 +75,7 @@ class ChangeCoverDialog() : BaseDialogFragment(R.layout.dialog_change_cover),
|
||||
override fun observeLiveBus() {
|
||||
super.observeLiveBus()
|
||||
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)
|
||||
|
||||
+13
-73
@@ -5,8 +5,6 @@ import android.os.Bundle
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.appcompat.widget.PopupMenu
|
||||
import androidx.core.graphics.drawable.DrawableCompat
|
||||
import androidx.core.view.isVisible
|
||||
import androidx.recyclerview.widget.DiffUtil
|
||||
import io.legato.kazusa.R
|
||||
import io.legato.kazusa.base.adapter.DiffRecyclerAdapter
|
||||
@@ -15,12 +13,10 @@ import io.legato.kazusa.data.entities.SearchBook
|
||||
import io.legato.kazusa.databinding.ItemChangeSourceBinding
|
||||
import io.legato.kazusa.help.config.AppConfig
|
||||
import io.legato.kazusa.lib.dialogs.alert
|
||||
import io.legato.kazusa.utils.getCompatColor
|
||||
import io.legato.kazusa.utils.gone
|
||||
import io.legato.kazusa.utils.invisible
|
||||
import io.legato.kazusa.utils.themeColor
|
||||
import io.legato.kazusa.utils.visible
|
||||
import splitties.init.appCtx
|
||||
import splitties.views.onLongClick
|
||||
|
||||
|
||||
@@ -88,38 +84,11 @@ class ChangeBookSourceAdapter(
|
||||
}
|
||||
val score = callBack.getBookScore(item)
|
||||
if (score > 0) {
|
||||
binding.ivBad.gone()
|
||||
binding.ivGood.visible()
|
||||
DrawableCompat.setTint(
|
||||
binding.ivGood.drawable,
|
||||
appCtx.getCompatColor(R.color.md_red_A200)
|
||||
)
|
||||
DrawableCompat.setTint(
|
||||
binding.ivBad.drawable,
|
||||
appCtx.getCompatColor(R.color.md_blue_100)
|
||||
)
|
||||
} else if (score < 0) {
|
||||
binding.ivGood.gone()
|
||||
binding.ivBad.visible()
|
||||
DrawableCompat.setTint(
|
||||
binding.ivGood.drawable,
|
||||
appCtx.getCompatColor(R.color.md_red_100)
|
||||
)
|
||||
DrawableCompat.setTint(
|
||||
binding.ivBad.drawable,
|
||||
appCtx.getCompatColor(R.color.md_blue_A200)
|
||||
)
|
||||
// 已置顶
|
||||
binding.ivGood.setImageResource(R.drawable.ic_praise_filled)
|
||||
} else {
|
||||
binding.ivGood.visible()
|
||||
binding.ivBad.visible()
|
||||
DrawableCompat.setTint(
|
||||
binding.ivGood.drawable,
|
||||
appCtx.getCompatColor(R.color.md_red_100)
|
||||
)
|
||||
DrawableCompat.setTint(
|
||||
binding.ivBad.drawable,
|
||||
appCtx.getCompatColor(R.color.md_blue_100)
|
||||
)
|
||||
// 未置顶
|
||||
binding.ivGood.setImageResource(R.drawable.ic_praise)
|
||||
}
|
||||
|
||||
if (AppConfig.changeSourceLoadWordCount && !item.chapterWordCountText.isNullOrBlank()) {
|
||||
@@ -138,45 +107,16 @@ class ChangeBookSourceAdapter(
|
||||
|
||||
override fun registerListener(holder: ItemViewHolder, binding: ItemChangeSourceBinding) {
|
||||
binding.ivGood.setOnClickListener {
|
||||
if (binding.ivBad.isVisible) {
|
||||
DrawableCompat.setTint(
|
||||
binding.ivGood.drawable,
|
||||
appCtx.getCompatColor(R.color.md_red_A200)
|
||||
)
|
||||
binding.ivBad.gone()
|
||||
getItem(holder.layoutPosition)?.let {
|
||||
callBack.setBookScore(it, 1)
|
||||
}
|
||||
val item = getItem(holder.layoutPosition) ?: return@setOnClickListener
|
||||
val score = callBack.getBookScore(item)
|
||||
if (score > 0) {
|
||||
// 已置顶 -> 取消置顶
|
||||
binding.ivGood.setImageResource(R.drawable.ic_praise)
|
||||
callBack.setBookScore(item, 0)
|
||||
} else {
|
||||
DrawableCompat.setTint(
|
||||
binding.ivGood.drawable,
|
||||
appCtx.getCompatColor(R.color.md_red_100)
|
||||
)
|
||||
binding.ivBad.visible()
|
||||
getItem(holder.layoutPosition)?.let {
|
||||
callBack.setBookScore(it, 0)
|
||||
}
|
||||
}
|
||||
}
|
||||
binding.ivBad.setOnClickListener {
|
||||
if (binding.ivGood.isVisible) {
|
||||
DrawableCompat.setTint(
|
||||
binding.ivBad.drawable,
|
||||
appCtx.getCompatColor(R.color.md_blue_A200)
|
||||
)
|
||||
binding.ivGood.gone()
|
||||
getItem(holder.layoutPosition)?.let {
|
||||
callBack.setBookScore(it, -1)
|
||||
}
|
||||
} else {
|
||||
DrawableCompat.setTint(
|
||||
binding.ivBad.drawable,
|
||||
appCtx.getCompatColor(R.color.md_blue_100)
|
||||
)
|
||||
binding.ivGood.visible()
|
||||
getItem(holder.layoutPosition)?.let {
|
||||
callBack.setBookScore(it, 0)
|
||||
}
|
||||
// 未置顶 -> 设置置顶
|
||||
binding.ivGood.setImageResource(R.drawable.ic_praise_filled)
|
||||
callBack.setBookScore(item, 1)
|
||||
}
|
||||
}
|
||||
holder.itemView.setOnClickListener {
|
||||
|
||||
+14
-55
@@ -5,8 +5,6 @@ import android.os.Bundle
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.appcompat.widget.PopupMenu
|
||||
import androidx.core.graphics.drawable.DrawableCompat
|
||||
import androidx.core.view.isVisible
|
||||
import androidx.recyclerview.widget.DiffUtil
|
||||
import io.legato.kazusa.R
|
||||
import io.legato.kazusa.base.adapter.DiffRecyclerAdapter
|
||||
@@ -14,11 +12,9 @@ import io.legato.kazusa.base.adapter.ItemViewHolder
|
||||
import io.legato.kazusa.data.entities.SearchBook
|
||||
import io.legato.kazusa.databinding.ItemChangeSourceBinding
|
||||
import io.legato.kazusa.help.config.AppConfig
|
||||
import io.legato.kazusa.utils.getCompatColor
|
||||
import io.legato.kazusa.utils.gone
|
||||
import io.legato.kazusa.utils.invisible
|
||||
import io.legato.kazusa.utils.visible
|
||||
import splitties.init.appCtx
|
||||
import splitties.views.onLongClick
|
||||
|
||||
|
||||
@@ -80,34 +76,14 @@ class ChangeChapterSourceAdapter(
|
||||
}
|
||||
val score = callBack.getBookScore(item)
|
||||
if (score > 0) {
|
||||
binding.ivBad.gone()
|
||||
binding.ivGood.visible()
|
||||
DrawableCompat.setTint(binding.ivGood.drawable, appCtx.getCompatColor(R.color.md_red_A200))
|
||||
DrawableCompat.setTint(binding.ivBad.drawable, appCtx.getCompatColor(R.color.md_blue_100))
|
||||
} else if (score < 0) {
|
||||
binding.ivGood.gone()
|
||||
binding.ivBad.visible()
|
||||
DrawableCompat.setTint(
|
||||
binding.ivGood.drawable,
|
||||
appCtx.getCompatColor(R.color.md_red_100)
|
||||
)
|
||||
DrawableCompat.setTint(
|
||||
binding.ivBad.drawable,
|
||||
appCtx.getCompatColor(R.color.md_blue_A200)
|
||||
)
|
||||
// 已置顶
|
||||
binding.ivGood.setImageResource(R.drawable.ic_praise_filled)
|
||||
} else {
|
||||
binding.ivGood.visible()
|
||||
binding.ivBad.visible()
|
||||
DrawableCompat.setTint(
|
||||
binding.ivGood.drawable,
|
||||
appCtx.getCompatColor(R.color.md_red_100)
|
||||
)
|
||||
DrawableCompat.setTint(
|
||||
binding.ivBad.drawable,
|
||||
appCtx.getCompatColor(R.color.md_blue_100)
|
||||
)
|
||||
// 未置顶
|
||||
binding.ivGood.setImageResource(R.drawable.ic_praise)
|
||||
}
|
||||
|
||||
|
||||
if (AppConfig.changeSourceLoadWordCount && !item.chapterWordCountText.isNullOrBlank()) {
|
||||
tvCurrentChapterWordCount.visible()
|
||||
} else {
|
||||
@@ -124,33 +100,16 @@ class ChangeChapterSourceAdapter(
|
||||
|
||||
override fun registerListener(holder: ItemViewHolder, binding: ItemChangeSourceBinding) {
|
||||
binding.ivGood.setOnClickListener {
|
||||
if (binding.ivBad.isVisible) {
|
||||
DrawableCompat.setTint(binding.ivGood.drawable, appCtx.getCompatColor(R.color.md_red_A200))
|
||||
binding.ivBad.gone()
|
||||
getItem(holder.layoutPosition)?.let {
|
||||
callBack.setBookScore(it, 1)
|
||||
}
|
||||
val item = getItem(holder.layoutPosition) ?: return@setOnClickListener
|
||||
val score = callBack.getBookScore(item)
|
||||
if (score > 0) {
|
||||
// 已置顶 -> 取消置顶
|
||||
binding.ivGood.setImageResource(R.drawable.ic_praise)
|
||||
callBack.setBookScore(item, 0)
|
||||
} else {
|
||||
DrawableCompat.setTint(binding.ivGood.drawable, appCtx.getCompatColor(R.color.md_red_100))
|
||||
binding.ivBad.visible()
|
||||
getItem(holder.layoutPosition)?.let {
|
||||
callBack.setBookScore(it, 0)
|
||||
}
|
||||
}
|
||||
}
|
||||
binding.ivBad.setOnClickListener {
|
||||
if (binding.ivGood.isVisible) {
|
||||
DrawableCompat.setTint(binding.ivBad.drawable, appCtx.getCompatColor(R.color.md_blue_A200))
|
||||
binding.ivGood.gone()
|
||||
getItem(holder.layoutPosition)?.let {
|
||||
callBack.setBookScore(it, -1)
|
||||
}
|
||||
} else {
|
||||
DrawableCompat.setTint(binding.ivBad.drawable, appCtx.getCompatColor(R.color.md_blue_100))
|
||||
binding.ivGood.visible()
|
||||
getItem(holder.layoutPosition)?.let {
|
||||
callBack.setBookScore(it, 0)
|
||||
}
|
||||
// 未置顶 -> 设置置顶
|
||||
binding.ivGood.setImageResource(R.drawable.ic_praise_filled)
|
||||
callBack.setBookScore(item, 1)
|
||||
}
|
||||
}
|
||||
holder.itemView.setOnClickListener {
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
package io.legato.kazusa.ui.book.group
|
||||
|
||||
//import io.legado.app.lib.theme.primaryColor
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import androidx.appcompat.widget.PopupMenu
|
||||
import android.widget.ArrayAdapter
|
||||
import androidx.fragment.app.viewModels
|
||||
import io.legato.kazusa.R
|
||||
import io.legato.kazusa.base.BaseBottomSheetDialogFragment
|
||||
@@ -69,6 +68,13 @@ class GroupEditDialog() : BaseBottomSheetDialogFragment(R.layout.dialog_book_gro
|
||||
@Suppress("DEPRECATION")
|
||||
bookGroup = arguments?.getParcelable("group")
|
||||
|
||||
val sortAdapter = ArrayAdapter(
|
||||
requireContext(),
|
||||
android.R.layout.simple_list_item_1,
|
||||
sortOptions
|
||||
)
|
||||
binding.actvSortMenu.setAdapter(sortAdapter)
|
||||
|
||||
bookGroup?.let { group ->
|
||||
binding.btnDelete.isEnabled = (group.groupId > 0 || group.groupId == Long.MIN_VALUE)
|
||||
binding.tieGroupName.setText(group.groupName)
|
||||
@@ -82,30 +88,20 @@ class GroupEditDialog() : BaseBottomSheetDialogFragment(R.layout.dialog_book_gro
|
||||
} else {
|
||||
0
|
||||
}
|
||||
binding.chipSortMenu.text = sortOptions[selectedSortIndex]
|
||||
binding.actvSortMenu.setText(sortOptions[selectedSortIndex], false)
|
||||
|
||||
} ?: run {
|
||||
binding.btnDelete.gone()
|
||||
binding.ivCover.load()
|
||||
selectedSortIndex = 0
|
||||
binding.chipSortMenu.text = sortOptions[selectedSortIndex]
|
||||
binding.actvSortMenu.setText(sortOptions[selectedSortIndex], false)
|
||||
}
|
||||
|
||||
binding.actvSortMenu.setOnItemClickListener { _, _, position, _ ->
|
||||
selectedSortIndex = position
|
||||
}
|
||||
|
||||
binding.run {
|
||||
chipSortMenu.setOnClickListener { chip ->
|
||||
PopupMenu(requireContext(), chip).apply {
|
||||
sortOptions.forEachIndexed { index, title ->
|
||||
menu.add(0, index, index, title)
|
||||
}
|
||||
setOnMenuItemClickListener { item ->
|
||||
selectedSortIndex = item.itemId
|
||||
chipSortMenu.text = sortOptions[selectedSortIndex]
|
||||
true
|
||||
}
|
||||
show()
|
||||
}
|
||||
}
|
||||
|
||||
ivCover.onClick {
|
||||
selectImage.launch()
|
||||
}
|
||||
@@ -149,8 +145,8 @@ class GroupEditDialog() : BaseBottomSheetDialogFragment(R.layout.dialog_book_gro
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
btnDelete.onClick {
|
||||
deleteGroup {
|
||||
bookGroup?.let {
|
||||
@@ -163,6 +159,7 @@ class GroupEditDialog() : BaseBottomSheetDialogFragment(R.layout.dialog_book_gro
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private fun deleteGroup(ok: () -> Unit) {
|
||||
alert(R.string.delete, R.string.sure_del) {
|
||||
yesButton {
|
||||
|
||||
@@ -584,23 +584,23 @@ class ReadMangaActivity : VMBaseActivity<ActivityMangaBinding, ReadMangaViewMode
|
||||
}
|
||||
|
||||
//点击滑动
|
||||
override fun onClickScrollDisabledChanged(enabled: Boolean) {
|
||||
AppConfig.disableClickScroll = enabled
|
||||
setDisableClickScroll(enabled)
|
||||
override fun onClickScrollDisabledChanged(disabled: Boolean) {
|
||||
AppConfig.disableClickScroll = disabled
|
||||
setDisableClickScroll(disabled)
|
||||
}
|
||||
|
||||
//双击缩放
|
||||
override fun onMangaScaleDisabledChanged(enabled: Boolean) {
|
||||
AppConfig.disableMangaScale = enabled
|
||||
setDisableMangaScale(enabled)
|
||||
override fun onMangaScaleDisabledChanged(disabled: Boolean) {
|
||||
AppConfig.disableMangaScale = disabled
|
||||
setDisableMangaScale(disabled)
|
||||
}
|
||||
|
||||
//侧边留白
|
||||
override fun upSidePadding(paddingDp: Int) {
|
||||
override fun upSidePadding(padding: Int) {
|
||||
viewModel.updateReadConfig {
|
||||
webtoonSidePaddingDp = paddingDp
|
||||
webtoonSidePaddingDp = padding
|
||||
}
|
||||
updateWebtoonSidePadding(paddingDp)
|
||||
updateWebtoonSidePadding(padding)
|
||||
}
|
||||
|
||||
//墨水屏
|
||||
|
||||
@@ -24,7 +24,9 @@ import io.legato.kazusa.help.glide.ImageLoader
|
||||
import io.legato.kazusa.help.glide.OkHttpModelLoader
|
||||
//import io.legado.app.lib.theme.accentColor
|
||||
import io.legato.kazusa.model.BookCover
|
||||
import io.legato.kazusa.utils.spToPx
|
||||
import io.legato.kazusa.utils.textHeight
|
||||
import io.legato.kazusa.utils.themeColor
|
||||
import io.legato.kazusa.utils.toStringArray
|
||||
|
||||
/**
|
||||
@@ -117,49 +119,63 @@ class CoverImageView @JvmOverloads constructor(
|
||||
}
|
||||
|
||||
private fun drawNameAuthor(canvas: Canvas) {
|
||||
if (!BookCover.drawBookName) return
|
||||
var startX = width * 0.2f
|
||||
var startY = viewHeight * 0.2f
|
||||
name?.toStringArray()?.let { name ->
|
||||
namePaint.textSize = viewWidth / 6
|
||||
namePaint.strokeWidth = namePaint.textSize / 5
|
||||
name.forEachIndexed { index, char ->
|
||||
namePaint.color = Color.WHITE
|
||||
namePaint.style = Paint.Style.STROKE
|
||||
canvas.drawText(char, startX, startY, namePaint)
|
||||
//namePaint.color = context.accentColor
|
||||
namePaint.style = Paint.Style.FILL
|
||||
canvas.drawText(char, startX, startY, namePaint)
|
||||
startY += namePaint.textHeight
|
||||
if (startY > viewHeight * 0.8) {
|
||||
startX += namePaint.textSize
|
||||
namePaint.textSize = viewWidth / 10
|
||||
startY = (viewHeight - (name.size - index - 1) * namePaint.textHeight) / 2
|
||||
if (BookCover.drawBookName) {
|
||||
var startX = width * 0.2f
|
||||
var startY = viewHeight * 0.2f
|
||||
|
||||
name?.toStringArray()?.let { nameChars ->
|
||||
val textSize = viewWidth / 8
|
||||
namePaint.textSize = textSize
|
||||
namePaint.strokeWidth = textSize / 8
|
||||
|
||||
nameChars.forEach { char ->
|
||||
namePaint.color = Color.WHITE
|
||||
namePaint.style = Paint.Style.STROKE
|
||||
canvas.drawText(char, startX, startY, namePaint)
|
||||
|
||||
namePaint.color = context.themeColor(androidx.appcompat.R.attr.colorPrimary)
|
||||
namePaint.style = Paint.Style.FILL
|
||||
canvas.drawText(char, startX, startY, namePaint)
|
||||
|
||||
startY += namePaint.textHeight
|
||||
|
||||
if (startY > viewHeight * 0.8f) {
|
||||
startX += textSize + 4.spToPx()
|
||||
startY = viewHeight * 0.2f
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!BookCover.drawBookAuthor) return
|
||||
author?.toStringArray()?.let { author ->
|
||||
authorPaint.textSize = viewWidth / 10
|
||||
authorPaint.strokeWidth = authorPaint.textSize / 5
|
||||
startX = width * 0.8f
|
||||
startY = viewHeight * 0.95f - author.size * authorPaint.textHeight
|
||||
startY = maxOf(startY, viewHeight * 0.3f)
|
||||
author.forEach {
|
||||
authorPaint.color = Color.WHITE
|
||||
authorPaint.style = Paint.Style.STROKE
|
||||
canvas.drawText(it, startX, startY, authorPaint)
|
||||
//authorPaint.color = context.accentColor
|
||||
authorPaint.style = Paint.Style.FILL
|
||||
canvas.drawText(it, startX, startY, authorPaint)
|
||||
startY += authorPaint.textHeight
|
||||
if (startY > viewHeight * 0.95) {
|
||||
return@let
|
||||
|
||||
if (BookCover.drawBookAuthor) {
|
||||
author?.toStringArray()?.let { authorChars ->
|
||||
val textSize = viewWidth / 10
|
||||
authorPaint.textSize = textSize
|
||||
authorPaint.strokeWidth = textSize / 5
|
||||
|
||||
var startX = width * 0.8f
|
||||
var startY = viewHeight * 0.8f
|
||||
|
||||
authorChars.forEach { char ->
|
||||
|
||||
authorPaint.color = Color.WHITE
|
||||
authorPaint.style = Paint.Style.STROKE
|
||||
canvas.drawText(char, startX, startY, authorPaint)
|
||||
|
||||
authorPaint.color =
|
||||
context.themeColor(com.google.android.material.R.attr.colorSecondary)
|
||||
authorPaint.style = Paint.Style.FILL
|
||||
canvas.drawText(char, startX, startY, authorPaint)
|
||||
|
||||
startY += authorPaint.textHeight
|
||||
|
||||
if (startY > viewHeight * 0.95f) return@let
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fun setHeight(height: Int) {
|
||||
val width = height * 5 / 7
|
||||
minimumWidth = width
|
||||
|
||||
Reference in New Issue
Block a user