Added option to use highlight color for unread shadow

pull/194/merge
M66B 3 years ago
parent 2abb222171
commit 94a9d60d2e

@ -231,6 +231,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
private int textColorSecondary; private int textColorSecondary;
private int textColorTertiary; private int textColorTertiary;
private int textColorLink; private int textColorLink;
private int colorUnreadHighlight;
private int colorUnread; private int colorUnread;
private int colorRead; private int colorRead;
private int colorSubject; private int colorSubject;
@ -249,6 +250,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
private boolean date; private boolean date;
private boolean cards; private boolean cards;
private boolean shadow_unread; private boolean shadow_unread;
private boolean shadow_highlight;
private boolean threading; private boolean threading;
private boolean threading_unread; private boolean threading_unread;
private boolean indentation; private boolean indentation;
@ -1621,7 +1623,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
if (cards && shadow_unread) { if (cards && shadow_unread) {
boolean shadow = (message.unseen > 0); boolean shadow = (message.unseen > 0);
int color = (shadow int color = (shadow
? ColorUtils.setAlphaComponent(colorAccent, 127) ? ColorUtils.setAlphaComponent(shadow_highlight ? colorUnreadHighlight : colorAccent, 127)
: Color.TRANSPARENT); : Color.TRANSPARENT);
if (!Objects.equals(itemView.getTag(), shadow)) { if (!Objects.equals(itemView.getTag(), shadow)) {
itemView.setTag(shadow); itemView.setTag(shadow);
@ -5996,9 +5998,9 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
boolean highlight_unread = prefs.getBoolean("highlight_unread", true); boolean highlight_unread = prefs.getBoolean("highlight_unread", true);
boolean highlight_subject = prefs.getBoolean("highlight_subject", false); boolean highlight_subject = prefs.getBoolean("highlight_subject", false);
int colorHighlight = prefs.getInt("highlight_color", Helper.resolveColor(context, R.attr.colorUnreadHighlight)); this.colorUnreadHighlight = prefs.getInt("highlight_color", Helper.resolveColor(context, R.attr.colorUnreadHighlight));
this.colorUnread = (highlight_unread ? colorHighlight : Helper.resolveColor(context, R.attr.colorUnread)); this.colorUnread = (highlight_unread ? colorUnreadHighlight : Helper.resolveColor(context, R.attr.colorUnread));
this.colorRead = Helper.resolveColor(context, R.attr.colorRead); this.colorRead = Helper.resolveColor(context, R.attr.colorRead);
this.colorSubject = Helper.resolveColor(context, highlight_subject ? R.attr.colorUnreadHighlight : R.attr.colorRead); this.colorSubject = Helper.resolveColor(context, highlight_subject ? R.attr.colorUnreadHighlight : R.attr.colorRead);
this.colorVerified = Helper.resolveColor(context, R.attr.colorVerified); this.colorVerified = Helper.resolveColor(context, R.attr.colorVerified);
@ -6022,6 +6024,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
this.date = prefs.getBoolean("date", true); this.date = prefs.getBoolean("date", true);
this.cards = prefs.getBoolean("cards", true); this.cards = prefs.getBoolean("cards", true);
this.shadow_unread = prefs.getBoolean("shadow_unread", false); this.shadow_unread = prefs.getBoolean("shadow_unread", false);
this.shadow_highlight = prefs.getBoolean("shadow_highlight", false);
this.threading = prefs.getBoolean("threading", true); this.threading = prefs.getBoolean("threading", true);
this.threading_unread = threading && prefs.getBoolean("threading_unread", false); this.threading_unread = threading && prefs.getBoolean("threading_unread", false);
this.indentation = prefs.getBoolean("indentation", false); this.indentation = prefs.getBoolean("indentation", false);

@ -125,7 +125,7 @@ public class FragmentOptions extends FragmentBase {
"subscriptions", "subscriptions",
"check_authentication", "check_reply_domain", "check_mx", "check_blocklist", "check_authentication", "check_reply_domain", "check_mx", "check_blocklist",
"send_pending", "send_pending",
"startup", "cards", "beige", "tabular_card_bg", "shadow_unread", "startup", "cards", "beige", "tabular_card_bg", "shadow_unread", "shadow_highlight",
"portrait2", "portrait2c", "landscape", "nav_count", "nav_unseen_drafts", "navbar_colorize", "portrait2", "portrait2c", "landscape", "nav_count", "nav_unseen_drafts", "navbar_colorize",
"indentation", "date", "date_fixed", "date_bold", "threading", "threading_unread", "indentation", "date", "date_fixed", "date_bold", "threading", "threading_unread",
"highlight_unread", "highlight_color", "color_stripe", "highlight_unread", "highlight_color", "color_stripe",

@ -63,6 +63,7 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
private SwitchCompat swBeige; private SwitchCompat swBeige;
private SwitchCompat swTabularBackground; private SwitchCompat swTabularBackground;
private SwitchCompat swShadow; private SwitchCompat swShadow;
private SwitchCompat swShadowHighlight;
private SwitchCompat swDate; private SwitchCompat swDate;
private SwitchCompat swDateFixed; private SwitchCompat swDateFixed;
private SwitchCompat swDateBold; private SwitchCompat swDateBold;
@ -159,7 +160,7 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
private NumberFormat NF = NumberFormat.getNumberInstance(); private NumberFormat NF = NumberFormat.getNumberInstance();
private final static String[] RESET_OPTIONS = new String[]{ private final static String[] RESET_OPTIONS = new String[]{
"theme", "startup", "cards", "beige", "tabular_card_bg", "shadow_unread", "theme", "startup", "cards", "beige", "tabular_card_bg", "shadow_unread", "shadow_highlight",
"date", "date_fixed", "date_bold", "date", "date_fixed", "date_bold",
"portrait2", "portrait2c", "landscape", "nav_options", "nav_count", "nav_unseen_drafts", "navbar_colorize", "portrait2", "portrait2c", "landscape", "nav_options", "nav_count", "nav_unseen_drafts", "navbar_colorize",
"threading", "threading_unread", "indentation", "seekbar", "actionbar", "actionbar_color", "threading", "threading_unread", "indentation", "seekbar", "actionbar", "actionbar_color",
@ -194,6 +195,7 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
swBeige = view.findViewById(R.id.swBeige); swBeige = view.findViewById(R.id.swBeige);
swTabularBackground = view.findViewById(R.id.swTabularCardBackground); swTabularBackground = view.findViewById(R.id.swTabularCardBackground);
swShadow = view.findViewById(R.id.swShadow); swShadow = view.findViewById(R.id.swShadow);
swShadowHighlight = view.findViewById(R.id.swShadowHighlight);
swDate = view.findViewById(R.id.swDate); swDate = view.findViewById(R.id.swDate);
swDateFixed = view.findViewById(R.id.swDateFixed); swDateFixed = view.findViewById(R.id.swDateFixed);
swDateBold = view.findViewById(R.id.swDateBold); swDateBold = view.findViewById(R.id.swDateBold);
@ -321,6 +323,7 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
swBeige.setEnabled(checked); swBeige.setEnabled(checked);
swTabularBackground.setEnabled(!checked); swTabularBackground.setEnabled(!checked);
swShadow.setEnabled(checked); swShadow.setEnabled(checked);
swShadowHighlight.setEnabled(swShadow.isEnabled() && checked);
swIndentation.setEnabled(checked); swIndentation.setEnabled(checked);
} }
}); });
@ -344,6 +347,14 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
@Override @Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("shadow_unread", checked).apply(); prefs.edit().putBoolean("shadow_unread", checked).apply();
swShadowHighlight.setEnabled(swShadow.isEnabled() && checked);
}
});
swShadowHighlight.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("shadow_highlight", checked).apply();
} }
}); });
@ -1071,9 +1082,11 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
swBeige.setChecked(prefs.getBoolean("beige", true)); swBeige.setChecked(prefs.getBoolean("beige", true));
swTabularBackground.setChecked(prefs.getBoolean("tabular_card_bg", false)); swTabularBackground.setChecked(prefs.getBoolean("tabular_card_bg", false));
swShadow.setChecked(prefs.getBoolean("shadow_unread", false)); swShadow.setChecked(prefs.getBoolean("shadow_unread", false));
swShadowHighlight.setChecked(prefs.getBoolean("shadow_highlight", false));
swBeige.setEnabled(swCards.isChecked()); swBeige.setEnabled(swCards.isChecked());
swTabularBackground.setEnabled(!swCards.isChecked()); swTabularBackground.setEnabled(!swCards.isChecked());
swShadow.setEnabled(swCards.isChecked()); swShadow.setEnabled(swCards.isChecked());
swShadowHighlight.setEnabled(swShadow.isEnabled() && swShadow.isChecked());
swDate.setChecked(prefs.getBoolean("date", true)); swDate.setChecked(prefs.getBoolean("date", true));
swDateFixed.setChecked(prefs.getBoolean("date_fixed", false)); swDateFixed.setChecked(prefs.getBoolean("date_fixed", false));
swDateFixed.setEnabled(!swDate.isChecked()); swDateFixed.setEnabled(!swDate.isChecked());

