diff --git a/app/src/main/java/eu/faircode/email/FragmentDialogTheme.java b/app/src/main/java/eu/faircode/email/FragmentDialogTheme.java index aeaa3b4271..10f926e6f9 100644 --- a/app/src/main/java/eu/faircode/email/FragmentDialogTheme.java +++ b/app/src/main/java/eu/faircode/email/FragmentDialogTheme.java @@ -6,11 +6,13 @@ import android.content.DialogInterface; import android.content.Intent; import android.content.SharedPreferences; import android.graphics.Paint; +import android.os.Build; import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; import android.widget.Button; import android.widget.CompoundButton; +import android.widget.RadioButton; import android.widget.RadioGroup; import android.widget.TextView; @@ -24,6 +26,7 @@ import androidx.preference.PreferenceManager; public class FragmentDialogTheme extends FragmentDialogBase { private RadioGroup rgTheme; private SwitchCompat swReverse; + private RadioButton rbThemeYou; private RadioGroup rgThemeOptions; private TextView tvSystem; private SwitchCompat swBlack; @@ -36,13 +39,14 @@ public class FragmentDialogTheme extends FragmentDialogBase { int checkedId = rgTheme.getCheckedRadioButtonId(); boolean grey = (checkedId == R.id.rbThemeGrey); boolean solarized = (checkedId == R.id.rbThemeSolarized); - boolean colored = (grey || solarized || + boolean you = (checkedId == R.id.rbThemeYou); + boolean colored = (grey || solarized || you || checkedId == R.id.rbThemeBlueOrange || checkedId == R.id.rbThemeRedGreen || checkedId == R.id.rbThemeYellowPurple); int optionId = rgThemeOptions.getCheckedRadioButtonId(); - swReverse.setEnabled(colored && !grey && !solarized); + swReverse.setEnabled(colored && !grey && !solarized && !you); rgThemeOptions.setEnabled(colored); for (int i = 0; i < rgThemeOptions.getChildCount(); i++) @@ -70,6 +74,7 @@ public class FragmentDialogTheme extends FragmentDialogBase { View dview = LayoutInflater.from(context).inflate(R.layout.dialog_theme, null); rgTheme = dview.findViewById(R.id.rgTheme); + rbThemeYou = dview.findViewById(R.id.rbThemeYou); swReverse = dview.findViewById(R.id.swReverse); rgThemeOptions = dview.findViewById(R.id.rgThemeOptions); tvSystem = dview.findViewById(R.id.tvSystem); @@ -86,6 +91,8 @@ public class FragmentDialogTheme extends FragmentDialogBase { } }); + rbThemeYou.setVisibility((Build.VERSION.SDK_INT < Build.VERSION_CODES.S ? View.GONE : View.VISIBLE)); + swReverse.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { @@ -188,6 +195,13 @@ public class FragmentDialogTheme extends FragmentDialogBase { case "black_and_white": rgTheme.check(R.id.rbThemeBlackAndWhite); break; + case "you_light": + case "you_dark": + case "you_black": + case "you_system": + case "you_system_black": + rgTheme.check(R.id.rbThemeYou); + break; } tvMore.setPaintFlags(tvMore.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG); @@ -272,6 +286,13 @@ public class FragmentDialogTheme extends FragmentDialogBase { editor.putString("theme", "black").apply(); } else if (checkedRadioButtonId == R.id.rbThemeBlackAndWhite) { editor.putString("theme", "black_and_white").apply(); + } else if (checkedRadioButtonId == R.id.rbThemeYou) { + if (system) + editor.putString("theme", "you_system" + + (black ? "_black" : "")).apply(); + else + editor.putString("theme", "you" + + (black ? "_black" : dark ? "_dark" : "_light")).apply(); } editor.putBoolean("default_light", swHtmlLight.isChecked()); @@ -458,6 +479,22 @@ public class FragmentDialogTheme extends FragmentDialogBase { return (night ? R.style.AppThemeSolarizedDark : R.style.AppThemeSolarizedLight); + case "you_light": + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) + return R.style.AppThemeYouLight; + case "you_dark": + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) + return (light ? R.style.AppThemeYouLight : R.style.AppThemeYouDark); + case "you_black": + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) + return (light ? R.style.AppThemeYouLight : R.style.AppThemeYouBlack); + case "you_system": + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) + return (night ? R.style.AppThemeYouDark : R.style.AppThemeYouLight); + case "you_system_black": + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) + return (night ? R.style.AppThemeYouBlack : R.style.AppThemeYouLight); + default: Log.e("Unknown theme=" + theme); return R.style.AppThemeBlueOrangeLight; diff --git a/app/src/main/res/layout/dialog_theme.xml b/app/src/main/res/layout/dialog_theme.xml index a86e53d189..194928f5d3 100644 --- a/app/src/main/res/layout/dialog_theme.xml +++ b/app/src/main/res/layout/dialog_theme.xml @@ -87,6 +87,14 @@ android:padding="6dp" android:text="@string/title_setup_theme_black_and_white" android:textAppearance="@style/TextAppearance.AppCompat.Medium" /> + + + + + + + + + + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 5c14447b94..930524a2f1 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -285,9 +285,10 @@ Yellow/purple Red/green Grey + Solarized Black Black and white - Solarized + Material You Swap colors Light