Making material you setting work fine. Its ready for release

This commit is contained in:
LucasGGamerM 2022-12-10 12:59:24 -03:00 committed by sk
parent c49660950d
commit 2dc884b1bb
8 changed files with 155 additions and 2 deletions

View File

@ -82,7 +82,9 @@ public class GlobalUserPreferences{
GREEN,
BLUE,
BROWN,
YELLOW
ORANGE,
YELLOW,
MATERIAL3
}
public enum ThemePreference{

View File

@ -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;
});
}
}

View File

@ -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;
}
}

View File

@ -6,4 +6,5 @@
<item android:id="@+id/blue_color" android:title="@string/sk_color_theme_blue"/>
<item android:id="@+id/brown_color" android:title="@string/sk_color_theme_brown"/>
<item android:id="@+id/yellow_color" android:title="@string/sk_color_theme_yellow"/>
<item android:id="@+id/m3_color" android:title="@string/sk_color_theme_material_you"/>
</menu>

View File

@ -17,4 +17,7 @@
<style name="Theme.Mastodon.AutoLightDark.Yellow" parent="Theme.Mastodon.Dark.Yellow"/>
<style name="Theme.Mastodon.AutoLightDark.TrueBlack.Yellow" parent="Theme.Mastodon.Dark.TrueBlack.Yellow"/>
<style name="Theme.Mastodon.AutoLightDark.Material3" parent="Theme.Mastodon.Dark.Material3"/>
<style name="Theme.Mastodon.AutoLightDark.TrueBlack.Material3" parent="Theme.Mastodon.Dark.TrueBlack.Material3"/>
</resources>

View File

@ -1,6 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- M3 dynamic colors -->
<color name="m3_navigation_bar_bg">@android:color/system_neutral1_50</color>
<color name="m3_gray_900">@android:color/system_neutral1_900</color>
<color name="m3_gray_800t">@android:color/system_neutral1_800</color>
<color name="m3_gray_800">@android:color/system_neutral1_800</color>

View File

@ -47,6 +47,7 @@
<string name="sk_color_theme_blue">Blue</string>
<string name="sk_color_theme_brown">Brown</string>
<string name="sk_color_theme_yellow">Yellow</string>
<string name="sk_color_theme_material_you">Material You</string>
<string name="sk_poll_allow_multiple">Allow multiple choices</string>
<string name="sk_translate_post">Translate</string>
<string name="sk_translate_show_original">Show original</string>
@ -59,4 +60,4 @@
<string name="sk_welcome_title">Welcome!</string>
<string name="sk_welcome_text">The shark salutes you! To get started, please enter your home instances domain name below.</string>
<string name="sk_example_domain">example.social</string>
</resources>
</resources>

View File

