Apply app theme styling to reader page errors and progress dialog (#5705)

This commit is contained in:
Hunter Nickel 2021-08-13 13:44:42 -06:00 committed by GitHub
parent feca30d7ed
commit d1bb0fdf1d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 6 deletions

View file

@ -97,6 +97,12 @@ class PagerPageHolder(
*/
private var readImageHeaderSubscription: Subscription? = null
/**
* Context that has been wrapped to use the correct theme values based on the
* current app theme and reader background color
*/
private val readerThemedContext = context.createReaderThemeContext(viewer.config.theme)
val stateChangedListener = object : SubsamplingScaleImageView.OnStateChangedListener {
override fun onScaleChanged(newScale: Float, origin: Int) {
viewer.activity.hideMenu()
@ -115,8 +121,7 @@ class PagerPageHolder(
}
init {
val indicatorContext = context.createReaderThemeContext(viewer.config.theme)
progressIndicator = ReaderProgressIndicator(indicatorContext).apply {
progressIndicator = ReaderProgressIndicator(readerThemedContext).apply {
updateLayoutParams<LayoutParams> {
gravity = Gravity.CENTER
}
@ -418,7 +423,7 @@ class PagerPageHolder(
private fun initRetryButton(): PagerButton {
if (retryButton != null) return retryButton!!
retryButton = PagerButton(context, viewer).apply {
retryButton = PagerButton(readerThemedContext, viewer).apply {
layoutParams = LayoutParams(WRAP_CONTENT, WRAP_CONTENT).apply {
gravity = Gravity.CENTER
}
@ -445,7 +450,7 @@ class PagerPageHolder(
}
decodeErrorLayout = decodeLayout
TextView(context).apply {
TextView(readerThemedContext).apply {
layoutParams = LinearLayout.LayoutParams(WRAP_CONTENT, WRAP_CONTENT).apply {
setMargins(margins, margins, margins, margins)
}
@ -455,7 +460,7 @@ class PagerPageHolder(
decodeLayout.addView(this)
}
PagerButton(context, viewer).apply {
PagerButton(readerThemedContext, viewer).apply {
layoutParams = LayoutParams(WRAP_CONTENT, WRAP_CONTENT).apply {
setMargins(margins, margins, margins, margins)
}
@ -469,7 +474,7 @@ class PagerPageHolder(
val imageUrl = page.imageUrl
if (imageUrl.orEmpty().startsWith("http", true)) {
PagerButton(context, viewer).apply {
PagerButton(readerThemedContext, viewer).apply {
layoutParams = LayoutParams(WRAP_CONTENT, WRAP_CONTENT).apply {
setMargins(margins, margins, margins, margins)
}

View file

@ -42,7 +42,9 @@
<item name="android:enforceNavigationBarContrast" tools:targetApi="Q">false</item>
<item name="android:enforceStatusBarContrast" tools:targetApi="Q">false</item>
<item name="android:itemTextAppearance">@style/TextAppearance.Widget.Menu</item>
<item name="android:alertDialogTheme">@style/ThemeOverlay.Tachiyomi.MaterialAlertDialog</item>
<item name="textAppearanceButton">@style/TextAppearance.Widget.Button</item>
<item name="android:buttonStyle">?attr/borderlessButtonStyle</item>
<item name="android:backgroundDimAmount">0.32</item>
<item name="windowActionModeOverlay">true</item>
<item name="actionModeStyle">@style/Widget.Tachiyomi.ActionMode</item>