mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-12-22 08:01:50 +01:00
Make Automatic Reader Theme pick background/text color based on dark mode preference (#5505)
* Make Automatic Reader Theme pick background/text color based on theme * Use extension method
This commit is contained in:
parent
37d30eb887
commit
c254aa6fcc
@ -854,6 +854,7 @@ class ReaderActivity : BaseRxActivity<ReaderActivityBinding, ReaderPresenter>()
|
||||
when (preferences.readerTheme().get()) {
|
||||
0 -> android.R.color.white
|
||||
2 -> R.color.reader_background_dark
|
||||
3 -> automaticBackgroundColor()
|
||||
else -> android.R.color.black
|
||||
}
|
||||
)
|
||||
@ -902,6 +903,17 @@ class ReaderActivity : BaseRxActivity<ReaderActivityBinding, ReaderPresenter>()
|
||||
.launchIn(lifecycleScope)
|
||||
}
|
||||
|
||||
/**
|
||||
* Picks background color for [ReaderActivity] based on light/dark theme preference
|
||||
*/
|
||||
private fun automaticBackgroundColor(): Int {
|
||||
return if (baseContext.isNightMode()) {
|
||||
R.color.reader_background_dark
|
||||
} else {
|
||||
android.R.color.white
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the visibility of the bottom page indicator according to [visible].
|
||||
*/
|
||||
|
@ -11,6 +11,7 @@ import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||
import eu.kanade.tachiyomi.databinding.ReaderTransitionViewBinding
|
||||
import eu.kanade.tachiyomi.ui.reader.model.ChapterTransition
|
||||
import eu.kanade.tachiyomi.util.system.isNightMode
|
||||
import uy.kohesive.injekt.Injekt
|
||||
import uy.kohesive.injekt.api.get
|
||||
|
||||
@ -23,7 +24,6 @@ class ReaderTransitionView @JvmOverloads constructor(context: Context, attrs: At
|
||||
binding = ReaderTransitionViewBinding.inflate(LayoutInflater.from(context), this, true)
|
||||
layoutParams = LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)
|
||||
}
|
||||
|
||||
fun bind(transition: ChapterTransition) {
|
||||
when (transition) {
|
||||
is ChapterTransition.Prev -> bindPrevChapterTransition(transition)
|
||||
@ -34,6 +34,7 @@ class ReaderTransitionView @JvmOverloads constructor(context: Context, attrs: At
|
||||
|
||||
val color = when (Injekt.get<PreferencesHelper>().readerTheme().get()) {
|
||||
0 -> context.getColor(android.R.color.black)
|
||||
3 -> context.getColor(automaticTextColor())
|
||||
else -> context.getColor(android.R.color.white)
|
||||
}
|
||||
listOf(binding.upperText, binding.warningText, binding.lowerText).forEach {
|
||||
@ -41,6 +42,17 @@ class ReaderTransitionView @JvmOverloads constructor(context: Context, attrs: At
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Picks text color for [ReaderActivity] based on light/dark theme preference
|
||||
*/
|
||||
private fun automaticTextColor(): Int {
|
||||
return if (context.isNightMode()) {
|
||||
android.R.color.white
|
||||
} else {
|
||||
android.R.color.black
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Binds a previous chapter transition on this view and subscribes to the page load status.
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user