Fix text alignment in transition view when no more chapters available

This commit is contained in:
arkon 2020-09-05 10:31:49 -04:00
parent 5e2e177aa9
commit b55d394a1f
3 changed files with 9 additions and 10 deletions

View File

@ -2,7 +2,6 @@ package eu.kanade.tachiyomi.ui.reader.viewer
import android.content.Context
import android.util.AttributeSet
import android.view.Gravity
import android.widget.LinearLayout
import androidx.core.text.bold
import androidx.core.text.buildSpannedString
@ -15,7 +14,7 @@ import kotlinx.android.synthetic.main.reader_transition_view.view.upper_text
import kotlinx.android.synthetic.main.reader_transition_view.view.warning
import kotlinx.android.synthetic.main.reader_transition_view.view.warning_text
class TransitionView @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) :
class ReaderTransitionView @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) :
LinearLayout(context, attrs) {
init {
@ -40,7 +39,7 @@ class TransitionView @JvmOverloads constructor(context: Context, attrs: Attribut
val hasPrevChapter = prevChapter != null
lower_text.isVisible = hasPrevChapter
if (hasPrevChapter) {
gravity = Gravity.CENTER_VERTICAL
upper_text.textAlignment = TEXT_ALIGNMENT_TEXT_START
upper_text.text = buildSpannedString {
bold { append(context.getString(R.string.transition_current)) }
append("\n${transition.from.chapter.name}")
@ -50,7 +49,7 @@ class TransitionView @JvmOverloads constructor(context: Context, attrs: Attribut
append("\n${prevChapter!!.chapter.name}")
}
} else {
gravity = Gravity.CENTER
upper_text.textAlignment = TEXT_ALIGNMENT_CENTER
upper_text.text = context.getString(R.string.transition_no_previous)
}
}
@ -64,7 +63,7 @@ class TransitionView @JvmOverloads constructor(context: Context, attrs: Attribut
val hasNextChapter = nextChapter != null
lower_text.isVisible = hasNextChapter
if (hasNextChapter) {
gravity = Gravity.CENTER_VERTICAL
upper_text.textAlignment = TEXT_ALIGNMENT_TEXT_START
upper_text.text = buildSpannedString {
bold { append(context.getString(R.string.transition_finished)) }
append("\n${transition.from.chapter.name}")
@ -74,7 +73,7 @@ class TransitionView @JvmOverloads constructor(context: Context, attrs: Attribut
append("\n${nextChapter!!.chapter.name}")
}
} else {
gravity = Gravity.CENTER
upper_text.textAlignment = TEXT_ALIGNMENT_CENTER
upper_text.text = context.getString(R.string.transition_no_next)
}
}

View File

@ -12,7 +12,7 @@ import androidx.appcompat.widget.AppCompatTextView
import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.ui.reader.model.ChapterTransition
import eu.kanade.tachiyomi.ui.reader.model.ReaderChapter
import eu.kanade.tachiyomi.ui.reader.viewer.TransitionView
import eu.kanade.tachiyomi.ui.reader.viewer.ReaderTransitionView
import eu.kanade.tachiyomi.util.system.dpToPx
import eu.kanade.tachiyomi.widget.ViewPagerAdapter
import rx.Subscription
@ -54,7 +54,7 @@ class PagerTransitionHolder(
val sidePadding = 64.dpToPx
setPadding(sidePadding, 0, sidePadding, 0)
val transitionView = TransitionView(context)
val transitionView = ReaderTransitionView(context)
addView(transitionView)
addView(pagesContainer)

View File

@ -12,7 +12,7 @@ import androidx.core.view.isVisible
import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.ui.reader.model.ChapterTransition
import eu.kanade.tachiyomi.ui.reader.model.ReaderChapter
import eu.kanade.tachiyomi.ui.reader.viewer.TransitionView
import eu.kanade.tachiyomi.ui.reader.viewer.ReaderTransitionView
import eu.kanade.tachiyomi.util.system.dpToPx
import rx.Subscription
import rx.android.schedulers.AndroidSchedulers
@ -30,7 +30,7 @@ class WebtoonTransitionHolder(
*/
private var statusSubscription: Subscription? = null
private val transitionView = TransitionView(context)
private val transitionView = ReaderTransitionView(context)
/**
* View container of the current status of the transition page. Child views will be added