From 4ef25c75b763811439bbd9a5512a22a14c864194 Mon Sep 17 00:00:00 2001 From: arkon Date: Tue, 18 Aug 2020 17:40:17 -0400 Subject: [PATCH] Use core-ktx for bolding chapter transition text --- .../viewer/pager/PagerTransitionHolder.kt | 18 +++++------------- .../viewer/webtoon/WebtoonTransitionHolder.kt | 18 +++++------------- 2 files changed, 10 insertions(+), 26 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/PagerTransitionHolder.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/PagerTransitionHolder.kt index ed93fa3d17..f116b2600f 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/PagerTransitionHolder.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/PagerTransitionHolder.kt @@ -1,9 +1,6 @@ package eu.kanade.tachiyomi.ui.reader.viewer.pager import android.annotation.SuppressLint -import android.graphics.Typeface -import android.text.Spanned -import android.text.style.StyleSpan import android.view.Gravity import android.view.View import android.view.ViewGroup @@ -13,6 +10,7 @@ import android.widget.LinearLayout import android.widget.ProgressBar import android.widget.TextView import androidx.appcompat.widget.AppCompatTextView +import androidx.core.text.bold import androidx.core.text.buildSpannedString import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.ui.reader.model.ChapterTransition @@ -91,12 +89,9 @@ class PagerTransitionHolder( textView.text = if (nextChapter != null) { buildSpannedString { - append(context.getString(R.string.transition_finished)) - setSpan(StyleSpan(Typeface.BOLD), 0, length, Spanned.SPAN_INCLUSIVE_EXCLUSIVE) + bold { append(context.getString(R.string.transition_finished)) } append("\n${transition.from.chapter.name}\n\n") - val currSize = length - append(context.getString(R.string.transition_next)) - setSpan(StyleSpan(Typeface.BOLD), currSize, length, Spanned.SPAN_INCLUSIVE_EXCLUSIVE) + bold { append(context.getString(R.string.transition_next)) } append("\n${nextChapter.chapter.name}\n\n") } } else { @@ -116,12 +111,9 @@ class PagerTransitionHolder( textView.text = if (prevChapter != null) { buildSpannedString { - append(context.getString(R.string.transition_current)) - setSpan(StyleSpan(Typeface.BOLD), 0, length, Spanned.SPAN_INCLUSIVE_EXCLUSIVE) + bold { append(context.getString(R.string.transition_current)) } append("\n${transition.from.chapter.name}\n\n") - val currSize = length - append(context.getString(R.string.transition_previous)) - setSpan(StyleSpan(Typeface.BOLD), currSize, length, Spanned.SPAN_INCLUSIVE_EXCLUSIVE) + bold { append(context.getString(R.string.transition_previous)) } append("\n${prevChapter.chapter.name}\n\n") } } else { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonTransitionHolder.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonTransitionHolder.kt index b45ed13de1..e220b06805 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonTransitionHolder.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonTransitionHolder.kt @@ -1,8 +1,5 @@ package eu.kanade.tachiyomi.ui.reader.viewer.webtoon -import android.graphics.Typeface -import android.text.Spanned -import android.text.style.StyleSpan import android.view.Gravity import android.view.ViewGroup.LayoutParams.MATCH_PARENT import android.view.ViewGroup.LayoutParams.WRAP_CONTENT @@ -11,6 +8,7 @@ import android.widget.ProgressBar import android.widget.TextView import androidx.appcompat.widget.AppCompatButton import androidx.appcompat.widget.AppCompatTextView +import androidx.core.text.bold import androidx.core.text.buildSpannedString import androidx.core.view.isNotEmpty import androidx.core.view.isVisible @@ -94,12 +92,9 @@ class WebtoonTransitionHolder( textView.text = if (nextChapter != null) { buildSpannedString { - append(context.getString(R.string.transition_finished)) - setSpan(StyleSpan(Typeface.BOLD), 0, length, Spanned.SPAN_INCLUSIVE_EXCLUSIVE) + bold { append(context.getString(R.string.transition_finished)) } append("\n${transition.from.chapter.name}\n\n") - val currSize = length - append(context.getString(R.string.transition_next)) - setSpan(StyleSpan(Typeface.BOLD), currSize, length, Spanned.SPAN_INCLUSIVE_EXCLUSIVE) + bold { append(context.getString(R.string.transition_next)) } append("\n${nextChapter.chapter.name}\n\n") } } else { @@ -119,12 +114,9 @@ class WebtoonTransitionHolder( textView.text = if (prevChapter != null) { buildSpannedString { - append(context.getString(R.string.transition_current)) - setSpan(StyleSpan(Typeface.BOLD), 0, length, Spanned.SPAN_INCLUSIVE_EXCLUSIVE) + bold { append(context.getString(R.string.transition_current)) } append("\n${transition.from.chapter.name}\n\n") - val currSize = length - append(context.getString(R.string.transition_previous)) - setSpan(StyleSpan(Typeface.BOLD), currSize, length, Spanned.SPAN_INCLUSIVE_EXCLUSIVE) + bold { append(context.getString(R.string.transition_previous)) } append("\n${prevChapter.chapter.name}\n\n") } } else {