Better page transition text alignment

This commit is contained in:
inorichi 2018-10-09 13:46:44 +02:00
parent 7a45cd5b56
commit 790e0908a3
3 changed files with 49 additions and 13 deletions

View file

@ -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)
}

View file

@ -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)
}

View file

@ -420,14 +420,14 @@
<string name="chapter_subtitle">Chapter %1$s</string>
<string name="no_next_chapter">Next chapter not found</string>
<string name="no_previous_chapter">Previous chapter not found</string>
<string name="decode_image_error">Image could not be loaded.\nTry changing the image decoder or with one of the options below</string>
<string name="decode_image_error">The image could not be decoded</string>
<string name="confirm_update_manga_sync">Update last chapter read in enabled services to %1$d?</string>
<string name="confirm_set_image_as_cover">Do you want to set this image as the cover?</string>
<string name="viewer_for_this_series">Viewer for this series</string>
<string name="transition_finished">Finished: %1$s</string>
<string name="transition_current">Current: %1$s</string>
<string name="transition_next">Next: %1$s</string>
<string name="transition_previous">Previous: %1$s</string>
<string name="transition_finished">Finished:</string>
<string name="transition_current">Current:</string>
<string name="transition_next">Next:</string>
<string name="transition_previous">Previous:</string>
<string name="transition_no_next">There\'s no next chapter</string>
<string name="transition_no_previous">There\'s no previous chapter</string>
<string name="transition_pages_loading">Loading pages…</string>