Enabled BIMI, Gravatars, Libravatars and favicons for Play store

pull/207/head
M66B 3 years ago
parent 7f42d01be0
commit df0668577c

@ -1,45 +0,0 @@
package eu.faircode.email;
/*
This file is part of FairEmail.
FairEmail is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
FairEmail is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with FairEmail. If not, see <http://www.gnu.org/licenses/>.
Copyright 2018-2022 by Marcel Bokhorst (M66B)
*/
import android.content.Context;
import android.os.OperationCanceledException;
import java.util.concurrent.Callable;
public class Extra {
static Callable<ContactInfo.Favicon> getG(String email, int scaleToPixels, Context context) {
return new Callable<ContactInfo.Favicon>() {
@Override
public ContactInfo.Favicon call() throws Exception {
throw new OperationCanceledException();
}
};
}
static Callable<ContactInfo.Favicon> getL(String email, int scaleToPixels, Context context) {
return new Callable<ContactInfo.Favicon>() {
@Override
public ContactInfo.Favicon call() throws Exception {
throw new OperationCanceledException();
}
};
}
}

@ -1,117 +0,0 @@
package eu.faircode.email;
/*
This file is part of FairEmail.
FairEmail is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
FairEmail is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with FairEmail. If not, see <http://www.gnu.org/licenses/>.
Copyright 2018-2021 by Marcel Bokhorst (M66B)
*/
import android.content.Context;
import android.graphics.Bitmap;
import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.concurrent.Callable;
public class Extra {
private static final String GRAVATAR_URI = "https://www.gravatar.com/avatar/";
private static final int GRAVATAR_CONNECT_TIMEOUT = 5 * 1000; // milliseconds
private static final int GRAVATAR_READ_TIMEOUT = 10 * 1000; // milliseconds
private static final int LIBRAVATAR_CONNECT_TIMEOUT = 5 * 1000; // milliseconds
private static final int LIBRAVATAR_READ_TIMEOUT = 10 * 1000; // milliseconds
private static final String LIBRAVATAR_DNS = "_avatars-sec._tcp,_avatars._tcp";
private static final String LIBRAVATAR_URI = "https://seccdn.libravatar.org/avatar/";
static Callable<ContactInfo.Favicon> getG(String email, int scaleToPixels, Context context) {
return new Callable<ContactInfo.Favicon>() {
@Override
public ContactInfo.Favicon call() throws Exception {
String hash = Helper.md5(email.getBytes());
URL url = new URL(GRAVATAR_URI + hash + "?d=404");
Log.i("Gravatar key=" + email + " url=" + url);
HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();
urlConnection.setRequestMethod("GET");
urlConnection.setReadTimeout(GRAVATAR_READ_TIMEOUT);
urlConnection.setConnectTimeout(GRAVATAR_CONNECT_TIMEOUT);
urlConnection.setRequestProperty("User-Agent", WebViewEx.getUserAgent(context));
urlConnection.connect();
try {
int status = urlConnection.getResponseCode();
if (status == HttpURLConnection.HTTP_OK) {
// Positive reply
Bitmap bitmap = ImageHelper.getScaledBitmap(urlConnection.getInputStream(), url.toString(), null, scaleToPixels);
return (bitmap == null ? null : new ContactInfo.Favicon(bitmap, "extra", false));
} else if (status == HttpURLConnection.HTTP_NOT_FOUND) {
// Negative reply
return null;
} else
throw new IOException("Error " + status + ": " + urlConnection.getResponseMessage());
} finally {
urlConnection.disconnect();
}
}
};
}
static Callable<ContactInfo.Favicon> getL(String email, int scaleToPixels, Context context) {
return new Callable<ContactInfo.Favicon>() {
@Override
public ContactInfo.Favicon call() throws Exception {
String domain = UriHelper.getEmailDomain(email);
// https://wiki.libravatar.org/api/
String baseUrl = LIBRAVATAR_URI;
for (String dns : LIBRAVATAR_DNS.split(",")) {
DnsHelper.DnsRecord[] records = DnsHelper.lookup(context, dns + "." + domain, "srv");
if (records.length > 0) {
baseUrl = (records[0].port == 443 ? "https" : "http") + "://" + records[0].name + "/avatar/";
break;
}
}
String hash = Helper.md5(email.getBytes());
URL url = new URL(baseUrl + hash + "?d=404");
Log.i("Libravatar key=" + email + " url=" + url);
HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();
urlConnection.setRequestMethod("GET");
urlConnection.setReadTimeout(LIBRAVATAR_READ_TIMEOUT);
urlConnection.setConnectTimeout(LIBRAVATAR_CONNECT_TIMEOUT);
urlConnection.setRequestProperty("User-Agent", WebViewEx.getUserAgent(context));
urlConnection.connect();
try {
int status = urlConnection.getResponseCode();
if (status == HttpURLConnection.HTTP_OK) {
// Positive reply
Bitmap bitmap = ImageHelper.getScaledBitmap(urlConnection.getInputStream(), url.toString(), null, scaleToPixels);
return (bitmap == null ? null : new ContactInfo.Favicon(bitmap, "extra", false));
} else if (status == HttpURLConnection.HTTP_NOT_FOUND) {
// Negative reply
return null;
} else
throw new IOException("Error " + status + ": " + urlConnection.getResponseMessage());
} finally {
urlConnection.disconnect();
}
}
};
}
}

