mirror of https://github.com/M66B/FairEmail.git
Improved favicon selection
This commit is contained in:
parent
5cda73e58c
commit
025aefea7d
|
@ -479,6 +479,15 @@ public class ContactInfo {
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
int dot = host.indexOf('.');
|
||||||
|
host = host.substring(dot + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
host = domain;
|
||||||
|
while (host.indexOf('.') > 0) {
|
||||||
|
final URL base = new URL("https://" + host);
|
||||||
|
final URL www = new URL("https://www." + host);
|
||||||
|
|
||||||
futures.add(executorFavicon.submit(new Callable<Favicon>() {
|
futures.add(executorFavicon.submit(new Callable<Favicon>() {
|
||||||
@Override
|
@Override
|
||||||
public Favicon call() throws Exception {
|
public Favicon call() throws Exception {
|
||||||
|
@ -502,7 +511,11 @@ public class ContactInfo {
|
||||||
for (Future<Favicon> future : futures)
|
for (Future<Favicon> future : futures)
|
||||||
try {
|
try {
|
||||||
Favicon favicon = future.get();
|
Favicon favicon = future.get();
|
||||||
if (favicon != null) {
|
Log.i("Using favicon source=" + (favicon == null ? null : favicon.source));
|
||||||
|
|
||||||
|
if (favicon == null)
|
||||||
|
continue;
|
||||||
|
|
||||||
float lum = 0; // ImageHelper.getLuminance(favicon.bitmap);
|
float lum = 0; // ImageHelper.getLuminance(favicon.bitmap);
|
||||||
if (lum < MIN_FAVICON_LUMINANCE) {
|
if (lum < MIN_FAVICON_LUMINANCE) {
|
||||||
Bitmap bitmap = Bitmap.createBitmap(
|
Bitmap bitmap = Bitmap.createBitmap(
|
||||||
|
@ -520,7 +533,6 @@ public class ContactInfo {
|
||||||
info.type = favicon.type;
|
info.type = favicon.type;
|
||||||
info.verified = favicon.verified;
|
info.verified = favicon.verified;
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
} catch (ExecutionException exex) {
|
} catch (ExecutionException exex) {
|
||||||
ex = exex.getCause();
|
ex = exex.getCause();
|
||||||
} catch (Throwable exex) {
|
} catch (Throwable exex) {
|
||||||
|
@ -865,7 +877,7 @@ public class ContactInfo {
|
||||||
Bitmap bitmap = ImageHelper.getScaledBitmap(connection.getInputStream(), url.toString(), mimeType, scaleToPixels);
|
Bitmap bitmap = ImageHelper.getScaledBitmap(connection.getInputStream(), url.toString(), mimeType, scaleToPixels);
|
||||||
if (bitmap == null)
|
if (bitmap == null)
|
||||||
throw new FileNotFoundException("decodeStream");
|
throw new FileNotFoundException("decodeStream");
|
||||||
return new Favicon(bitmap);
|
return new Favicon(bitmap, url.toString());
|
||||||
} finally {
|
} finally {
|
||||||
connection.disconnect();
|
connection.disconnect();
|
||||||
}
|
}
|
||||||
|
@ -1053,15 +1065,18 @@ public class ContactInfo {
|
||||||
private Bitmap bitmap;
|
private Bitmap bitmap;
|
||||||
private String type;
|
private String type;
|
||||||
private boolean verified;
|
private boolean verified;
|
||||||
|
private String source;
|
||||||
|
|
||||||
private Favicon(@NonNull Bitmap bitmap) {
|
private Favicon(@NonNull Bitmap bitmap, String source) {
|
||||||
this(bitmap, "favicon", false);
|
this(bitmap, "favicon", false);
|
||||||
|
this.source = source;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Favicon(@NonNull Bitmap bitmap, String type, boolean verified) {
|
private Favicon(@NonNull Bitmap bitmap, String type, boolean verified) {
|
||||||
this.bitmap = bitmap;
|
this.bitmap = bitmap;
|
||||||
this.type = type;
|
this.type = type;
|
||||||
this.verified = verified;
|
this.verified = verified;
|
||||||
|
this.source = type;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue