mirror of https://github.com/M66B/FairEmail.git
Simplified theme selection
This commit is contained in:
parent
3b3799df02
commit
6e91df64e6
|
@ -21,6 +21,7 @@ package eu.faircode.email;
|
|||
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.res.Configuration;
|
||||
import android.graphics.Bitmap;
|
||||
|
@ -662,99 +663,101 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
|
|||
public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) {
|
||||
View dview = LayoutInflater.from(getContext()).inflate(R.layout.dialog_theme, null);
|
||||
final RadioGroup rgTheme = dview.findViewById(R.id.rgTheme);
|
||||
final SwitchCompat swReverse = dview.findViewById(R.id.swReverse);
|
||||
final SwitchCompat swDark = dview.findViewById(R.id.swDark);
|
||||
final SwitchCompat swSystem = dview.findViewById(R.id.swSystem);
|
||||
|
||||
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
|
||||
String theme = prefs.getString("theme", "light");
|
||||
|
||||
switch (theme) {
|
||||
case "light":
|
||||
case "blue_orange_light":
|
||||
rgTheme.check(R.id.rbThemeBlueOrangeLight);
|
||||
break;
|
||||
case "yellow_purple_light":
|
||||
rgTheme.check(R.id.rbThemeYellowPurpleLight);
|
||||
break;
|
||||
case "red_green_light":
|
||||
rgTheme.check(R.id.rbThemeRedGreenLight);
|
||||
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 "red_green_dark":
|
||||
rgTheme.check(R.id.rbThemeRedGreenDark);
|
||||
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;
|
||||
}
|
||||
swDark.setChecked(theme.endsWith("dark"));
|
||||
swSystem.setChecked(theme.endsWith("system"));
|
||||
|
||||
rgTheme.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(RadioGroup group, int checkedId) {
|
||||
getActivity().getIntent().putExtra("tab", "display");
|
||||
|
||||
ContactInfo.clearCache();
|
||||
|
||||
switch (checkedId) {
|
||||
case R.id.rbThemeBlueOrangeLight:
|
||||
prefs.edit().putString("theme", "blue_orange_light").apply();
|
||||
break;
|
||||
case R.id.rbThemeYellowPurpleLight:
|
||||
prefs.edit().putString("theme", "yellow_purple_light").apply();
|
||||
break;
|
||||
case R.id.rbThemeRedGreenLight:
|
||||
prefs.edit().putString("theme", "red_green_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.rbThemeRedGreenDark:
|
||||
prefs.edit().putString("theme", "red_green_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;
|
||||
case R.id.rbThemeGreySystem:
|
||||
prefs.edit().putString("theme", "grey_system").apply();
|
||||
break;
|
||||
}
|
||||
swReverse.setEnabled(checkedId == R.id.rbThemeBlueOrange ||
|
||||
checkedId == R.id.rbThemeYellowPurple ||
|
||||
checkedId == R.id.rbThemeRedGreen);
|
||||
swDark.setEnabled(checkedId == R.id.rbThemeBlueOrange ||
|
||||
checkedId == R.id.rbThemeYellowPurple ||
|
||||
checkedId == R.id.rbThemeRedGreen ||
|
||||
checkedId == R.id.rbThemeGrey);
|
||||
swSystem.setEnabled(checkedId == R.id.rbThemeBlueOrange ||
|
||||
checkedId == R.id.rbThemeGrey);
|
||||
}
|
||||
});
|
||||
|
||||
switch (theme) {
|
||||
case "light":
|
||||
case "dark":
|
||||
case "system":
|
||||
case "blue_orange_light":
|
||||
case "blue_orange_dark":
|
||||
rgTheme.check(R.id.rbThemeBlueOrange);
|
||||
break;
|
||||
case "yellow_purple_light":
|
||||
case "yellow_purple_dark":
|
||||
rgTheme.check(R.id.rbThemeYellowPurple);
|
||||
break;
|
||||
case "red_green_light":
|
||||
case "red_green_dark":
|
||||
rgTheme.check(R.id.rbThemeRedGreen);
|
||||
break;
|
||||
case "grey_system":
|
||||
case "grey_light":
|
||||
case "grey_dark":
|
||||
rgTheme.check(R.id.rbThemeGrey);
|
||||
break;
|
||||
case "black":
|
||||
rgTheme.check(R.id.rbThemeBlack);
|
||||
break;
|
||||
}
|
||||
|
||||
return new AlertDialog.Builder(getContext())
|
||||
.setView(dview)
|
||||
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
getActivity().getIntent().putExtra("tab", "display");
|
||||
|
||||
ContactInfo.clearCache();
|
||||
|
||||
switch (rgTheme.getCheckedRadioButtonId()) {
|
||||
case R.id.rbThemeBlueOrange:
|
||||
if (swSystem.isChecked())
|
||||
prefs.edit().putString("theme", "system").apply();
|
||||
else if (swDark.isChecked())
|
||||
prefs.edit().putString("theme", "blue_orange_dark").apply();
|
||||
else
|
||||
prefs.edit().putString("theme", "blue_orange_light").apply();
|
||||
break;
|
||||
case R.id.rbThemeYellowPurple:
|
||||
if (swDark.isChecked())
|
||||
prefs.edit().putString("theme", "yellow_purple_dark").apply();
|
||||
else
|
||||
prefs.edit().putString("theme", "yellow_purple_light").apply();
|
||||
break;
|
||||
case R.id.rbThemeRedGreen:
|
||||
if (swDark.isChecked())
|
||||
prefs.edit().putString("theme", "red_green_dark").apply();
|
||||
else
|
||||
prefs.edit().putString("theme", "red_green_light").apply();
|
||||
break;
|
||||
case R.id.rbThemeGrey:
|
||||
if (swSystem.isChecked())
|
||||
prefs.edit().putString("theme", "grey_system").apply();
|
||||
else if (swDark.isChecked())
|
||||
prefs.edit().putString("theme", "grey_dark").apply();
|
||||
else
|
||||
prefs.edit().putString("theme", "grey_light").apply();
|
||||
break;
|
||||
case R.id.rbThemeBlack:
|
||||
prefs.edit().putString("theme", "black").apply();
|
||||
break;
|
||||
}
|
||||
}
|
||||
})
|
||||
.setNegativeButton(android.R.string.cancel, null)
|
||||
.create();
|
||||
}
|
||||
|
|
|
@ -29,67 +29,35 @@
|
|||
app:layout_constraintTop_toBottomOf="@id/tvCaption">
|
||||
|
||||
<RadioButton
|
||||
android:id="@+id/rbThemeBlueOrangeLight"
|
||||
android:id="@+id/rbThemeBlueOrange"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="6dp"
|
||||
android:text="@string/title_setup_blue_orange_light_theme"
|
||||
android:text="@string/title_setup_theme_blue_amber"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Medium" />
|
||||
|
||||
<RadioButton
|
||||
android:id="@+id/rbThemeYellowPurpleLight"
|
||||
android:id="@+id/rbThemeYellowPurple"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="6dp"
|
||||
android:text="@string/title_setup_yellow_purple_light_theme"
|
||||
android:text="@string/title_setup_theme_yellow_purple"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Medium" />
|
||||
|
||||
<RadioButton
|
||||
android:id="@+id/rbThemeRedGreenLight"
|
||||
android:id="@+id/rbThemeRedGreen"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="6dp"
|
||||
android:text="@string/title_setup_red_green_light_theme"
|
||||
android:text="@string/title_setup_theme_red_green"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Medium" />
|
||||
|
||||
<RadioButton
|
||||
android:id="@+id/rbThemeGreyLight"
|
||||
android:id="@+id/rbThemeGrey"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="6dp"
|
||||
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/rbThemeRedGreenDark"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="6dp"
|
||||
android:text="@string/title_setup_red_green_dark_theme"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Medium" />
|
||||
|
||||
<RadioButton
|
||||
android:id="@+id/rbThemeGreyDark"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="6dp"
|
||||
android:text="@string/title_setup_grey_dark_theme"
|
||||
android:text="@string/title_setup_theme_grey"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Medium" />
|
||||
|
||||
<RadioButton
|
||||
|
@ -97,36 +65,50 @@
|
|||
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_theme_black"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Medium" />
|
||||
|
||||
<RadioButton
|
||||
android:id="@+id/rbThemeSystem"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="6dp"
|
||||
android:text="@string/title_setup_system_theme"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Medium" />
|
||||
|
||||
<RadioButton
|
||||
android:id="@+id/rbThemeGreySystem"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="6dp"
|
||||
android:text="@string/title_setup_grey_system_theme"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Medium" />
|
||||
|
||||
</RadioGroup>
|
||||
|
||||
<androidx.appcompat.widget.SwitchCompat
|
||||
android:id="@+id/swReverse"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="12dp"
|
||||
android:text="@string/title_setup_theme_reverse"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/rgTheme" />
|
||||
|
||||
<androidx.appcompat.widget.SwitchCompat
|
||||
android:id="@+id/swDark"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="12dp"
|
||||
android:text="@string/title_setup_theme_dark"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/swReverse" />
|
||||
|
||||
<androidx.appcompat.widget.SwitchCompat
|
||||
android:id="@+id/swSystem"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="12dp"
|
||||
android:text="@string/title_setup_theme_system"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/swDark" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvSystem"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="24dp"
|
||||
android:text="@string/title_setup_system_theme_hint"
|
||||
android:layout_marginTop="12dp"
|
||||
android:text="@string/title_setup_theme_system_hint"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Small"
|
||||
android:textStyle="italic"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/rgTheme" />
|
||||
app:layout_constraintTop_toBottomOf="@id/swSystem" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</ScrollView>
|
|
@ -2,16 +2,6 @@
|
|||
<resources xmlns:tools="http://schemas.android.com/tools">
|
||||
<!-- https://material.io/resources/color/ -->
|
||||
|
||||
<!-- Light blue 600 / Amber 600 -->
|
||||
<color name="colorPrimary">#039be5</color>
|
||||
<color name="colorPrimaryDark">#006db3</color>
|
||||
<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>
|
||||
|
||||
|
@ -67,6 +57,16 @@
|
|||
<color name="darkActionForegroundDisabled">#666</color>
|
||||
<color name="darkActionBackground">#444</color>
|
||||
|
||||
<!-- Light blue 600 / Amber 600 -->
|
||||
<color name="lightBluePrimary">#039be5</color>
|
||||
<color name="lightBluePrimaryDark">#006db3</color>
|
||||
<color name="lightAmberAccent">#ffb300</color>
|
||||
<color name="lightAmberAccentDark">#c68400</color>
|
||||
|
||||
<!-- Light blue 900 -->
|
||||
<color name="darkBluePrimary">#01579b</color>
|
||||
<color name="darkBluePrimaryDark">#002f6c</color>
|
||||
|
||||
<!-- Yellow 600 / Purple 800 -->
|
||||
<color name="lightYellowPrimary">#fdd835</color>
|
||||
<color name="lightYellowPrimaryDark">#c6a700</color>
|
||||
|
|
|
@ -201,21 +201,17 @@
|
|||
|
||||
<string name="title_setup_theme">Select 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_red_green_light_theme">Red/green light theme</string>
|
||||
<string name="title_setup_grey_light_theme">Grey light theme</string>
|
||||
<string name="title_setup_theme_blue_amber">Blue/orange</string>
|
||||
<string name="title_setup_theme_yellow_purple">Yellow/purple</string>
|
||||
<string name="title_setup_theme_red_green">Red/green</string>
|
||||
<string name="title_setup_theme_grey">Grey</string>
|
||||
<string name="title_setup_theme_black">Black</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_red_green_dark_theme">Red/green dark theme</string>
|
||||
<string name="title_setup_grey_dark_theme">Grey dark theme</string>
|
||||
<string name="title_setup_theme_reverse">Reverse colors</string>
|
||||
<string name="title_setup_theme_dark">Dark</string>
|
||||
<string name="title_setup_theme_system">Follow system</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_theme_system_hint">Follow system theme will automatically switch to light/dark on day/night, if supported by Android</string>
|
||||
|
||||
<string name="title_setup_advanced">Advanced</string>
|
||||
|
||||
|
|
|
@ -98,20 +98,20 @@
|
|||
</style>
|
||||
|
||||
<style name="AppThemeBlueOrangeLight" parent="AppThemeBaseLight">
|
||||
<item name="colorPrimary">@color/colorPrimary</item>
|
||||
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
|
||||
<item name="colorAccent">@color/colorAccent</item>
|
||||
<item name="colorPrimary">@color/lightBluePrimary</item>
|
||||
<item name="colorPrimaryDark">@color/lightBluePrimaryDark</item>
|
||||
<item name="colorAccent">@color/lightAmberAccent</item>
|
||||
|
||||
<item name="colorUnreadHighlight">@color/colorAccentDark</item>
|
||||
<item name="colorUnreadHighlight">@color/lightAmberAccentDark</item>
|
||||
|
||||
<item name="colorWarning">@color/colorAccent</item>
|
||||
<item name="colorWarning">@color/lightAmberAccent</item>
|
||||
|
||||
<item name="colorFabBackground">@color/colorAccent</item>
|
||||
<item name="colorFabBackground">@color/lightAmberAccent</item>
|
||||
|
||||
<item name="colorInfoForeground">@color/black</item>
|
||||
<item name="colorInfoBackground">@color/colorAccent</item>
|
||||
<item name="colorInfoBackground">@color/lightAmberAccent</item>
|
||||
|
||||
<item name="android:textColorLink">@color/colorAccentDark</item>
|
||||
<item name="android:textColorLink">@color/lightAmberAccentDark</item>
|
||||
</style>
|
||||
|
||||
<style name="AppThemeYellowPurpleLight" parent="AppThemeBaseLight">
|
||||
|
@ -145,18 +145,18 @@
|
|||
</style>
|
||||
|
||||
<style name="AppThemeBlueOrangeDark" parent="AppThemeBaseDark">
|
||||
<item name="colorPrimary">@color/darkColorPrimary</item>
|
||||
<item name="colorPrimaryDark">@color/darkColorPrimaryDark</item>
|
||||
<item name="colorAccent">@color/colorAccent</item>
|
||||
<item name="colorPrimary">@color/darkBluePrimary</item>
|
||||
<item name="colorPrimaryDark">@color/darkBluePrimaryDark</item>
|
||||
<item name="colorAccent">@color/lightAmberAccent</item>
|
||||
|
||||
<item name="colorUnreadHighlight">@color/colorAccent</item>
|
||||
<item name="colorUnreadHighlight">@color/lightAmberAccent</item>
|
||||
|
||||
<item name="colorWarning">@color/colorAccent</item>
|
||||
<item name="colorWarning">@color/lightAmberAccent</item>
|
||||
|
||||
<item name="colorFabBackground">@color/colorAccent</item>
|
||||
<item name="colorFabBackground">@color/lightAmberAccent</item>
|
||||
|
||||
<item name="colorInfoForeground">@color/black</item>
|
||||
<item name="colorInfoBackground">@color/colorAccent</item>
|
||||
<item name="colorInfoBackground">@color/lightAmberAccent</item>
|
||||
</style>
|
||||
|
||||
<style name="AppThemeYellowPurpleDark" parent="AppThemeBaseDark">
|
||||
|
|
Loading…
Reference in New Issue