@ -6880,9 +6880,10 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
boolean contacts = Helper.hasPermission(context, Manifest.permission.READ_CONTACTS); boolean contacts = Helper.hasPermission(context, Manifest.permission.READ_CONTACTS);
boolean avatars = prefs.getBoolean("avatars", true); boolean avatars = prefs.getBoolean("avatars", true);
boolean bimi = (prefs.getBoolean("bimi", false) && !BuildConfig.PLAY_STORE_RELEASE); boolean bimi = prefs.getBoolean("bimi", false);
boolean efavicons = (prefs.getBoolean("efavicons", false) && !BuildConfig.PLAY_STORE_RELEASE); boolean gravatars = prefs.getBoolean("gravatars", false);
boolean favicons = (prefs.getBoolean("favicons", false) && !BuildConfig.PLAY_STORE_RELEASE); boolean libravatars = prefs.getBoolean("libravatars", false);
boolean favicons = prefs.getBoolean("favicons", false);
boolean generated = prefs.getBoolean("generated_icons", true); boolean generated = prefs.getBoolean("generated_icons", true);
this.date = prefs.getBoolean("date", true); this.date = prefs.getBoolean("date", true);
@ -6893,7 +6894,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
this.threading_unread = threading && prefs.getBoolean("threading_unread", false); this.threading_unread = threading && prefs.getBoolean("threading_unread", false);
this.indentation = prefs.getBoolean("indentation", false); this.indentation = prefs.getBoolean("indentation", false);
this.avatars = (contacts && avatars) || (bimi || efavicons || favicons || generated); this.avatars = (contacts && avatars) || (bimi || gravatars || libravatars || favicons || generated);
this.color_stripe = prefs.getBoolean("color_stripe", true); this.color_stripe = prefs.getBoolean("color_stripe", true);
this.check_authentication = prefs.getBoolean("check_authentication", true); this.check_authentication = prefs.getBoolean("check_authentication", true);
this.check_tls = prefs.getBoolean("check_tls", true); this.check_tls = prefs.getBoolean("check_tls", true);

