Added settings for font size sender/subject

This commit is contained in:
M66B 2019-11-17 20:30:33 +01:00
parent daf40a399e
commit f5edd14d69
5 changed files with 127 additions and 7 deletions

View File

@ -195,6 +195,8 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
private boolean avatars;
private boolean name_email;
private boolean distinguish_contacts;
private Float font_size_sender;
private Float font_size_subject;
private boolean subject_top;
private boolean subject_italic;
private String subject_ellipsize;
@ -684,15 +686,14 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
// Text size
if (textSize != 0) {
tvFrom.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize * (message.unseen > 0 ? 1.1f : 1f));
tvSubject.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize * 0.9f);
float fz_sender = (font_size_sender == null ? textSize : font_size_sender) * (message.unseen > 0 ? 1.1f : 1f);
float fz_subject = (font_size_subject == null ? textSize : font_size_subject) * 0.9f;
tvFrom.setTextSize(TypedValue.COMPLEX_UNIT_PX, fz_sender);
tvSubject.setTextSize(TypedValue.COMPLEX_UNIT_PX, fz_subject);
tvFolder.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize * 0.9f);
tvPreview.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize * 0.9f);
int px = Math.round(
textSize * (message.unseen > 0 ? 1.1f : 1f) +
textSize * 0.9f +
(compact ? 0 : textSize * 0.9f));
int px = Math.round(fz_sender + fz_subject + (compact ? 0 : textSize * 0.9f));
ViewGroup.LayoutParams lparams = ibAvatar.getLayoutParams();
if (lparams.height != px) {
lparams.width = px;
@ -3634,6 +3635,15 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
this.avatars = (contacts && avatars) || generated;
this.name_email = prefs.getBoolean("name_email", false);
this.distinguish_contacts = prefs.getBoolean("distinguish_contacts", false);
int fz_sender = prefs.getInt("font_size_sender", -1);
if (fz_sender >= 0)
font_size_sender = Helper.getTextSize(context, fz_sender);
int fz_subject = prefs.getInt("font_size_subject", -1);
if (fz_subject >= 0)
font_size_subject = Helper.getTextSize(context, fz_subject);
this.subject_top = prefs.getBoolean("subject_top", false);
this.subject_italic = prefs.getBoolean("subject_italic", true);
this.subject_ellipsize = prefs.getString("subject_ellipsize", "middle");

View File

@ -41,6 +41,7 @@ public class FragmentOptions extends FragmentBase {
"subscriptions",
"landscape", "startup", "cards", "indentation", "date", "threading", "highlight_unread",
"avatars", "generated_icons", "identicons", "circular", "saturation", "brightness", "threshold",
"font_size_sender", "font_size_subject",
"name_email", "distinguish_contacts", "authentication",
"subject_top", "subject_italic", "subject_ellipsize",
"flags", "flags_background", "preview", "preview_italic", "preview_lines",

View File

@ -69,6 +69,8 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
private SwitchCompat swNameEmail;
private SwitchCompat swDistinguishContacts;
private SwitchCompat swAuthentication;
private Spinner spFontSizeSender;
private Spinner spFontSizeSubject;
private SwitchCompat swSubjectTop;
private SwitchCompat swSubjectItalic;
private Spinner spSubjectEllipsize;
@ -92,6 +94,7 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
"theme", "landscape", "startup", "cards", "indentation", "date", "threading", "highlight_unread",
"avatars", "generated_icons", "identicons", "circular", "saturation", "brightness", "threshold",
"name_email", "distinguish_contacts", "authentication",
"font_size_sender", "font_size_subject",
"subject_top", "subject_italic", "subject_ellipsize",
"flags", "flags_background", "preview", "preview_italic", "preview_lines", "addresses", "attachments_alt",
"contrast", "monospaced", "text_color",
@ -129,6 +132,8 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
swNameEmail = view.findViewById(R.id.swNameEmail);
swDistinguishContacts = view.findViewById(R.id.swDistinguishContacts);
swAuthentication = view.findViewById(R.id.swAuthentication);
spFontSizeSender = view.findViewById(R.id.spFontSizeSender);
spFontSizeSubject = view.findViewById(R.id.spFontSizeSubject);
swSubjectTop = view.findViewById(R.id.swSubjectTop);
swSubjectItalic = view.findViewById(R.id.swSubjectItalic);
spSubjectEllipsize = view.findViewById(R.id.spSubjectEllipsize);
@ -332,6 +337,32 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
}
});
spFontSizeSender.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_sender", values[position]).apply();
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
prefs.edit().remove("font_size_sender").apply();
}
});
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();
}
});
swSubjectTop.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
@ -548,6 +579,23 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
swNameEmail.setChecked(prefs.getBoolean("name_email", false));
swDistinguishContacts.setChecked(prefs.getBoolean("distinguish_contacts", false));
swAuthentication.setChecked(prefs.getBoolean("authentication", true));
int[] fontSizeValues = getResources().getIntArray(R.array.fontSizeValues);
int font_size_sender = prefs.getInt("font_size_sender", -1);
for (int pos = 0; pos < fontSizeValues.length; pos++)
if (fontSizeValues[pos] == font_size_sender) {
spFontSizeSender.setSelection(pos);
break;
}
int font_size_subject = prefs.getInt("font_size_subject", -1);
for (int pos = 0; pos < fontSizeValues.length; pos++)
if (fontSizeValues[pos] == font_size_subject) {
spFontSizeSubject.setSelection(pos);
break;
}
swSubjectTop.setChecked(prefs.getBoolean("subject_top", false));
swSubjectItalic.setChecked(prefs.getBoolean("subject_italic", true));

