From c38026886afd9df3221f8725c397fdf9d28255b7 Mon Sep 17 00:00:00 2001 From: arkon Date: Fri, 6 Mar 2020 22:46:21 -0500 Subject: [PATCH] Combine chapter date/scanlator lines --- .../ui/manga/chapter/ChapterHolder.kt | 42 +++++++++---------- app/src/main/res/layout/chapters_item.xml | 31 ++------------ 2 files changed, 23 insertions(+), 50 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/ChapterHolder.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/ChapterHolder.kt index 45e07801f2..98f25b44ae 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/ChapterHolder.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/ChapterHolder.kt @@ -6,12 +6,9 @@ import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.data.database.models.Manga import eu.kanade.tachiyomi.data.download.model.Download import eu.kanade.tachiyomi.ui.base.holder.BaseFlexibleViewHolder -import eu.kanade.tachiyomi.util.view.gone import java.util.Date -import kotlinx.android.synthetic.main.chapters_item.chapter_date +import kotlinx.android.synthetic.main.chapters_item.chapter_description import kotlinx.android.synthetic.main.chapters_item.chapter_menu -import kotlinx.android.synthetic.main.chapters_item.chapter_pages -import kotlinx.android.synthetic.main.chapters_item.chapter_scanlator import kotlinx.android.synthetic.main.chapters_item.chapter_title import kotlinx.android.synthetic.main.chapters_item.download_text @@ -39,30 +36,29 @@ class ChapterHolder( } // Set correct text color - chapter_title.setTextColor(if (chapter.read) adapter.readColor else adapter.unreadColor) - if (chapter.bookmark) chapter_title.setTextColor(adapter.bookmarkedColor) + val chapterColor = if (chapter.read) adapter.readColor else adapter.unreadColor + chapter_title.setTextColor(chapterColor) + chapter_description.setTextColor(chapterColor) + if (chapter.bookmark) { + chapter_title.setTextColor(adapter.bookmarkedColor) + } + + val descriptions = mutableListOf() if (chapter.date_upload > 0) { - chapter_date.text = adapter.dateFormat.format(Date(chapter.date_upload)) - chapter_date.setTextColor(if (chapter.read) adapter.readColor else adapter.unreadColor) - } else { - chapter_date.text = "" + descriptions.add(adapter.dateFormat.format(Date(chapter.date_upload))) + } + if (!chapter.scanlator.isNullOrBlank()) { + descriptions.add(chapter.scanlator!!) + } + if (!chapter.read && chapter.last_page_read > 0) { + descriptions.add(itemView.context.getString(R.string.chapter_progress, chapter.last_page_read + 1)) } - // add scanlator if exists - chapter_scanlator.text = chapter.scanlator - // allow longer titles if there is no scanlator (most sources) - if (chapter_scanlator.text.isNullOrBlank()) { - chapter_title.maxLines = 2 - chapter_scanlator.gone() + if (descriptions.isNotEmpty()) { + chapter_description.text = descriptions.joinToString(" • ") } else { - chapter_title.maxLines = 1 - } - - chapter_pages.text = if (!chapter.read && chapter.last_page_read > 0) { - itemView.context.getString(R.string.chapter_progress, chapter.last_page_read + 1) - } else { - "" + chapter_description.text = "" } notifyStatus(item.status) diff --git a/app/src/main/res/layout/chapters_item.xml b/app/src/main/res/layout/chapters_item.xml index d88cfffdd7..bed5fb8b42 100644 --- a/app/src/main/res/layout/chapters_item.xml +++ b/app/src/main/res/layout/chapters_item.xml @@ -21,41 +21,17 @@ tools:text="Title" /> - - - - + tools:text="22/02/2016 • Scanlator • Page: 45" />