Added option to truncate sender

pull/206/head
M66B 3 years ago
parent 1c01bb980d
commit fa8472468b

@ -265,6 +265,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
private Float font_size_subject;
private boolean subject_top;
private boolean subject_italic;
private String sender_ellipsize;
private String subject_ellipsize;
private boolean keywords_header;
@ -659,8 +660,19 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
ibHelp = itemView.findViewById(R.id.ibHelp);
if (tvFrom != null) {
if (compact)
tvFrom.setSingleLine(true);
if (compact) {
boolean full = "full".equals(sender_ellipsize);
tvFrom.setSingleLine(!full);
if ("start".equals(sender_ellipsize))
tvFrom.setEllipsize(TextUtils.TruncateAt.START);
else if ("end".equals(sender_ellipsize))
tvFrom.setEllipsize(TextUtils.TruncateAt.END);
else if ("middle".equals(sender_ellipsize))
tvFrom.setEllipsize(TextUtils.TruncateAt.MIDDLE);
else
tvFrom.setEllipsize(null);
}
}
if (tvSubject != null) {
@ -1419,11 +1431,15 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
private void clearExpanded(TupleMessageEx message) {
if (compact) {
if (tvFrom.getMaxLines() > 1)
tvFrom.setSingleLine(true);
boolean full = "full".equals(subject_ellipsize);
if (full ? tvSubject.getMaxLines() == 1 : tvSubject.getMaxLines() > 1)
tvSubject.setSingleLine(!full);
if ("full".equals(sender_ellipsize)
? tvFrom.getMaxLines() == 1
: tvFrom.getMaxLines() > 1)
tvFrom.setSingleLine(!"full".equals(sender_ellipsize));
if ("full".equals(subject_ellipsize)
? tvSubject.getMaxLines() == 1
: tvSubject.getMaxLines() > 1)
tvSubject.setSingleLine(!"full".equals(subject_ellipsize));
}
tvPreview.setVisibility(
@ -5846,6 +5862,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
font_size_subject = Helper.getTextSize(context, fz_subject);
this.subject_italic = prefs.getBoolean("subject_italic", true);
this.sender_ellipsize = prefs.getString("sender_ellipsize", "end");
this.subject_ellipsize = prefs.getString("subject_ellipsize", "full");
this.keywords_header = prefs.getBoolean("keywords_header", false);
this.labels_header = prefs.getBoolean("labels_header", true);

@ -130,9 +130,10 @@ public class FragmentOptions extends FragmentBase {
"indentation", "date", "date_fixed", "date_bold", "threading", "threading_unread",
"highlight_unread", "highlight_color", "color_stripe",
"avatars", "bimi", "gravatars", "favicons", "generated_icons", "identicons", "circular", "saturation", "brightness", "threshold",
"email_format", "prefer_contact", "only_contact", "distinguish_contacts", "show_recipients",
"authentication", "authentication_indicator",
"subject_top", "font_size_sender", "font_size_subject", "subject_italic", "highlight_subject", "subject_ellipsize",
"email_format", "prefer_contact", "only_contact", "distinguish_contacts", "show_recipients",
"font_size_sender", "sender_ellipsize",
"subject_top", "subject_italic", "highlight_subject", "font_size_subject", "subject_ellipsize",
"keywords_header", "labels_header", "flags", "flags_background", "preview", "preview_italic", "preview_lines",
"message_zoom", "overview_mode", "addresses", "button_extra", "attachments_alt", "thumbnails",
"contrast", "monospaced", "monospaced_pre",

@ -104,17 +104,21 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
private SeekBar sbBrightness;
private TextView tvThreshold;
private SeekBar sbThreshold;
private Spinner spNameEmail;
private SwitchCompat swPreferContact;
private SwitchCompat swOnlyContact;
private SwitchCompat swDistinguishContacts;
private SwitchCompat swShowRecipients;
private SwitchCompat swSubjectTop;
private Spinner spFontSizeSender;
private Spinner spFontSizeSubject;
private Spinner spSenderEllipsize;
private SwitchCompat swSubjectTop;
private SwitchCompat swSubjectItalic;
private SwitchCompat swHighlightSubject;
private Spinner spFontSizeSubject;
private Spinner spSubjectEllipsize;
private SwitchCompat swKeywords;
private SwitchCompat swLabels;
private SwitchCompat swFlags;
@ -161,7 +165,8 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
"highlight_unread", "highlight_color", "color_stripe",
"avatars", "bimi", "gravatars", "favicons", "generated_icons", "identicons", "circular", "saturation", "brightness", "threshold",
"email_format", "prefer_contact", "only_contact", "distinguish_contacts", "show_recipients",
"subject_top", "font_size_sender", "font_size_subject", "subject_italic", "highlight_subject", "subject_ellipsize",
"font_size_sender", "sender_ellipsize",
"subject_top", "subject_italic", "highlight_subject", "font_size_subject", "subject_ellipsize",
"keywords_header", "labels_header", "flags", "flags_background",
"preview", "preview_italic", "preview_lines",
"addresses",
@ -229,17 +234,21 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
sbBrightness = view.findViewById(R.id.sbBrightness);
tvThreshold = view.findViewById(R.id.tvThreshold);
sbThreshold = view.findViewById(R.id.sbThreshold);
spNameEmail = view.findViewById(R.id.spNameEmail);
swPreferContact = view.findViewById(R.id.swPreferContact);
swOnlyContact = view.findViewById(R.id.swOnlyContact);
swDistinguishContacts = view.findViewById(R.id.swDistinguishContacts);
swShowRecipients = view.findViewById(R.id.swShowRecipients);
swSubjectTop = view.findViewById(R.id.swSubjectTop);
spFontSizeSender = view.findViewById(R.id.spFontSizeSender);
spFontSizeSubject = view.findViewById(R.id.spFontSizeSubject);
spSenderEllipsize = view.findViewById(R.id.spSenderEllipsize);
swSubjectTop = view.findViewById(R.id.swSubjectTop);
swSubjectItalic = view.findViewById(R.id.swSubjectItalic);
swHighlightSubject = view.findViewById(R.id.swHighlightSubject);
spFontSizeSubject = view.findViewById(R.id.spFontSizeSubject);
spSubjectEllipsize = view.findViewById(R.id.spSubjectEllipsize);
swKeywords = view.findViewById(R.id.swKeywords);
swLabels = view.findViewById(R.id.swLabels);
swFlags = view.findViewById(R.id.swFlags);
@ -688,14 +697,6 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
}
});
swSubjectTop.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("subject_top", checked).apply();
WidgetUnified.updateData(getContext());
}
});
spFontSizeSender.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> adapterView, View view, int position, long id) {
@ -709,16 +710,24 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
}
});
spFontSizeSubject.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
spSenderEllipsize.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> adapterView, View view, int position, long id) {
int[] values = getResources().getIntArray(R.array.fontSizeValues);
prefs.edit().putInt("font_size_subject", values[position]).apply();
String[] values = getResources().getStringArray(R.array.ellipsizeValues);
prefs.edit().putString("sender_ellipsize", values[position]).apply();
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
prefs.edit().remove("font_size_subject").apply();
prefs.edit().remove("sender_ellipsize").apply();
}
});
swSubjectTop.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("subject_top", checked).apply();
WidgetUnified.updateData(getContext());
}
});
@ -737,6 +746,19 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
}
});
spFontSizeSubject.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> adapterView, View view, int position, long id) {
int[] values = getResources().getIntArray(R.array.fontSizeValues);
prefs.edit().putInt("font_size_subject", values[position]).apply();
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
prefs.edit().remove("font_size_subject").apply();
}
});
spSubjectEllipsize.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> adapterView, View view, int position, long id) {
@ -1097,9 +1119,13 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
swOnlyContact.setChecked(prefs.getBoolean("only_contact", false));
swDistinguishContacts.setChecked(prefs.getBoolean("distinguish_contacts", false));
swShowRecipients.setChecked(prefs.getBoolean("show_recipients", false));
swSubjectTop.setChecked(prefs.getBoolean("subject_top", false));
swSubjectItalic.setChecked(prefs.getBoolean("subject_italic", true));
swHighlightSubject.setChecked(prefs.getBoolean("highlight_subject", false));
int[] fontSizeValues = getResources().getIntArray(R.array.fontSizeValues);
String[] ellipsizeValues = getResources().getStringArray(R.array.ellipsizeValues);
int font_size_sender = prefs.getInt("font_size_sender", -1);
for (int pos = 0; pos < fontSizeValues.length; pos++)
@ -1115,11 +1141,14 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
break;
}
swSubjectItalic.setChecked(prefs.getBoolean("subject_italic", true));
swHighlightSubject.setChecked(prefs.getBoolean("highlight_subject", false));
String sender_ellipsize = prefs.getString("sender_ellipsize", "end");
for (int pos = 0; pos < startupValues.length; pos++)
if (ellipsizeValues[pos].equals(sender_ellipsize)) {
spSenderEllipsize.setSelection(pos);
break;
}
String subject_ellipsize = prefs.getString("subject_ellipsize", "full");
String[] ellipsizeValues = getResources().getStringArray(R.array.ellipsizeValues);
for (int pos = 0; pos < startupValues.length; pos++)
if (ellipsizeValues[pos].equals(subject_ellipsize)) {
spSubjectEllipsize.setSelection(pos);

@ -892,17 +892,6 @@
app:layout_constraintTop_toBottomOf="@id/swDistinguishContacts"
app:switchPadding="12dp" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swSubjectTop"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:text="@string/title_advanced_subject_top"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swShowRecipients"
app:switchPadding="12dp" />
<eu.faircode.email.FixedTextView
android:id="@+id/tvFontSizeSender"
android:layout_width="0dp"
@ -914,7 +903,7 @@
android:textColor="?android:attr/textColorPrimary"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swSubjectTop" />
app:layout_constraintTop_toBottomOf="@id/swShowRecipients" />
<Spinner
android:id="@+id/spFontSizeSender"
@ -926,12 +915,11 @@
app:layout_constraintTop_toBottomOf="@id/tvFontSizeSender" />
<eu.faircode.email.FixedTextView
android:id="@+id/tvFontSizeSubject"
android:id="@+id/tvSenderEllipsize"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:layout_marginEnd="48dp"
android:text="@string/title_advanced_font_size_subject"
android:text="@string/title_advanced_sender_ellipsize"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
android:textColor="?android:attr/textColorPrimary"
app:layout_constraintEnd_toEndOf="parent"
@ -939,13 +927,37 @@
app:layout_constraintTop_toBottomOf="@id/spFontSizeSender" />
<Spinner
android:id="@+id/spFontSizeSubject"
android:id="@+id/spSenderEllipsize"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:entries="@array/fontSizeNames"
android:entries="@array/ellipsizeNames"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvFontSizeSubject" />
app:layout_constraintTop_toBottomOf="@id/tvSenderEllipsize" />
<eu.faircode.email.FixedTextView
android:id="@+id/tvSenderEllipsizeRemark"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="6dp"
android:layout_marginEnd="48dp"
android:text="@string/title_advanced_compact_mode_remark"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
android:textStyle="italic"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/spSenderEllipsize" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swSubjectTop"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:text="@string/title_advanced_subject_top"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvSenderEllipsizeRemark"
app:switchPadding="12dp" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swSubjectItalic"
@ -956,7 +968,7 @@
android:text="@string/title_advanced_subject_italic"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/spFontSizeSubject"
app:layout_constraintTop_toBottomOf="@id/swSubjectTop"
app:switchPadding="12dp" />
<androidx.appcompat.widget.SwitchCompat
@ -983,17 +995,39 @@
app:layout_constraintTop_toBottomOf="@id/swHighlightSubject" />
<eu.faircode.email.FixedTextView
android:id="@+id/tvSubjectEllipsize"
android:id="@+id/tvFontSizeSubject"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:text="@string/title_advanced_subject_elipsed"
android:layout_marginEnd="48dp"
android:text="@string/title_advanced_font_size_subject"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
android:textColor="?android:attr/textColorPrimary"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvHighlightSubjectHint" />
<Spinner
android:id="@+id/spFontSizeSubject"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:entries="@array/fontSizeNames"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvFontSizeSubject" />
<eu.faircode.email.FixedTextView
android:id="@+id/tvSubjectEllipsize"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:text="@string/title_advanced_subject_ellipsize"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
android:textColor="?android:attr/textColorPrimary"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/spFontSizeSubject" />
<Spinner
android:id="@+id/spSubjectEllipsize"
android:layout_width="wrap_content"
@ -1003,6 +1037,19 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvSubjectEllipsize" />
<eu.faircode.email.FixedTextView
android:id="@+id/tvSubjectEllipsizeRemark"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="6dp"
android:layout_marginEnd="48dp"
android:text="@string/title_advanced_compact_mode_remark"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
android:textStyle="italic"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/spSubjectEllipsize" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swKeywords"
android:layout_width="0dp"
@ -1011,7 +1058,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/tvSubjectEllipsizeRemark"
app:switchPadding="12dp" />
<androidx.appcompat.widget.SwitchCompat

@ -427,7 +427,6 @@
<string name="title_advanced_threading_unread">Show number of unread messages in conversations</string>
<string name="title_advanced_indentation">Left/right indent received/sent messages in conversations</string>
<string name="title_advanced_highlight_unread">Highlight unread messages</string>
<string name="title_advanced_highlight_subject">Highlight subject</string>
<string name="title_advanced_color_stripe">Show color stripe</string>
<string name="title_advanced_avatars">Show contact photos</string>
<string name="title_advanced_gravatars">Show Gravatars</string>
@ -441,16 +440,23 @@
<string name="title_advanced_color_saturation">Saturation: %1$s %%</string>
<string name="title_advanced_color_value">Brightness: %1$s %%</string>
<string name="title_advanced_color_threshold">Threshold letter color: %1$s %%</string>
<string name="title_advanced_name_email">Show names and email addresses</string>
<string name="title_advanced_replace_name">Prefer a contact name over a sent name</string>
<string name="title_advanced_only_name">Display contact names only</string>
<string name="title_advanced_distinguish_contacts">Underline the sender when the sender is known as local \'to\' contact</string>
<string name="title_advanced_show_recipients">Show recipients in message header</string>
<string name="title_advanced_font_size_sender">Text size sender</string>
<string name="title_advanced_font_size_subject">Text size subject</string>
<string name="title_advanced_sender_ellipsize">If needed, shorten the sender</string>
<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_subject">Highlight subject</string>
<string name="title_advanced_font_size_subject">Text size subject</string>
<string name="title_advanced_subject_ellipsize">If needed, shorten the subject</string>
<string name="title_advanced_compact_mode_remark">Compact mode only</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>

Loading…
Cancel
Save