From d1bb0fdf1dabd59cae2949c707dce441f054d1cf Mon Sep 17 00:00:00 2001 From: Hunter Nickel Date: Fri, 13 Aug 2021 13:44:42 -0600 Subject: [PATCH] Apply app theme styling to reader page errors and progress dialog (#5705) --- .../ui/reader/viewer/pager/PagerPageHolder.kt | 17 +++++++++++------ app/src/main/res/values/themes.xml | 2 ++ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/PagerPageHolder.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/PagerPageHolder.kt index 11cad18dff..3d209a9d48 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/PagerPageHolder.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/PagerPageHolder.kt @@ -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 { 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) } diff --git a/app/src/main/res/values/themes.xml b/app/src/main/res/values/themes.xml index 27e408124c..cb132c8a97 100644 --- a/app/src/main/res/values/themes.xml +++ b/app/src/main/res/values/themes.xml @@ -42,7 +42,9 @@ false false @style/TextAppearance.Widget.Menu + @style/ThemeOverlay.Tachiyomi.MaterialAlertDialog @style/TextAppearance.Widget.Button + ?attr/borderlessButtonStyle 0.32 true @style/Widget.Tachiyomi.ActionMode