Added option to show authentication indicator

pull/200/head
M66B 3 years ago
parent fe8202595a
commit 29d8c62f91

@ -227,6 +227,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
private int colorSubject;
private int colorEncrypt;
private int colorSeparator;
private int colorWarning;
private int colorError;
private int colorControlNormal;
@ -244,9 +245,9 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
private boolean avatars;
private boolean color_stripe;
private boolean check_authentication;
private boolean check_reply_domain;
private boolean check_mx;
private boolean check_blocklist;
private boolean check_reply_domain;
private MessageHelper.AddressFormat email_format;
private boolean prefer_contact;
@ -274,6 +275,8 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
private boolean inline;
private boolean collapse_quotes;
private boolean authentication;
private boolean authentication_indicator;
private boolean language_detection;
private List<String> languages;
private static boolean debug;
@ -952,9 +955,13 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
!((Boolean.FALSE.equals(message.dkim) && check_authentication) ||
(Boolean.FALSE.equals(message.spf) && check_authentication) ||
(Boolean.FALSE.equals(message.dmarc) && check_authentication) ||
(Boolean.FALSE.equals(message.reply_domain) && check_reply_domain) ||
(Boolean.FALSE.equals(message.mx) && check_mx) ||
(Boolean.TRUE.equals(message.blocklist) && check_blocklist) ||
(Boolean.FALSE.equals(message.reply_domain) && check_reply_domain));
(Boolean.TRUE.equals(message.blocklist) && check_blocklist));
int auths = (check_authentication &&
Boolean.TRUE.equals(message.dkim) ? 1 : 0) +
(Boolean.TRUE.equals(message.spf) ? 1 : 0) +
(Boolean.TRUE.equals(message.dmarc) ? 1 : 0);
boolean expanded = (viewType == ViewType.THREAD && properties.getValue("expanded", message.id));
// Text size
@ -1034,7 +1041,17 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
// Line 1
ibVerified.setVisibility(View.GONE);
ibAuth.setVisibility(authentication && !authenticated ? View.VISIBLE : View.GONE);
if (authentication && !authenticated) {
ibAuth.setImageLevel(0);
ibAuth.setImageTintList(ColorStateList.valueOf(colorWarning));
ibAuth.setVisibility(View.VISIBLE);
} else if (authentication_indicator && auths > 0) {
ibAuth.setImageLevel(auths);
ibAuth.setImageTintList(ColorStateList.valueOf(colorControlNormal));
ibAuth.setVisibility(View.VISIBLE);
} else
ibAuth.setVisibility(View.GONE);
if (EntityMessage.PRIORITIY_HIGH.equals(message.ui_priority)) {
ibPriority.setImageLevel(0);
@ -1542,18 +1559,19 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
}
ibAvatar.setVisibility(main == null || !main.hasPhoto() ? View.GONE : View.VISIBLE);
boolean vmc = (main != null && "vmc".equals(main.getType()));
boolean verified = (main != null && main.isVerified() &&
Boolean.TRUE.equals(message.spf) &&
Boolean.TRUE.equals(message.dkim) &&
Boolean.TRUE.equals(message.spf) &&
Boolean.TRUE.equals(message.dmarc));
ibVerified.setImageLevel(verified ? 1 : 0);
ibVerified.setImageTintList(ColorStateList.valueOf(verified
? colorAccent : colorSeparator));
ibVerified.setContentDescription(context.getString(verified
? R.string.title_advanced_bimi_verified : R.string.title_advanced_bimi_unverified));
ibVerified.setVisibility(
main != null && "vmc".equals(main.getType())
? View.VISIBLE : View.GONE);
ibVerified.setVisibility(vmc ? View.VISIBLE : View.GONE);
if (authentication_indicator && vmc)
ibAuth.setVisibility(View.GONE);
}
if (distinguish_contacts) {
@ -3486,6 +3504,16 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
if (result.size() > 0)
sb.append(context.getString(R.string.title_authentication_failed, TextUtils.join(", ", result)));
else {
sb.append("DKIM: ")
.append(message.dkim == null ? "-" : (message.dkim ? "pass" : "fail"))
.append('\n');
sb.append("SPF: ")
.append(message.spf == null ? "-" : (message.spf ? "pass" : "fail"))
.append('\n');
sb.append("DMARC: ")
.append(message.dmarc == null ? "-" : (message.dmarc ? "pass" : "fail"));
}
if (Boolean.TRUE.equals(message.blocklist)) {
if (sb.length() > 0)
@ -5591,6 +5619,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
this.colorEncrypt = Helper.resolveColor(context, R.attr.colorEncrypt);
this.colorSeparator = Helper.resolveColor(context, R.attr.colorSeparator);
this.colorError = Helper.resolveColor(context, R.attr.colorError);
this.colorWarning = Helper.resolveColor(context, R.attr.colorWarning);
this.colorControlNormal = Helper.resolveColor(context, R.attr.colorControlNormal);
this.hasWebView = Helper.hasWebView(context);
@ -5614,9 +5643,9 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
this.avatars = (contacts && avatars) || (gravatars || favicons || generated);
this.color_stripe = prefs.getBoolean("color_stripe", true);
this.check_authentication = prefs.getBoolean("check_authentication", true);
this.check_reply_domain = prefs.getBoolean("check_reply_domain", true);
this.check_mx = prefs.getBoolean("check_mx", false);
this.check_blocklist = prefs.getBoolean("check_blocklist", false);
this.check_reply_domain = prefs.getBoolean("check_reply_domain", true);
this.email_format = MessageHelper.getAddressFormat(context);
this.prefer_contact = prefs.getBoolean("prefer_contact", false);
@ -5651,6 +5680,8 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
this.inline = prefs.getBoolean("inline_images", false);
this.collapse_quotes = prefs.getBoolean("collapse_quotes", false);
this.authentication = prefs.getBoolean("authentication", true);
this.authentication_indicator = (this.authentication &&
prefs.getBoolean("authentication_indicator", false));
this.language_detection = prefs.getBoolean("language_detection", false);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {

@ -105,14 +105,16 @@ public class FragmentOptions extends FragmentBase {
static String[] OPTIONS_RESTART = new String[]{
"first", "app_support", "notify_archive", "message_swipe", "message_select", "folder_actions", "folder_sync",
"subscriptions", "check_authentication", "check_reply_domain",
"subscriptions",
"check_authentication", "check_reply_domain", "check_mx", "check_blocklist",
"send_pending",
"portrait2", "landscape", "landscape3", "startup",
"cards", "beige", "tabular_card_bg", "shadow_unread",
"indentation", "date", "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",
"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",
"keywords_header", "labels_header", "flags", "flags_background", "preview", "preview_italic", "preview_lines",
"message_zoom", "overview_mode", "addresses", "button_extra", "attachments_alt", "thumbnails",

@ -146,6 +146,7 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
private SwitchCompat swParseClasses;
private SwitchCompat swAuthentication;
private SwitchCompat swAuthenticationIndicator;
private Group grpGravatars;
@ -165,7 +166,8 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
"message_zoom", "overview_mode", "contrast", "monospaced", "monospaced_pre",
"background_color", "text_color", "text_size", "text_font", "text_align", "text_separators",
"collapse_quotes", "image_placeholders", "inline_images", "button_extra", "attachments_alt", "thumbnails",
"parse_classes", "authentication"
"parse_classes",
"authentication", "authentication_indicator"
};
@Override
@ -260,6 +262,7 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
swThumbnails = view.findViewById(R.id.swThumbnails);
swParseClasses = view.findViewById(R.id.swParseClasses);
swAuthentication = view.findViewById(R.id.swAuthentication);
swAuthenticationIndicator = view.findViewById(R.id.swAuthenticationIndicator);
grpGravatars = view.findViewById(R.id.grpGravatars);
@ -931,6 +934,14 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("authentication", checked).apply();
swAuthenticationIndicator.setEnabled(checked);
}
});
swAuthenticationIndicator.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("authentication_indicator", checked).apply();
}
});
@ -1118,6 +1129,8 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
swParseClasses.setChecked(prefs.getBoolean("parse_classes", true));
swAuthentication.setChecked(prefs.getBoolean("authentication", true));
swAuthenticationIndicator.setChecked(prefs.getBoolean("authentication_indicator", false));
swAuthenticationIndicator.setEnabled(swAuthentication.isChecked());
updateColor();
}