View File

@ -65,6 +65,7 @@
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:layout_marginEnd="48dp"
android:text="@string/title_advanced_startup"
android:textAppearance="@style/Base.TextAppearance.AppCompat.Small"
android:textColor="?android:attr/textColorPrimary"
@ -370,6 +371,50 @@
app:layout_constraintTop_toBottomOf="@id/swDistinguishContacts"
app:switchPadding="12dp" />
<TextView
android:id="@+id/tvFontSizeSender"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:layout_marginEnd="48dp"
android:text="@string/title_advanced_font_size_sender"
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/swAuthentication" />
<Spinner
android:id="@+id/spFontSizeSender"
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/tvFontSizeSender" />
<TextView
android:id="@+id/tvFontSizeSubject"
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: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/spFontSizeSender" />
<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" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swSubjectTop"
android:layout_width="0dp"
@ -379,7 +424,7 @@
android:text="@string/title_advanced_subject_top"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swAuthentication"
app:layout_constraintTop_toBottomOf="@id/spFontSizeSubject"
app:switchPadding="12dp" />
<androidx.appcompat.widget.SwitchCompat

View File

@ -264,6 +264,8 @@
<string name="title_advanced_color_threshold">Threshold letter color</string>
<string name="title_advanced_name_email">Show names and email addresses</string>
<string name="title_advanced_authentication">Show a warning when the receiving server could not authenticate the message</string>
<string name="title_advanced_font_size_sender">Font size sender</string>
<string name="title_advanced_font_size_subject">Font size subject</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>
@ -1130,6 +1132,20 @@
<item>4</item>
</string-array>
<integer-array name="fontSizeValues" translatable="false">
<item>-1</item>
<item>0</item>
<item>1</item>
<item>2</item>
</integer-array>
<string-array name="fontSizeNames">
<item>Default</item>
<item>Small</item>
<item>Medium</item>
<item>Large</item>
</string-array>
<string name="fingerprint" translatable="false">17BA15C1AF55D925F98B99CEA4375D4CDF4C174B</string>
<string name="public_key" translatable="false">MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAtFbxEbzL8u5accPGgBw/XdyiSS5BBE6ZQ9ELpKyJ/OQN+kdYniCAOw3lsQ/GuJScy4Y2HobqbBgLL8GLHG+Yu2EHC9dLjA3v2Mc25vvnfn86BsrpQvz1poN2n+roTBdq09FWbtebJ8m0hDBVmtfRi7RhTKIL4No3kodLhksdnucKjcFheubebWKgpmvbmw7NwuELhaZmyhw8WTtnQ4rZPMhjY1JJZgzwNExXgD7zzg4pJPkuQlfkuRkkvBpHpi3C7VDnYjrBlLHngI4wv3wxQBVwJqlvAT9PmX8dOVnTsWWdJdLQBZVWphuqVY54kjBIovN+o8w03WjsV9QiOQq+XwIDAQAB</string>
</resources>