diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/download/DownloadButton.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/download/DownloadButton.kt index 1d0f8965ed..c48125539a 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/download/DownloadButton.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/download/DownloadButton.kt @@ -22,64 +22,46 @@ class DownloadButton @JvmOverloads constructor(context: Context, attrs: Attribut var colorSecondary = context.getResourceColor(R.attr.colorSecondary) set(value) { field = value - activeColor = ColorUtils.blendARGB( - colorSecondary, - context.getResourceColor(R.attr.background), - 0.05f, - ) - downloadedColor = ColorUtils.blendARGB( - colorSecondary, - context.getResourceColor(R.attr.colorOnBackground), - 0.3f, - ) + activeColor = colorSecondary + downloadedColor = colorSecondary } - private var activeColor = ColorUtils.blendARGB( - colorSecondary, - context.getResourceColor(R.attr.background), - 0.05f, - ) - private val progressBGColor = ContextCompat.getColor( - context, - R.color.divider, - ) - private val disabledColor = ContextCompat.getColor( - context, - R.color.material_on_surface_disabled, - ) - private var downloadedColor = ColorUtils.blendARGB( - colorSecondary, - context.getResourceColor(R.attr.colorOnBackground), - 0.3f, - ) + private var activeColor = colorSecondary + set(value) { + ColorUtils.blendARGB(value, context.getResourceColor(R.attr.background), 0.05f) + } + + private var downloadedColor = colorSecondary + set(value) { + ColorUtils.blendARGB(value, context.getResourceColor(R.attr.colorOnBackground), 0.3f) + } + private val progressBGColor by lazy { + ContextCompat.getColor(context, R.color.divider) + } + private val disabledColor by lazy { + ContextCompat.getColor(context, R.color.material_on_surface_disabled) + } private val downloadedTextColor = context.getResourceColor(R.attr.background) - private val errorColor = ContextCompat.getColor( - context, - R.color.material_red_500, - ) - private val filledCircle = ContextCompat.getDrawable( - context, - R.drawable.filled_circle, - )?.mutate() - private val borderCircle = ContextCompat.getDrawable( - context, - R.drawable.border_circle, - )?.mutate() - private val downloadDrawable = ContextCompat.getDrawable( - context, - R.drawable.ic_arrow_downward_24dp, - )?.mutate() - private val checkDrawable = ContextCompat.getDrawable( - context, - R.drawable.ic_check_24dp, - )?.mutate() - private val filledAnim = AnimatedVectorDrawableCompat.create( - context, - R.drawable.anim_outline_to_filled, - ) - private val checkAnim = AnimatedVectorDrawableCompat.create( - context, - R.drawable.anim_dl_to_check_to_dl, - ) + private val errorColor by lazy { + ContextCompat.getColor(context, R.color.material_red_500) + } + private val filledCircle by lazy { + ContextCompat.getDrawable(context, R.drawable.filled_circle)?.mutate() + } + private val borderCircle by lazy { + ContextCompat.getDrawable(context, R.drawable.border_circle)?.mutate() + } + private val downloadDrawable by lazy { + ContextCompat.getDrawable(context, R.drawable.ic_arrow_downward_24dp)?.mutate() + } + private val checkDrawable by lazy { + ContextCompat.getDrawable(context, R.drawable.ic_check_24dp)?.mutate() + } + private val filledAnim by lazy { + AnimatedVectorDrawableCompat.create(context, R.drawable.anim_outline_to_filled) + } + private val checkAnim by lazy { + AnimatedVectorDrawableCompat.create(context, R.drawable.anim_dl_to_check_to_dl) + } private var isAnimating = false private var iconAnimation: ObjectAnimator? = null diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/recents/RecentMangaHolder.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/recents/RecentMangaHolder.kt index cff36bc65f..0763a445fc 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/recents/RecentMangaHolder.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/recents/RecentMangaHolder.kt @@ -59,12 +59,15 @@ class RecentMangaHolder( ) if (moreVisible) { binding.moreChaptersLayout.children.forEach { view -> - try { - RecentSubChapterItemBinding.bind(view).updateDivider() - } catch (_: Exception) { - } + RecentSubChapterItemBinding.bind(view).updateDivider() } } + if (binding.moreChaptersLayout.children.any { view -> + !RecentSubChapterItemBinding.bind(view).subtitle.text.isNullOrBlank() + } + ) { + showScanlatorInBody(moreVisible) + } binding.endView.updateLayoutParams { height = binding.mainView.height } @@ -223,15 +226,34 @@ class RecentMangaHolder( RecentSubChapterItemBinding.bind(binding.moreChaptersLayout.getChildAt(index)) .configureView(chapter, item) } + if (binding.moreChaptersLayout.children.any { view -> + !RecentSubChapterItemBinding.bind(view).subtitle.text.isNullOrBlank() + } + ) { + showScanlatorInBody(moreVisible, item) + } } else { binding.moreChaptersLayout.removeAllViews() + var hasSameChapter = false if (item.mch.extraChapters.isNotEmpty()) { item.mch.extraChapters.forEach { chapter -> - RecentSubChapterItemBinding.inflate( + val binding = RecentSubChapterItemBinding.inflate( LayoutInflater.from(context), binding.moreChaptersLayout, true, - ).configureView(chapter, item) + ) + binding.configureView(chapter, item) + if (chapter.isRecognizedNumber && + chapter.chapter_number == item.chapter.chapter_number && + !chapter.scanlator.isNullOrBlank() + ) { + binding.subtitle.text = chapter.scanlator + binding.subtitle.isVisible = true + if (!hasSameChapter) { + showScanlatorInBody(moreVisible, item) + hasSameChapter = true + } + } } } else { chapterId = null @@ -254,6 +276,29 @@ class RecentMangaHolder( } } + private fun showScanlatorInBody(add: Boolean, originalItem: RecentMangaItem? = null) { + val item = originalItem ?: adapter.getItem(bindingAdapterPosition) as? RecentMangaItem ?: return + val originalText = binding.body.text + binding.body.maxLines = 2 + val scanlator = item.chapter.scanlator ?: return + if (add) { + if (isSmallUpdates) { + binding.body.maxLines = 1 + binding.body.text = item.chapter.scanlator + binding.body.isVisible = true + } else if (!originalText.contains(scanlator)) { + val text = "$originalText\n$scanlator" + binding.body.text = text + } + } else { + if (isSmallUpdates) { + binding.body.isVisible = false + } else { + binding.body.text = originalText.removeSuffix("\n$scanlator") + } + } + } + @SuppressLint("ClickableViewAccessibility") private fun RecentSubChapterItemBinding.configureView(chapter: Chapter, item: RecentMangaItem) { val context = itemView.context @@ -282,7 +327,7 @@ class RecentMangaHolder( false } } - title.updatePaddingRelative(start = if (isSmallUpdates) 64.dpToPx else 84.dpToPx) + textLayout.updatePaddingRelative(start = if (isSmallUpdates) 64.dpToPx else 84.dpToPx) updateDivider() root.transitionName = "recents sub chapter ${chapter.id ?: 0L} transition" root.tag = "sub ${chapter.id}" diff --git a/app/src/main/res/layout/download_button.xml b/app/src/main/res/layout/download_button.xml index a93780ddf2..023e7f9d0e 100644 --- a/app/src/main/res/layout/download_button.xml +++ b/app/src/main/res/layout/download_button.xml @@ -5,8 +5,8 @@ android:id="@+id/download_button" android:clickable="true" android:focusable="true" - android:layout_width="30dp" - android:layout_height="30dp"> + android:layout_width="32dp" + android:layout_height="32dp"> - + android:layout_height="wrap_content"> + + + + + \ No newline at end of file