More themes

This commit is contained in:
M66B 2019-12-26 16:15:46 +01:00
parent 37f526ec21
commit 78f8e3a445
7 changed files with 234 additions and 46 deletions

View File

@ -83,27 +83,53 @@ abstract class ActivityBase extends AppCompatActivity implements SharedPreferenc
if (!this.getClass().equals(ActivityMain.class)) {
String theme = prefs.getString("theme", "light");
int uiMode = getResources().getConfiguration().uiMode;
Log.i("UI mode=" + uiMode);
if ("dark".equals(theme))
setTheme(R.style.AppThemeBlueOrangeDark);
else if ("black".equals(theme))
setTheme(R.style.AppThemeBlack);
else if ("grey_light".equals(theme))
setTheme(R.style.AppThemeGreySteelBlueLight);
else if ("grey_dark".equals(theme))
setTheme(R.style.AppThemeGreySteelBlueDark);
else if ("system".equals(theme)) {
int uiMode = getResources().getConfiguration().uiMode;
Log.i("UI mode=" + uiMode);
if ((uiMode & Configuration.UI_MODE_NIGHT_YES) != 0)
setTheme(R.style.AppThemeBlack);
} else if ("grey_system".equals(theme)) {
int uiMode = getResources().getConfiguration().uiMode;
Log.i("UI mode=" + uiMode);
if ((uiMode & Configuration.UI_MODE_NIGHT_YES) != 0)
setTheme(R.style.AppThemeGreySteelBlueDark);
else
switch (theme) {
case "light":
case "blue_orange_light":
setTheme(R.style.AppThemeBlueOrangeLight);
break;
case "yellow_purple_light":
setTheme(R.style.AppThemeYellowPurpleLight);
break;
case "green_red_light":
setTheme(R.style.AppThemeGreenRedLight);
break;
case "grey_light":
setTheme(R.style.AppThemeGreySteelBlueLight);
break;
case "dark":
case "blue_orange_dark":
setTheme(R.style.AppThemeBlueOrangeDark);
break;
case "yellow_purple_dark":
setTheme(R.style.AppThemeYellowPurpleDark);
break;
case "green_red_dark":
setTheme(R.style.AppThemeGreenRedDark);
break;
case "grey_dark":
setTheme(R.style.AppThemeGreySteelBlueDark);
break;
case "black":
setTheme(R.style.AppThemeBlack);
break;
case "system":
if ((uiMode & Configuration.UI_MODE_NIGHT_YES) != 0)
setTheme(R.style.AppThemeBlueOrangeDark);
else
setTheme(R.style.AppThemeBlueOrangeLight);
break;
case "grey_system":
if ((uiMode & Configuration.UI_MODE_NIGHT_YES) != 0)
setTheme(R.style.AppThemeGreySteelBlueDark);
else
setTheme(R.style.AppThemeGreySteelBlueLight);
break;
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {

View File

@ -667,26 +667,43 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
String theme = prefs.getString("theme", "light");
switch (theme) {
case "dark":
rgTheme.check(R.id.rbThemeDark);
case "light":
case "blue_orange_light":
rgTheme.check(R.id.rbThemeBlueOrangeLight);
break;
case "black":
rgTheme.check(R.id.rbThemeBlack);
case "yellow_purple_light":
rgTheme.check(R.id.rbThemeYellowPurpleLight);
break;
case "green_red_light":
rgTheme.check(R.id.rbThemeGreenRedLight);
break;
case "grey_light":
rgTheme.check(R.id.rbThemeGreyLight);
break;
case "dark":
case "blue_orange_dark":
rgTheme.check(R.id.rbThemeBlueOrangeDark);
break;
case "yellow_purple_dark":
rgTheme.check(R.id.rbThemeYellowPurpleDark);
break;
case "green_red_dark":
rgTheme.check(R.id.rbThemeGreenRedDark);
break;
case "grey_dark":
rgTheme.check(R.id.rbThemeGreyDark);
break;
case "black":
rgTheme.check(R.id.rbThemeBlack);
break;
case "system":
rgTheme.check(R.id.rbThemeSystem);
break;
case "grey_system":
rgTheme.check(R.id.rbThemeGreySystem);
break;
default:
rgTheme.check(R.id.rbThemeLight);
}
rgTheme.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
@ -697,21 +714,35 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
ContactInfo.clearCache();
switch (checkedId) {
case R.id.rbThemeLight:
prefs.edit().putString("theme", "light").apply();
case R.id.rbThemeBlueOrangeLight:
prefs.edit().putString("theme", "blue_orange_light").apply();
break;
case R.id.rbThemeDark:
prefs.edit().putString("theme", "dark").apply();
case R.id.rbThemeYellowPurpleLight:
prefs.edit().putString("theme", "yellow_purple_light").apply();
break;
case R.id.rbThemeBlack:
prefs.edit().putString("theme", "black").apply();
case R.id.rbThemeGreenRedLight:
prefs.edit().putString("theme", "green_red_light").apply();
break;
case R.id.rbThemeGreyLight:
prefs.edit().putString("theme", "grey_light").apply();
break;
case R.id.rbThemeBlueOrangeDark:
prefs.edit().putString("theme", "blue_orange_dark").apply();
break;
case R.id.rbThemeYellowPurpleDark:
prefs.edit().putString("theme", "yellow_purple_dark").apply();
break;
case R.id.rbThemeGreenRedDark:
prefs.edit().putString("theme", "green_red_dark").apply();
break;
case R.id.rbThemeGreyDark:
prefs.edit().putString("theme", "grey_dark").apply();
break;
case R.id.rbThemeBlack:
prefs.edit().putString("theme", "black").apply();
break;
case R.id.rbThemeSystem:
prefs.edit().putString("theme", "system").apply();
break;

View File

@ -29,27 +29,27 @@
app:layout_constraintTop_toBottomOf="@id/tvCaption">
<RadioButton
android:id="@+id/rbThemeLight"
android:id="@+id/rbThemeBlueOrangeLight"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="6dp"
android:text="@string/title_setup_light_theme"
android:text="@string/title_setup_blue_orange_light_theme"
android:textAppearance="@style/TextAppearance.AppCompat.Medium" />
<RadioButton
android:id="@+id/rbThemeDark"
android:id="@+id/rbThemeYellowPurpleLight"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="6dp"
android:text="@string/title_setup_dark_theme"
android:text="@string/title_setup_yellow_purple_light_theme"
android:textAppearance="@style/TextAppearance.AppCompat.Medium" />
<RadioButton
android:id="@+id/rbThemeBlack"
android:id="@+id/rbThemeGreenRedLight"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="6dp"
android:text="@string/title_setup_black_theme"
android:text="@string/title_setup_green_red_light_theme"
android:textAppearance="@style/TextAppearance.AppCompat.Medium" />
<RadioButton
@ -60,6 +60,30 @@
android:text="@string/title_setup_grey_light_theme"
android:textAppearance="@style/TextAppearance.AppCompat.Medium" />
<RadioButton
android:id="@+id/rbThemeBlueOrangeDark"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="6dp"
android:text="@string/title_setup_blue_orange_dark_theme"
android:textAppearance="@style/TextAppearance.AppCompat.Medium" />
<RadioButton
android:id="@+id/rbThemeYellowPurpleDark"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="6dp"
android:text="@string/title_setup_yellow_purple_dark_theme"
android:textAppearance="@style/TextAppearance.AppCompat.Medium" />
<RadioButton
android:id="@+id/rbThemeGreenRedDark"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="6dp"
android:text="@string/title_setup_green_red_dark_theme"
android:textAppearance="@style/TextAppearance.AppCompat.Medium" />
<RadioButton
android:id="@+id/rbThemeGreyDark"
android:layout_width="wrap_content"
@ -68,6 +92,14 @@
android:text="@string/title_setup_grey_dark_theme"
android:textAppearance="@style/TextAppearance.AppCompat.Medium" />
<RadioButton
android:id="@+id/rbThemeBlack"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="6dp"
android:text="@string/title_setup_black_theme"
android:textAppearance="@style/TextAppearance.AppCompat.Medium" />
<RadioButton
android:id="@+id/rbThemeSystem"
android:layout_width="wrap_content"
@ -83,6 +115,7 @@
android:padding="6dp"
android:text="@string/title_setup_grey_system_theme"
android:textAppearance="@style/TextAppearance.AppCompat.Medium" />
</RadioGroup>
<TextView

View File

@ -85,11 +85,11 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:backgroundTint="?attr/colorAccent"
android:backgroundTint="?attr/colorPrimary"
android:minWidth="0dp"
android:minHeight="0dp"
android:text="@string/title_setup_help"
android:textColor="@android:color/black"
android:textColor="@android:color/white"
android:textStyle="bold"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvQuick" />

View File

@ -8,6 +8,10 @@
<color name="colorAccent">#ffb300</color>
<color name="colorAccentDark">#c68400</color>
<!-- Light blue 900 -->
<color name="darkColorPrimary">#01579b</color>
<color name="darkColorPrimaryDark">#002f6c</color>
<color name="colorReadLight">#b3000000</color>
<color name="colorUnreadLight">#ff000000</color>
@ -51,7 +55,7 @@
<color name="darkColorItemSelected">#444</color>
<color name="darkColorSeparator">#444</color>
<color name="darkColorWarning">#ffffb300</color>
<color name="darkColorWarning">#ffffb74d</color>
<color name="darkColorDrawerScrim">#997f7f7f</color>
<color name="darkColorDrawerText">#fff</color>
@ -63,6 +67,26 @@
<color name="darkActionForegroundDisabled">#666</color>
<color name="darkActionBackground">#444</color>
<!-- Yellow 600 / Purple 800 -->
<color name="lightYellowPrimary">#fdd835</color>
<color name="lightYellowPrimaryDark">#c6a700</color>
<color name="lightPurpleAccent">#8e24aa</color>
<!-- Yellow 900 / Purple 300 -->
<color name="darkYellowPrimary">#f57f17</color>
<color name="darkYellowPrimaryDark">#bc5100</color>
<color name="darkPurpleAccent">#ba68c8</color>
<!-- Green 600 / Red 600 -->
<color name="lightGreenPrimary">#43a047</color>
<color name="lightGreenPrimaryDark">#00701a</color>
<color name="lightRedAccent">#e53935</color>
<!-- Green 900 / red 300 -->
<color name="darkGreenPrimary">#1b5e20</color>
<color name="darkGreenPrimaryDark">#003300</color>
<color name="darkRedAccent">#e57373</color>
<!-- default: #323232 -->
<color name="design_snackbar_background_color" tools:override="true">#222</color>

View File

@ -198,15 +198,25 @@
<string name="title_setup_biometrics_enable">Enable</string>
<string name="title_setup_biometrics_disable">Disable</string>
<string name="title_setup_biometrics_unlock">Unlock</string>
<string name="title_setup_theme">Select theme</string>
<string name="title_setup_light_theme">Light theme</string>
<string name="title_setup_dark_theme">Dark theme</string>
<string name="title_setup_black_theme">Black theme</string>
<string name="title_setup_blue_orange_light_theme">Blue/orange light theme</string>
<string name="title_setup_yellow_purple_light_theme">Yellow/purple light theme</string>
<string name="title_setup_green_red_light_theme">Green/red light theme</string>
<string name="title_setup_grey_light_theme">Grey light theme</string>
<string name="title_setup_blue_orange_dark_theme">Blue/orange dark theme</string>
<string name="title_setup_yellow_purple_dark_theme">Yellow/purple dark theme</string>
<string name="title_setup_green_red_dark_theme">Green/red dark theme</string>
<string name="title_setup_grey_dark_theme">Grey dark theme</string>
<string name="title_setup_black_theme">Black theme</string>
<string name="title_setup_system_theme">System theme</string>
<string name="title_setup_grey_system_theme">Grey system theme</string>
<string name="title_setup_system_theme_hint">The system themes will automatically switch to light/dark on day/night, if supported by Android</string>
<string name="title_setup_advanced">Advanced</string>
<string name="title_setup_options">Options</string>

View File

@ -104,6 +104,8 @@
<item name="colorUnreadHighlight">@color/colorAccentDark</item>
<item name="colorWarning">@color/colorAccent</item>
<item name="colorFabBackground">@color/colorAccent</item>
<item name="colorToastForeground">@color/white</item>
@ -112,9 +114,39 @@
<item name="android:textColorLink">@color/colorAccentDark</item>
</style>
<style name="AppThemeYellowPurpleLight" parent="AppThemeBaseLight">
<item name="colorPrimary">@color/lightYellowPrimary</item>
<item name="colorPrimaryDark">@color/lightYellowPrimaryDark</item>
<item name="colorAccent">@color/lightPurpleAccent</item>
<item name="colorUnreadHighlight">@color/lightPurpleAccent</item>
<item name="colorFabBackground">@color/lightPurpleAccent</item>
<item name="colorToastForeground">@color/white</item>
<item name="colorToastBackground">@color/lightPurpleAccent</item>
<item name="android:textColorLink">@color/lightPurpleAccent</item>
</style>
<style name="AppThemeGreenRedLight" parent="AppThemeBaseLight">
<item name="colorPrimary">@color/lightGreenPrimary</item>
<item name="colorPrimaryDark">@color/lightGreenPrimaryDark</item>
<item name="colorAccent">@color/lightRedAccent</item>
<item name="colorUnreadHighlight">@color/lightRedAccent</item>
<item name="colorFabBackground">@color/lightRedAccent</item>
<item name="colorToastForeground">@color/white</item>
<item name="colorToastBackground">@color/lightRedAccent</item>
<item name="android:textColorLink">@color/lightRedAccent</item>
</style>
<style name="AppThemeBlueOrangeDark" parent="AppThemeBaseDark">
<item name="colorPrimary">@color/darkPrimary</item>
<item name="colorPrimaryDark">@color/darkPrimaryDark</item>
<item name="colorPrimary">@color/darkColorPrimary</item>
<item name="colorPrimaryDark">@color/darkColorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="colorUnreadHighlight">@color/colorAccent</item>
@ -124,11 +156,43 @@
<item name="colorFabBackground">@color/colorAccent</item>
<item name="colorToastForeground">@color/white</item>
<item name="colorToastBackground">@color/darkPrimaryLight</item>
<item name="colorToastBackground">@color/darkColorPrimary</item>
</style>
<style name="AppThemeYellowPurpleDark" parent="AppThemeBaseDark">
<item name="colorPrimary">@color/darkYellowPrimary</item>
<item name="colorPrimaryDark">@color/darkYellowPrimaryDark</item>
<item name="colorAccent">@color/darkPurpleAccent</item>
<item name="colorUnreadHighlight">@color/darkPurpleAccent</item>
<item name="colorFabBackground">@color/darkPurpleAccent</item>
<item name="colorToastForeground">@color/white</item>
<item name="colorToastBackground">@color/darkPurpleAccent</item>
<item name="android:textColorLink">@color/darkPurpleAccent</item>
</style>
<style name="AppThemeGreenRedDark" parent="AppThemeBaseDark">
<item name="colorPrimary">@color/darkGreenPrimary</item>
<item name="colorPrimaryDark">@color/darkGreenPrimaryDark</item>
<item name="colorAccent">@color/darkRedAccent</item>
<item name="colorUnreadHighlight">@color/darkRedAccent</item>
<item name="colorFabBackground">@color/darkRedAccent</item>
<item name="colorToastForeground">@color/white</item>
<item name="colorToastBackground">@color/darkRedAccent</item>
<item name="android:textColorLink">@color/darkRedAccent</item>
</style>
<style name="AppThemeBlack" parent="AppThemeBlueOrangeDark">
<item name="themeName">black</item>
<item name="colorPrimary">@color/darkPrimary</item>
<item name="colorPrimaryDark">@color/darkPrimaryDark</item>
<item name="android:windowBackground">@color/black</item>
<item name="colorDrawerBackground">@color/black</item>