@ -95,7 +95,8 @@ public class FragmentOptionsSynchronize extends FragmentBase implements SharedPr
"enabled", "poll_interval", "auto_optimize", "schedule", "schedule_start", "schedule_end",
"sync_nodate", "sync_unseen", "sync_flagged", "delete_unseen", "sync_kept", "gmail_thread_id",
"sync_folders", "sync_shared_folders", "subscriptions",
"check_authentication", "check_reply_domain", "check_mx", "check_blocklist", "use_blocklist", "tune_keep_alive"
"check_authentication", "check_reply_domain", "check_mx", "check_blocklist", "use_blocklist",
"tune_keep_alive"
};
@Override

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<level-list xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:drawable="@drawable/twotone_flag_24"
android:maxLevel="0" />
<item
android:drawable="@drawable/twotone_shield_warning_24"
android:maxLevel="1" />
<item
android:drawable="@drawable/twotone_shield_warning_24"
android:maxLevel="2" />
<item
android:drawable="@drawable/twotone_shield_24"
android:maxLevel="3" />
</level-list>

@ -0,0 +1,15 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="@android:color/white"
android:pathData="M6,6.39v4.7c0,4 2.55,7.7 6,8.83c3.45,-1.13 6,-4.82 6,-8.83v-4.7l-6,-2.25L6,6.39z"
android:strokeAlpha="0.3"
android:fillAlpha="0.3"/>
<path
android:fillColor="@android:color/white"
android:pathData="M12,2L4,5v6.09c0,5.05 3.41,9.76 8,10.91c4.59,-1.15 8,-5.86 8,-10.91V5L12,2zM18,11.09c0,4 -2.55,7.7 -6,8.83c-3.45,-1.13 -6,-4.82 -6,-8.83v-4.7l6,-2.25l6,2.25V11.09z"/>
</vector>

