Added option to show text high contrast

pull/157/head
M66B 5 years ago
parent 9fada9c0e4
commit 11dc9b40af

@ -161,6 +161,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
private int colorPrimary;
private int colorAccent;
private int colorWarning;
private int textColorPrimary;
private int textColorSecondary;
private int colorUnread;
@ -176,6 +177,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
private boolean flags;
private boolean preview;
private boolean attachments_alt;
private boolean contrast;
private boolean monospaced;
private boolean autoimages;
private boolean authentication;
@ -912,6 +914,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
if (textSize != 0)
tvBody.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize);
tvBody.setTextColor(contrast ? textColorPrimary : textColorSecondary);
tvBody.setTypeface(monospaced ? Typeface.MONOSPACE : Typeface.DEFAULT);
tvBody.setVisibility(View.INVISIBLE);
@ -2894,6 +2897,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
this.colorPrimary = Helper.resolveColor(context, R.attr.colorPrimary);
this.colorAccent = Helper.resolveColor(context, R.attr.colorAccent);
this.colorWarning = Helper.resolveColor(context, R.attr.colorWarning);
this.textColorPrimary = Helper.resolveColor(context, android.R.attr.textColorPrimary);
this.textColorSecondary = Helper.resolveColor(context, android.R.attr.textColorSecondary);
this.colorUnread = Helper.resolveColor(context, R.attr.colorUnread);
@ -2911,6 +2915,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
this.flags = prefs.getBoolean("flags", true);
this.preview = prefs.getBoolean("preview", false);
this.attachments_alt = prefs.getBoolean("attachments_alt", false);
this.contrast = prefs.getBoolean("contrast", false);
this.monospaced = prefs.getBoolean("monospaced", false);
this.autoimages = (this.contacts && prefs.getBoolean("autoimages", false));
this.authentication = prefs.getBoolean("authentication", false);

@ -39,7 +39,7 @@ public class FragmentOptions extends FragmentBase {
static String[] OPTIONS_RESTART = new String[]{
"startup", "date", "threading", "avatars", "identicons", "circular", "name_email", "subject_italic", "flags", "preview",
"addresses", "attachments_alt", "monospaced", "autohtml", "autoimages", "actionbar",
"addresses", "attachments_alt", "contrast", "monospaced", "autohtml", "autoimages", "actionbar",
"pull", "autoscroll", "swipenav", "autoexpand", "autoclose", "autonext",
"subscriptions",
"authentication", "debug"

@ -54,6 +54,7 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
private SwitchCompat swPreview;
private SwitchCompat swAddresses;
private SwitchCompat swAttachmentsAlt;
private SwitchCompat swContrast;
private SwitchCompat swMonospaced;
private SwitchCompat swInline;
private SwitchCompat swImages;
@ -62,7 +63,7 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
private final static String[] RESET_OPTIONS = new String[]{
"theme", "startup", "date", "threading", "avatars", "identicons", "circular", "name_email", "subject_italic",
"flags", "preview", "addresses", "attachments_alt", "monospaced", "inline_images", "autoimages", "autocontent", "actionbar",
"flags", "preview", "addresses", "attachments_alt", "contrast", "monospaced", "inline_images", "autoimages", "autocontent", "actionbar",
};
@Override
@ -88,6 +89,7 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
swPreview = view.findViewById(R.id.swPreview);
swAddresses = view.findViewById(R.id.swAddresses);
swAttachmentsAlt = view.findViewById(R.id.swAttachmentsAlt);
swContrast = view.findViewById(R.id.swContrast);
swMonospaced = view.findViewById(R.id.swMonospaced);
swInline = view.findViewById(R.id.swInline);
swImages = view.findViewById(R.id.swImages);
@ -200,6 +202,13 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
}
});
swContrast.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("contrast", checked).apply();
}
});
swMonospaced.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
@ -300,6 +309,7 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
swPreview.setChecked(prefs.getBoolean("preview", false));
swAddresses.setChecked(prefs.getBoolean("addresses", false));
swAttachmentsAlt.setChecked(prefs.getBoolean("attachments_alt", false));
swContrast.setChecked(prefs.getBoolean("contrast", false));
swMonospaced.setChecked(prefs.getBoolean("monospaced", false));
swInline.setChecked(prefs.getBoolean("inline_images", false));
swImages.setChecked(prefs.getBoolean("autoimages", false));

@ -202,6 +202,16 @@
app:layout_constraintTop_toBottomOf="@id/swAddresses"
app:switchPadding="12dp" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swContrast"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:text="@string/title_advanced_contrast"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swAttachmentsAlt"
app:switchPadding="12dp" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swMonospaced"
android:layout_width="match_parent"
@ -209,7 +219,7 @@
android:layout_marginTop="12dp"
android:text="@string/title_advanced_monospaced"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swAttachmentsAlt"
app:layout_constraintTop_toBottomOf="@id/swContrast"
app:switchPadding="12dp" />
<androidx.appcompat.widget.SwitchCompat

@ -207,6 +207,7 @@
<string name="title_advanced_preview">Show message preview</string>
<string name="title_advanced_addresses">Show address details by default</string>
<string name="title_advanced_attachments_alt">Show attachments after the message text</string>
<string name="title_advanced_contrast">Use high contrast for message text</string>
<string name="title_advanced_monospaced">Use monospaced font for message text</string>
<string name="title_advanced_images_inline">Automatically show inline images</string>
<string name="title_advanced_images">Automatically show images for known contacts</string>

Loading…
Cancel
Save