Added option to use card color as tabular background color

This commit is contained in:
M66B 2021-06-27 08:40:39 +02:00
parent 513ef8a854
commit 4aa7112adb
5 changed files with 40 additions and 19 deletions

View File

@ -255,18 +255,24 @@ public class FragmentDialogTheme extends FragmentDialogBase {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
boolean cards = prefs.getBoolean("cards", true);
boolean beige = prefs.getBoolean("beige", true);
boolean tabular_card_bg = prefs.getBoolean("tabular_card_bg", false);
String theme = prefs.getString("theme", "blue_orange_system");
boolean dark = Helper.isDarkTheme(context);
boolean solarized = (theme != null && theme.startsWith("solarized"));
if (compose) {
if (cards && (!dark || solarized))
view.setBackgroundColor(Helper.resolveColor(context, R.attr.colorCardBackground));
if (cards) {
if (compose) {
if (!dark || solarized)
view.setBackgroundColor(Helper.resolveColor(context, R.attr.colorCardBackground));
} else {
if (!dark && !solarized)
view.setBackgroundColor(ContextCompat.getColor(context, beige
? R.color.lightColorBackground_cards_beige
: R.color.lightColorBackground_cards));
}
} else {
if (cards && !dark && !solarized)
view.setBackgroundColor(ContextCompat.getColor(context, beige
? R.color.lightColorBackground_cards_beige
: R.color.lightColorBackground_cards));
if (tabular_card_bg)
view.setBackgroundColor(Helper.resolveColor(context, R.attr.colorCardBackground));
}
}
}

View File

@ -88,7 +88,8 @@ public class FragmentOptions extends FragmentBase {
"first", "app_support", "notify_archive", "message_swipe", "message_select", "folder_actions", "folder_sync",
"subscriptions", "check_authentication", "check_reply_domain",
"send_pending",
"portrait2", "landscape", "landscape3", "startup", "cards", "beige", "shadow_unread",
"portrait2", "landscape", "landscape3", "startup",
"cards", "beige", "tabular_card_bg", "shadow_unread",
"indentation", "date", "date_bold", "threading", "threading_unread",
"highlight_unread", "highlight_color", "color_stripe",
"avatars", "gravatars", "favicons", "generated_icons", "identicons", "circular", "saturation", "brightness", "threshold",

View File

@ -64,6 +64,7 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
private Spinner spStartup;
private SwitchCompat swCards;
private SwitchCompat swBeige;
private SwitchCompat swTabularBackground;
private SwitchCompat swShadow;
private SwitchCompat swDate;
private SwitchCompat swDateBold;
@ -145,7 +146,7 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
private NumberFormat NF = NumberFormat.getNumberInstance();
private final static String[] RESET_OPTIONS = new String[]{
"theme", "startup", "cards", "beige", "shadow_unread",
"theme", "startup", "cards", "beige", "tabular_card_bg", "shadow_unread",
"date", "date_bold", "navbar_colorize", "portrait2", "landscape", "landscape3",
"threading", "threading_unread", "indentation", "seekbar", "actionbar", "actionbar_color",
"highlight_unread", "highlight_color", "color_stripe",
@ -175,6 +176,7 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
spStartup = view.findViewById(R.id.spStartup);
swCards = view.findViewById(R.id.swCards);
swBeige = view.findViewById(R.id.swBeige);
swTabularBackground = view.findViewById(R.id.swTabularCardBackground);
swShadow = view.findViewById(R.id.swShadow);
swDate = view.findViewById(R.id.swDate);
swDateBold = view.findViewById(R.id.swDateBold);
@ -281,6 +283,7 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("cards", checked).apply();
swBeige.setEnabled(checked);
swTabularBackground.setEnabled(!checked);
swShadow.setEnabled(checked);
swIndentation.setEnabled(checked);
}
@ -294,6 +297,13 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
}
});
swTabularBackground.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("tabular_card_bg", checked).apply();
}
});
swShadow.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
@ -933,8 +943,10 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
swCards.setChecked(prefs.getBoolean("cards", true));
swBeige.setChecked(prefs.getBoolean("beige", true));
swTabularBackground.setChecked(prefs.getBoolean("tabular_card_bg", false));
swShadow.setChecked(prefs.getBoolean("shadow_unread", false));
swBeige.setEnabled(swCards.isChecked());
swTabularBackground.setEnabled(!swCards.isChecked());
swShadow.setEnabled(swCards.isChecked());
swDate.setChecked(prefs.getBoolean("date", true));
swDateBold.setChecked(prefs.getBoolean("date_bold", false));

View File

@ -136,6 +136,7 @@
android:id="@+id/swBeige"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="12dp"
android:layout_marginTop="12dp"
android:checked="true"
android:text="@string/title_advanced_cards_beige"
@ -144,28 +145,29 @@
app:layout_constraintTop_toBottomOf="@id/swCards"
app:switchPadding="12dp" />
<eu.faircode.email.FixedTextView
android:id="@+id/tvBeigeHint"
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swTabularCardBackground"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="48dp"
android:text="@string/title_advanced_beige_hint"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
android:textStyle="italic"
android:layout_marginStart="12dp"
android:layout_marginTop="12dp"
android:text="@string/title_advanced_tabular_background"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swBeige" />
app:layout_constraintTop_toBottomOf="@id/swBeige"
app:switchPadding="12dp" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swShadow"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="12dp"
android:layout_marginTop="12dp"
android:checked="true"
android:text="@string/title_advanced_cards_shadow"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvBeigeHint"
app:layout_constraintTop_toBottomOf="@id/swTabularCardBackground"
app:switchPadding="12dp" />
<androidx.appcompat.widget.SwitchCompat

View File

@ -375,7 +375,8 @@
<string name="title_advanced_landscape3">Show navigation menu in landscape mode by default</string>
<string name="title_advanced_startup">Show on start screen</string>
<string name="title_advanced_cards">Use card style instead of tabular style</string>
<string name="title_advanced_cards_beige">Use beige background when using card style</string>
<string name="title_advanced_cards_beige">Use beige background when using card style (light themes only)</string>
<string name="title_advanced_tabular_background">Use card color as background color when using tabular style</string>
<string name="title_advanced_cards_shadow">Use shadow for unread messages when using card style</string>
<string name="title_advanced_date_header">Group by date</string>
<string name="title_advanced_date_bold">Show date in bold</string>
@ -622,7 +623,6 @@
<string name="title_advanced_layout_hint">Switching to a more compact layout and changing the message text size can be done in the top action bar menu in the message view</string>
<string name="title_advanced_startup_hint">Long press any folder in the folder list to add or remove it from the list of unified folders</string>
<string name="title_advanced_beige_hint">Light themes only</string>
<string name="title_advanced_date_hint">Messages are only grouped by date if they are sorted by time</string>
<string name="title_advanced_navbar_colorize_hint">Whether this works depends on the Android version and variant</string>
<string name="title_advanced_split_hint">This will split the screen into parts</string>