From 790e0908a3ffd5d875a9cbf9972091545a3e5a3c Mon Sep 17 00:00:00 2001 From: inorichi Date: Tue, 9 Oct 2018 13:46:44 +0200 Subject: [PATCH] Better page transition text alignment --- .../viewer/pager/PagerTransitionHolder.kt | 26 ++++++++++++++++--- .../viewer/webtoon/WebtoonTransitionHolder.kt | 26 ++++++++++++++++--- app/src/main/res/values/strings.xml | 10 +++---- 3 files changed, 49 insertions(+), 13 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 716d99872..ce33d09f0 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,7 +1,11 @@ package eu.kanade.tachiyomi.ui.reader.viewer.pager import android.annotation.SuppressLint +import android.graphics.Typeface import android.support.v7.widget.AppCompatTextView +import android.text.SpannableStringBuilder +import android.text.Spanned +import android.text.style.StyleSpan import android.view.Gravity import android.view.View import android.view.ViewGroup @@ -85,8 +89,15 @@ class PagerTransitionHolder( val nextChapter = transition.to textView.text = if (nextChapter != null) { - context.getString(R.string.transition_finished, transition.from.chapter.name) + "\n\n" + - context.getString(R.string.transition_next, nextChapter.chapter.name) + "\n\n" + SpannableStringBuilder().apply { + append(context.getString(R.string.transition_finished)) + setSpan(StyleSpan(Typeface.BOLD), 0, length, Spanned.SPAN_INCLUSIVE_EXCLUSIVE) + 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) + append("\n${nextChapter.chapter.name}\n\n") + } } else { context.getString(R.string.transition_no_next) } @@ -103,8 +114,15 @@ class PagerTransitionHolder( val prevChapter = transition.to textView.text = if (prevChapter != null) { - context.getString(R.string.transition_current, transition.from.chapter.name) + "\n\n" + - context.getString(R.string.transition_previous, prevChapter.chapter.name) + "\n\n" + SpannableStringBuilder().apply { + append(context.getString(R.string.transition_current)) + setSpan(StyleSpan(Typeface.BOLD), 0, length, Spanned.SPAN_INCLUSIVE_EXCLUSIVE) + 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) + append("\n${prevChapter.chapter.name}\n\n") + } } else { context.getString(R.string.transition_no_previous) } 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 6bbed6008..4a1812c2c 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,7 +1,11 @@ package eu.kanade.tachiyomi.ui.reader.viewer.webtoon +import android.graphics.Typeface import android.support.v7.widget.AppCompatButton import android.support.v7.widget.AppCompatTextView +import android.text.SpannableStringBuilder +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 @@ -85,8 +89,15 @@ class WebtoonTransitionHolder( val nextChapter = transition.to textView.text = if (nextChapter != null) { - context.getString(R.string.transition_finished, transition.from.chapter.name) + "\n\n" + - context.getString(R.string.transition_next, nextChapter.chapter.name) + SpannableStringBuilder().apply { + append(context.getString(R.string.transition_finished)) + setSpan(StyleSpan(Typeface.BOLD), 0, length, Spanned.SPAN_INCLUSIVE_EXCLUSIVE) + 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) + append("\n${nextChapter.chapter.name}\n\n") + } } else { context.getString(R.string.transition_no_next) } @@ -103,8 +114,15 @@ class WebtoonTransitionHolder( val prevChapter = transition.to textView.text = if (prevChapter != null) { - context.getString(R.string.transition_current, transition.from.chapter.name) + "\n\n" + - context.getString(R.string.transition_previous, prevChapter.chapter.name) + SpannableStringBuilder().apply { + append(context.getString(R.string.transition_current)) + setSpan(StyleSpan(Typeface.BOLD), 0, length, Spanned.SPAN_INCLUSIVE_EXCLUSIVE) + 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) + append("\n${prevChapter.chapter.name}\n\n") + } } else { context.getString(R.string.transition_no_previous) } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index ddd00452a..2ae703eaf 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -420,14 +420,14 @@ Chapter %1$s Next chapter not found Previous chapter not found - Image could not be loaded.\nTry changing the image decoder or with one of the options below + The image could not be decoded Update last chapter read in enabled services to %1$d? Do you want to set this image as the cover? Viewer for this series - Finished: %1$s - Current: %1$s - Next: %1$s - Previous: %1$s + Finished: + Current: + Next: + Previous: There\'s no next chapter There\'s no previous chapter Loading pages…