@ -119,6 +119,14 @@ public class ContactInfo {
private static final long CACHE_FAVICON_DURATION = 2 * 7 * 24 * 60 * 60 * 1000L; // milliseconds private static final long CACHE_FAVICON_DURATION = 2 * 7 * 24 * 60 * 60 * 1000L; // milliseconds
private static final float MIN_FAVICON_LUMINANCE = 0.2f; private static final float MIN_FAVICON_LUMINANCE = 0.2f;
private static final String GRAVATAR_URI = "https://www.gravatar.com/avatar/";
private static final int GRAVATAR_CONNECT_TIMEOUT = 5 * 1000; // milliseconds
private static final int GRAVATAR_READ_TIMEOUT = 10 * 1000; // milliseconds
private static final int LIBRAVATAR_CONNECT_TIMEOUT = 5 * 1000; // milliseconds
private static final int LIBRAVATAR_READ_TIMEOUT = 10 * 1000; // milliseconds
private static final String LIBRAVATAR_DNS = "_avatars-sec._tcp,_avatars._tcp";
private static final String LIBRAVATAR_URI = "https://seccdn.libravatar.org/avatar/";
// https://css-tricks.com/prefetching-preloading-prebrowsing/ // https://css-tricks.com/prefetching-preloading-prebrowsing/
// https://developer.mozilla.org/en-US/docs/Web/Performance/dns-prefetch // https://developer.mozilla.org/en-US/docs/Web/Performance/dns-prefetch
private static final List<String> REL_EXCLUDE = Collections.unmodifiableList(Arrays.asList( private static final List<String> REL_EXCLUDE = Collections.unmodifiableList(Arrays.asList(
@ -133,6 +141,10 @@ public class ContactInfo {
return type; return type;
} }
boolean isEmailBased() {
return ("gravatar".equals(type) || "libravatar".equals(type));
}
boolean isVerified() { boolean isVerified() {
return (bitmap != null && verified); return (bitmap != null && verified);
} }
@ -254,9 +266,10 @@ public class ContactInfo {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
boolean avatars = prefs.getBoolean("avatars", true); boolean avatars = prefs.getBoolean("avatars", true);
boolean bimi = (prefs.getBoolean("bimi", false) && !BuildConfig.PLAY_STORE_RELEASE); boolean bimi = prefs.getBoolean("bimi", false);
boolean efavicons = (prefs.getBoolean("efavicons", false) && !BuildConfig.PLAY_STORE_RELEASE); boolean gravatars = prefs.getBoolean("gravatars", false);
boolean favicons = (prefs.getBoolean("favicons", false) && !BuildConfig.PLAY_STORE_RELEASE); boolean libravatars = prefs.getBoolean("libravatars", false);
boolean favicons = prefs.getBoolean("favicons", false);
boolean generated = prefs.getBoolean("generated_icons", true); boolean generated = prefs.getBoolean("generated_icons", true);
boolean identicons = prefs.getBoolean("identicons", false); boolean identicons = prefs.getBoolean("identicons", false);
boolean circular = prefs.getBoolean("circular", true); boolean circular = prefs.getBoolean("circular", true);
@ -305,7 +318,7 @@ public class ContactInfo {
// Favicon // Favicon
if (info.bitmap == null && if (info.bitmap == null &&
!EntityFolder.JUNK.equals(folderType) && (bimi || efavicons || favicons)) { !EntityFolder.JUNK.equals(folderType) && (bimi || gravatars || libravatars || favicons)) {
String d = UriHelper.getEmailDomain(info.email); String d = UriHelper.getEmailDomain(info.email);
if (d != null) { if (d != null) {
// Prevent using Doodles // Prevent using Doodles
@ -331,8 +344,13 @@ public class ContactInfo {
try { try {
// check cache // check cache
File[] files = null; File[] files = null;
if (efavicons) { if (gravatars) {
File f = new File(dir, email + ".extra"); File f = new File(dir, email + ".gravatar");
if (f.exists())
files = new File[]{f};
}
if (files == null && libravatars) {
File f = new File(dir, email + ".libravatar");
if (f.exists()) if (f.exists())
files = new File[]{f}; files = new File[]{f};
} }
@ -371,10 +389,10 @@ public class ContactInfo {
} }
})); }));
if (efavicons) { if (gravatars)
futures.add(executorFavicon.submit(Extra.getG(email, scaleToPixels, context))); futures.add(executorFavicon.submit(getGravatar(email, scaleToPixels, context)));
futures.add(executorFavicon.submit(Extra.getL(email, scaleToPixels, context))); if (libravatars)
} futures.add(executorFavicon.submit(getLibravatar(email, scaleToPixels, context)));
if (favicons) { if (favicons) {
String host = domain; String host = domain;
@ -464,7 +482,7 @@ public class ContactInfo {
// Add to cache // Add to cache
File output = new File(dir, File output = new File(dir,
("extra".equals(info.type) ? email : domain) + (info.isEmailBased() ? email : domain) +
"." + info.type + "." + info.type +
(info.verified ? "_verified" : "")); (info.verified ? "_verified" : ""));
try (OutputStream os = new BufferedOutputStream(new FileOutputStream(output))) { try (OutputStream os = new BufferedOutputStream(new FileOutputStream(output))) {
@ -860,6 +878,85 @@ public class ContactInfo {
} }
} }
static Callable<ContactInfo.Favicon> getGravatar(String email, int scaleToPixels, Context context) {
return new Callable<ContactInfo.Favicon>() {
@Override
public ContactInfo.Favicon call() throws Exception {
String hash = Helper.md5(email.getBytes());
URL url = new URL(GRAVATAR_URI + hash + "?d=404");
Log.i("Gravatar key=" + email + " url=" + url);
HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();
urlConnection.setRequestMethod("GET");
urlConnection.setReadTimeout(GRAVATAR_READ_TIMEOUT);
urlConnection.setConnectTimeout(GRAVATAR_CONNECT_TIMEOUT);
urlConnection.setRequestProperty("User-Agent", WebViewEx.getUserAgent(context));
urlConnection.connect();
try {
int status = urlConnection.getResponseCode();
if (status == HttpURLConnection.HTTP_OK) {
// Positive reply
Bitmap bitmap = ImageHelper.getScaledBitmap(urlConnection.getInputStream(), url.toString(), null, scaleToPixels);
return (bitmap == null ? null : new ContactInfo.Favicon(bitmap, "gravatar", false));
} else if (status == HttpURLConnection.HTTP_NOT_FOUND) {
// Negative reply
return null;
} else
throw new IOException("Error " + status + ": " + urlConnection.getResponseMessage());
} finally {
urlConnection.disconnect();
}
}
};
}
static Callable<ContactInfo.Favicon> getLibravatar(String email, int scaleToPixels, Context context) {
return new Callable<ContactInfo.Favicon>() {
@Override
public ContactInfo.Favicon call() throws Exception {
String domain = UriHelper.getEmailDomain(email);
// https://wiki.libravatar.org/api/
String baseUrl = LIBRAVATAR_URI;
for (String dns : LIBRAVATAR_DNS.split(",")) {
DnsHelper.DnsRecord[] records = DnsHelper.lookup(context, dns + "." + domain, "srv");
if (records.length > 0) {
baseUrl = (records[0].port == 443 ? "https" : "http") + "://" + records[0].name + "/avatar/";
break;
}
}
String hash = Helper.md5(email.getBytes());
URL url = new URL(baseUrl + hash + "?d=404");
Log.i("Libravatar key=" + email + " url=" + url);
HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();
urlConnection.setRequestMethod("GET");
urlConnection.setReadTimeout(LIBRAVATAR_READ_TIMEOUT);
urlConnection.setConnectTimeout(LIBRAVATAR_CONNECT_TIMEOUT);
urlConnection.setRequestProperty("User-Agent", WebViewEx.getUserAgent(context));
urlConnection.connect();
try {
int status = urlConnection.getResponseCode();
if (status == HttpURLConnection.HTTP_OK) {
// Positive reply
Bitmap bitmap = ImageHelper.getScaledBitmap(urlConnection.getInputStream(), url.toString(), null, scaleToPixels);
return (bitmap == null ? null : new ContactInfo.Favicon(bitmap, "libravatar", false));
} else if (status == HttpURLConnection.HTTP_NOT_FOUND) {
// Negative reply
return null;
} else
throw new IOException("Error " + status + ": " + urlConnection.getResponseMessage());
} finally {
urlConnection.disconnect();
}
}
};
}
private static boolean isRecoverable(Throwable ex, Context context) { private static boolean isRecoverable(Throwable ex, Context context) {
if (ex instanceof SocketTimeoutException) { if (ex instanceof SocketTimeoutException) {
ConnectivityManager cm = Helper.getSystemService(context, ConnectivityManager.class); ConnectivityManager cm = Helper.getSystemService(context, ConnectivityManager.class);

@ -108,7 +108,10 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
private TextView tvBimiHint; private TextView tvBimiHint;
private TextView tvBimiUnverified; private TextView tvBimiUnverified;
private SwitchCompat swBimi; private SwitchCompat swBimi;
private SwitchCompat swEFavicons; private SwitchCompat swGravatars;
private TextView tvGravatarPrivacy;
private SwitchCompat swLibravatars;
private TextView tvLibravatarPrivacy;
private SwitchCompat swFavicons; private SwitchCompat swFavicons;
private SwitchCompat swFaviconsPartial; private SwitchCompat swFaviconsPartial;
private TextView tvFaviconsHint; private TextView tvFaviconsHint;
@ -177,7 +180,6 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
private SwitchCompat swAuthentication; private SwitchCompat swAuthentication;
private SwitchCompat swAuthenticationIndicator; private SwitchCompat swAuthenticationIndicator;
private Group grpPlay;
private Group grpUnzip; private Group grpUnzip;
private NumberFormat NF = NumberFormat.getNumberInstance(); private NumberFormat NF = NumberFormat.getNumberInstance();
@ -190,7 +192,7 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
"nav_options", "nav_categories", "nav_count", "nav_unseen_drafts", "nav_count_pinned", "navbar_colorize", "nav_options", "nav_categories", "nav_count", "nav_unseen_drafts", "nav_count_pinned", "navbar_colorize",
"threading", "threading_unread", "indentation", "seekbar", "actionbar", "actionbar_color", "threading", "threading_unread", "indentation", "seekbar", "actionbar", "actionbar_color",
"highlight_unread", "highlight_color", "color_stripe", "color_stripe_wide", "highlight_unread", "highlight_color", "color_stripe", "color_stripe_wide",
"avatars", "bimi", "efavicons", "favicons", "favicons_partial", "generated_icons", "identicons", "avatars", "bimi", "gravatars", "libravatars", "favicons", "favicons_partial", "generated_icons", "identicons",
"circular", "saturation", "brightness", "threshold", "circular", "saturation", "brightness", "threshold",
"email_format", "prefer_contact", "only_contact", "distinguish_contacts", "show_recipients", "email_format", "prefer_contact", "only_contact", "distinguish_contacts", "show_recipients",
"font_size_sender", "sender_ellipsize", "font_size_sender", "sender_ellipsize",
@ -262,7 +264,10 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
tvBimiHint = view.findViewById(R.id.tvBimiHint); tvBimiHint = view.findViewById(R.id.tvBimiHint);
tvBimiUnverified = view.findViewById(R.id.tvBimiUnverified); tvBimiUnverified = view.findViewById(R.id.tvBimiUnverified);
ibBimi = view.findViewById(R.id.ibBimi); ibBimi = view.findViewById(R.id.ibBimi);
swEFavicons = view.findViewById(R.id.swEFavicons); swGravatars = view.findViewById(R.id.swGravatars);
tvGravatarPrivacy = view.findViewById(R.id.tvGravatarPrivacy);
swLibravatars = view.findViewById(R.id.swLibravatars);
tvLibravatarPrivacy = view.findViewById(R.id.tvLibravatarPrivacy);
swFavicons = view.findViewById(R.id.swFavicons); swFavicons = view.findViewById(R.id.swFavicons);
swFaviconsPartial = view.findViewById(R.id.swFaviconsPartial); swFaviconsPartial = view.findViewById(R.id.swFaviconsPartial);
tvFaviconsHint = view.findViewById(R.id.tvFaviconsHint); tvFaviconsHint = view.findViewById(R.id.tvFaviconsHint);
@ -329,7 +334,6 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
swAuthentication = view.findViewById(R.id.swAuthentication); swAuthentication = view.findViewById(R.id.swAuthentication);
swAuthenticationIndicator = view.findViewById(R.id.swAuthenticationIndicator); swAuthenticationIndicator = view.findViewById(R.id.swAuthenticationIndicator);
grpPlay = view.findViewById(R.id.grpPlay);
grpUnzip = view.findViewById(R.id.grpUnzip); grpUnzip = view.findViewById(R.id.grpUnzip);
List<StyleHelper.FontDescriptor> fonts = StyleHelper.getFonts(getContext()); List<StyleHelper.FontDescriptor> fonts = StyleHelper.getFonts(getContext());
@ -728,14 +732,38 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
} }
}); });
swEFavicons.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { swGravatars.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override @Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("efavicons", checked).apply(); prefs.edit().putBoolean("gravatars", checked).apply();
ContactInfo.clearCache(compoundButton.getContext()); ContactInfo.clearCache(compoundButton.getContext());
} }
}); });
tvGravatarPrivacy.getPaint().setUnderlineText(true);
tvGravatarPrivacy.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Helper.view(v.getContext(), Uri.parse(Helper.GRAVATAR_PRIVACY_URI), true);
}
});
swLibravatars.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("libravatars", checked).apply();
ContactInfo.clearCache(compoundButton.getContext());
}
});
tvLibravatarPrivacy.getPaint().setUnderlineText(true);
tvLibravatarPrivacy.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Helper.view(v.getContext(), Uri.parse(Helper.LIBRAVATAR_PRIVACY_URI), true);
}
});
swFavicons.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { swFavicons.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override @Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
@ -1227,7 +1255,6 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
// Initialize // Initialize
FragmentDialogTheme.setBackground(getContext(), view, false); FragmentDialogTheme.setBackground(getContext(), view, false);
grpPlay.setVisibility(BuildConfig.PLAY_STORE_RELEASE || BuildConfig.DEBUG ? View.VISIBLE : View.GONE);
swFaviconsPartial.setText(getString(R.string.title_advanced_favicons_partial, swFaviconsPartial.setText(getString(R.string.title_advanced_favicons_partial,
Helper.humanReadableByteCount(ContactInfo.FAVICON_READ_BYTES, false))); Helper.humanReadableByteCount(ContactInfo.FAVICON_READ_BYTES, false)));
grpUnzip.setVisibility(Build.VERSION.SDK_INT < Build.VERSION_CODES.O ? View.GONE : View.VISIBLE); grpUnzip.setVisibility(Build.VERSION.SDK_INT < Build.VERSION_CODES.O ? View.GONE : View.VISIBLE);
@ -1338,12 +1365,10 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
swColorStripeWide.setChecked(prefs.getBoolean("color_stripe_wide", false)); swColorStripeWide.setChecked(prefs.getBoolean("color_stripe_wide", false));
//swColorStripeWide.setEnabled(swColorStripe.isChecked()); //swColorStripeWide.setEnabled(swColorStripe.isChecked());
swAvatars.setChecked(prefs.getBoolean("avatars", true)); swAvatars.setChecked(prefs.getBoolean("avatars", true));
swBimi.setChecked(prefs.getBoolean("bimi", false) && !BuildConfig.PLAY_STORE_RELEASE); swBimi.setChecked(prefs.getBoolean("bimi", false));
swBimi.setEnabled(!BuildConfig.PLAY_STORE_RELEASE); swGravatars.setChecked(prefs.getBoolean("gravatars", false));
swEFavicons.setChecked(prefs.getBoolean("efavicons", false) && !BuildConfig.PLAY_STORE_RELEASE); swLibravatars.setChecked(prefs.getBoolean("libravatars", false));
swEFavicons.setEnabled(!BuildConfig.PLAY_STORE_RELEASE); swFavicons.setChecked(prefs.getBoolean("favicons", false));
swFavicons.setChecked(prefs.getBoolean("favicons", false) && !BuildConfig.PLAY_STORE_RELEASE);
swFavicons.setEnabled(!BuildConfig.PLAY_STORE_RELEASE);
swFaviconsPartial.setChecked(prefs.getBoolean("favicons_partial", true)); swFaviconsPartial.setChecked(prefs.getBoolean("favicons_partial", true));
swFaviconsPartial.setEnabled(swFavicons.isChecked()); swFaviconsPartial.setEnabled(swFavicons.isChecked());
swGeneratedIcons.setChecked(prefs.getBoolean("generated_icons", true)); swGeneratedIcons.setChecked(prefs.getBoolean("generated_icons", true));

@ -184,6 +184,8 @@ public class Helper {
static final String SUPPORT_URI = "https://contact.faircode.eu/"; static final String SUPPORT_URI = "https://contact.faircode.eu/";
static final String TEST_URI = "https://play.google.com/apps/testing/" + BuildConfig.APPLICATION_ID; static final String TEST_URI = "https://play.google.com/apps/testing/" + BuildConfig.APPLICATION_ID;
static final String BIMI_PRIVACY_URI = "https://datatracker.ietf.org/doc/html/draft-brotman-ietf-bimi-guidance-03#section-7.4"; static final String BIMI_PRIVACY_URI = "https://datatracker.ietf.org/doc/html/draft-brotman-ietf-bimi-guidance-03#section-7.4";
static final String GRAVATAR_PRIVACY_URI = "https://automattic.com/privacy/";
static final String LIBRAVATAR_PRIVACY_URI = "https://www.libravatar.org/privacy/";
static final String ID_COMMAND_URI = "https://datatracker.ietf.org/doc/html/rfc2971#section-3.1"; static final String ID_COMMAND_URI = "https://datatracker.ietf.org/doc/html/rfc2971#section-3.1";
static final String AUTH_RESULTS_URI = "https://datatracker.ietf.org/doc/html/rfc7601"; static final String AUTH_RESULTS_URI = "https://datatracker.ietf.org/doc/html/rfc7601";
static final String FAVICON_PRIVACY_URI = "https://en.wikipedia.org/wiki/Favicon"; static final String FAVICON_PRIVACY_URI = "https://en.wikipedia.org/wiki/Favicon";

@ -808,23 +808,6 @@
app:layout_constraintTop_toBottomOf="@id/vSeparatorAvatar" app:layout_constraintTop_toBottomOf="@id/vSeparatorAvatar"
app:switchPadding="12dp" /> app:switchPadding="12dp" />
<View
android:id="@+id/vwFavicon"
android:layout_width="6dp"
android:layout_height="0dp"
android:background="?attr/colorSeparator"
app:layout_constraintBottom_toBottomOf="@+id/tvFaviconsPlay"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@+id/swBimi" />
<View
android:id="@+id/vwFaviconPadding"
android:layout_width="6dp"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="@+id/tvFaviconsPlay"
app:layout_constraintStart_toEndOf="@+id/vwFavicon"
app:layout_constraintTop_toTopOf="@+id/swBimi" />
<androidx.appcompat.widget.SwitchCompat <androidx.appcompat.widget.SwitchCompat
android:id="@+id/swBimi" android:id="@+id/swBimi"
android:layout_width="0dp" android:layout_width="0dp"
@ -832,7 +815,7 @@
android:layout_marginTop="12dp" android:layout_marginTop="12dp"
android:text="@string/title_advanced_bimi" android:text="@string/title_advanced_bimi"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/vwFaviconPadding" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swAvatars" app:layout_constraintTop_toBottomOf="@id/swAvatars"
app:switchPadding="12dp" /> app:switchPadding="12dp" />
@ -840,6 +823,7 @@
android:id="@+id/tvBimiHint" android:id="@+id/tvBimiHint"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="12dp"
android:layout_marginTop="6dp" android:layout_marginTop="6dp"
android:drawableEnd="@drawable/twotone_open_in_new_12" android:drawableEnd="@drawable/twotone_open_in_new_12"
android:drawablePadding="6dp" android:drawablePadding="6dp"
@ -847,13 +831,14 @@
android:text="@string/title_advanced_privacy_risk" android:text="@string/title_advanced_privacy_risk"
android:textAppearance="@style/TextAppearance.AppCompat.Small" android:textAppearance="@style/TextAppearance.AppCompat.Small"
android:textColor="?attr/colorWarning" android:textColor="?attr/colorWarning"
app:layout_constraintStart_toEndOf="@id/vwFaviconPadding" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swBimi" /> app:layout_constraintTop_toBottomOf="@id/swBimi" />
<eu.faircode.email.FixedTextView <eu.faircode.email.FixedTextView
android:id="@+id/tvBimiUnverified" android:id="@+id/tvBimiUnverified"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="12dp"
android:layout_marginTop="6dp" android:layout_marginTop="6dp"
android:drawableStart="@drawable/twotone_check_24" android:drawableStart="@drawable/twotone_check_24"
android:drawablePadding="6dp" android:drawablePadding="6dp"
@ -861,13 +846,14 @@
android:text="@string/title_advanced_bimi_unverified" android:text="@string/title_advanced_bimi_unverified"
android:textAppearance="@style/TextAppearance.AppCompat.Small" android:textAppearance="@style/TextAppearance.AppCompat.Small"
android:textStyle="italic" android:textStyle="italic"
app:layout_constraintStart_toEndOf="@id/vwFaviconPadding" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvBimiHint" /> app:layout_constraintTop_toBottomOf="@id/tvBimiHint" />
<eu.faircode.email.FixedTextView <eu.faircode.email.FixedTextView
android:id="@+id/tvBimiVerified" android:id="@+id/tvBimiVerified"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="12dp"
android:layout_marginTop="6dp" android:layout_marginTop="6dp"
android:drawableStart="@drawable/twotone_done_all_24" android:drawableStart="@drawable/twotone_done_all_24"
android:drawablePadding="6dp" android:drawablePadding="6dp"
@ -875,31 +861,99 @@
android:text="@string/title_advanced_bimi_verified" android:text="@string/title_advanced_bimi_verified"
android:textAppearance="@style/TextAppearance.AppCompat.Small" android:textAppearance="@style/TextAppearance.AppCompat.Small"
android:textStyle="italic" android:textStyle="italic"
app:layout_constraintStart_toEndOf="@id/vwFaviconPadding" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvBimiUnverified" /> app:layout_constraintTop_toBottomOf="@id/tvBimiUnverified" />
<eu.faircode.email.FixedImageButton <eu.faircode.email.FixedImageButton
android:id="@+id/ibBimi" android:id="@+id/ibBimi"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="12dp"
android:layout_marginTop="6dp" android:layout_marginTop="6dp"
android:contentDescription="@string/title_info" android:contentDescription="@string/title_info"
android:tooltipText="@string/title_info" android:tooltipText="@string/title_info"
app:layout_constraintStart_toEndOf="@id/vwFaviconPadding" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/tvBimiVerified" app:layout_constraintTop_toBottomOf="@+id/tvBimiVerified"
app:srcCompat="@drawable/twotone_info_24" /> app:srcCompat="@drawable/twotone_info_24" />
<androidx.appcompat.widget.SwitchCompat <androidx.appcompat.widget.SwitchCompat
android:id="@+id/swEFavicons" android:id="@+id/swGravatars"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="12dp" android:layout_marginTop="12dp"
android:text="@string/title_advanced_efavicons" android:text="@string/title_advanced_gravatars"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/vwFaviconPadding" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/ibBimi" app:layout_constraintTop_toBottomOf="@id/ibBimi"
app:switchPadding="12dp" /> app:switchPadding="12dp" />
<eu.faircode.email.FixedTextView
android:id="@+id/tvGravatarsHint"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="12dp"
android:layout_marginTop="6dp"
android:drawableTint="?attr/colorWarning"
android:text="@string/title_advanced_privacy_risk"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
android:textColor="?attr/colorWarning"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swGravatars" />
<eu.faircode.email.FixedTextView
android:id="@+id/tvGravatarPrivacy"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="12dp"
android:layout_marginTop="12dp"
android:drawableEnd="@drawable/twotone_open_in_new_12"
android:drawablePadding="6dp"
android:drawableTint="?android:attr/textColorLink"
android:text="@string/title_privacy_policy"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
android:textColor="?android:attr/textColorLink"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvGravatarsHint" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swLibravatars"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:text="@string/title_advanced_libravatars"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvGravatarPrivacy"
app:switchPadding="12dp" />
<eu.faircode.email.FixedTextView
android:id="@+id/tvLibravatarsHint"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="12dp"
android:layout_marginTop="6dp"
android:drawableTint="?attr/colorWarning"
android:text="@string/title_advanced_privacy_risk"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
android:textColor="?attr/colorWarning"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swLibravatars" />
<eu.faircode.email.FixedTextView
android:id="@+id/tvLibravatarPrivacy"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="12dp"
android:layout_marginTop="12dp"
android:drawableEnd="@drawable/twotone_open_in_new_12"
android:drawablePadding="6dp"
android:drawableTint="?android:attr/textColorLink"
android:text="@string/title_privacy_policy"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
android:textColor="?android:attr/textColorLink"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvLibravatarsHint" />
<androidx.appcompat.widget.SwitchCompat <androidx.appcompat.widget.SwitchCompat
android:id="@+id/swFavicons" android:id="@+id/swFavicons"
android:layout_width="0dp" android:layout_width="0dp"
@ -907,14 +961,15 @@
android:layout_marginTop="12dp" android:layout_marginTop="12dp"
android:text="@string/title_advanced_favicons" android:text="@string/title_advanced_favicons"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/vwFaviconPadding" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swEFavicons" app:layout_constraintTop_toBottomOf="@id/tvLibravatarPrivacy"
app:switchPadding="12dp" /> app:switchPadding="12dp" />
<eu.faircode.email.FixedTextView <eu.faircode.email.FixedTextView
android:id="@+id/tvFaviconsHint" android:id="@+id/tvFaviconsHint"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="12dp"
android:layout_marginTop="6dp" android:layout_marginTop="6dp"
android:drawableEnd="@drawable/twotone_open_in_new_12" android:drawableEnd="@drawable/twotone_open_in_new_12"
android:drawablePadding="6dp" android:drawablePadding="6dp"
@ -922,7 +977,7 @@
android:text="@string/title_advanced_privacy_risk" android:text="@string/title_advanced_privacy_risk"
android:textAppearance="@style/TextAppearance.AppCompat.Small" android:textAppearance="@style/TextAppearance.AppCompat.Small"
android:textColor="?attr/colorWarning" android:textColor="?attr/colorWarning"
app:layout_constraintStart_toEndOf="@id/vwFaviconPadding" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swFavicons" /> app:layout_constraintTop_toBottomOf="@id/swFavicons" />
<androidx.appcompat.widget.SwitchCompat <androidx.appcompat.widget.SwitchCompat
@ -934,24 +989,10 @@
android:checked="true" android:checked="true"
android:text="@string/title_advanced_favicons_partial" android:text="@string/title_advanced_favicons_partial"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/vwFaviconPadding" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvFaviconsHint" app:layout_constraintTop_toBottomOf="@id/tvFaviconsHint"
app:switchPadding="12dp" /> app:switchPadding="12dp" />
<eu.faircode.email.FixedTextView
android:id="@+id/tvFaviconsPlay"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:drawablePadding="6dp"
android:drawableTint="?attr/colorWarning"
android:text="@string/title_advanced_favicons_play"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
android:textColor="?attr/colorWarning"
android:textStyle="bold"
app:layout_constraintStart_toEndOf="@id/vwFaviconPadding"
app:layout_constraintTop_toBottomOf="@id/swFaviconsPartial" />
<androidx.appcompat.widget.SwitchCompat <androidx.appcompat.widget.SwitchCompat
android:id="@+id/swGeneratedIcons" android:id="@+id/swGeneratedIcons"
android:layout_width="0dp" android:layout_width="0dp"
@ -961,7 +1002,7 @@
android:text="@string/title_advanced_generated_icons" android:text="@string/title_advanced_generated_icons"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvFaviconsPlay" app:layout_constraintTop_toBottomOf="@id/swFaviconsPartial"
app:switchPadding="12dp" /> app:switchPadding="12dp" />
<androidx.appcompat.widget.SwitchCompat <androidx.appcompat.widget.SwitchCompat
@ -1483,12 +1524,6 @@
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvPreviewLinesHint" /> app:layout_constraintTop_toBottomOf="@id/tvPreviewLinesHint" />
<androidx.constraintlayout.widget.Group
android:id="@+id/grpPlay"
android:layout_width="0dp"
android:layout_height="0dp"
app:constraint_referenced_ids="vwFavicon,vwFaviconPadding,tvFaviconsPlay" />
</eu.faircode.email.ConstraintLayoutEx> </eu.faircode.email.ConstraintLayoutEx>
</androidx.cardview.widget.CardView> </androidx.cardview.widget.CardView>

@ -495,10 +495,10 @@
<string name="title_advanced_bimi" translatable="false">Show Brand Indicators for Message Identification (BIMI)</string> <string name="title_advanced_bimi" translatable="false">Show Brand Indicators for Message Identification (BIMI)</string>
<string name="title_advanced_bimi_unverified">Unverified sender</string> <string name="title_advanced_bimi_unverified">Unverified sender</string>
<string name="title_advanced_bimi_verified">Verified sender</string> <string name="title_advanced_bimi_verified">Verified sender</string>
<string name="title_advanced_efavicons">Show avatars</string> <string name="title_advanced_gravatars">Show Gravatars</string>
<string name="title_advanced_libravatars">Show Libravatars</string>
<string name="title_advanced_favicons">Show favicons</string> <string name="title_advanced_favicons">Show favicons</string>
<string name="title_advanced_favicons_partial">Scan only the first %1$s of the web page</string> <string name="title_advanced_favicons_partial">Scan only the first %1$s of the web page</string>
<string name="title_advanced_favicons_play">Google presumably doesn\'t allow online icons for privacy reasons</string>
<string name="title_advanced_generated_icons">Show generated icons</string> <string name="title_advanced_generated_icons">Show generated icons</string>
<string name="title_advanced_identicons">Show identicons</string> <string name="title_advanced_identicons">Show identicons</string>
<string name="title_advanced_circular">Show round icons</string> <string name="title_advanced_circular">Show round icons</string>

Loading…
Cancel
Save