mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-12-23 20:21:49 +01:00
Use bookmark icon instead of changing text color
Didn't look at the upstream code for this, but maybe should've
This commit is contained in:
parent
6341077abf
commit
27bc2bacfb
@ -47,10 +47,7 @@ class ChapterHolder(
|
||||
localSource = manga.source == LocalSource.ID
|
||||
download_button.visibleIf(!localSource && !isLocked)
|
||||
|
||||
val chapterColor = ChapterUtil.chapterColor(itemView.context, item, isLocked)
|
||||
|
||||
// Set correct text color
|
||||
chapter_title.setTextColor(chapterColor)
|
||||
ChapterUtil.setTextViewForChapter(chapter_title, item, hideStatus = isLocked)
|
||||
|
||||
val statuses = mutableListOf<String>()
|
||||
|
||||
@ -83,7 +80,9 @@ class ChapterHolder(
|
||||
)
|
||||
}
|
||||
// this will color the scanlator the same bookmarks
|
||||
chapter_scanlator.setTextColor(chapterColor)
|
||||
ChapterUtil.setTextViewForChapter(
|
||||
chapter_scanlator, item, showBookmark = false, hideStatus = isLocked
|
||||
)
|
||||
chapter_scanlator.text = statuses.joinToString(" • ")
|
||||
|
||||
val status = when {
|
||||
@ -94,8 +93,7 @@ class ChapterHolder(
|
||||
notifyStatus(status, item.isLocked, item.progress)
|
||||
resetFrontView()
|
||||
if (adapterPosition == 1) {
|
||||
if (!adapter.hasShownSwipeTut.get())
|
||||
showSlideAnimation()
|
||||
if (!adapter.hasShownSwipeTut.get()) showSlideAnimation()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -16,8 +16,8 @@ import java.text.DecimalFormat
|
||||
import java.text.DecimalFormatSymbols
|
||||
|
||||
class ReaderChapterItem(val chapter: Chapter, val manga: Manga, val isCurrent: Boolean) :
|
||||
AbstractItem<ReaderChapterItem.ViewHolder>
|
||||
() {
|
||||
AbstractItem<ReaderChapterItem.ViewHolder>(),
|
||||
Chapter by chapter {
|
||||
|
||||
val decimalFormat =
|
||||
DecimalFormat("#.###", DecimalFormatSymbols().apply { decimalSeparator = '.' })
|
||||
@ -28,9 +28,7 @@ class ReaderChapterItem(val chapter: Chapter, val manga: Manga, val isCurrent: B
|
||||
/** defines the layout which will be used for this item in the list */
|
||||
override val layoutRes: Int = R.layout.reader_chapter_item
|
||||
|
||||
override var identifier: Long
|
||||
get() = chapter.id!!
|
||||
set(value) {}
|
||||
override var identifier: Long = chapter.id!!
|
||||
|
||||
override fun getViewHolder(v: View): ViewHolder {
|
||||
return ViewHolder(v)
|
||||
@ -43,23 +41,22 @@ class ReaderChapterItem(val chapter: Chapter, val manga: Manga, val isCurrent: B
|
||||
private var bookmarkImage: ImageView = view.findViewById(R.id.bookmark_image)
|
||||
|
||||
override fun bindView(item: ReaderChapterItem, payloads: List<Any>) {
|
||||
val chapter = item.chapter
|
||||
val manga = item.manga
|
||||
|
||||
val chapterColor = ChapterUtil.chapterColor(itemView.context, item.chapter)
|
||||
|
||||
chapterTitle.setTextColor(chapterColor)
|
||||
ChapterUtil.setTextViewForChapter(chapterTitle, item)
|
||||
chapterTitle.text = when (manga.displayMode) {
|
||||
Manga.DISPLAY_NUMBER -> {
|
||||
val number = item.decimalFormat.format(chapter.chapter_number.toDouble())
|
||||
val number = item.decimalFormat.format(item.chapter_number.toDouble())
|
||||
itemView.context.getString(R.string.chapter_, number)
|
||||
}
|
||||
else -> chapter.name
|
||||
else -> item.name
|
||||
}
|
||||
|
||||
val statuses = mutableListOf<String>()
|
||||
ChapterUtil.relativeDate(chapter)?.let { statuses.add(it) }
|
||||
chapter.scanlator?.isNotBlank()?.let { statuses.add(chapter.scanlator!!) }
|
||||
ChapterUtil.relativeDate(item)?.let { statuses.add(it) }
|
||||
item.scanlator?.isNotBlank()?.let { statuses.add(item.scanlator!!) }
|
||||
|
||||
if (item.isCurrent) {
|
||||
chapterTitle.setTypeface(null, Typeface.BOLD_ITALIC)
|
||||
@ -73,11 +70,11 @@ class ReaderChapterItem(val chapter: Chapter, val manga: Manga, val isCurrent: B
|
||||
chapterSubtitle.setTextColor(chapterColor)
|
||||
|
||||
bookmarkImage.setImageResource(
|
||||
if (chapter.bookmark) R.drawable.ic_bookmark_24dp
|
||||
if (item.bookmark) R.drawable.ic_bookmark_24dp
|
||||
else R.drawable.ic_bookmark_border_24dp
|
||||
)
|
||||
|
||||
val drawableColor = ChapterUtil.bookmarkColor(itemView.context, chapter)
|
||||
val drawableColor = ChapterUtil.bookmarkColor(itemView.context, item)
|
||||
|
||||
DrawableCompat.setTint(bookmarkImage.drawable, drawableColor)
|
||||
|
||||
|
@ -38,7 +38,7 @@ class RecentMangaHolder(
|
||||
|
||||
title.apply {
|
||||
text = item.chapter.name
|
||||
setTextColor(ChapterUtil.chapterColor(context, item))
|
||||
ChapterUtil.setTextViewForChapter(this, item)
|
||||
}
|
||||
subtitle.apply {
|
||||
text = item.mch.manga.title
|
||||
|
@ -1,10 +1,15 @@
|
||||
package eu.kanade.tachiyomi.util.chapter
|
||||
|
||||
import android.content.Context
|
||||
import android.content.res.ColorStateList
|
||||
import android.widget.TextView
|
||||
import androidx.core.graphics.ColorUtils
|
||||
import androidx.vectordrawable.graphics.drawable.VectorDrawableCompat
|
||||
import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.data.database.models.Chapter
|
||||
import eu.kanade.tachiyomi.util.system.contextCompatColor
|
||||
import eu.kanade.tachiyomi.util.system.dpToPx
|
||||
import eu.kanade.tachiyomi.util.system.dpToPxEnd
|
||||
import eu.kanade.tachiyomi.util.system.timeSpanFromNow
|
||||
|
||||
class ChapterUtil {
|
||||
@ -17,11 +22,43 @@ class ChapterUtil {
|
||||
}
|
||||
}
|
||||
|
||||
fun setTextViewForChapter(
|
||||
textView: TextView,
|
||||
chapter: Chapter,
|
||||
showBookmark: Boolean = true,
|
||||
hideStatus: Boolean = false
|
||||
) {
|
||||
val context = textView.context
|
||||
textView.setTextColor(chapterColor(context, chapter, hideStatus))
|
||||
if (!hideStatus && showBookmark) {
|
||||
setBookmark(textView, chapter)
|
||||
}
|
||||
}
|
||||
|
||||
fun setBookmark(textView: TextView, chapter: Chapter) {
|
||||
if (chapter.bookmark) {
|
||||
val context = textView.context
|
||||
val drawable = VectorDrawableCompat.create(
|
||||
textView.resources, R.drawable.ic_bookmark_24dp, context.theme
|
||||
)
|
||||
drawable?.setBounds(0, 0, textView.textSize.toInt(), textView.textSize.toInt())
|
||||
textView.setCompoundDrawablesRelative(
|
||||
drawable, null, null, null
|
||||
)
|
||||
textView.compoundDrawableTintList = ColorStateList.valueOf(
|
||||
bookmarkedColor(context)
|
||||
)
|
||||
textView.compoundDrawablePadding = 3.dpToPx
|
||||
textView.translationX = (-2f).dpToPxEnd
|
||||
} else {
|
||||
textView.setCompoundDrawablesRelative(null, null, null, null)
|
||||
textView.translationX = 0f
|
||||
}
|
||||
}
|
||||
|
||||
fun chapterColor(context: Context, chapter: Chapter, hideStatus: Boolean = false): Int {
|
||||
return when {
|
||||
hideStatus -> unreadColor(context)
|
||||
chapter.bookmark && chapter.read -> bookmarkedAndReadColor(context)
|
||||
chapter.bookmark -> bookmarkedColor(context)
|
||||
chapter.read -> readColor(context)
|
||||
else -> unreadColor(context)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user