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 @@ + + + + + + + + + + + + + + +