mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-12-23 15:01:52 +01:00
Added Monet Themes
This commit is contained in:
parent
34fe1e44e5
commit
6d6ac4df05
@ -1,9 +1,11 @@
|
||||
package eu.kanade.tachiyomi.ui.setting
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.app.Activity
|
||||
import android.content.Context
|
||||
import android.content.res.ColorStateList
|
||||
import android.graphics.Color
|
||||
import android.os.Build
|
||||
import android.util.AttributeSet
|
||||
import android.view.View
|
||||
import androidx.appcompat.app.AppCompatDelegate
|
||||
@ -26,6 +28,7 @@ import eu.kanade.tachiyomi.databinding.ThemesPreferenceBinding
|
||||
import eu.kanade.tachiyomi.util.system.ThemeUtil
|
||||
import eu.kanade.tachiyomi.util.system.Themes
|
||||
import eu.kanade.tachiyomi.util.system.appDelegateNightMode
|
||||
import eu.kanade.tachiyomi.util.system.contextCompatColor
|
||||
import eu.kanade.tachiyomi.util.system.dpToPx
|
||||
import eu.kanade.tachiyomi.util.system.isInNightMode
|
||||
import uy.kohesive.injekt.injectLazy
|
||||
@ -56,14 +59,15 @@ class ThemePreference @JvmOverloads constructor(context: Context, attrs: Attribu
|
||||
selectExtensionLight = fastAdapterLight.getSelectExtension().setThemeListener(false)
|
||||
selectExtensionDark = fastAdapterDark.getSelectExtension().setThemeListener(true)
|
||||
val enumConstants = Themes.values()
|
||||
val isOnA12 = Build.VERSION.SDK_INT + Build.VERSION.PREVIEW_SDK_INT >= 31
|
||||
itemAdapterLight.set(
|
||||
enumConstants
|
||||
.filter { !it.isDarkTheme || it.followsSystem }
|
||||
.filter { (!it.isDarkTheme || it.followsSystem) && (it.styleRes != R.style.Theme_Tachiyomi_Monet || isOnA12) }
|
||||
.map { ThemeItem(it, false) }
|
||||
)
|
||||
itemAdapterDark.set(
|
||||
enumConstants
|
||||
.filter { it.isDarkTheme || it.followsSystem }
|
||||
.filter { (it.isDarkTheme || it.followsSystem) && (it.styleRes != R.style.Theme_Tachiyomi_Monet || isOnA12) }
|
||||
.map { ThemeItem(it, true) }
|
||||
)
|
||||
isSelectable = false
|
||||
@ -207,6 +211,8 @@ class ThemePreference @JvmOverloads constructor(context: Context, attrs: Attribu
|
||||
inner class ViewHolder(view: View) : FastAdapter.ViewHolder<ThemeItem>(view) {
|
||||
|
||||
val binding = ThemeItemBinding.bind(view)
|
||||
|
||||
@SuppressLint("InlinedApi")
|
||||
override fun bindView(item: ThemeItem, payloads: List<Any>) {
|
||||
binding.themeNameText.setText(
|
||||
if (item.isDarkTheme) {
|
||||
@ -228,27 +234,73 @@ class ThemePreference @JvmOverloads constructor(context: Context, attrs: Attribu
|
||||
binding.themeSelected.alpha = if (themeMatchesApp) 1f else 0.5f
|
||||
binding.checkbox.alpha = if (themeMatchesApp) 1f else 0.5f
|
||||
}
|
||||
binding.themeToolbar.setBackgroundColor(item.colors.appBar)
|
||||
binding.themeAppBarText.imageTintList =
|
||||
ColorStateList.valueOf(item.colors.appBarText)
|
||||
binding.themeHeroImage.imageTintList =
|
||||
ColorStateList.valueOf(item.colors.primaryText)
|
||||
binding.themePrimaryText.imageTintList =
|
||||
ColorStateList.valueOf(item.colors.primaryText)
|
||||
binding.themeAccentedButton.imageTintList =
|
||||
ColorStateList.valueOf(item.colors.colorAccent)
|
||||
binding.themeSecondaryText.imageTintList =
|
||||
ColorStateList.valueOf(item.colors.secondaryText)
|
||||
binding.themeSecondaryText2.imageTintList =
|
||||
ColorStateList.valueOf(item.colors.secondaryText)
|
||||
if (item.theme.styleRes == R.style.Theme_Tachiyomi_Monet) {
|
||||
val nightMode = item.isDarkTheme
|
||||
val appBar = context.contextCompatColor(
|
||||
if (nightMode) android.R.color.system_neutral1_900
|
||||
else android.R.color.system_neutral1_50
|
||||
)
|
||||
val appBarText = context.contextCompatColor(
|
||||
if (nightMode) android.R.color.system_accent2_10
|
||||
else android.R.color.system_accent2_800
|
||||
)
|
||||
val colorAccent = context.contextCompatColor(
|
||||
if (nightMode) android.R.color.system_accent1_300
|
||||
else android.R.color.system_accent1_500
|
||||
)
|
||||
val bottomBar = context.contextCompatColor(
|
||||
if (nightMode) android.R.color.system_neutral1_800
|
||||
else android.R.color.system_accent2_100
|
||||
)
|
||||
val colorBackground = context.contextCompatColor(
|
||||
if (nightMode) android.R.color.system_neutral1_900
|
||||
else android.R.color.system_neutral1_50
|
||||
)
|
||||
|
||||
binding.themeBottomBar.setBackgroundColor(item.colors.bottomBar)
|
||||
binding.themeItem1.imageTintList =
|
||||
ColorStateList.valueOf(item.colors.inactiveTab)
|
||||
binding.themeItem2.imageTintList = ColorStateList.valueOf(item.colors.activeTab)
|
||||
binding.themeItem3.imageTintList =
|
||||
ColorStateList.valueOf(item.colors.inactiveTab)
|
||||
binding.themeLayout.setBackgroundColor(item.colors.colorBackground)
|
||||
binding.themeToolbar.setBackgroundColor(appBar)
|
||||
binding.themeAppBarText.imageTintList =
|
||||
ColorStateList.valueOf(appBarText)
|
||||
binding.themeHeroImage.imageTintList =
|
||||
ColorStateList.valueOf(item.colors.primaryText)
|
||||
binding.themePrimaryText.imageTintList =
|
||||
ColorStateList.valueOf(item.colors.primaryText)
|
||||
binding.themeAccentedButton.imageTintList =
|
||||
ColorStateList.valueOf(colorAccent)
|
||||
binding.themeSecondaryText.imageTintList =
|
||||
ColorStateList.valueOf(item.colors.secondaryText)
|
||||
binding.themeSecondaryText2.imageTintList =
|
||||
ColorStateList.valueOf(item.colors.secondaryText)
|
||||
|
||||
binding.themeBottomBar.setBackgroundColor(bottomBar)
|
||||
binding.themeItem1.imageTintList =
|
||||
ColorStateList.valueOf(item.colors.inactiveTab)
|
||||
binding.themeItem2.imageTintList = ColorStateList.valueOf(colorAccent)
|
||||
binding.themeItem3.imageTintList =
|
||||
ColorStateList.valueOf(item.colors.inactiveTab)
|
||||
binding.themeLayout.setBackgroundColor(colorBackground)
|
||||
} else {
|
||||
binding.themeToolbar.setBackgroundColor(item.colors.appBar)
|
||||
binding.themeAppBarText.imageTintList =
|
||||
ColorStateList.valueOf(item.colors.appBarText)
|
||||
binding.themeHeroImage.imageTintList =
|
||||
ColorStateList.valueOf(item.colors.primaryText)
|
||||
binding.themePrimaryText.imageTintList =
|
||||
ColorStateList.valueOf(item.colors.primaryText)
|
||||
binding.themeAccentedButton.imageTintList =
|
||||
ColorStateList.valueOf(item.colors.colorAccent)
|
||||
binding.themeSecondaryText.imageTintList =
|
||||
ColorStateList.valueOf(item.colors.secondaryText)
|
||||
binding.themeSecondaryText2.imageTintList =
|
||||
ColorStateList.valueOf(item.colors.secondaryText)
|
||||
|
||||
binding.themeBottomBar.setBackgroundColor(item.colors.bottomBar)
|
||||
binding.themeItem1.imageTintList =
|
||||
ColorStateList.valueOf(item.colors.inactiveTab)
|
||||
binding.themeItem2.imageTintList = ColorStateList.valueOf(item.colors.activeTab)
|
||||
binding.themeItem3.imageTintList =
|
||||
ColorStateList.valueOf(item.colors.inactiveTab)
|
||||
binding.themeLayout.setBackgroundColor(item.colors.colorBackground)
|
||||
}
|
||||
if (item.isDarkTheme && preferences.themeDarkAmoled().get()) {
|
||||
binding.themeLayout.setBackgroundColor(Color.BLACK)
|
||||
if (!ThemeUtil.isColoredTheme(item.theme)) {
|
||||
|
@ -11,6 +11,12 @@ import kotlin.math.roundToInt
|
||||
|
||||
@Suppress("unused")
|
||||
enum class Themes(@StyleRes val styleRes: Int, val nightMode: Int, @StringRes val nameRes: Int, @StringRes altNameRes: Int? = null) {
|
||||
MONET(
|
||||
R.style.Theme_Tachiyomi_Monet,
|
||||
AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM,
|
||||
R.string.a_brighter_you,
|
||||
R.string.a_calmer_you
|
||||
),
|
||||
DEFAULT(
|
||||
R.style.Theme_Tachiyomi,
|
||||
AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM,
|
||||
|
15
app/src/main/res/values-night-v31/themes.xml
Normal file
15
app/src/main/res/values-night-v31/themes.xml
Normal file
@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<style name="Theme.Tachiyomi.Monet">
|
||||
<item name="colorPrimary">@android:color/system_accent2_800</item>
|
||||
<item name="colorAccent">@android:color/system_accent1_300</item>
|
||||
<item name="colorAccentText">@android:color/system_accent1_200</item>
|
||||
<item name="colorPrimaryVariant">@android:color/system_neutral1_800</item>
|
||||
<item name="colorSecondary">@android:color/system_neutral1_900</item>
|
||||
<item name="background">@android:color/system_neutral1_900</item>
|
||||
<item name="android:textColorPrimary">@android:color/system_accent2_10</item>
|
||||
<item name="android:colorBackground">@android:color/system_neutral1_900</item>
|
||||
<item name="actionBarTintColor">@android:color/system_accent2_10</item>
|
||||
<item name="colorOnAccent">@android:color/system_neutral2_900</item>
|
||||
</style>
|
||||
</resources>
|
14
app/src/main/res/values-v31/themes.xml
Normal file
14
app/src/main/res/values-v31/themes.xml
Normal file
@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<style name="Theme.Tachiyomi.Monet">
|
||||
<item name="colorPrimary">@android:color/system_accent2_100</item>
|
||||
<item name="colorAccent">@android:color/system_accent1_500</item>
|
||||
<item name="colorAccentText">@android:color/system_accent1_800</item>
|
||||
<item name="colorPrimaryVariant">@android:color/system_accent2_100</item>
|
||||
<item name="colorSecondary">@android:color/system_neutral1_50</item>
|
||||
<item name="background">@android:color/system_neutral1_50</item>
|
||||
<item name="android:textColorPrimary">@android:color/system_neutral1_900</item>
|
||||
<item name="android:colorBackground">@android:color/system_neutral1_50</item>
|
||||
<item name="actionBarTintColor">@android:color/system_accent2_800</item>
|
||||
</style>
|
||||
</resources>
|
@ -625,6 +625,8 @@
|
||||
<string name="midnight_dusk">Midnight Dusk</string>
|
||||
<string name="spring_blossom">Spring Blossom</string>
|
||||
<string name="strawberry_daiquiri">Strawberry Daiquiri</string>
|
||||
<string name="a_brighter_you">A Brighter You</string>
|
||||
<string name="a_calmer_you">A Calmer You</string>
|
||||
<string name="yotsuba">Yotsuba</string>
|
||||
<string name="yin">Yin</string>
|
||||
<string name="yang">Yang</string>
|
||||
|
@ -105,6 +105,7 @@
|
||||
<item name="colorAccentText">@color/colorAccentYinyangText</item>
|
||||
<item name="colorOnAccent">@color/colorOnAccentYinyang</item>
|
||||
</style>
|
||||
<style name="Theme.Tachiyomi.Monet"/>
|
||||
|
||||
<!--===============-->
|
||||
<!-- Launch Screen -->
|
||||
|
Loading…
Reference in New Issue
Block a user