From b2d58e04d262ef30e9232c46e917d45e6dc34c8d Mon Sep 17 00:00:00 2001 From: Ivan Iskandar <12537387+ivaniskandar@users.noreply.github.com> Date: Mon, 19 Jul 2021 00:01:58 +0700 Subject: [PATCH] Add Dynamic theme for Android 12 (#5569) * Add Dynamic theme for Android 12 * Also theme text colors --- .../data/preference/PreferenceValues.kt | 1 + .../ui/base/activity/BaseThemedActivity.kt | 3 +++ .../ui/setting/SettingsGeneralController.kt | 9 ++++++++- .../res/color-night-v31/text_primary_monet.xml | 5 +++++ .../color-night-v31/text_secondary_monet.xml | 5 +++++ .../main/res/color-v31/ripple_colored_monet.xml | 4 ++++ .../main/res/color-v31/text_primary_monet.xml | 5 +++++ .../main/res/color-v31/text_secondary_monet.xml | 5 +++++ app/src/main/res/values-night/colors.xml | 11 ++++++++++- app/src/main/res/values-v31/themes.xml | 17 +++++++++++++++++ app/src/main/res/values/colors.xml | 13 ++++++++++++- app/src/main/res/values/strings.xml | 1 + app/src/main/res/values/themes.xml | 3 +++ 13 files changed, 79 insertions(+), 3 deletions(-) create mode 100644 app/src/main/res/color-night-v31/text_primary_monet.xml create mode 100644 app/src/main/res/color-night-v31/text_secondary_monet.xml create mode 100644 app/src/main/res/color-v31/ripple_colored_monet.xml create mode 100644 app/src/main/res/color-v31/text_primary_monet.xml create mode 100644 app/src/main/res/color-v31/text_secondary_monet.xml create mode 100644 app/src/main/res/values-v31/themes.xml diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferenceValues.kt b/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferenceValues.kt index 73ee5da1ba..59c524f559 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferenceValues.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferenceValues.kt @@ -23,6 +23,7 @@ object PreferenceValues { enum class AppTheme(val titleResId: Int?) { DEFAULT(R.string.theme_default), + MONET(R.string.theme_monet), BLUE(R.string.theme_blue), GREEN_APPLE(R.string.theme_greenapple), MIDNIGHT_DUSK(R.string.theme_midnightdusk), diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/base/activity/BaseThemedActivity.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/base/activity/BaseThemedActivity.kt index a1a298c231..ffe30c6f9b 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/base/activity/BaseThemedActivity.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/base/activity/BaseThemedActivity.kt @@ -40,6 +40,9 @@ abstract class BaseThemedActivity : AppCompatActivity() { fun AppCompatActivity.applyThemePreferences(preferences: PreferencesHelper) { val resIds = mutableListOf() when (preferences.appTheme().get()) { + PreferenceValues.AppTheme.MONET -> { + resIds += R.style.Theme_Tachiyomi_Monet + } PreferenceValues.AppTheme.BLUE -> { resIds += R.style.Theme_Tachiyomi_Blue resIds += R.style.ThemeOverlay_Tachiyomi_ColoredBars diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsGeneralController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsGeneralController.kt index 7078473307..a517b517d1 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsGeneralController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsGeneralController.kt @@ -122,7 +122,14 @@ class SettingsGeneralController : SettingsController() { key = Keys.appTheme titleRes = R.string.pref_app_theme - val appThemes = Values.AppTheme.values().filter { it.titleResId != null } + val appThemes = Values.AppTheme.values().filter { + val monetFilter = if (it == Values.AppTheme.MONET) { + Build.VERSION.SDK_INT >= Build.VERSION_CODES.S + } else { + true + } + it.titleResId != null && monetFilter + } entriesRes = appThemes.map { it.titleResId!! }.toTypedArray() entryValues = appThemes.map { it.name }.toTypedArray() defaultValue = appThemes[0].name diff --git a/app/src/main/res/color-night-v31/text_primary_monet.xml b/app/src/main/res/color-night-v31/text_primary_monet.xml new file mode 100644 index 0000000000..97887072c3 --- /dev/null +++ b/app/src/main/res/color-night-v31/text_primary_monet.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/app/src/main/res/color-night-v31/text_secondary_monet.xml b/app/src/main/res/color-night-v31/text_secondary_monet.xml new file mode 100644 index 0000000000..532e203af5 --- /dev/null +++ b/app/src/main/res/color-night-v31/text_secondary_monet.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/app/src/main/res/color-v31/ripple_colored_monet.xml b/app/src/main/res/color-v31/ripple_colored_monet.xml new file mode 100644 index 0000000000..efaa46d448 --- /dev/null +++ b/app/src/main/res/color-v31/ripple_colored_monet.xml @@ -0,0 +1,4 @@ + + + + diff --git a/app/src/main/res/color-v31/text_primary_monet.xml b/app/src/main/res/color-v31/text_primary_monet.xml new file mode 100644 index 0000000000..21d75f6238 --- /dev/null +++ b/app/src/main/res/color-v31/text_primary_monet.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/app/src/main/res/color-v31/text_secondary_monet.xml b/app/src/main/res/color-v31/text_secondary_monet.xml new file mode 100644 index 0000000000..bd555089a7 --- /dev/null +++ b/app/src/main/res/color-v31/text_secondary_monet.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/app/src/main/res/values-night/colors.xml b/app/src/main/res/values-night/colors.xml index f1ce4138ab..4e43f3595d 100644 --- a/app/src/main/res/values-night/colors.xml +++ b/app/src/main/res/values-night/colors.xml @@ -1,5 +1,5 @@ - + @color/background_default @@ -9,6 +9,15 @@ #202125 #1F3399FF + + @android:color/system_accent1_100 + @android:color/system_accent1_900 + @android:color/system_neutral1_700 + @android:color/system_accent3_100 + @android:color/system_accent3_900 + @android:color/system_neutral1_900 + @android:color/system_neutral1_50 + #48E484 @color/md_black_1000 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..04aa6893ff --- /dev/null +++ b/app/src/main/res/values-v31/themes.xml @@ -0,0 +1,17 @@ + + + + diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index 89b3195f14..ffaae60531 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -1,5 +1,5 @@ - + @color/accent_blue @@ -9,6 +9,17 @@ @color/md_grey_50 @color/md_blue_A400_12 + + @android:color/system_accent1_600 + @android:color/system_accent1_10 + @android:color/system_neutral1_200 + @android:color/system_accent3_600 + @android:color/system_accent3_10 + @android:color/system_neutral1_50 + @android:color/system_neutral1_900 + @color/surface_monet + @color/on_surface_monet + #54759E #1F54759E diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index ba8e570278..a6429a94f1 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -148,6 +148,7 @@ On App theme Default + Dynamic Blue Green Apple Midnight Dusk diff --git a/app/src/main/res/values/themes.xml b/app/src/main/res/values/themes.xml index e1ae64e4bd..c95271d495 100644 --- a/app/src/main/res/values/themes.xml +++ b/app/src/main/res/values/themes.xml @@ -74,6 +74,9 @@