From 34fe1e44e5e675661de37d8fb4b96ac029c74217 Mon Sep 17 00:00:00 2001 From: Jays2Kings Date: Mon, 5 Jul 2021 14:47:03 -0400 Subject: [PATCH 01/22] Set compile sdk to Android S --- buildSrc/src/main/kotlin/Dependencies.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buildSrc/src/main/kotlin/Dependencies.kt b/buildSrc/src/main/kotlin/Dependencies.kt index c6bb5b7277..85dc33075b 100644 --- a/buildSrc/src/main/kotlin/Dependencies.kt +++ b/buildSrc/src/main/kotlin/Dependencies.kt @@ -93,7 +93,7 @@ object LegacyPluginClassPath { } object AndroidVersions { - const val compileSdk = 30 + const val compileSdk = "android-S" const val minSdk = 23 const val targetSdk = 30 const val versionCode = 77 From 6d6ac4df0566c0d8bbfbd31266dc8884be3bdbc9 Mon Sep 17 00:00:00 2001 From: Jays2Kings Date: Mon, 5 Jul 2021 14:48:02 -0400 Subject: [PATCH 02/22] Added Monet Themes --- .../tachiyomi/ui/setting/ThemePreference.kt | 96 ++++++++++++++----- .../eu/kanade/tachiyomi/util/system/Themes.kt | 6 ++ app/src/main/res/values-night-v31/themes.xml | 15 +++ app/src/main/res/values-v31/themes.xml | 14 +++ app/src/main/res/values/strings.xml | 2 + app/src/main/res/values/themes.xml | 1 + 6 files changed, 112 insertions(+), 22 deletions(-) create mode 100644 app/src/main/res/values-night-v31/themes.xml create mode 100644 app/src/main/res/values-v31/themes.xml diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/ThemePreference.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/ThemePreference.kt index 43c9f10972..d5a4e46165 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/ThemePreference.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/ThemePreference.kt @@ -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(view) { val binding = ThemeItemBinding.bind(view) + + @SuppressLint("InlinedApi") override fun bindView(item: ThemeItem, payloads: List) { 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)) { diff --git a/app/src/main/java/eu/kanade/tachiyomi/util/system/Themes.kt b/app/src/main/java/eu/kanade/tachiyomi/util/system/Themes.kt index cecf938f2e..2b4bb83de0 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/util/system/Themes.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/util/system/Themes.kt @@ -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, diff --git a/app/src/main/res/values-night-v31/themes.xml b/app/src/main/res/values-night-v31/themes.xml new file mode 100644 index 0000000000..eed409b7ec --- /dev/null +++ b/app/src/main/res/values-night-v31/themes.xml @@ -0,0 +1,15 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/values-v31/themes.xml b/app/src/main/res/values-v31/themes.xml new file mode 100644 index 0000000000..882a83cb4f --- /dev/null +++ b/app/src/main/res/values-v31/themes.xml @@ -0,0 +1,14 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 9467ff6ff4..a446809e68 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -625,6 +625,8 @@ Midnight Dusk Spring Blossom Strawberry Daiquiri + A Brighter You + A Calmer You Yotsuba Yin Yang diff --git a/app/src/main/res/values/themes.xml b/app/src/main/res/values/themes.xml index 6ae4156e8d..86d4227ac7 100644 --- a/app/src/main/res/values/themes.xml +++ b/app/src/main/res/values/themes.xml @@ -105,6 +105,7 @@ @color/colorAccentYinyangText @color/colorOnAccentYinyang +