mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-11-10 14:27:47 +01:00
Match ReaderActivity theme with the rest of the app (#5450)
* Match ReaderActivity theme with the rest of the app * Fix viewer inset when fullscreen reader is off * Fix incorrect toolbar color after recreate * Remove animated inset * Move isDarkMode to PreferencesHelper
This commit is contained in:
parent
feddd9285d
commit
64c95305b9
9 changed files with 113 additions and 169 deletions
|
@ -1,6 +1,7 @@
|
||||||
package eu.kanade.tachiyomi.data.preference
|
package eu.kanade.tachiyomi.data.preference
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
|
import android.content.res.Configuration
|
||||||
import android.os.Environment
|
import android.os.Environment
|
||||||
import androidx.core.content.edit
|
import androidx.core.content.edit
|
||||||
import androidx.core.net.toUri
|
import androidx.core.net.toUri
|
||||||
|
@ -10,6 +11,7 @@ import com.tfcporciuncula.flow.Preference
|
||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
import eu.kanade.tachiyomi.data.database.models.Manga
|
import eu.kanade.tachiyomi.data.database.models.Manga
|
||||||
import eu.kanade.tachiyomi.data.preference.PreferenceValues.DisplayMode
|
import eu.kanade.tachiyomi.data.preference.PreferenceValues.DisplayMode
|
||||||
|
import eu.kanade.tachiyomi.data.preference.PreferenceValues.ThemeMode.*
|
||||||
import eu.kanade.tachiyomi.data.track.TrackService
|
import eu.kanade.tachiyomi.data.track.TrackService
|
||||||
import eu.kanade.tachiyomi.data.track.anilist.Anilist
|
import eu.kanade.tachiyomi.data.track.anilist.Anilist
|
||||||
import eu.kanade.tachiyomi.ui.reader.setting.OrientationType
|
import eu.kanade.tachiyomi.ui.reader.setting.OrientationType
|
||||||
|
@ -84,7 +86,7 @@ class PreferencesHelper(val context: Context) {
|
||||||
|
|
||||||
fun showLibraryUpdateErrors() = prefs.getBoolean(Keys.showLibraryUpdateErrors, true)
|
fun showLibraryUpdateErrors() = prefs.getBoolean(Keys.showLibraryUpdateErrors, true)
|
||||||
|
|
||||||
fun themeMode() = flowPrefs.getEnum(Keys.themeMode, Values.ThemeMode.system)
|
fun themeMode() = flowPrefs.getEnum(Keys.themeMode, system)
|
||||||
|
|
||||||
fun themeLight() = flowPrefs.getEnum(Keys.themeLight, Values.LightThemeVariant.default)
|
fun themeLight() = flowPrefs.getEnum(Keys.themeLight, Values.LightThemeVariant.default)
|
||||||
|
|
||||||
|
@ -322,4 +324,15 @@ class PreferencesHelper(val context: Context) {
|
||||||
putInt(Keys.defaultChapterSortByAscendingOrDescending, if (manga.sortDescending()) Manga.CHAPTER_SORT_DESC else Manga.CHAPTER_SORT_ASC)
|
putInt(Keys.defaultChapterSortByAscendingOrDescending, if (manga.sortDescending()) Manga.CHAPTER_SORT_DESC else Manga.CHAPTER_SORT_ASC)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun isDarkMode(): Boolean {
|
||||||
|
return when (themeMode().get()) {
|
||||||
|
light -> false
|
||||||
|
dark -> true
|
||||||
|
system -> {
|
||||||
|
context.applicationContext.resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK ==
|
||||||
|
Configuration.UI_MODE_NIGHT_YES
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,14 +1,11 @@
|
||||||
package eu.kanade.tachiyomi.ui.base.activity
|
package eu.kanade.tachiyomi.ui.base.activity
|
||||||
|
|
||||||
import android.content.res.Configuration.UI_MODE_NIGHT_MASK
|
|
||||||
import android.content.res.Configuration.UI_MODE_NIGHT_YES
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import androidx.lifecycle.lifecycleScope
|
import androidx.lifecycle.lifecycleScope
|
||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
import eu.kanade.tachiyomi.data.preference.PreferenceValues.DarkThemeVariant
|
import eu.kanade.tachiyomi.data.preference.PreferenceValues.DarkThemeVariant
|
||||||
import eu.kanade.tachiyomi.data.preference.PreferenceValues.LightThemeVariant
|
import eu.kanade.tachiyomi.data.preference.PreferenceValues.LightThemeVariant
|
||||||
import eu.kanade.tachiyomi.data.preference.PreferenceValues.ThemeMode
|
|
||||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||||
import eu.kanade.tachiyomi.data.preference.asImmediateFlow
|
import eu.kanade.tachiyomi.data.preference.asImmediateFlow
|
||||||
import eu.kanade.tachiyomi.util.view.setSecureScreen
|
import eu.kanade.tachiyomi.util.view.setSecureScreen
|
||||||
|
@ -22,29 +19,7 @@ abstract class BaseThemedActivity : AppCompatActivity() {
|
||||||
val preferences: PreferencesHelper by injectLazy()
|
val preferences: PreferencesHelper by injectLazy()
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
val isDarkMode = when (preferences.themeMode().get()) {
|
setTheme(getThemeResourceId(preferences))
|
||||||
ThemeMode.light -> false
|
|
||||||
ThemeMode.dark -> true
|
|
||||||
ThemeMode.system -> resources.configuration.uiMode and UI_MODE_NIGHT_MASK == UI_MODE_NIGHT_YES
|
|
||||||
}
|
|
||||||
val themeId = if (isDarkMode) {
|
|
||||||
when (preferences.themeDark().get()) {
|
|
||||||
DarkThemeVariant.default -> R.style.Theme_Tachiyomi_Dark
|
|
||||||
DarkThemeVariant.blue -> R.style.Theme_Tachiyomi_Dark_Blue
|
|
||||||
DarkThemeVariant.greenapple -> R.style.Theme_Tachiyomi_Dark_GreenApple
|
|
||||||
DarkThemeVariant.midnightdusk -> R.style.Theme_Tachiyomi_Dark_MidnightDusk
|
|
||||||
DarkThemeVariant.amoled -> R.style.Theme_Tachiyomi_Amoled
|
|
||||||
DarkThemeVariant.hotpink -> R.style.Theme_Tachiyomi_Amoled_HotPink
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
when (preferences.themeLight().get()) {
|
|
||||||
LightThemeVariant.default -> R.style.Theme_Tachiyomi_Light
|
|
||||||
LightThemeVariant.blue -> R.style.Theme_Tachiyomi_Light_Blue
|
|
||||||
LightThemeVariant.strawberrydaiquiri -> R.style.Theme_Tachiyomi_Light_StrawberryDaiquiri
|
|
||||||
LightThemeVariant.yotsuba -> R.style.Theme_Tachiyomi_Light_Yotsuba
|
|
||||||
}
|
|
||||||
}
|
|
||||||
setTheme(themeId)
|
|
||||||
|
|
||||||
Injekt.get<PreferencesHelper>().incognitoMode()
|
Injekt.get<PreferencesHelper>().incognitoMode()
|
||||||
.asImmediateFlow {
|
.asImmediateFlow {
|
||||||
|
@ -54,4 +29,26 @@ abstract class BaseThemedActivity : AppCompatActivity() {
|
||||||
|
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
fun getThemeResourceId(preferences: PreferencesHelper): Int {
|
||||||
|
return if (preferences.isDarkMode()) {
|
||||||
|
when (preferences.themeDark().get()) {
|
||||||
|
DarkThemeVariant.default -> R.style.Theme_Tachiyomi_Dark
|
||||||
|
DarkThemeVariant.blue -> R.style.Theme_Tachiyomi_Dark_Blue
|
||||||
|
DarkThemeVariant.greenapple -> R.style.Theme_Tachiyomi_Dark_GreenApple
|
||||||
|
DarkThemeVariant.midnightdusk -> R.style.Theme_Tachiyomi_Dark_MidnightDusk
|
||||||
|
DarkThemeVariant.amoled -> R.style.Theme_Tachiyomi_Amoled
|
||||||
|
DarkThemeVariant.hotpink -> R.style.Theme_Tachiyomi_Amoled_HotPink
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
when (preferences.themeLight().get()) {
|
||||||
|
LightThemeVariant.default -> R.style.Theme_Tachiyomi_Light
|
||||||
|
LightThemeVariant.blue -> R.style.Theme_Tachiyomi_Light_Blue
|
||||||
|
LightThemeVariant.strawberrydaiquiri -> R.style.Theme_Tachiyomi_Light_StrawberryDaiquiri
|
||||||
|
LightThemeVariant.yotsuba -> R.style.Theme_Tachiyomi_Light_Yotsuba
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,11 +6,13 @@ import android.app.ProgressDialog
|
||||||
import android.content.ClipData
|
import android.content.ClipData
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
|
import android.content.res.ColorStateList
|
||||||
import android.graphics.Bitmap
|
import android.graphics.Bitmap
|
||||||
import android.graphics.Color
|
import android.graphics.Color
|
||||||
import android.graphics.ColorMatrix
|
import android.graphics.ColorMatrix
|
||||||
import android.graphics.ColorMatrixColorFilter
|
import android.graphics.ColorMatrixColorFilter
|
||||||
import android.graphics.Paint
|
import android.graphics.Paint
|
||||||
|
import android.graphics.drawable.ColorDrawable
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.KeyEvent
|
import android.view.KeyEvent
|
||||||
|
@ -23,12 +25,14 @@ import android.view.animation.Animation
|
||||||
import android.view.animation.AnimationUtils
|
import android.view.animation.AnimationUtils
|
||||||
import android.widget.SeekBar
|
import android.widget.SeekBar
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
import androidx.core.view.ViewCompat
|
import androidx.core.view.WindowCompat
|
||||||
import androidx.core.view.WindowInsetsCompat
|
import androidx.core.view.WindowInsetsCompat
|
||||||
|
import androidx.core.view.WindowInsetsControllerCompat
|
||||||
import androidx.core.view.isVisible
|
import androidx.core.view.isVisible
|
||||||
import androidx.core.view.setPadding
|
|
||||||
import androidx.lifecycle.lifecycleScope
|
import androidx.lifecycle.lifecycleScope
|
||||||
import com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView
|
import com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView
|
||||||
|
import com.google.android.material.shape.MaterialShapeDrawable
|
||||||
|
import dev.chrisbanes.insetter.applyInsetter
|
||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
import eu.kanade.tachiyomi.data.database.models.Chapter
|
import eu.kanade.tachiyomi.data.database.models.Chapter
|
||||||
import eu.kanade.tachiyomi.data.database.models.Manga
|
import eu.kanade.tachiyomi.data.database.models.Manga
|
||||||
|
@ -38,6 +42,7 @@ import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||||
import eu.kanade.tachiyomi.data.preference.toggle
|
import eu.kanade.tachiyomi.data.preference.toggle
|
||||||
import eu.kanade.tachiyomi.databinding.ReaderActivityBinding
|
import eu.kanade.tachiyomi.databinding.ReaderActivityBinding
|
||||||
import eu.kanade.tachiyomi.ui.base.activity.BaseRxActivity
|
import eu.kanade.tachiyomi.ui.base.activity.BaseRxActivity
|
||||||
|
import eu.kanade.tachiyomi.ui.base.activity.BaseThemedActivity
|
||||||
import eu.kanade.tachiyomi.ui.main.MainActivity
|
import eu.kanade.tachiyomi.ui.main.MainActivity
|
||||||
import eu.kanade.tachiyomi.ui.manga.MangaController
|
import eu.kanade.tachiyomi.ui.manga.MangaController
|
||||||
import eu.kanade.tachiyomi.ui.reader.ReaderPresenter.SetAsCoverResult.AddToLibraryFirst
|
import eu.kanade.tachiyomi.ui.reader.ReaderPresenter.SetAsCoverResult.AddToLibraryFirst
|
||||||
|
@ -55,12 +60,8 @@ import eu.kanade.tachiyomi.util.storage.getUriCompat
|
||||||
import eu.kanade.tachiyomi.util.system.GLUtil
|
import eu.kanade.tachiyomi.util.system.GLUtil
|
||||||
import eu.kanade.tachiyomi.util.system.hasDisplayCutout
|
import eu.kanade.tachiyomi.util.system.hasDisplayCutout
|
||||||
import eu.kanade.tachiyomi.util.system.toast
|
import eu.kanade.tachiyomi.util.system.toast
|
||||||
import eu.kanade.tachiyomi.util.view.defaultBar
|
|
||||||
import eu.kanade.tachiyomi.util.view.hideBar
|
|
||||||
import eu.kanade.tachiyomi.util.view.isDefaultBar
|
|
||||||
import eu.kanade.tachiyomi.util.view.popupMenu
|
import eu.kanade.tachiyomi.util.view.popupMenu
|
||||||
import eu.kanade.tachiyomi.util.view.setTooltip
|
import eu.kanade.tachiyomi.util.view.setTooltip
|
||||||
import eu.kanade.tachiyomi.util.view.showBar
|
|
||||||
import eu.kanade.tachiyomi.widget.listener.SimpleAnimationListener
|
import eu.kanade.tachiyomi.widget.listener.SimpleAnimationListener
|
||||||
import eu.kanade.tachiyomi.widget.listener.SimpleSeekBarListener
|
import eu.kanade.tachiyomi.widget.listener.SimpleSeekBarListener
|
||||||
import kotlinx.coroutines.flow.drop
|
import kotlinx.coroutines.flow.drop
|
||||||
|
@ -129,22 +130,20 @@ class ReaderActivity : BaseRxActivity<ReaderActivityBinding, ReaderPresenter>()
|
||||||
|
|
||||||
private var readingModeToast: Toast? = null
|
private var readingModeToast: Toast? = null
|
||||||
|
|
||||||
|
private val windowInsetsController by lazy { WindowInsetsControllerCompat(window, binding.root) }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when the activity is created. Initializes the presenter and configuration.
|
* Called when the activity is created. Initializes the presenter and configuration.
|
||||||
*/
|
*/
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
setTheme(
|
setTheme(BaseThemedActivity.getThemeResourceId(preferences))
|
||||||
when (preferences.readerTheme().get()) {
|
|
||||||
0 -> R.style.Theme_Reader_Light
|
|
||||||
2 -> R.style.Theme_Reader_Dark_Grey
|
|
||||||
else -> R.style.Theme_Reader_Dark
|
|
||||||
}
|
|
||||||
)
|
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
|
|
||||||
binding = ReaderActivityBinding.inflate(layoutInflater)
|
binding = ReaderActivityBinding.inflate(layoutInflater)
|
||||||
setContentView(binding.root)
|
setContentView(binding.root)
|
||||||
|
|
||||||
|
windowInsetsController.systemBarsBehavior = WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE
|
||||||
|
|
||||||
if (presenter.needsInit()) {
|
if (presenter.needsInit()) {
|
||||||
val manga = intent.extras!!.getLong("manga", -1)
|
val manga = intent.extras!!.getLong("manga", -1)
|
||||||
val chapter = intent.extras!!.getLong("chapter", -1)
|
val chapter = intent.extras!!.getLong("chapter", -1)
|
||||||
|
@ -163,9 +162,10 @@ class ReaderActivity : BaseRxActivity<ReaderActivityBinding, ReaderPresenter>()
|
||||||
config = ReaderConfig()
|
config = ReaderConfig()
|
||||||
initializeMenu()
|
initializeMenu()
|
||||||
|
|
||||||
// Avoid status bar showing up on rotation
|
binding.pageNumber.applyInsetter {
|
||||||
window.decorView.setOnSystemUiVisibilityChangeListener {
|
type(navigationBars = true) {
|
||||||
setMenuVisibility(menuVisible, animate = false)
|
margin()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Finish when incognito mode is disabled
|
// Finish when incognito mode is disabled
|
||||||
|
@ -299,17 +299,15 @@ class ReaderActivity : BaseRxActivity<ReaderActivityBinding, ReaderPresenter>()
|
||||||
onBackPressed()
|
onBackPressed()
|
||||||
}
|
}
|
||||||
|
|
||||||
ViewCompat.setOnApplyWindowInsetsListener(binding.readerMenu) { _, insets ->
|
binding.toolbar.applyInsetter {
|
||||||
if (!window.isDefaultBar()) {
|
type(navigationBars = true, statusBars = true) {
|
||||||
val systemInsets = insets.getInsets(WindowInsetsCompat.Type.systemBars())
|
margin(top = true, horizontal = true)
|
||||||
binding.readerMenu.setPadding(
|
}
|
||||||
systemInsets.left,
|
}
|
||||||
systemInsets.top,
|
binding.readerMenuBottom.applyInsetter {
|
||||||
systemInsets.right,
|
type(navigationBars = true) {
|
||||||
systemInsets.bottom
|
margin(bottom = true, horizontal = true)
|
||||||
)
|
|
||||||
}
|
}
|
||||||
insets
|
|
||||||
}
|
}
|
||||||
|
|
||||||
binding.toolbar.setOnClickListener {
|
binding.toolbar.setOnClickListener {
|
||||||
|
@ -355,6 +353,21 @@ class ReaderActivity : BaseRxActivity<ReaderActivityBinding, ReaderPresenter>()
|
||||||
|
|
||||||
initBottomShortcuts()
|
initBottomShortcuts()
|
||||||
|
|
||||||
|
val alpha = if (preferences.isDarkMode()) 230 else 242 // 90% dark 95% light
|
||||||
|
listOf(
|
||||||
|
binding.toolbarBottom,
|
||||||
|
binding.leftChapter,
|
||||||
|
binding.readerSeekbar,
|
||||||
|
binding.rightChapter
|
||||||
|
).forEach {
|
||||||
|
it.background.alpha = alpha
|
||||||
|
}
|
||||||
|
|
||||||
|
val systemBarsColor = (binding.toolbarBottom.background as ColorDrawable).color
|
||||||
|
window.statusBarColor = systemBarsColor
|
||||||
|
window.navigationBarColor = systemBarsColor
|
||||||
|
(binding.toolbar.background as MaterialShapeDrawable).fillColor = ColorStateList.valueOf(systemBarsColor)
|
||||||
|
|
||||||
// Set initial visibility
|
// Set initial visibility
|
||||||
setMenuVisibility(menuVisible)
|
setMenuVisibility(menuVisible)
|
||||||
}
|
}
|
||||||
|
@ -475,11 +488,7 @@ class ReaderActivity : BaseRxActivity<ReaderActivityBinding, ReaderPresenter>()
|
||||||
fun setMenuVisibility(visible: Boolean, animate: Boolean = true) {
|
fun setMenuVisibility(visible: Boolean, animate: Boolean = true) {
|
||||||
menuVisible = visible
|
menuVisible = visible
|
||||||
if (visible) {
|
if (visible) {
|
||||||
if (preferences.fullscreen().get()) {
|
windowInsetsController.show(WindowInsetsCompat.Type.systemBars())
|
||||||
window.showBar()
|
|
||||||
} else {
|
|
||||||
resetDefaultMenuAndBar()
|
|
||||||
}
|
|
||||||
binding.readerMenu.isVisible = true
|
binding.readerMenu.isVisible = true
|
||||||
|
|
||||||
if (animate) {
|
if (animate) {
|
||||||
|
@ -503,9 +512,7 @@ class ReaderActivity : BaseRxActivity<ReaderActivityBinding, ReaderPresenter>()
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (preferences.fullscreen().get()) {
|
if (preferences.fullscreen().get()) {
|
||||||
window.hideBar()
|
windowInsetsController.hide(WindowInsetsCompat.Type.systemBars())
|
||||||
} else {
|
|
||||||
resetDefaultMenuAndBar()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (animate) {
|
if (animate) {
|
||||||
|
@ -529,14 +536,6 @@ class ReaderActivity : BaseRxActivity<ReaderActivityBinding, ReaderPresenter>()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Reset menu padding and system bar
|
|
||||||
*/
|
|
||||||
private fun resetDefaultMenuAndBar() {
|
|
||||||
binding.readerMenu.setPadding(0)
|
|
||||||
window.defaultBar()
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called from the presenter when a manga is ready. Used to instantiate the appropriate viewer
|
* Called from the presenter when a manga is ready. Used to instantiate the appropriate viewer
|
||||||
* and the toolbar title.
|
* and the toolbar title.
|
||||||
|
@ -557,6 +556,7 @@ class ReaderActivity : BaseRxActivity<ReaderActivityBinding, ReaderPresenter>()
|
||||||
binding.viewerContainer.removeAllViews()
|
binding.viewerContainer.removeAllViews()
|
||||||
}
|
}
|
||||||
viewer = newViewer
|
viewer = newViewer
|
||||||
|
updateViewerInset(preferences.fullscreen().get())
|
||||||
binding.viewerContainer.addView(newViewer.getView())
|
binding.viewerContainer.addView(newViewer.getView())
|
||||||
|
|
||||||
if (preferences.showReadingMode()) {
|
if (preferences.showReadingMode()) {
|
||||||
|
@ -811,6 +811,19 @@ class ReaderActivity : BaseRxActivity<ReaderActivityBinding, ReaderPresenter>()
|
||||||
updateOrientationShortcut(presenter.getMangaOrientationType(resolveDefault = false))
|
updateOrientationShortcut(presenter.getMangaOrientationType(resolveDefault = false))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates viewer inset depending on fullscreen reader preferences.
|
||||||
|
*/
|
||||||
|
fun updateViewerInset(fullscreen: Boolean) {
|
||||||
|
viewer?.getView()?.applyInsetter {
|
||||||
|
if (!fullscreen) {
|
||||||
|
type(navigationBars = true, statusBars = true) {
|
||||||
|
padding()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class that handles the user preferences of the reader.
|
* Class that handles the user preferences of the reader.
|
||||||
*/
|
*/
|
||||||
|
@ -831,8 +844,15 @@ class ReaderActivity : BaseRxActivity<ReaderActivityBinding, ReaderPresenter>()
|
||||||
*/
|
*/
|
||||||
init {
|
init {
|
||||||
preferences.readerTheme().asFlow()
|
preferences.readerTheme().asFlow()
|
||||||
.drop(1) // We only care about updates
|
.onEach {
|
||||||
.onEach { recreate() }
|
binding.readerContainer.setBackgroundResource(
|
||||||
|
when (preferences.readerTheme().get()) {
|
||||||
|
0 -> android.R.color.white
|
||||||
|
2 -> R.color.background_dark
|
||||||
|
else -> android.R.color.black
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
.launchIn(lifecycleScope)
|
.launchIn(lifecycleScope)
|
||||||
|
|
||||||
preferences.showPageNumber().asFlow()
|
preferences.showPageNumber().asFlow()
|
||||||
|
@ -868,6 +888,13 @@ class ReaderActivity : BaseRxActivity<ReaderActivityBinding, ReaderPresenter>()
|
||||||
preferences.grayscale().asFlow()
|
preferences.grayscale().asFlow()
|
||||||
.onEach { setGrayscale(it) }
|
.onEach { setGrayscale(it) }
|
||||||
.launchIn(lifecycleScope)
|
.launchIn(lifecycleScope)
|
||||||
|
|
||||||
|
preferences.fullscreen().asFlow()
|
||||||
|
.onEach {
|
||||||
|
WindowCompat.setDecorFitsSystemWindows(window, !it)
|
||||||
|
updateViewerInset(it)
|
||||||
|
}
|
||||||
|
.launchIn(lifecycleScope)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -3,32 +3,11 @@ package eu.kanade.tachiyomi.util.view
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.graphics.Color
|
import android.graphics.Color
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
import android.view.View
|
|
||||||
import android.view.Window
|
import android.view.Window
|
||||||
import android.view.WindowManager
|
import android.view.WindowManager
|
||||||
import eu.kanade.tachiyomi.util.system.InternalResourceHelper
|
import eu.kanade.tachiyomi.util.system.InternalResourceHelper
|
||||||
import eu.kanade.tachiyomi.util.system.getResourceColor
|
import eu.kanade.tachiyomi.util.system.getResourceColor
|
||||||
|
|
||||||
fun Window.showBar() {
|
|
||||||
decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN or
|
|
||||||
View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION or
|
|
||||||
View.SYSTEM_UI_FLAG_LAYOUT_STABLE
|
|
||||||
}
|
|
||||||
|
|
||||||
fun Window.hideBar() {
|
|
||||||
decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN or
|
|
||||||
View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION or
|
|
||||||
View.SYSTEM_UI_FLAG_FULLSCREEN or
|
|
||||||
View.SYSTEM_UI_FLAG_HIDE_NAVIGATION or
|
|
||||||
View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
|
|
||||||
}
|
|
||||||
|
|
||||||
fun Window.defaultBar() {
|
|
||||||
decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_VISIBLE
|
|
||||||
}
|
|
||||||
|
|
||||||
fun Window.isDefaultBar() = decorView.systemUiVisibility == View.SYSTEM_UI_FLAG_VISIBLE
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets navigation bar color to transparent if system's config_navBarNeedsScrim is false,
|
* Sets navigation bar color to transparent if system's config_navBarNeedsScrim is false,
|
||||||
* otherwise it will use the theme navigationBarColor with 70% opacity.
|
* otherwise it will use the theme navigationBarColor with 70% opacity.
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package eu.kanade.tachiyomi.widget.sheet
|
package eu.kanade.tachiyomi.widget.sheet
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.res.Configuration
|
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.util.DisplayMetrics
|
import android.util.DisplayMetrics
|
||||||
|
@ -10,7 +9,6 @@ import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import com.google.android.material.bottomsheet.BottomSheetDialog
|
import com.google.android.material.bottomsheet.BottomSheetDialog
|
||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
import eu.kanade.tachiyomi.data.preference.PreferenceValues
|
|
||||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||||
import eu.kanade.tachiyomi.util.system.displayCompat
|
import eu.kanade.tachiyomi.util.system.displayCompat
|
||||||
import eu.kanade.tachiyomi.util.view.setNavigationBarTransparentCompat
|
import eu.kanade.tachiyomi.util.view.setNavigationBarTransparentCompat
|
||||||
|
@ -45,16 +43,9 @@ abstract class BaseBottomSheetDialog(context: Context) : BottomSheetDialog(conte
|
||||||
@Suppress("DEPRECATION")
|
@Suppress("DEPRECATION")
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||||
window?.setNavigationBarTransparentCompat(context)
|
window?.setNavigationBarTransparentCompat(context)
|
||||||
val isDarkMode = when (Injekt.get<PreferencesHelper>().themeMode().get()) {
|
|
||||||
PreferenceValues.ThemeMode.light -> false
|
|
||||||
PreferenceValues.ThemeMode.dark -> true
|
|
||||||
PreferenceValues.ThemeMode.system ->
|
|
||||||
context.resources.configuration.uiMode and
|
|
||||||
Configuration.UI_MODE_NIGHT_MASK == Configuration.UI_MODE_NIGHT_YES
|
|
||||||
}
|
|
||||||
val bottomSheet = rootView.parent as ViewGroup
|
val bottomSheet = rootView.parent as ViewGroup
|
||||||
var flags = bottomSheet.systemUiVisibility
|
var flags = bottomSheet.systemUiVisibility
|
||||||
flags = if (isDarkMode) {
|
flags = if (Injekt.get<PreferencesHelper>().isDarkMode()) {
|
||||||
flags and View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR.inv()
|
flags and View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR.inv()
|
||||||
} else {
|
} else {
|
||||||
flags or View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR
|
flags or View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR
|
||||||
|
|
|
@ -61,7 +61,6 @@
|
||||||
android:id="@+id/toolbar"
|
android:id="@+id/toolbar"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:background="?attr/colorToolbar"
|
|
||||||
android:minHeight="?attr/actionBarSize" />
|
android:minHeight="?attr/actionBarSize" />
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
|
@ -147,6 +146,7 @@
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<androidx.constraintlayout.widget.ConstraintLayout
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
|
android:id="@+id/toolbar_bottom"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="?attr/actionBarSize"
|
android:layout_height="?attr/actionBarSize"
|
||||||
android:layout_gravity="bottom"
|
android:layout_gravity="bottom"
|
||||||
|
|
|
@ -53,9 +53,6 @@
|
||||||
<color name="accent_hotpink">#FF3399</color>
|
<color name="accent_hotpink">#FF3399</color>
|
||||||
<color name="ripple_colored_hotpink">#1FFF3399</color>
|
<color name="ripple_colored_hotpink">#1FFF3399</color>
|
||||||
|
|
||||||
<!-- Reader Theme -->
|
|
||||||
<color name="reader_toolbar">#242529</color>
|
|
||||||
|
|
||||||
<color name="filterColorLight">#FFC107</color>
|
<color name="filterColorLight">#FFC107</color>
|
||||||
<color name="filterColorDark">#FFEB3B</color>
|
<color name="filterColorDark">#FFEB3B</color>
|
||||||
<color name="filterColorAmoled">#FFEB3B</color>
|
<color name="filterColorAmoled">#FFEB3B</color>
|
||||||
|
|
|
@ -219,11 +219,6 @@
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
|
||||||
<style name="Widget.Tachiyomi.BasicSwitch" parent="Widget.MaterialComponents.CompoundButton.Switch">
|
|
||||||
<item name="useMaterialThemeColors">false</item>
|
|
||||||
</style>
|
|
||||||
|
|
||||||
|
|
||||||
<style name="Widget.Tachiyomi.CircularProgressIndicator.Small" parent="Widget.MaterialComponents.CircularProgressIndicator">
|
<style name="Widget.Tachiyomi.CircularProgressIndicator.Small" parent="Widget.MaterialComponents.CircularProgressIndicator">
|
||||||
<item name="indicatorSize">16dp</item>
|
<item name="indicatorSize">16dp</item>
|
||||||
<item name="trackThickness">2dp</item>
|
<item name="trackThickness">2dp</item>
|
||||||
|
|
|
@ -39,6 +39,7 @@
|
||||||
<item name="android:navigationBarColor">@color/md_black_1000</item>
|
<item name="android:navigationBarColor">@color/md_black_1000</item>
|
||||||
<item name="android:navigationBarDividerColor" tools:targetApi="o_mr1">@null</item>
|
<item name="android:navigationBarDividerColor" tools:targetApi="o_mr1">@null</item>
|
||||||
<item name="android:enforceNavigationBarContrast" tools:targetApi="Q">false</item>
|
<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:itemTextAppearance">@style/TextAppearance.Widget.Menu</item>
|
||||||
<item name="android:backgroundDimAmount">0.32</item>
|
<item name="android:backgroundDimAmount">0.32</item>
|
||||||
<item name="windowActionModeOverlay">true</item>
|
<item name="windowActionModeOverlay">true</item>
|
||||||
|
@ -174,6 +175,7 @@
|
||||||
<item name="android:navigationBarColor">@color/md_black_1000</item>
|
<item name="android:navigationBarColor">@color/md_black_1000</item>
|
||||||
<item name="android:navigationBarDividerColor" tools:targetApi="o_mr1">@null</item>
|
<item name="android:navigationBarDividerColor" tools:targetApi="o_mr1">@null</item>
|
||||||
<item name="android:enforceNavigationBarContrast" tools:targetApi="Q">false</item>
|
<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:itemTextAppearance">@style/TextAppearance.Widget.Menu</item>
|
||||||
<item name="android:backgroundDimAmount">0.32</item>
|
<item name="android:backgroundDimAmount">0.32</item>
|
||||||
<item name="windowActionModeOverlay">true</item>
|
<item name="windowActionModeOverlay">true</item>
|
||||||
|
@ -298,6 +300,7 @@
|
||||||
<item name="android:statusBarColor">?attr/colorSurface</item>
|
<item name="android:statusBarColor">?attr/colorSurface</item>
|
||||||
<item name="android:navigationBarDividerColor" tools:targetApi="o_mr1">@null</item>
|
<item name="android:navigationBarDividerColor" tools:targetApi="o_mr1">@null</item>
|
||||||
<item name="android:enforceNavigationBarContrast" tools:targetApi="Q">false</item>
|
<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:itemTextAppearance">@style/TextAppearance.Widget.Menu</item>
|
||||||
<item name="android:backgroundDimAmount">0.32</item>
|
<item name="android:backgroundDimAmount">0.32</item>
|
||||||
<item name="windowActionModeOverlay">true</item>
|
<item name="windowActionModeOverlay">true</item>
|
||||||
|
@ -349,64 +352,6 @@
|
||||||
<item name="colorControlHighlight">@color/ripple_colored_hotpink</item>
|
<item name="colorControlHighlight">@color/ripple_colored_hotpink</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<!--===============-->
|
|
||||||
<!-- Reader Themes -->
|
|
||||||
<!--===============-->
|
|
||||||
|
|
||||||
<!--== Light Reader base ==-->
|
|
||||||
<style name="Theme.Base.Reader.Light" parent="Theme.Base.Light">
|
|
||||||
<!-- Theme colors -->
|
|
||||||
<item name="colorSurface">@color/md_white_1000</item>
|
|
||||||
<item name="colorToolbar">@color/reader_toolbar</item>
|
|
||||||
<item name="colorOnToolbar">@color/md_white_1000</item>
|
|
||||||
|
|
||||||
<!-- Base background/text colors -->
|
|
||||||
<item name="android:colorBackground">@color/md_white_1000</item>
|
|
||||||
<item name="android:statusBarColor">?attr/colorToolbar</item>
|
|
||||||
<item name="android:navigationBarColor">?attr/colorToolbar</item>
|
|
||||||
|
|
||||||
<!-- Themes -->
|
|
||||||
<item name="toolbarStyle">@style/Widget.Tachiyomi.Toolbar.Primary</item>
|
|
||||||
<item name="switchStyle">@style/Widget.Tachiyomi.BasicSwitch</item>
|
|
||||||
<item name="bottomSheetDialogTheme">@style/ThemeOverlay.Tachiyomi.BottomSheetDialog</item>
|
|
||||||
<item name="android:alertDialogTheme">@style/ThemeOverlay.Tachiyomi.MaterialAlertDialog</item>
|
|
||||||
</style>
|
|
||||||
|
|
||||||
<!--== Light Reader ==-->
|
|
||||||
<style name="Theme.Reader.Light" parent="Theme.Base.Reader.Light" />
|
|
||||||
|
|
||||||
<!--== Dark Reader base ==-->
|
|
||||||
<style name="Theme.Base.Reader.Dark" parent="Theme.Base.Dark">
|
|
||||||
<!-- Theme colors -->
|
|
||||||
<item name="colorSurface">@color/md_black_1000</item>
|
|
||||||
<item name="colorToolbar">@color/reader_toolbar</item>
|
|
||||||
|
|
||||||
<!-- Base background/text colors -->
|
|
||||||
<item name="android:colorBackground">@color/md_black_1000</item>
|
|
||||||
<item name="android:statusBarColor">?attr/colorToolbar</item>
|
|
||||||
<item name="android:navigationBarColor">?attr/colorToolbar</item>
|
|
||||||
|
|
||||||
<!-- Themes -->
|
|
||||||
<item name="switchStyle">@style/Widget.Tachiyomi.BasicSwitch</item>
|
|
||||||
<item name="bottomSheetDialogTheme">@style/ThemeOverlay.Tachiyomi.BottomSheetDialog</item>
|
|
||||||
<item name="android:alertDialogTheme">@style/ThemeOverlay.Tachiyomi.MaterialAlertDialog</item>
|
|
||||||
</style>
|
|
||||||
|
|
||||||
<!--== Dark Reader ==-->
|
|
||||||
<style name="Theme.Reader.Dark" parent="Theme.Base.Reader.Dark" />
|
|
||||||
|
|
||||||
<!--== Dark Grey Reader ==-->
|
|
||||||
<style name="Theme.Reader.Dark.Grey" parent="Theme.Base.Reader.Dark">
|
|
||||||
<!-- Theme colors -->
|
|
||||||
<item name="colorSurface">@color/background_dark</item>
|
|
||||||
|
|
||||||
<!-- Base background/text colors -->
|
|
||||||
<item name="android:colorBackground">@color/background_dark</item>
|
|
||||||
|
|
||||||
<!-- Alert Dialog -->
|
|
||||||
<item name="android:alertDialogTheme">@style/ThemeOverlay.Tachiyomi.MaterialAlertDialog</item>
|
|
||||||
</style>
|
|
||||||
|
|
||||||
<!--===============-->
|
<!--===============-->
|
||||||
<!-- Launch Screen -->
|
<!-- Launch Screen -->
|
||||||
<!--===============-->
|
<!--===============-->
|
||||||
|
|
Loading…
Reference in a new issue