From 507807eee0641c3f37f219d235f14e18f1090961 Mon Sep 17 00:00:00 2001 From: Jay Date: Sun, 27 Oct 2019 19:05:35 -0700 Subject: [PATCH] Fixed various reader themes + dialogs --- .../tachiyomi/ui/reader/ReaderActivity.kt | 37 ++++---- .../tachiyomi/ui/reader/ReaderSeekBar.kt | 14 ++++ .../ui/reader/viewer/pager/PagerPageHolder.kt | 2 - .../viewer/pager/PagerTransitionHolder.kt | 4 + .../res/layout/reader_color_filter_sheet.xml | 3 +- app/src/main/res/values-night/themes.xml | 6 +- app/src/main/res/values-v21/themes.xml | 28 ------- app/src/main/res/values-v29/themes.xml | 2 +- app/src/main/res/values/themes.xml | 84 +++++++++++++++++-- 9 files changed, 121 insertions(+), 59 deletions(-) delete mode 100644 app/src/main/res/values-v21/themes.xml 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 e2a61a623d..51f21d1b27 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 @@ -10,9 +10,11 @@ import android.graphics.Bitmap import android.graphics.Color import android.os.Build import android.os.Bundle +import android.support.design.widget.BottomSheetDialog import android.view.* import android.view.animation.Animation import android.view.animation.AnimationUtils +import android.widget.LinearLayout import android.widget.SeekBar import com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView import eu.kanade.tachiyomi.R @@ -36,6 +38,7 @@ import eu.kanade.tachiyomi.util.* import eu.kanade.tachiyomi.widget.SimpleAnimationListener import eu.kanade.tachiyomi.widget.SimpleSeekBarListener import kotlinx.android.synthetic.main.reader_activity.* +import kotlinx.android.synthetic.main.reader_activity.toolbar import me.zhanghai.android.systemuihelper.SystemUiHelper import nucleus.factory.RequiresPresenter import rx.Observable @@ -86,6 +89,11 @@ class ReaderActivity : BaseRxActivity() { */ private var config: ReaderConfig? = null + /** + * Current Bottom Sheet on display, used to dismiss + */ + private var bottomSheet: BottomSheetDialog? = null + /** * Progress dialog used when switching chapters from the menu buttons. */ @@ -112,8 +120,9 @@ class ReaderActivity : BaseRxActivity() { */ override fun onCreate(savedState: Bundle?) { setTheme(when (preferences.readerTheme().getOrDefault()) { - 1 -> R.style.Theme_Reader - else -> R.style.Theme_Reader_Light + 0 -> R.style.Theme_Base_Reader_Light + 1 -> R.style.Theme_Base_Reader_Dark + else -> R.style.Theme_Base_Reader }) super.onCreate(savedState) setContentView(R.layout.reader_activity) @@ -136,17 +145,6 @@ class ReaderActivity : BaseRxActivity() { config = ReaderConfig() initializeMenu() - val container: ViewGroup = findViewById(R.id.reader_container) - val readerBHeight = reader_menu_bottom.layoutParams.height - container.doOnApplyWindowInsets { _, insets, padding -> - val bottomInset = if (Build.VERSION.SDK_INT >= 29) - (insets.mandatorySystemGestureInsets.bottom - insets.systemWindowInsetBottom) - else 0 - reader_menu_bottom.updateLayoutParams { - height = readerBHeight + bottomInset - } - reader_menu_bottom.updatePaddingRelative(bottom = padding.bottom + bottomInset) - } } /** @@ -158,6 +156,8 @@ class ReaderActivity : BaseRxActivity() { viewer = null config?.destroy() config = null + bottomSheet?.dismiss() + bottomSheet = null progressDialog?.dismiss() progressDialog = null } @@ -198,11 +198,12 @@ class ReaderActivity : BaseRxActivity() { * entries. */ override fun onOptionsItemSelected(item: MenuItem): Boolean { - when (item.itemId) { - R.id.action_settings -> ReaderSettingsSheet(this).show() - R.id.action_custom_filter -> ReaderColorFilterSheet(this).show() + bottomSheet = when (item.itemId) { + R.id.action_settings -> ReaderSettingsSheet(this) + R.id.action_custom_filter -> ReaderColorFilterSheet(this) else -> return super.onOptionsItemSelected(item) } + bottomSheet?.show() return true } @@ -286,15 +287,11 @@ class ReaderActivity : BaseRxActivity() { val toolbarAnimation = AnimationUtils.loadAnimation(this, R.anim.enter_from_top) toolbarAnimation.setAnimationListener(object : SimpleAnimationListener() { override fun onAnimationStart(animation: Animation) { - // Fix status bar being translucent the first time it's opened. - if (Build.VERSION.SDK_INT >= 21) { window.addFlags( WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS) - } } }) toolbar.startAnimation(toolbarAnimation) - val bottomAnimation = AnimationUtils.loadAnimation(this, R.anim.enter_from_bottom) reader_menu_bottom.startAnimation(bottomAnimation) } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderSeekBar.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderSeekBar.kt index c429804eb8..8a750c2ded 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderSeekBar.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderSeekBar.kt @@ -2,6 +2,8 @@ package eu.kanade.tachiyomi.ui.reader import android.content.Context import android.graphics.Canvas +import android.graphics.Rect +import android.os.Build import android.support.v7.widget.AppCompatSeekBar import android.util.AttributeSet import android.view.MotionEvent @@ -18,6 +20,8 @@ class ReaderSeekBar @JvmOverloads constructor( * Whether the seekbar should draw from right to left. */ var isRTL = false + private val boundingBox: Rect = Rect() + private val exclusions = listOf(boundingBox) /** * Draws the seekbar, translating the canvas if using a right to left reader. @@ -42,4 +46,14 @@ class ReaderSeekBar @JvmOverloads constructor( return super.onTouchEvent(event) } + override fun onLayout(changed: Boolean, left: Int, top: Int, right: Int, bottom: Int) { + super.onLayout(changed, left, top, right, bottom) + if (Build.VERSION.SDK_INT >= 29) { + if (changed) { + boundingBox.set(left, top, right, bottom) + systemGestureExclusionRects = exclusions + } + } + + } } 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 478b5ec712..6bcdf1055a 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 @@ -351,8 +351,6 @@ class PagerPageHolder( }) } addView(subsamplingImageView) - if (Build.VERSION.SDK_INT >= 29) - subsamplingImageView?.isForceDarkAllowed = false return subsamplingImageView!! } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/PagerTransitionHolder.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/PagerTransitionHolder.kt index ce33d09f07..386974a327 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/PagerTransitionHolder.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/PagerTransitionHolder.kt @@ -2,6 +2,7 @@ package eu.kanade.tachiyomi.ui.reader.viewer.pager import android.annotation.SuppressLint import android.graphics.Typeface +import android.os.Build import android.support.v7.widget.AppCompatTextView import android.text.SpannableStringBuilder import android.text.Spanned @@ -18,6 +19,7 @@ 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.util.dpToPx +import eu.kanade.tachiyomi.util.getResourceColor import eu.kanade.tachiyomi.widget.ViewPagerAdapter import rx.Subscription import rx.android.schedulers.AndroidSchedulers @@ -46,6 +48,8 @@ class PagerTransitionHolder( * Text view used to display the text of the current and next/prev chapters. */ private var textView = TextView(context).apply { + //if (Build.VERSION.SDK_INT >= 23) + //setTextColor(context.getResourceColor(R.attr.)) wrapContent() } diff --git a/app/src/main/res/layout/reader_color_filter_sheet.xml b/app/src/main/res/layout/reader_color_filter_sheet.xml index 3155bc15cb..8a9980a3ff 100644 --- a/app/src/main/res/layout/reader_color_filter_sheet.xml +++ b/app/src/main/res/layout/reader_color_filter_sheet.xml @@ -3,7 +3,8 @@ android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" - android:background="?android:colorBackground"> + android:background="?android:colorBackground" + android:forceDarkAllowed="false"> @color/iconColorDark - diff --git a/app/src/main/res/values-v21/themes.xml b/app/src/main/res/values-v21/themes.xml deleted file mode 100644 index c49d72e6d8..0000000000 --- a/app/src/main/res/values-v21/themes.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - - - - - - - - - diff --git a/app/src/main/res/values-v29/themes.xml b/app/src/main/res/values-v29/themes.xml index 3cd718a156..056509289b 100644 --- a/app/src/main/res/values-v29/themes.xml +++ b/app/src/main/res/values-v29/themes.xml @@ -1,8 +1,8 @@ + diff --git a/app/src/main/res/values/themes.xml b/app/src/main/res/values/themes.xml index d4f136e705..d08a8b1de2 100644 --- a/app/src/main/res/values/themes.xml +++ b/app/src/main/res/values/themes.xml @@ -6,10 +6,9 @@ + + -