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