@ -0,0 +1,27 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:tint="?attr/colorControlNormal"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillAlpha="0.3"
android:fillColor="@android:color/white"
android:pathData="M6,6.39v4.7c0,4 2.55,7.7 6,8.83c3.45,-1.13 6,-4.82 6,-8.83v-4.7l-6,-2.25L6,6.39z"
android:strokeAlpha="0.3" />
<path
android:fillColor="@android:color/white"
android:pathData="M12,2L4,5v6.09c0,5.05 3.41,9.76 8,10.91c4.59,-1.15 8,-5.86 8,-10.91V5L12,2zM18,11.09c0,4 -2.55,7.7 -6,8.83c-3.45,-1.13 -6,-4.82 -6,-8.83v-4.7l6,-2.25l6,2.25V11.09z" />
<group
android:pivotX="12"
android:pivotY="12"
android:scaleX="0.5"
android:scaleY="0.5">
<path
android:fillColor="@android:color/white"
android:pathData="M12,19m-2,0a2,2 0,1 1,4 0a2,2 0,1 1,-4 0" />
<path
android:fillColor="@android:color/white"
android:pathData="M10,3h4v12h-4z" />
</group>
</vector>

@ -1414,29 +1414,35 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swParseClasses" />
<ImageView
android:id="@+id/ivAuth"
android:layout_width="21dp"
android:layout_height="21dp"
android:contentDescription="@string/title_legend_auth"
app:layout_constraintBottom_toBottomOf="@+id/swAuthentication"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@+id/swAuthentication"
app:srcCompat="@drawable/twotone_flag_24"
app:tint="?attr/colorWarning" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swAuthentication"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="6dp"
android:layout_marginTop="12dp"
android:checked="true"
android:drawableStart="@drawable/twotone_flag_24"
android:drawablePadding="6dp"
android:drawableTint="?attr/colorWarning"
android:text="@string/title_advanced_authentication"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/ivAuth"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvParseClassesHint"
app:switchPadding="12dp" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swAuthenticationIndicator"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="12dp"
android:layout_marginTop="12dp"
android:checked="true"
android:drawableStart="@drawable/twotone_shield_warning_24"
android:drawablePadding="6dp"
android:text="@string/title_advanced_authentication_indicator"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swAuthentication"
app:switchPadding="12dp" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.cardview.widget.CardView>
</androidx.constraintlayout.widget.ConstraintLayout>

@ -79,7 +79,7 @@
app:layout_constraintBottom_toBottomOf="@+id/tvFrom"
app:layout_constraintStart_toEndOf="@id/ibVerified"
app:layout_constraintTop_toTopOf="@+id/tvFrom"
app:srcCompat="@drawable/twotone_flag_24"
app:srcCompat="@drawable/authenticated"
app:tint="?attr/colorWarning" />
<ImageButton

@ -78,7 +78,7 @@
app:layout_constraintBottom_toBottomOf="@+id/tvFrom"
app:layout_constraintStart_toEndOf="@id/ibVerified"
app:layout_constraintTop_toTopOf="@+id/tvFrom"
app:srcCompat="@drawable/twotone_flag_24"
app:srcCompat="@drawable/authenticated"
app:tint="?attr/colorWarning" />
<ImageButton

@ -449,6 +449,7 @@
<string name="title_advanced_navbar_colorize">Colorize the Android navigation bar</string>
<string name="title_advanced_parse_classes">Parse style sheets</string>
<string name="title_advanced_authentication">Show a warning when the receiving server could not authenticate the message</string>
<string name="title_advanced_authentication_indicator">Show authentication status indicator</string>
<string name="title_advanced_sync_on_launch">Synchronize on start</string>
<string name="title_advanced_double_back">Double \'back\' to exit</string>

Loading…
Cancel
Save