mirror of
https://github.com/mihonapp/mihon.git
synced 2024-11-21 20:47:03 -05:00
Fix text alignment in transition view when no more chapters available
This commit is contained in:
parent
5e2e177aa9
commit
b55d394a1f
3 changed files with 9 additions and 10 deletions
|
@ -2,7 +2,6 @@ package eu.kanade.tachiyomi.ui.reader.viewer
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.util.AttributeSet
|
import android.util.AttributeSet
|
||||||
import android.view.Gravity
|
|
||||||
import android.widget.LinearLayout
|
import android.widget.LinearLayout
|
||||||
import androidx.core.text.bold
|
import androidx.core.text.bold
|
||||||
import androidx.core.text.buildSpannedString
|
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
|
||||||
import kotlinx.android.synthetic.main.reader_transition_view.view.warning_text
|
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) {
|
LinearLayout(context, attrs) {
|
||||||
|
|
||||||
init {
|
init {
|
||||||
|
@ -40,7 +39,7 @@ class TransitionView @JvmOverloads constructor(context: Context, attrs: Attribut
|
||||||
val hasPrevChapter = prevChapter != null
|
val hasPrevChapter = prevChapter != null
|
||||||
lower_text.isVisible = hasPrevChapter
|
lower_text.isVisible = hasPrevChapter
|
||||||
if (hasPrevChapter) {
|
if (hasPrevChapter) {
|
||||||
gravity = Gravity.CENTER_VERTICAL
|
upper_text.textAlignment = TEXT_ALIGNMENT_TEXT_START
|
||||||
upper_text.text = buildSpannedString {
|
upper_text.text = buildSpannedString {
|
||||||
bold { append(context.getString(R.string.transition_current)) }
|
bold { append(context.getString(R.string.transition_current)) }
|
||||||
append("\n${transition.from.chapter.name}")
|
append("\n${transition.from.chapter.name}")
|
||||||
|
@ -50,7 +49,7 @@ class TransitionView @JvmOverloads constructor(context: Context, attrs: Attribut
|
||||||
append("\n${prevChapter!!.chapter.name}")
|
append("\n${prevChapter!!.chapter.name}")
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
gravity = Gravity.CENTER
|
upper_text.textAlignment = TEXT_ALIGNMENT_CENTER
|
||||||
upper_text.text = context.getString(R.string.transition_no_previous)
|
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
|
val hasNextChapter = nextChapter != null
|
||||||
lower_text.isVisible = hasNextChapter
|
lower_text.isVisible = hasNextChapter
|
||||||
if (hasNextChapter) {
|
if (hasNextChapter) {
|
||||||
gravity = Gravity.CENTER_VERTICAL
|
upper_text.textAlignment = TEXT_ALIGNMENT_TEXT_START
|
||||||
upper_text.text = buildSpannedString {
|
upper_text.text = buildSpannedString {
|
||||||
bold { append(context.getString(R.string.transition_finished)) }
|
bold { append(context.getString(R.string.transition_finished)) }
|
||||||
append("\n${transition.from.chapter.name}")
|
append("\n${transition.from.chapter.name}")
|
||||||
|
@ -74,7 +73,7 @@ class TransitionView @JvmOverloads constructor(context: Context, attrs: Attribut
|
||||||
append("\n${nextChapter!!.chapter.name}")
|
append("\n${nextChapter!!.chapter.name}")
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
gravity = Gravity.CENTER
|
upper_text.textAlignment = TEXT_ALIGNMENT_CENTER
|
||||||
upper_text.text = context.getString(R.string.transition_no_next)
|
upper_text.text = context.getString(R.string.transition_no_next)
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -12,7 +12,7 @@ import androidx.appcompat.widget.AppCompatTextView
|
||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
import eu.kanade.tachiyomi.ui.reader.model.ChapterTransition
|
import eu.kanade.tachiyomi.ui.reader.model.ChapterTransition
|
||||||
import eu.kanade.tachiyomi.ui.reader.model.ReaderChapter
|
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.util.system.dpToPx
|
||||||
import eu.kanade.tachiyomi.widget.ViewPagerAdapter
|
import eu.kanade.tachiyomi.widget.ViewPagerAdapter
|
||||||
import rx.Subscription
|
import rx.Subscription
|
||||||
|
@ -54,7 +54,7 @@ class PagerTransitionHolder(
|
||||||
val sidePadding = 64.dpToPx
|
val sidePadding = 64.dpToPx
|
||||||
setPadding(sidePadding, 0, sidePadding, 0)
|
setPadding(sidePadding, 0, sidePadding, 0)
|
||||||
|
|
||||||
val transitionView = TransitionView(context)
|
val transitionView = ReaderTransitionView(context)
|
||||||
addView(transitionView)
|
addView(transitionView)
|
||||||
addView(pagesContainer)
|
addView(pagesContainer)
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@ import androidx.core.view.isVisible
|
||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
import eu.kanade.tachiyomi.ui.reader.model.ChapterTransition
|
import eu.kanade.tachiyomi.ui.reader.model.ChapterTransition
|
||||||
import eu.kanade.tachiyomi.ui.reader.model.ReaderChapter
|
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.util.system.dpToPx
|
||||||
import rx.Subscription
|
import rx.Subscription
|
||||||
import rx.android.schedulers.AndroidSchedulers
|
import rx.android.schedulers.AndroidSchedulers
|
||||||
|
@ -30,7 +30,7 @@ class WebtoonTransitionHolder(
|
||||||
*/
|
*/
|
||||||
private var statusSubscription: Subscription? = null
|
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
|
* View container of the current status of the transition page. Child views will be added
|
||||||
|
|
Loading…
Reference in a new issue