Change color of 'last page read' in chapter description (#2855)

Change color of 'last page read' in chapter description
This commit is contained in:
FlaminSarge 2020-04-10 05:37:58 -07:00 committed by GitHub
parent 0b811773e1
commit 9044760a10
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,5 +1,8 @@
package eu.kanade.tachiyomi.ui.manga.chapter
import android.text.SpannableString
import android.text.SpannableStringBuilder
import android.text.style.ForegroundColorSpan
import android.view.View
import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.data.database.models.Manga
@ -34,20 +37,23 @@ class ChapterHolder(
chapter_title.setTextColor(adapter.bookmarkedColor)
}
val descriptions = mutableListOf<String>()
val descriptions = mutableListOf<CharSequence>()
if (chapter.date_upload > 0) {
descriptions.add(adapter.dateFormat.format(Date(chapter.date_upload)))
}
if (!chapter.read && chapter.last_page_read > 0) {
descriptions.add(itemView.context.getString(R.string.chapter_progress, chapter.last_page_read + 1))
val lastPageRead = SpannableString(itemView.context.getString(R.string.chapter_progress, chapter.last_page_read + 1)).apply {
setSpan(ForegroundColorSpan(adapter.bookmarkedColor), 0, length, SpannableString.SPAN_EXCLUSIVE_EXCLUSIVE)
}
descriptions.add(lastPageRead)
}
if (!chapter.scanlator.isNullOrBlank()) {
descriptions.add(chapter.scanlator!!)
}
if (descriptions.isNotEmpty()) {
chapter_description.text = descriptions.joinToString("")
chapter_description.text = descriptions.joinTo(SpannableStringBuilder(), "")
} else {
chapter_description.text = ""
}