@ -205,6 +205,122 @@
<item name="colorBackgroundLightest">@color/black</item>
</style>
<style name="Theme.Mastodon.Light.Material3" parent="Theme.Mastodon.Light">
<!-- needed to disable scrim on API 29+ -->
<item name="android:colorPrimary">@color/m3_gray_800</item>
<item name="android:textColorPrimary">@color/m3_gray_800</item>
<item name="android:textColorSecondary">@color/m3_gray_500</item>
<item name="colorDarkIcon">@color/m3_gray_900</item>
<item name="colorSearchHint">@color/m3_gray_600</item>
<item name="profileHeaderBackground">@color/m3_gray_500</item>
<item name="android:colorAccent">@color/m3_primary_700</item>
<item name="android:colorBackground">@color/m3_gray_100</item>
<item name="colorButtonText">@color/m3_gray_50</item>
<item name="colorBackgroundLight">@color/m3_gray_50</item>
<item name="colorBackgroundLightest">@color/m3_gray_25</item>
<item name="android:statusBarColor">@color/m3_gray_50</item>
<item name="android:navigationBarColor">@color/m3_navigation_bar_bg</item>
<item name="android:actionBarTheme">@style/Theme.Mastodon.Toolbar.M3</item>
<item name="android:alertDialogTheme">@style/Theme.Mastodon.Dialog.Alert.M3</item>
<item name="colorPollMostVoted">@color/m3_primary_500</item>
<item name="colorPollVoted">@color/m3_gray_300</item>
<item name="colorAccentLight">@color/m3_primary_600</item>
<item name="colorSearchField">@color/m3_gray_200</item>
<item name="colorTabInactive">@color/m3_gray_400</item>
<item name="colorAccentLightest">@color/m3_primary_100</item>
<item name="colorSecondary">@color/m3_gray_50</item>
</style>
<style name="Theme.Mastodon.Dark.Material3" parent="Theme.Mastodon.Dark">
<!-- needed to disable scrim on API 29+ -->
<item name="android:colorBackground">@color/m3_gray_700</item>
<item name="colorButtonText">@color/m3_gray_800</item>
<item name="colorBackgroundLight">@color/m3_gray_700</item>
<item name="colorBackgroundLightest">@color/m3_gray_900</item>
<item name="colorBackgroundPopup">@color/m3_gray_900</item>
<item name="colorDarkIcon">@color/gray_25</item>
<item name="colorWindowBackground">@color/m3_gray_800</item>
<item name="android:statusBarColor">@color/m3_gray_800</item>
<item name="android:navigationBarColor">@color/m3_gray_800</item>
<item name="colorPollVoted">@color/m3_gray_600</item>
<item name="profileHeaderBackground">?colorWindowBackground</item>
<item name="android:actionBarTheme">@style/Theme.Mastodon.Toolbar.Dark.CustomBase</item>
<item name="android:colorAccent">@color/m3_primary_400</item>
<item name="android:colorPrimary">@color/m3_gray_50</item>
<item name="android:textColorPrimary">@color/m3_gray_50</item>
<item name="android:textColorSecondary">@color/m3_gray_400</item>
<item name="android:alertDialogTheme">@style/Theme.Mastodon.Dialog.Alert.Dark.M3</item>
<item name="colorPollMostVoted">@color/m3_primary_700</item>
<item name="colorAccentLight">@color/m3_primary_600</item>
<item name="colorAccentLightest">@color/m3_primary_800</item>
<item name="colorTabInactive">@color/m3_gray_400</item>
<item name="colorSearchHint">@color/m3_gray_300</item>
<item name="colorSecondary">@color/m3_gray_50</item>
<!-- TODO dark colors -->
<item name="colorSearchField">@color/m3_gray_700</item>
</style>
<style name="Theme.Mastodon.Dark.TrueBlack.Material3">
<item name="android:colorAccent">@color/m3_primary_400</item>
<item name="colorPollMostVoted">@color/m3_primary_700</item>
<item name="colorAccentLight">@color/m3_primary_600</item>
<item name="colorAccentLightest">@color/m3_primary_800</item>
<item name="colorSecondary">@color/m3_gray_50</item>
<item name="colorPollVoted">@color/m3_gray_800</item>
<item name="colorSearchField">@color/m3_gray_900</item>
<item name="colorBackgroundPopup">@color/m3_gray_900</item>
<item name="android:navigationBarColor">@color/black</item>
<item name="android:colorBackground">@color/black</item>
<item name="android:statusBarColor">@color/black</item>
<item name="android:actionBarTheme">@style/Theme.Mastodon.Toolbar.Dark.TrueBlack</item>
<item name="colorBackgroundLight">@color/black</item>
<item name="colorWindowBackground">@color/black</item>
<item name="colorButtonText">@color/black</item>
<item name="colorBackgroundLightest">@color/black</item>
</style>
<style name="Theme.Mastodon.AutoLightDark.Material3" parent="Theme.Mastodon.Light.Material3"/>
<style name="Theme.Mastodon.AutoLightDark.TrueBlack.Material3" parent="Theme.Mastodon.Light.Material3"/>
<style name="Theme.Mastodon.Dialog.Alert.Dark.M3" parent="android:Theme.Material.Dialog.Alert">
<item name="android:windowTitleStyle">@style/alert_title</item>
<item name="android:dialogPreferredPadding">24dp</item>
<item name="android:windowBackground">@drawable/bg_alert</item>
<item name="android:buttonBarButtonStyle">@style/Widget.Mastodon.ButtonBarButton</item>
<!-- colors -->
<item name="android:colorAccent">@color/m3_primary_600</item>
<item name="android:colorPrimary">@color/m3_gray_50</item>
<item name="android:colorBackground">@color/custom_gray_700</item>
<item name="android:textColorPrimary">@color/m3_gray_50</item>
<item name="android:textColorSecondary">@color/m3_gray_400</item>
</style>
<style name="Theme.Mastodon.Dialog.Alert.M3" parent="android:Theme.Material.Light.Dialog.Alert">
<item name="android:windowTitleStyle">@style/alert_title</item>
<item name="android:dialogPreferredPadding">24dp</item>
<item name="android:windowBackground">@drawable/bg_alert</item>
<item name="android:buttonBarButtonStyle">@style/Widget.Mastodon.ButtonBarButton</item>
<!-- colors -->
<item name="android:colorAccent">@color/m3_primary_700</item>
<item name="android:colorPrimary">@color/custom_gray_800</item>
<item name="android:colorBackground">@color/m3_gray_100</item>
<item name="android:textColorPrimary">@color/custom_gray_800</item>
<item name="android:textColorSecondary">@color/custom_gray_500</item>
</style>
<style name="Theme.Mastodon.Toolbar.M3" parent="android:ThemeOverlay.Material.ActionBar">
<item name="android:colorPrimary">@color/m3_gray_50</item>
<item name="android:textColorPrimary">@color/custom_gray_800</item>
<item name="android:textColorSecondary">@color/custom_gray_800</item>
</style>
<style name="Theme.Mastodon.Light.Green" parent="Theme.Mastodon.Light.CustomBase">
<item name="android:colorAccent">@color/green_primary_700</item>
<item name="android:colorBackground">@color/green_gray_100</item>
@ -619,6 +735,12 @@
<item name="android:textColorSecondary">@color/gray_50</item>
</style>
<style name="Theme.Mastodon.Toolbar.Dark.Material3" parent="android:ThemeOverlay.Material.Dark.ActionBar">
<item name="android:colorPrimary">@color/m3_gray_800</item>
<item name="android:textColorPrimary">@color/m3_gray_50</item>
<item name="android:textColorSecondary">@color/m3_gray_50</item>
</style>
<style name="Theme.Mastodon.Toolbar.Dark.TrueBlack" parent="android:ThemeOverlay.Material.Dark.ActionBar">
<item name="android:colorPrimary">@color/black</item>
</style>