From 2dc884b1bb107765b16971953e0eb83bce22987e Mon Sep 17 00:00:00 2001 From: LucasGGamerM Date: Sat, 10 Dec 2022 12:59:24 -0300 Subject: [PATCH] Making material you setting work fine. Its ready for release --- .../android/GlobalUserPreferences.java | 4 +- .../android/fragments/SettingsFragment.java | 11 ++ .../android/ui/utils/UiUtils.java | 10 ++ mastodon/src/main/res/menu/color_picker.xml | 1 + mastodon/src/main/res/values-night/styles.xml | 3 + mastodon/src/main/res/values-v31/colors.xml | 3 + mastodon/src/main/res/values/strings_sk.xml | 3 +- mastodon/src/main/res/values/styles.xml | 122 ++++++++++++++++++ 8 files changed, 155 insertions(+), 2 deletions(-) diff --git a/mastodon/src/main/java/org/joinmastodon/android/GlobalUserPreferences.java b/mastodon/src/main/java/org/joinmastodon/android/GlobalUserPreferences.java index 5ef37ee08..630bf63f4 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/GlobalUserPreferences.java +++ b/mastodon/src/main/java/org/joinmastodon/android/GlobalUserPreferences.java @@ -82,7 +82,9 @@ public class GlobalUserPreferences{ GREEN, BLUE, BROWN, - YELLOW + ORANGE, + YELLOW, + MATERIAL3 } public enum ThemePreference{ diff --git a/mastodon/src/main/java/org/joinmastodon/android/fragments/SettingsFragment.java b/mastodon/src/main/java/org/joinmastodon/android/fragments/SettingsFragment.java index 60648fe9b..f0d9d3231 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/SettingsFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/SettingsFragment.java @@ -242,6 +242,7 @@ public class SettingsFragment extends MastodonToolbarFragment{ } private void onColorPreferenceClick(GlobalUserPreferences.ColorPreference color){ + GlobalUserPreferences.color=color; GlobalUserPreferences.save(); restartActivityToApplyNewTheme(); @@ -709,6 +710,15 @@ public class SettingsFragment extends MastodonToolbarFragment{ pref = GlobalUserPreferences.ColorPreference.YELLOW; onColorPreferenceClick(pref); } + else if(id==R.id.m3_color) { + if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) { + pref = GlobalUserPreferences.ColorPreference.MATERIAL3; + onColorPreferenceClick(pref); + }else{ + Toast.makeText(getActivity(), R.string.sk_not_supported, + Toast.LENGTH_LONG).show(); + } + } else return false; return true; @@ -728,6 +738,7 @@ public class SettingsFragment extends MastodonToolbarFragment{ case BLUE -> R.string.sk_color_theme_blue; case BROWN -> R.string.sk_color_theme_brown; case YELLOW -> R.string.sk_color_theme_yellow; + case MATERIAL3 -> R.string.sk_color_theme_material_you; }); } } diff --git a/mastodon/src/main/java/org/joinmastodon/android/ui/utils/UiUtils.java b/mastodon/src/main/java/org/joinmastodon/android/ui/utils/UiUtils.java index 7caf71663..eb08329eb 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/ui/utils/UiUtils.java +++ b/mastodon/src/main/java/org/joinmastodon/android/ui/utils/UiUtils.java @@ -718,6 +718,16 @@ public class UiUtils{ GlobalUserPreferences.trueBlackTheme ? R.style.Theme_Mastodon_Dark_TrueBlack_Yellow : R.style.Theme_Mastodon_Dark_Yellow; }); break; + case MATERIAL3: + context.setTheme(switch(GlobalUserPreferences.theme){ + case AUTO -> + GlobalUserPreferences.trueBlackTheme ? R.style.Theme_Mastodon_AutoLightDark_TrueBlack_Material3 : R.style.Theme_Mastodon_AutoLightDark_Material3; + case LIGHT -> + R.style.Theme_Mastodon_Light_Material3; + case DARK -> + GlobalUserPreferences.trueBlackTheme ? R.style.Theme_Mastodon_Dark_TrueBlack_Material3 : R.style.Theme_Mastodon_Dark_Material3; + }); + break; } } diff --git a/mastodon/src/main/res/menu/color_picker.xml b/mastodon/src/main/res/menu/color_picker.xml index 85e4fa1bf..8edbeab1d 100644 --- a/mastodon/src/main/res/menu/color_picker.xml +++ b/mastodon/src/main/res/menu/color_picker.xml @@ -6,4 +6,5 @@ + \ No newline at end of file diff --git a/mastodon/src/main/res/values-night/styles.xml b/mastodon/src/main/res/values-night/styles.xml index 6d2c4b41e..8d00d786b 100644 --- a/mastodon/src/main/res/values-night/styles.xml +++ b/mastodon/src/main/res/values-night/styles.xml @@ -17,4 +17,7 @@ + + + + + + + + + + + + + + +