Fixed various reader themes + dialogs
This commit is contained in:
parent
a5c32bb35c
commit
507807eee0
@ -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<ReaderPresenter>() {
|
||||
*/
|
||||
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<ReaderPresenter>() {
|
||||
*/
|
||||
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<ReaderPresenter>() {
|
||||
|
||||
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<ViewGroup.MarginLayoutParams> {
|
||||
height = readerBHeight + bottomInset
|
||||
}
|
||||
reader_menu_bottom.updatePaddingRelative(bottom = padding.bottom + bottomInset)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -158,6 +156,8 @@ class ReaderActivity : BaseRxActivity<ReaderPresenter>() {
|
||||
viewer = null
|
||||
config?.destroy()
|
||||
config = null
|
||||
bottomSheet?.dismiss()
|
||||
bottomSheet = null
|
||||
progressDialog?.dismiss()
|
||||
progressDialog = null
|
||||
}
|
||||
@ -198,11 +198,12 @@ class ReaderActivity : BaseRxActivity<ReaderPresenter>() {
|
||||
* 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<ReaderPresenter>() {
|
||||
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)
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -351,8 +351,6 @@ class PagerPageHolder(
|
||||
})
|
||||
}
|
||||
addView(subsamplingImageView)
|
||||
if (Build.VERSION.SDK_INT >= 29)
|
||||
subsamplingImageView?.isForceDarkAllowed = false
|
||||
return subsamplingImageView!!
|
||||
}
|
||||
|
||||
|
@ -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()
|
||||
}
|
||||
|
||||
|
@ -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">
|
||||
|
||||
<FrameLayout
|
||||
android:layout_width="match_parent"
|
||||
|
@ -33,9 +33,11 @@
|
||||
<item name="icon_color">@color/iconColorDark</item>
|
||||
</style>
|
||||
|
||||
<style name="Theme.Base.Reader.Light" parent="Theme.Tachiyomi">
|
||||
<style name="Theme.Base.Reader" parent="Theme.Base">
|
||||
<item name="android:statusBarColor">?colorPrimaryDark</item>
|
||||
<item name="android:navigationBarColor">?colorPrimaryDark</item>
|
||||
<item name="colorPrimary">@color/colorDarkPrimary</item>
|
||||
<item name="colorPrimaryDark">@color/colorDarkPrimaryDark</item>
|
||||
<item name="colorPrimaryDark">@color/colorDarkPrimary</item>
|
||||
<item name="android:colorBackground">@color/backgroundDark</item>
|
||||
</style>
|
||||
|
||||
|
@ -1,28 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<!--===========-->
|
||||
<!-- Main Theme-->
|
||||
<!--===========-->
|
||||
<style name="Theme.Tachiyomi" parent="Theme.Base">
|
||||
<!-- Attributes specific for SDK 21 and up -->
|
||||
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
|
||||
<item name="android:statusBarColor">@android:color/transparent</item>
|
||||
<item name="android:navigationBarColor">@color/oldNavBarBackground</item>
|
||||
</style>
|
||||
|
||||
<!--==============-->
|
||||
<!-- Reader Theme -->
|
||||
<!--==============-->
|
||||
<style name="Theme.Reader" parent="Theme.Base.Reader.Dark">
|
||||
<!-- Attributes specific for SDK 21 and up -->
|
||||
<item name="android:statusBarColor">?colorPrimaryDark</item>
|
||||
<item name="android:navigationBarColor">?colorPrimaryDark</item>
|
||||
</style>
|
||||
|
||||
<style name="Theme.Reader.Light" parent="Theme.Base.Reader.Light">
|
||||
<!-- Attributes specific for SDK 21 and up -->
|
||||
<item name="android:statusBarColor">?colorPrimaryDark</item>
|
||||
<item name="android:navigationBarColor">?colorPrimaryDark</item>
|
||||
</style>
|
||||
|
||||
</resources>
|
@ -1,8 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
|
||||
<!-- values-v29/themes.xml -->
|
||||
<style name="Theme.Tachiyomi" parent="Theme.Base">
|
||||
<!-- Attributes specific for SDK 21 and up -->
|
||||
<item name="android:statusBarColor">@android:color/transparent</item>
|
||||
<item name="android:navigationBarColor">@android:color/transparent</item>
|
||||
</style>
|
||||
|
@ -6,10 +6,9 @@
|
||||
<!--============-->
|
||||
<style name="Theme"/>
|
||||
|
||||
<!--==============-->
|
||||
<!-- Light Themes -->
|
||||
<!--=======-======-->
|
||||
<style name="Theme.Base" parent="Theme.AppCompat.DayNight.NoActionBar">
|
||||
<item name="android:forceDarkAllowed">false</item>
|
||||
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
|
||||
<item name="colorPrimary">@color/colorPrimary</item>
|
||||
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
|
||||
<item name="colorAccent">@color/colorAccentLight</item>
|
||||
@ -29,6 +28,7 @@
|
||||
<item name="actionBarTheme">@style/Theme.ActionBar.Light</item>
|
||||
<item name="preferenceTheme">@style/PreferenceThemeOverlay.Material</item>
|
||||
<item name="alertDialogTheme">@style/Theme.AlertDialog.Light</item>
|
||||
<item name="md_background_color">@color/dialogLight</item>
|
||||
|
||||
|
||||
<!-- Custom Attributes-->
|
||||
@ -38,6 +38,9 @@
|
||||
<item name="text_color_primary">@color/textColorPrimaryLight</item>
|
||||
<item name="background_card">@color/dialogLight</item>
|
||||
<item name="icon_color">@color/iconColorLight</item>
|
||||
|
||||
<item name="android:statusBarColor">@android:color/transparent</item>
|
||||
<item name="android:navigationBarColor">@color/oldNavBarBackground</item>
|
||||
</style>
|
||||
|
||||
<style name="Theme.Tachiyomi" parent="Theme.Base"/>
|
||||
@ -46,16 +49,87 @@
|
||||
<!--==============-->
|
||||
<!-- Reader Theme -->
|
||||
<!--==============-->
|
||||
<style name="Theme.Base.Reader.Dark" parent="Theme.Base">
|
||||
<style name="Theme.Base.Reader" parent="Theme.Base">
|
||||
<item name="android:forceDarkAllowed">false</item>
|
||||
<item name="colorPrimary">@color/colorDarkPrimary</item>
|
||||
<item name="colorPrimaryDark">@color/colorDarkPrimary</item>
|
||||
<item name="android:colorBackground">@android:color/white</item>
|
||||
<item name="android:statusBarColor">?colorPrimaryDark</item>
|
||||
<item name="android:navigationBarColor">?colorPrimaryDark</item>
|
||||
</style>
|
||||
|
||||
<style name="Theme.Base.Reader.Dark" parent="Theme.AppCompat.NoActionBar">
|
||||
<item name="android:forceDarkAllowed">false</item>
|
||||
<item name="colorPrimary">@color/colorDarkPrimary</item>
|
||||
<item name="colorPrimaryDark">@color/colorDarkPrimaryDark</item>
|
||||
<item name="android:colorBackground">@android:color/black</item>
|
||||
<item name="colorAccent">@color/colorAccentDark</item>
|
||||
<item name="android:textColorPrimary">@color/textColorPrimaryDark</item>
|
||||
<item name="android:textColorSecondary">@color/textColorSecondaryDark</item>
|
||||
<item name="android:textColorHint">@color/textColorHintDark</item>
|
||||
<item name="android:textColorPrimaryInverse">@color/textColorPrimaryLight</item>
|
||||
<item name="android:textColorSecondaryInverse">@color/textColorSecondaryLight</item>
|
||||
<item name="android:textColorHintInverse">@color/textColorHintLight</item>
|
||||
<item name="android:listSelector">?colorAccent</item>
|
||||
<item name="android:divider">@color/dividerDark</item>
|
||||
<item name="android:listDivider">@drawable/line_divider_dark</item>
|
||||
|
||||
<!-- Themes -->
|
||||
<item name="windowActionModeOverlay">true</item>
|
||||
<item name="actionBarTheme">@style/ThemeOverlay.AppCompat.Dark.ActionBar</item>
|
||||
<item name="actionBarPopupTheme">@style/ThemeOverlay.AppCompat</item>
|
||||
<item name="preferenceTheme">@style/PreferenceThemeOverlay.Material</item>
|
||||
<item name="md_background_color">@color/dialogDark</item>
|
||||
<item name="alertDialogTheme">@style/Theme.AlertDialog.Dark</item>
|
||||
|
||||
|
||||
<!-- Custom Attributes-->
|
||||
<item name="navigation_view_theme">@style/Theme.Widget.NavigationView</item>
|
||||
<item name="selectable_list_drawable">@drawable/list_item_selector_dark</item>
|
||||
<item name="selectable_library_drawable">@drawable/library_item_selector_dark</item>
|
||||
<item name="text_color_primary">@color/textColorPrimaryDark</item>
|
||||
<item name="background_card">@color/dialogDark</item>
|
||||
<item name="icon_color">@color/iconColorDark</item>
|
||||
|
||||
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
|
||||
<item name="android:statusBarColor">?colorPrimaryDark</item>
|
||||
<item name="android:navigationBarColor">?colorPrimaryDark</item>
|
||||
</style>
|
||||
|
||||
<style name="Theme.Base.Reader.Light" parent="Theme.Base">
|
||||
<style name="Theme.Base.Reader.Light" parent="Theme.AppCompat.Light.NoActionBar">
|
||||
<item name="android:forceDarkAllowed">false</item>
|
||||
<item name="colorPrimary">@color/colorDarkPrimary</item>
|
||||
<item name="colorPrimaryDark">@color/colorDarkPrimaryDark</item>
|
||||
<item name="android:colorBackground">@android:color/white</item>
|
||||
<item name="colorAccent">@color/colorAccentLight</item>
|
||||
<item name="android:textColorPrimary">@color/textColorPrimaryLight</item>
|
||||
<item name="android:textColorSecondary">@color/textColorSecondaryLight</item>
|
||||
<item name="android:textColorHint">@color/textColorHintLight</item>
|
||||
<item name="android:textColorPrimaryInverse">@color/textColorPrimaryDark</item>
|
||||
<item name="android:textColorSecondaryInverse">@color/textColorSecondaryDark</item>
|
||||
<item name="android:textColorHintInverse">@color/textColorHintDark</item>
|
||||
<item name="android:listSelector">?colorAccent</item>
|
||||
<item name="android:divider">@color/dividerLight</item>
|
||||
<item name="android:listDivider">@drawable/line_divider_light</item>
|
||||
|
||||
<!-- Themes -->
|
||||
<item name="windowActionModeOverlay">true</item>
|
||||
<item name="actionBarTheme">@style/Theme.ActionBar.Light</item>
|
||||
<item name="preferenceTheme">@style/PreferenceThemeOverlay.Material</item>
|
||||
<item name="alertDialogTheme">@style/Theme.AlertDialog.Light</item>
|
||||
|
||||
|
||||
<!-- Custom Attributes-->
|
||||
<item name="navigation_view_theme">@style/Theme.Widget.NavigationView</item>
|
||||
<item name="selectable_list_drawable">@drawable/list_item_selector_light</item>
|
||||
<item name="selectable_library_drawable">@drawable/library_item_selector_light</item>
|
||||
<item name="text_color_primary">@color/textColorPrimaryLight</item>
|
||||
<item name="background_card">@color/dialogLight</item>
|
||||
<item name="icon_color">@color/iconColorLight</item>
|
||||
|
||||
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
|
||||
<item name="android:statusBarColor">?colorPrimaryDark</item>
|
||||
<item name="android:navigationBarColor">?colorPrimaryDark</item>
|
||||
</style>
|
||||
|
||||
<!--===============-->
|
||||
|
Loading…
Reference in New Issue
Block a user