From a4eba50cfd9e304d0d3298def3d410ae7affe7ee Mon Sep 17 00:00:00 2001 From: arkon Date: Fri, 6 Aug 2021 17:28:39 -0400 Subject: [PATCH] Revert "Use correct color for reader loading indicator (#5645)" (fixes #5669) This reverts commit 7a1b6142df4951e8d4ff5bdcc555eb3d393a9559. --- .../tachiyomi/ui/reader/ReaderActivity.kt | 18 +++------------- .../ui/reader/viewer/pager/PagerConfig.kt | 11 +--------- .../ui/reader/viewer/pager/PagerPageHolder.kt | 13 +++++------- .../ui/reader/viewer/webtoon/WebtoonConfig.kt | 6 ------ .../viewer/webtoon/WebtoonPageHolder.kt | 4 +--- .../util/system/ContextExtensions.kt | 21 ------------------- app/src/main/res/layout/reader_activity.xml | 9 ++++++++ 7 files changed, 19 insertions(+), 63 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderActivity.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderActivity.kt index 2be8eb111..4c13ecee4 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderActivity.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderActivity.kt @@ -16,7 +16,6 @@ import android.graphics.Paint import android.graphics.PorterDuff import android.os.Build import android.os.Bundle -import android.view.Gravity import android.view.KeyEvent import android.view.Menu import android.view.MenuItem @@ -25,7 +24,6 @@ import android.view.View.LAYER_TYPE_HARDWARE import android.view.WindowManager import android.view.animation.Animation import android.view.animation.AnimationUtils -import android.widget.FrameLayout import android.widget.SeekBar import android.widget.Toast import androidx.core.graphics.ColorUtils @@ -34,7 +32,6 @@ import androidx.core.view.WindowInsetsCompat import androidx.core.view.WindowInsetsControllerCompat import androidx.core.view.isInvisible import androidx.core.view.isVisible -import androidx.core.view.updateLayoutParams import androidx.lifecycle.lifecycleScope import com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView import com.google.android.material.shape.MaterialShapeDrawable @@ -62,11 +59,9 @@ import eu.kanade.tachiyomi.ui.reader.setting.OrientationType import eu.kanade.tachiyomi.ui.reader.setting.ReaderSettingsSheet import eu.kanade.tachiyomi.ui.reader.setting.ReadingModeType import eu.kanade.tachiyomi.ui.reader.viewer.BaseViewer -import eu.kanade.tachiyomi.ui.reader.viewer.ReaderProgressIndicator import eu.kanade.tachiyomi.ui.reader.viewer.pager.R2LPagerViewer import eu.kanade.tachiyomi.util.storage.getUriCompat import eu.kanade.tachiyomi.util.system.GLUtil -import eu.kanade.tachiyomi.util.system.createReaderThemeContext import eu.kanade.tachiyomi.util.system.hasDisplayCutout import eu.kanade.tachiyomi.util.system.isNightMode import eu.kanade.tachiyomi.util.system.toast @@ -142,8 +137,6 @@ class ReaderActivity : BaseRxActivity() private val windowInsetsController by lazy { WindowInsetsControllerCompat(window, binding.root) } - private var loadingIndicator: ReaderProgressIndicator? = null - var isScrollingThroughPages = false private set @@ -607,13 +600,8 @@ class ReaderActivity : BaseRxActivity() binding.rightChapter.setTooltip(R.string.action_next_chapter) } - val loadingIndicatorContext = createReaderThemeContext(preferences.readerTheme().get()) - loadingIndicator = ReaderProgressIndicator(loadingIndicatorContext).apply { - updateLayoutParams { - gravity = Gravity.CENTER - } - } - binding.readerContainer.addView(loadingIndicator) + binding.pleaseWait.isVisible = true + binding.pleaseWait.startAnimation(AnimationUtils.loadAnimation(this, R.anim.fade_in_long)) } private fun showReadingModeToast(mode: Int) { @@ -632,7 +620,7 @@ class ReaderActivity : BaseRxActivity() * hides or disables the reader prev/next buttons if there's a prev or next chapter */ fun setChapters(viewerChapters: ViewerChapters) { - binding.readerContainer.removeView(loadingIndicator) + binding.pleaseWait.isVisible = false viewer?.setChapters(viewerChapters) binding.toolbar.subtitle = viewerChapters.currChapter.chapter.name diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/PagerConfig.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/PagerConfig.kt index 6acfc4519..d02fcda4e 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/PagerConfig.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/PagerConfig.kt @@ -23,9 +23,6 @@ class PagerConfig( preferences: PreferencesHelper = Injekt.get() ) : ViewerConfig(preferences, scope) { - var theme = preferences.readerTheme().get() - private set - var automaticBackground = false private set @@ -42,13 +39,7 @@ class PagerConfig( init { preferences.readerTheme() - .register( - { - theme = it - automaticBackground = it == 3 - }, - { imagePropertyChangedListener?.invoke() } - ) + .register({ automaticBackground = it == 3 }, { imagePropertyChangedListener?.invoke() }) preferences.imageScaleType() .register({ imageScaleType = it }, { imagePropertyChangedListener?.invoke() }) 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 11cad18df..5e0b7484d 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 @@ -30,7 +30,6 @@ import eu.kanade.tachiyomi.ui.reader.viewer.ReaderProgressIndicator import eu.kanade.tachiyomi.ui.reader.viewer.pager.PagerConfig.ZoomType import eu.kanade.tachiyomi.ui.webview.WebViewActivity import eu.kanade.tachiyomi.util.system.ImageUtil -import eu.kanade.tachiyomi.util.system.createReaderThemeContext import eu.kanade.tachiyomi.util.system.dpToPx import eu.kanade.tachiyomi.widget.ViewPagerAdapter import rx.Observable @@ -59,7 +58,11 @@ class PagerPageHolder( /** * Loading progress bar to indicate the current progress. */ - private val progressIndicator: ReaderProgressIndicator + private val progressIndicator = ReaderProgressIndicator(context).apply { + updateLayoutParams { + gravity = Gravity.CENTER + } + } /** * Image view that supports subsampling on zoom. @@ -115,12 +118,6 @@ class PagerPageHolder( } init { - val indicatorContext = context.createReaderThemeContext(viewer.config.theme) - progressIndicator = ReaderProgressIndicator(indicatorContext).apply { - updateLayoutParams { - gravity = Gravity.CENTER - } - } addView(progressIndicator) observeStatus() viewer.activity.addOnMenuVisibilityListener(visibilityListener) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonConfig.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonConfig.kt index 9cd3c28a3..c5a585724 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonConfig.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonConfig.kt @@ -28,9 +28,6 @@ class WebtoonConfig( var sidePadding = 0 private set - var theme = preferences.readerTheme().get() - private set - init { preferences.cropBordersWebtoon() .register({ imageCropBorders = it }, { imagePropertyChangedListener?.invoke() }) @@ -53,9 +50,6 @@ class WebtoonConfig( preferences.dualPageInvertWebtoon() .register({ dualPageInvert = it }, { imagePropertyChangedListener?.invoke() }) - - preferences.readerTheme() - .register({ theme = it }, { imagePropertyChangedListener?.invoke() }) } override var navigator: ViewerNavigation = defaultNavigation() diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonPageHolder.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonPageHolder.kt index 6e0498eb8..2fd37402f 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonPageHolder.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonPageHolder.kt @@ -27,7 +27,6 @@ import eu.kanade.tachiyomi.ui.reader.model.ReaderPage import eu.kanade.tachiyomi.ui.reader.viewer.ReaderProgressIndicator import eu.kanade.tachiyomi.ui.webview.WebViewActivity import eu.kanade.tachiyomi.util.system.ImageUtil -import eu.kanade.tachiyomi.util.system.createReaderThemeContext import eu.kanade.tachiyomi.util.system.dpToPx import rx.Observable import rx.Subscription @@ -346,8 +345,7 @@ class WebtoonPageHolder( progressContainer = FrameLayout(context) frame.addView(progressContainer, MATCH_PARENT, parentHeight) - val indicatorContext = context.createReaderThemeContext(viewer.config.theme) - val progress = ReaderProgressIndicator(indicatorContext).apply { + val progress = ReaderProgressIndicator(context).apply { updateLayoutParams { gravity = Gravity.CENTER_HORIZONTAL updateMargins(top = parentHeight / 4) diff --git a/app/src/main/java/eu/kanade/tachiyomi/util/system/ContextExtensions.kt b/app/src/main/java/eu/kanade/tachiyomi/util/system/ContextExtensions.kt index 5eda037b6..95cb979f2 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/util/system/ContextExtensions.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/util/system/ContextExtensions.kt @@ -284,24 +284,3 @@ fun Context.isTablet(): Boolean { fun Context.isNightMode(): Boolean { return resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK == Configuration.UI_MODE_NIGHT_YES } - -/** - * Creates night mode Context depending on reader theme/background - */ -fun Context.createReaderThemeContext(readerThemeSelected: Int): Context { - val isDarkBackground = when (readerThemeSelected) { - 1, 2 -> true // Black, Gray - 3 -> isNightMode() // Automatic bg uses activity background by default - else -> false // White - } - val expected = if (isDarkBackground) Configuration.UI_MODE_NIGHT_YES else Configuration.UI_MODE_NIGHT_NO - if (resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK != expected) { - val overrideConfig = Configuration(resources.configuration).apply { - uiMode = (uiMode and Configuration.UI_MODE_NIGHT_MASK.inv()) or expected - } - return createConfigurationContext(overrideConfig).also { - it.theme.setTo(theme) - } - } - return this -} diff --git a/app/src/main/res/layout/reader_activity.xml b/app/src/main/res/layout/reader_activity.xml index baf93e471..fb90ddaf5 100644 --- a/app/src/main/res/layout/reader_activity.xml +++ b/app/src/main/res/layout/reader_activity.xml @@ -15,6 +15,15 @@ android:layout_width="match_parent" android:layout_height="match_parent" /> + +