@ -165,13 +165,24 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="12dp" android:layout_marginStart="12dp"
android:layout_marginTop="12dp" android:layout_marginTop="12dp"
android:checked="true"
android:text="@string/title_advanced_cards_shadow" android:text="@string/title_advanced_cards_shadow"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swTabularCardBackground" app:layout_constraintTop_toBottomOf="@id/swTabularCardBackground"
app:switchPadding="12dp" /> app:switchPadding="12dp" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swShadowHighlight"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="24dp"
android:layout_marginTop="12dp"
android:text="@string/title_advanced_cards_shadow_highlight"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swShadow"
app:switchPadding="12dp" />
<androidx.appcompat.widget.SwitchCompat <androidx.appcompat.widget.SwitchCompat
android:id="@+id/swDate" android:id="@+id/swDate"
android:layout_width="0dp" android:layout_width="0dp"
@ -181,7 +192,7 @@
android:text="@string/title_advanced_date_header" android:text="@string/title_advanced_date_header"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swShadow" app:layout_constraintTop_toBottomOf="@id/swShadowHighlight"
app:switchPadding="12dp" /> app:switchPadding="12dp" />
<eu.faircode.email.FixedTextView <eu.faircode.email.FixedTextView

@ -438,6 +438,7 @@
<string name="title_advanced_cards_beige">Use beige background when using card style (light themes only)</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_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_cards_shadow">Use shadow for unread messages when using card style</string>
<string name="title_advanced_cards_shadow_highlight">Use highlight color instead of accent color</string>
<string name="title_advanced_date_header">Group by date</string> <string name="title_advanced_date_header">Group by date</string>
<string name="title_advanced_date_fixed">Show fixed date header at the top</string> <string name="title_advanced_date_fixed">Show fixed date header at the top</string>
<string name="title_advanced_date_bold">Show date in bold</string> <string name="title_advanced_date_bold">Show date in bold</string>

Loading…
Cancel
Save