mirror of
https://github.com/null2264/yokai.git
synced 2025-06-21 10:44:42 +00:00
parent
5322c3c4b1
commit
4ef3360066
11 changed files with 55 additions and 46 deletions
|
@ -104,6 +104,7 @@ import eu.kanade.tachiyomi.ui.security.SecureActivityDelegate
|
|||
import eu.kanade.tachiyomi.ui.webview.WebViewActivity
|
||||
import eu.kanade.tachiyomi.util.chapter.ChapterUtil.Companion.preferredChapterName
|
||||
import eu.kanade.tachiyomi.util.storage.getUriCompat
|
||||
import eu.kanade.tachiyomi.util.system.ThemeUtil
|
||||
import eu.kanade.tachiyomi.util.system.contextCompatColor
|
||||
import eu.kanade.tachiyomi.util.system.contextCompatDrawable
|
||||
import eu.kanade.tachiyomi.util.system.dpToPx
|
||||
|
@ -1548,12 +1549,7 @@ class ReaderActivity : BaseActivity<ReaderActivityBinding>() {
|
|||
6, 7 -> extraPage?.let { secondPage ->
|
||||
(viewer as? PagerViewer)?.let { viewer ->
|
||||
val isLTR = (viewer !is R2LPagerViewer).xor(viewer.config.invertDoublePages)
|
||||
val bg =
|
||||
if (viewer.config.readerTheme >= 2 || viewer.config.readerTheme == 0) {
|
||||
Color.WHITE
|
||||
} else {
|
||||
Color.BLACK
|
||||
}
|
||||
val bg = ThemeUtil.readerBackgroundColor(viewer.config.readerTheme)
|
||||
if (item == 6) {
|
||||
viewModel.shareImages(page, secondPage, isLTR, bg)
|
||||
} else {
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
package eu.kanade.tachiyomi.ui.reader.settings
|
||||
|
||||
import androidx.annotation.StringRes
|
||||
import eu.kanade.tachiyomi.R
|
||||
|
||||
enum class ReaderBackgroundColor(val prefValue: Int, @StringRes val stringRes: Int, @StringRes val longStringRes: Int? = null) {
|
||||
WHITE(0, R.string.white),
|
||||
GRAY(4, R.string.gray_background),
|
||||
BLACK(1, R.string.black),
|
||||
SMART_PAGE(2, R.string.smart_by_page, R.string.smart_based_on_page),
|
||||
SMART_THEME(3, R.string.smart_by_theme, R.string.smart_based_on_page_and_theme),
|
||||
;
|
||||
|
||||
val isSmartColor get() = this == SMART_PAGE || this == SMART_THEME
|
||||
companion object {
|
||||
fun indexFromPref(preference: Int) = values().indexOf(fromPreference(preference))
|
||||
fun fromPreference(preference: Int): ReaderBackgroundColor =
|
||||
values().find { it.prefValue == preference } ?: SMART_PAGE
|
||||
}
|
||||
}
|
|
@ -39,7 +39,16 @@ class ReaderGeneralView @JvmOverloads constructor(context: Context, attrs: Attri
|
|||
} ?: 0,
|
||||
)
|
||||
|
||||
binding.backgroundColor.bindToPreference(preferences.readerTheme(), 0)
|
||||
binding.backgroundColor.setEntries(
|
||||
ReaderBackgroundColor.values()
|
||||
.map { context.getString(it.stringRes) },
|
||||
)
|
||||
val selection = ReaderBackgroundColor.indexFromPref(preferences.readerTheme().get())
|
||||
binding.backgroundColor.setSelection(selection)
|
||||
binding.backgroundColor.onItemSelectedListener = { position ->
|
||||
val backgroundColor = ReaderBackgroundColor.values()[position]
|
||||
preferences.readerTheme().set(backgroundColor.prefValue)
|
||||
}
|
||||
binding.showPageNumber.bindToPreference(preferences.showPageNumber())
|
||||
binding.fullscreen.bindToPreference(preferences.fullscreen())
|
||||
binding.keepscreen.bindToPreference(preferences.keepScreenOn())
|
||||
|
|
|
@ -21,6 +21,7 @@ import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
|||
import eu.kanade.tachiyomi.databinding.ReaderErrorBinding
|
||||
import eu.kanade.tachiyomi.source.model.Page
|
||||
import eu.kanade.tachiyomi.ui.reader.model.ReaderPage
|
||||
import eu.kanade.tachiyomi.ui.reader.settings.ReaderBackgroundColor
|
||||
import eu.kanade.tachiyomi.ui.reader.viewer.ReaderErrorView
|
||||
import eu.kanade.tachiyomi.ui.reader.viewer.ReaderPageImageView
|
||||
import eu.kanade.tachiyomi.ui.reader.viewer.ReaderProgressBar
|
||||
|
@ -131,7 +132,7 @@ class PagerPageHolder(
|
|||
launchLoadJob()
|
||||
setBackgroundColor(
|
||||
when (val theme = viewer.config.readerTheme) {
|
||||
3 -> Color.TRANSPARENT
|
||||
ReaderBackgroundColor.SMART_THEME.prefValue -> Color.TRANSPARENT
|
||||
else -> ThemeUtil.readerBackgroundColor(theme)
|
||||
},
|
||||
)
|
||||
|
@ -490,8 +491,9 @@ class PagerPageHolder(
|
|||
val isAnimated = ImageUtil.isAnimatedAndSupported(stream) ||
|
||||
(stream2?.let { ImageUtil.isAnimatedAndSupported(stream2) } ?: false)
|
||||
withUIContext {
|
||||
val bgColor = ReaderBackgroundColor.fromPreference(viewer.config.readerTheme)
|
||||
if (!isAnimated) {
|
||||
if (viewer.config.readerTheme >= 2) {
|
||||
if (bgColor.isSmartColor) {
|
||||
val bgType = getBGType(viewer.config.readerTheme, context)
|
||||
if (page.bg != null && page.bgType == bgType) {
|
||||
setImage(openStream, false, imageConfig)
|
||||
|
@ -519,7 +521,7 @@ class PagerPageHolder(
|
|||
}
|
||||
} else {
|
||||
setImage(openStream, true, imageConfig)
|
||||
if (viewer.config.readerTheme >= 2 && page.bg != null) {
|
||||
if (bgColor.isSmartColor && page.bg != null) {
|
||||
pageView?.background = page.bg
|
||||
}
|
||||
}
|
||||
|
@ -801,12 +803,7 @@ class PagerPageHolder(
|
|||
splitDoublePages()
|
||||
return supportHingeIfThere(imageBytes.inputStream())
|
||||
}
|
||||
val bg = if (viewer.config.readerTheme >= 2 || viewer.config.readerTheme == 0) {
|
||||
Color.WHITE
|
||||
} else {
|
||||
Color.BLACK
|
||||
}
|
||||
|
||||
val bg = ThemeUtil.readerBackgroundColor(viewer.config.readerTheme)
|
||||
closeStreams(imageStream, imageStream2)
|
||||
extraPage?.let { extraPage ->
|
||||
val shouldSubShiftAnyway = !viewer.activity.manuallyShiftedPages &&
|
||||
|
@ -871,11 +868,7 @@ class PagerPageHolder(
|
|||
return imageBytes.inputStream()
|
||||
}
|
||||
val isLTR = (viewer !is R2LPagerViewer).xor(viewer.config.invertDoublePages)
|
||||
val bg = if (viewer.config.readerTheme >= 2 || viewer.config.readerTheme == 0) {
|
||||
Color.WHITE
|
||||
} else {
|
||||
Color.BLACK
|
||||
}
|
||||
val bg = ThemeUtil.readerBackgroundColor(viewer.config.readerTheme)
|
||||
return ImageUtil.padSingleImage(
|
||||
imageBitmap = imageBitmap,
|
||||
isLTR = isLTR,
|
||||
|
@ -913,7 +906,7 @@ class PagerPageHolder(
|
|||
}
|
||||
|
||||
private fun getBGType(readerTheme: Int, context: Context): Int {
|
||||
return if (readerTheme == 3) {
|
||||
return if (ReaderBackgroundColor.fromPreference(readerTheme) == ReaderBackgroundColor.SMART_THEME) {
|
||||
if (context.isInNightMode()) 2 else 1
|
||||
} else {
|
||||
0 + (context.resources.configuration?.orientation ?: 0) * 10
|
||||
|
|
|
@ -8,6 +8,7 @@ import eu.kanade.tachiyomi.data.preference.asImmediateFlow
|
|||
import eu.kanade.tachiyomi.data.preference.asImmediateFlowIn
|
||||
import eu.kanade.tachiyomi.ui.reader.settings.OrientationType
|
||||
import eu.kanade.tachiyomi.ui.reader.settings.PageLayout
|
||||
import eu.kanade.tachiyomi.ui.reader.settings.ReaderBackgroundColor
|
||||
import eu.kanade.tachiyomi.ui.reader.settings.ReaderBottomButton
|
||||
import eu.kanade.tachiyomi.ui.reader.settings.ReadingModeType
|
||||
import eu.kanade.tachiyomi.ui.reader.viewer.ViewerNavigation
|
||||
|
@ -94,21 +95,16 @@ class SettingsReaderController : SettingsController() {
|
|||
titleRes = R.string.default_orientation
|
||||
val enumConstants = OrientationType.values().drop(1)
|
||||
entriesRes = enumConstants.map { it.stringRes }.toTypedArray()
|
||||
entryValues = OrientationType.values().drop(1)
|
||||
.map { value -> value.flagValue }
|
||||
entryValues = enumConstants.map { value -> value.flagValue }
|
||||
defaultValue = OrientationType.FREE.flagValue
|
||||
}
|
||||
intListPreference(activity) {
|
||||
key = Keys.readerTheme
|
||||
titleRes = R.string.background_color
|
||||
entriesRes = arrayOf(
|
||||
R.string.white,
|
||||
R.string.black,
|
||||
R.string.smart_based_on_page,
|
||||
R.string.smart_based_on_page_and_theme,
|
||||
)
|
||||
entryRange = 0..3
|
||||
defaultValue = 2
|
||||
val enumConstants = ReaderBackgroundColor.values()
|
||||
entriesRes = enumConstants.map { it.longStringRes ?: it.stringRes }.toTypedArray()
|
||||
entryValues = enumConstants.map { it.prefValue }
|
||||
defaultValue = ReaderBackgroundColor.SMART_PAGE.prefValue
|
||||
}
|
||||
switchPreference {
|
||||
key = Keys.fullscreen
|
||||
|
|
|
@ -10,6 +10,7 @@ import androidx.preference.PreferenceManager
|
|||
import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.data.preference.PreferenceKeys
|
||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||
import eu.kanade.tachiyomi.ui.reader.settings.ReaderBackgroundColor
|
||||
import uy.kohesive.injekt.injectLazy
|
||||
|
||||
object ThemeUtil {
|
||||
|
@ -46,8 +47,9 @@ object ThemeUtil {
|
|||
}
|
||||
|
||||
fun readerBackgroundColor(theme: Int): Int {
|
||||
return when (theme) {
|
||||
1 -> Color.BLACK
|
||||
return when (ReaderBackgroundColor.fromPreference(theme)) {
|
||||
ReaderBackgroundColor.GRAY -> Color.rgb(32, 33, 37)
|
||||
ReaderBackgroundColor.BLACK -> Color.BLACK
|
||||
else -> Color.WHITE
|
||||
}
|
||||
}
|
||||
|
|
|
@ -112,14 +112,14 @@ class MaterialSpinnerView constructor(context: Context, attrs: AttributeSet?) :
|
|||
}
|
||||
|
||||
fun setSelection(selection: Int) {
|
||||
if (selectedPosition >= 0 && selectedPosition < popup?.menu?.size() ?: 0) {
|
||||
if (selectedPosition >= 0 && selectedPosition < (popup?.menu?.size() ?: 0)) {
|
||||
popup?.menu?.get(selectedPosition)?.let {
|
||||
it.icon = ContextCompat.getDrawable(context, R.drawable.ic_blank_24dp)
|
||||
it.title = entries[selectedPosition]
|
||||
}
|
||||
}
|
||||
selectedPosition = selection
|
||||
if (selectedPosition >= 0 && selectedPosition < popup?.menu?.size() ?: 0) {
|
||||
if (selectedPosition >= 0 && selectedPosition < (popup?.menu?.size() ?: 0)) {
|
||||
popup?.menu?.get(selectedPosition)?.let {
|
||||
it.icon = tintedCheck()
|
||||
it.title = it.title?.tintText(blendedAccent)
|
||||
|
|
|
@ -60,8 +60,7 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="4dp"
|
||||
app:title="@string/background_color"
|
||||
android:entries="@array/reader_themes" />
|
||||
app:title="@string/background_color" />
|
||||
|
||||
<com.google.android.material.materialswitch.MaterialSwitch
|
||||
android:id="@+id/show_page_number"
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
<color name="tachiyomi_primaryInverse">#0057CE</color>
|
||||
|
||||
<!-- Application Colors -->
|
||||
<color name="primaryVariantTachiyomi">#272829</color>
|
||||
<color name="primaryVariantTachiyomi">#202125</color>
|
||||
<color name="colorPrimaryInactive">@color/md_white_1000_76</color>
|
||||
<color name="onPrimaryTachiyomi">#071D39</color>
|
||||
<color name="primaryTachiyomi">#78bcff</color>
|
||||
|
|
|
@ -10,13 +10,6 @@
|
|||
<item>@string/continuous_vertical</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="reader_themes">
|
||||
<item>@string/white</item>
|
||||
<item>@string/black</item>
|
||||
<item>@string/smart_by_page</item>
|
||||
<item>@string/smart_by_theme</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="hopper_long_press">
|
||||
<item>@string/search</item>
|
||||
<item>@string/expand_collapse_all_categories</item>
|
||||
|
|
|
@ -438,6 +438,7 @@
|
|||
<string name="invert_volume_keys">Invert volume keys</string>
|
||||
<string name="background_color">Background color</string>
|
||||
<string name="white">White</string>
|
||||
<string name="gray_background">Gray</string>
|
||||
<string name="black">Black</string>
|
||||
<string name="smart_by_page">Smart (by page)</string>
|
||||
<string name="smart_by_theme">Smart (by theme)</string>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue