Added option for sender/subject highlight color

pull/187/head
M66B 4 years ago
parent bead7a9051
commit 37526c7e1e

@ -5096,10 +5096,11 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
boolean highlight_unread = prefs.getBoolean("highlight_unread", true);
boolean highlight_subject = prefs.getBoolean("highlight_subject", false);
int colorHighlight = prefs.getInt("highlight_color", Helper.resolveColor(context, R.attr.colorUnreadHighlight));
this.colorUnread = Helper.resolveColor(context, highlight_unread ? R.attr.colorUnreadHighlight : R.attr.colorUnread);
this.colorUnread = (highlight_unread ? colorHighlight : Helper.resolveColor(context, R.attr.colorUnread));
this.colorRead = Helper.resolveColor(context, R.attr.colorRead);
this.colorSubject = Helper.resolveColor(context, highlight_subject ? R.attr.colorUnreadHighlight : R.attr.colorRead);
this.colorSubject = (highlight_subject ? colorHighlight : Helper.resolveColor(context, R.attr.colorRead));
this.colorEncrypt = Helper.resolveColor(context, R.attr.colorEncrypt);
this.colorSeparator = Helper.resolveColor(context, R.attr.colorSeparator);

@ -82,7 +82,7 @@ public class FragmentOptions extends FragmentBase {
"highlight_unread", "color_stripe",
"avatars", "gravatars", "favicons", "generated_icons", "identicons", "circular", "saturation", "brightness", "threshold",
"name_email", "prefer_contact", "distinguish_contacts", "show_recipients", "authentication",
"subject_top", "font_size_sender", "font_size_subject", "subject_italic", "highlight_subject", "subject_ellipsize",
"subject_top", "font_size_sender", "font_size_subject", "subject_italic", "highlight_subject", "subject_ellipsize", "highlight_color",
"keywords_header", "labels_header", "flags", "flags_background", "preview", "preview_italic", "preview_lines",
"message_zoom", "overview_mode", "addresses", "attachments_alt", "thumbnails",
"contrast", "monospaced",

@ -57,6 +57,10 @@ import androidx.fragment.app.FragmentActivity;
import androidx.lifecycle.Lifecycle;
import androidx.preference.PreferenceManager;
import com.flask.colorpicker.ColorPickerView;
import com.flask.colorpicker.builder.ColorPickerClickListener;
import com.flask.colorpicker.builder.ColorPickerDialogBuilder;
public class FragmentOptionsDisplay extends FragmentBase implements SharedPreferences.OnSharedPreferenceChangeListener {
private Button btnTheme;
private Spinner spStartup;
@ -100,6 +104,7 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
private SwitchCompat swSubjectItalic;
private SwitchCompat swHighlightSubject;
private Spinner spSubjectEllipsize;
private ViewButtonColor btnHighlightColor;
private SwitchCompat swKeywords;
private SwitchCompat swLabels;
private SwitchCompat swFlags;
@ -133,7 +138,7 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
"highlight_unread", "color_stripe",
"avatars", "gravatars", "favicons", "generated_icons", "identicons", "circular", "saturation", "brightness", "threshold",
"name_email", "prefer_contact", "distinguish_contacts", "show_recipients",
"subject_top", "font_size_sender", "font_size_subject", "subject_italic", "highlight_subject", "subject_ellipsize",
"subject_top", "font_size_sender", "font_size_subject", "subject_italic", "highlight_subject", "subject_ellipsize", "highlight_color",
"keywords_header", "labels_header", "flags", "flags_background",
"preview", "preview_italic", "preview_lines",
"addresses",
@ -195,6 +200,7 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
swSubjectItalic = view.findViewById(R.id.swSubjectItalic);
swHighlightSubject = view.findViewById(R.id.swHighlightSubject);
spSubjectEllipsize = view.findViewById(R.id.spSubjectEllipsize);
btnHighlightColor = view.findViewById(R.id.btnHighlightColor);
swKeywords = view.findViewById(R.id.swKeywords);
swLabels = view.findViewById(R.id.swLabels);
swFlags = view.findViewById(R.id.swFlags);
@ -566,6 +572,39 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
}
});
btnHighlightColor.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Context context = getContext();
int editTextColor = Helper.resolveColor(context, android.R.attr.editTextColor);
ColorPickerDialogBuilder builder = ColorPickerDialogBuilder
.with(context)
.setTitle(R.string.title_advanced_highlight_color)
.showColorEdit(true)
.setColorEditTextColor(editTextColor)
.wheelType(ColorPickerView.WHEEL_TYPE.FLOWER)
.density(6)
.lightnessSliderOnly()
.setPositiveButton(android.R.string.ok, new ColorPickerClickListener() {
@Override
public void onClick(DialogInterface dialog, int selectedColor, Integer[] allColors) {
prefs.edit().putInt("highlight_color", selectedColor).apply();
btnHighlightColor.setColor(selectedColor);
}
})
.setNegativeButton(R.string.title_reset, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
prefs.edit().remove("highlight_color").apply();
btnHighlightColor.setColor(Helper.resolveColor(context, R.attr.colorAccent));
}
});
builder.build().show();
}
});
swKeywords.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
@ -889,6 +928,9 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
break;
}
btnHighlightColor.setColor(prefs.getInt("highlight_color",
Helper.resolveColor(getContext(), R.attr.colorUnreadHighlight)));
swKeywords.setChecked(prefs.getBoolean("keywords_header", false));
swLabels.setChecked(prefs.getBoolean("labels_header", true));
swFlags.setChecked(prefs.getBoolean("flags", true));

