Added Monet Themes

This commit is contained in:
Jays2Kings 2021-07-05 14:48:02 -04:00
parent 34fe1e44e5
commit 6d6ac4df05
6 changed files with 112 additions and 22 deletions

View File

@ -1,9 +1,11 @@
package eu.kanade.tachiyomi.ui.setting package eu.kanade.tachiyomi.ui.setting
import android.annotation.SuppressLint
import android.app.Activity import android.app.Activity
import android.content.Context import android.content.Context
import android.content.res.ColorStateList import android.content.res.ColorStateList
import android.graphics.Color import android.graphics.Color
import android.os.Build
import android.util.AttributeSet import android.util.AttributeSet
import android.view.View import android.view.View
import androidx.appcompat.app.AppCompatDelegate 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.ThemeUtil
import eu.kanade.tachiyomi.util.system.Themes import eu.kanade.tachiyomi.util.system.Themes
import eu.kanade.tachiyomi.util.system.appDelegateNightMode 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.dpToPx
import eu.kanade.tachiyomi.util.system.isInNightMode import eu.kanade.tachiyomi.util.system.isInNightMode
import uy.kohesive.injekt.injectLazy import uy.kohesive.injekt.injectLazy
@ -56,14 +59,15 @@ class ThemePreference @JvmOverloads constructor(context: Context, attrs: Attribu
selectExtensionLight = fastAdapterLight.getSelectExtension().setThemeListener(false) selectExtensionLight = fastAdapterLight.getSelectExtension().setThemeListener(false)
selectExtensionDark = fastAdapterDark.getSelectExtension().setThemeListener(true) selectExtensionDark = fastAdapterDark.getSelectExtension().setThemeListener(true)
val enumConstants = Themes.values() val enumConstants = Themes.values()
val isOnA12 = Build.VERSION.SDK_INT + Build.VERSION.PREVIEW_SDK_INT >= 31
itemAdapterLight.set( itemAdapterLight.set(
enumConstants enumConstants
.filter { !it.isDarkTheme || it.followsSystem } .filter { (!it.isDarkTheme || it.followsSystem) && (it.styleRes != R.style.Theme_Tachiyomi_Monet || isOnA12) }
.map { ThemeItem(it, false) } .map { ThemeItem(it, false) }
) )
itemAdapterDark.set( itemAdapterDark.set(
enumConstants enumConstants
.filter { it.isDarkTheme || it.followsSystem } .filter { (it.isDarkTheme || it.followsSystem) && (it.styleRes != R.style.Theme_Tachiyomi_Monet || isOnA12) }
.map { ThemeItem(it, true) } .map { ThemeItem(it, true) }
) )
isSelectable = false isSelectable = false
@ -207,6 +211,8 @@ class ThemePreference @JvmOverloads constructor(context: Context, attrs: Attribu
inner class ViewHolder(view: View) : FastAdapter.ViewHolder<ThemeItem>(view) { inner class ViewHolder(view: View) : FastAdapter.ViewHolder<ThemeItem>(view) {
val binding = ThemeItemBinding.bind(view) val binding = ThemeItemBinding.bind(view)
@SuppressLint("InlinedApi")
override fun bindView(item: ThemeItem, payloads: List<Any>) { override fun bindView(item: ThemeItem, payloads: List<Any>) {
binding.themeNameText.setText( binding.themeNameText.setText(
if (item.isDarkTheme) { if (item.isDarkTheme) {
@ -228,6 +234,51 @@ class ThemePreference @JvmOverloads constructor(context: Context, attrs: Attribu
binding.themeSelected.alpha = if (themeMatchesApp) 1f else 0.5f binding.themeSelected.alpha = if (themeMatchesApp) 1f else 0.5f
binding.checkbox.alpha = if (themeMatchesApp) 1f else 0.5f binding.checkbox.alpha = if (themeMatchesApp) 1f else 0.5f
} }
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.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.themeToolbar.setBackgroundColor(item.colors.appBar)
binding.themeAppBarText.imageTintList = binding.themeAppBarText.imageTintList =
ColorStateList.valueOf(item.colors.appBarText) ColorStateList.valueOf(item.colors.appBarText)
@ -249,6 +300,7 @@ class ThemePreference @JvmOverloads constructor(context: Context, attrs: Attribu
binding.themeItem3.imageTintList = binding.themeItem3.imageTintList =
ColorStateList.valueOf(item.colors.inactiveTab) ColorStateList.valueOf(item.colors.inactiveTab)
binding.themeLayout.setBackgroundColor(item.colors.colorBackground) binding.themeLayout.setBackgroundColor(item.colors.colorBackground)
}
if (item.isDarkTheme && preferences.themeDarkAmoled().get()) { if (item.isDarkTheme && preferences.themeDarkAmoled().get()) {
binding.themeLayout.setBackgroundColor(Color.BLACK) binding.themeLayout.setBackgroundColor(Color.BLACK)
if (!ThemeUtil.isColoredTheme(item.theme)) { if (!ThemeUtil.isColoredTheme(item.theme)) {

View File

@ -11,6 +11,12 @@ import kotlin.math.roundToInt
@Suppress("unused") @Suppress("unused")
enum class Themes(@StyleRes val styleRes: Int, val nightMode: Int, @StringRes val nameRes: Int, @StringRes altNameRes: Int? = null) { 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( DEFAULT(
R.style.Theme_Tachiyomi, R.style.Theme_Tachiyomi,
AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM, AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM,

View 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>

View 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>

View File

@ -625,6 +625,8 @@
<string name="midnight_dusk">Midnight Dusk</string> <string name="midnight_dusk">Midnight Dusk</string>
<string name="spring_blossom">Spring Blossom</string> <string name="spring_blossom">Spring Blossom</string>
<string name="strawberry_daiquiri">Strawberry Daiquiri</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="yotsuba">Yotsuba</string>
<string name="yin">Yin</string> <string name="yin">Yin</string>
<string name="yang">Yang</string> <string name="yang">Yang</string>

View File

@ -105,6 +105,7 @@
<item name="colorAccentText">@color/colorAccentYinyangText</item> <item name="colorAccentText">@color/colorAccentYinyangText</item>
<item name="colorOnAccent">@color/colorOnAccentYinyang</item> <item name="colorOnAccent">@color/colorOnAccentYinyang</item>
</style> </style>
<style name="Theme.Tachiyomi.Monet"/>
<!--===============--> <!--===============-->
<!-- Launch Screen --> <!-- Launch Screen -->