Added option to select subject ellipsizing

pull/162/head
M66B 5 years ago
parent cfe5368e56
commit 6a9562937b

@ -186,6 +186,8 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
private boolean name_email;
private boolean subject_top;
private boolean subject_italic;
private String subject_ellipsize;
private boolean flags;
private boolean preview;
private boolean preview_italic;
@ -370,11 +372,13 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
btnHelp = itemView.findViewById(R.id.btnHelp);
pbLoading = itemView.findViewById(R.id.pbLoading);
if (subject_top) {
TextUtils.TruncateAt ellipsize = tvFrom.getEllipsize();
tvFrom.setEllipsize(tvSubject.getEllipsize());
tvSubject.setEllipsize(ellipsize);
}
if (compact)
if ("start".equals(subject_ellipsize))
tvSubject.setEllipsize(TextUtils.TruncateAt.START);
else if ("end".equals(subject_ellipsize))
tvSubject.setEllipsize(TextUtils.TruncateAt.END);
else
tvSubject.setEllipsize(TextUtils.TruncateAt.MIDDLE);
}
private void ensureExpanded() {
@ -3132,6 +3136,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
this.name_email = prefs.getBoolean("name_email", false);
this.subject_top = prefs.getBoolean("subject_top", false);
this.subject_italic = prefs.getBoolean("subject_italic", true);
this.subject_ellipsize = prefs.getString("subject_ellipsize", "middle");
this.flags = prefs.getBoolean("flags", true);
this.preview = prefs.getBoolean("preview", false);
this.preview_italic = prefs.getBoolean("preview_italic", true);

@ -40,7 +40,7 @@ public class FragmentOptions extends FragmentBase {
static String[] OPTIONS_RESTART = new String[]{
"subscriptions",
"startup", "cards", "date", "threading", "highlight_unread", "avatars", "generated_icons", "identicons", "circular",
"name_email", "subject_top", "subject_italic", "flags", "preview", "preview_italic",
"name_email", "subject_top", "subject_italic", "subject_ellipsize", "flags", "preview", "preview_italic",
"addresses", "attachments_alt", "contrast", "monospaced", "inline_images", "collapse_quotes", "autocontent", "actionbar",
"autoscroll", "swipenav", "autoexpand", "autoclose", "onclose",
"experiments", "debug",

@ -55,6 +55,7 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
private SwitchCompat swNameEmail;
private SwitchCompat swSubjectTop;
private SwitchCompat swSubjectItalic;
private Spinner spSubjectEllipsize;
private SwitchCompat swFlags;
private SwitchCompat swPreview;
private SwitchCompat swPreviewItalic;
@ -70,7 +71,7 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
private final static String[] RESET_OPTIONS = new String[]{
"theme", "startup", "cards", "date", "threading", "highlight_unread",
"avatars", "generated_icons", "identicons", "circular", "name_email", "subject_top", "subject_italic",
"avatars", "generated_icons", "identicons", "circular", "name_email", "subject_top", "subject_italic", "subject_ellipsize",
"flags", "preview", "preview_italic", "addresses", "attachments_alt",
"contrast", "monospaced", "inline_images", "collapse_quotes", "autocontent", "actionbar",
};
@ -98,6 +99,7 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
swNameEmail = view.findViewById(R.id.swNameEmail);
swSubjectTop = view.findViewById(R.id.swSubjectTop);
swSubjectItalic = view.findViewById(R.id.swSubjectItalic);
spSubjectEllipsize = view.findViewById(R.id.spSubjectEllipsize);
swFlags = view.findViewById(R.id.swFlags);
swPreview = view.findViewById(R.id.swPreview);
swPreviewItalic = view.findViewById(R.id.swPreviewItalic);
@ -218,6 +220,19 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
}
});
spSubjectEllipsize.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> adapterView, View view, int position, long id) {
String[] values = getResources().getStringArray(R.array.ellipsizeValues);
prefs.edit().putString("subject_ellipsize", values[position]).apply();
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
prefs.edit().remove("subject_ellipsize").apply();
}
});
swFlags.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
@ -361,6 +376,15 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
swNameEmail.setChecked(prefs.getBoolean("name_email", false));
swSubjectTop.setChecked(prefs.getBoolean("subject_top", false));
swSubjectItalic.setChecked(prefs.getBoolean("subject_italic", true));
String subject_ellipsize = prefs.getString("subject_ellipsize", "middle");
String[] ellipsizeValues = getResources().getStringArray(R.array.ellipsizeValues);
for (int pos = 0; pos < startupValues.length; pos++)
if (ellipsizeValues[pos].equals(subject_ellipsize)) {
spSubjectEllipsize.setSelection(pos);
break;
}
swFlags.setChecked(prefs.getBoolean("flags", true));
swPreview.setChecked(prefs.getBoolean("preview", false));
swPreviewItalic.setChecked(prefs.getBoolean("preview_italic", true));

@ -205,6 +205,27 @@
app:layout_constraintTop_toBottomOf="@id/swSubjectTop"
app:switchPadding="12dp" />
<TextView
android:id="@+id/tvSubjectEllipsize"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:text="@string/title_advanced_subject_elipsed"
android:textAppearance="@style/Base.TextAppearance.AppCompat.Small"
android:textColor="?android:attr/textColorPrimary"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swSubjectItalic" />
<Spinner
android:id="@+id/spSubjectEllipsize"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:entries="@array/ellipsizeNames"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvSubjectEllipsize" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swFlags"
android:layout_width="0dp"
@ -214,7 +235,7 @@
android:text="@string/title_advanced_flags"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swSubjectItalic"
app:layout_constraintTop_toBottomOf="@id/spSubjectEllipsize"
app:switchPadding="12dp" />
<androidx.appcompat.widget.SwitchCompat

@ -196,7 +196,7 @@
android:layout_height="wrap_content"
android:layout_marginStart="6dp"
android:layout_marginEnd="6dp"
android:ellipsize="middle"
android:ellipsize="end"
android:gravity="center_vertical"
android:minHeight="21dp"
android:singleLine="true"

@ -243,6 +243,7 @@
<string name="title_advanced_name_email">Show names and email addresses</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_flags">Show stars</string>
<string name="title_advanced_preview">Show message preview</string>
<string name="title_advanced_preview_italic">Show message preview in italics</string>
@ -962,6 +963,18 @@
<item>20 minutes</item>
</string-array>
<string-array name="ellipsizeValues" translatable="false">
<item>start</item>
<item>middle</item>
<item>end</item>
</string-array>
<string-array name="ellipsizeNames">
<item>At the start</item>
<item>In the middle</item>
<item>At the end</item>
</string-array>
<array name="colorPicker">
<item>@color/red</item>
<item>@color/pink</item>

Loading…
Cancel
Save