@ -325,18 +325,6 @@
app:layout_constraintTop_toBottomOf="@id/tvCaptionHeader"
app:switchPadding="12dp" />
<eu.faircode.email.FixedTextView
android:id="@+id/tvHighlightUnreadHint"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="48dp"
android:text="@string/title_advanced_highlight_hint"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
android:textStyle="italic"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swHighlightUnread" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swColorStripe"
android:layout_width="0dp"
@ -347,7 +335,7 @@
android:text="@string/title_advanced_color_stripe"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvHighlightUnreadHint"
app:layout_constraintTop_toBottomOf="@id/swHighlightUnread"
app:switchPadding="12dp" />
<androidx.appcompat.widget.SwitchCompat
@ -676,18 +664,6 @@
app:layout_constraintTop_toBottomOf="@id/swSubjectItalic"
app:switchPadding="12dp" />
<eu.faircode.email.FixedTextView
android:id="@+id/tvHighlightSubjectHint"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="48dp"
android:text="@string/title_advanced_highlight_hint"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
android:textStyle="italic"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swHighlightSubject" />
<eu.faircode.email.FixedTextView
android:id="@+id/tvSubjectEllipsize"
android:layout_width="0dp"
@ -698,7 +674,7 @@
android:textColor="?android:attr/textColorPrimary"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvHighlightSubjectHint" />
app:layout_constraintTop_toBottomOf="@id/swHighlightSubject" />
<Spinner
android:id="@+id/spSubjectEllipsize"
@ -709,6 +685,29 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvSubjectEllipsize" />
<eu.faircode.email.ViewButtonColor
android:id="@+id/btnHighlightColor"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:paddingHorizontal="6dp"
android:text="@string/title_advanced_highlight_color"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/spSubjectEllipsize" />
<eu.faircode.email.FixedTextView
android:id="@+id/tvHighlightColorHint"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="48dp"
android:text="@string/title_advanced_highlight_color_hint"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
android:textStyle="italic"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/btnHighlightColor" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swKeywords"
android:layout_width="0dp"
@ -717,7 +716,7 @@
android:text="@string/title_advanced_keywords"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/spSubjectEllipsize"
app:layout_constraintTop_toBottomOf="@id/tvHighlightColorHint"
app:switchPadding="12dp" />
<androidx.appcompat.widget.SwitchCompat

@ -366,6 +366,7 @@
<string name="title_advanced_subject_top">Show subject above sender</string>
<string name="title_advanced_subject_italic">Show subject in italics</string>
<string name="title_advanced_subject_elipsed">When needed, shorten the subject</string>
<string name="title_advanced_highlight_color">Highlight color</string>
<string name="title_advanced_keywords">Show keywords in message header</string>
<string name="title_advanced_labels">Show Gmail labels in message header</string>
<string name="title_advanced_flags">Show stars</string>
@ -551,9 +552,9 @@
<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_threading_hint">Group messages related to each other</string>
<string name="title_advanced_highlight_hint">The accent color of the theme will be used for highlighting</string>
<string name="title_advanced_gravatars_hint">There might be a privacy risk</string>
<string name="title_advanced_name_email_hint">When disabled only names will be shown when available</string>
<string name="title_advanced_highlight_color_hint">The highlight color for the sender and subject</string>
<string name="title_advanced_preview_hint">Only available when message text has been downloaded</string>
<string name="title_advanced_preview_issue">Scrolling can be slow due to a bug in some Android versions when the number of lines is more than one</string>
<string name="title_advanced_overview_mode_hint">This can result in very small fonts</string>

Loading…
Cancel
Save