Prioritize web app manifest favicons

This commit is contained in:
M66B 2023-08-10 07:45:41 +02:00
parent 652145e365
commit 3d5eb73d08
1 changed files with 11 additions and 3 deletions

View File

@ -712,12 +712,14 @@ public class ContactInfo {
String src = jicon.optString("src");
String sizes = jicon.optString("sizes", "");
String type = jicon.optString("type", "");
String purpose = jicon.optString("purpose", "");
if (!TextUtils.isEmpty(src)) {
Element img = doc.createElement("link")
.attr("rel", "manifest")
.attr("href", src)
.attr("sizes", sizes)
.attr("type", type);
.attr("type", type)
.attr("purpose", purpose);
imgs.add(img);
}
}
@ -849,6 +851,9 @@ public class ContactInfo {
.trim();
String type = img.attr("type")
.trim();
String purpose = img.attr("purpose")
.toLowerCase(Locale.ROOT)
.trim();
int order = 0;
if ("link".equals(img.tagName()))
@ -856,12 +861,15 @@ public class ContactInfo {
boolean isIco = (href.endsWith(".ico") || "image/x-icon".equals(type));
boolean isSvg = (href.endsWith(".svg") || "image/svg+xml".equals(type));
boolean isMask = ("mask-icon".equals(rel) || img.hasAttr("mask"));
boolean isMask = ("mask-icon".equals(rel) || img.hasAttr("mask") || purpose.contains("mask"));
boolean isMonochrome = purpose.contains("monochrome");
if (isMask)
if (isMask || isMonochrome)
order = -10; // Safari: "mask-icon"
else if ("icon".equals(rel) && !isIco)
order += 20;
else if ("manifest".equals(rel))
order += 20;
else if ("apple-touch-icon".equals(rel) ||
"apple-touch-icon-precomposed".equals(rel)) {
// "apple-touch-startup-image"