mirror of
https://github.com/M66B/FairEmail.git
synced 2025-01-03 13:44:40 +00:00
Added option to always scan web app manifest for favicons
This commit is contained in:
parent
f5a29c30f2
commit
7c91e4bacc
4 changed files with 32 additions and 3 deletions
|
@ -640,6 +640,7 @@ public class ContactInfo {
|
|||
private static Favicon parseFavicon(URL base, int scaleToPixels, Context context) throws IOException {
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
boolean favicons_partial = prefs.getBoolean("favicons_partial", true);
|
||||
boolean favicons_manifest = prefs.getBoolean("favicons_manifest", false);
|
||||
|
||||
Log.i("PARSE favicon " + base);
|
||||
HttpURLConnection connection = ConnectionHelper
|
||||
|
@ -681,7 +682,7 @@ public class ContactInfo {
|
|||
imgs.addAll(doc.head().select("meta[itemprop=image]"));
|
||||
|
||||
// https://developer.mozilla.org/en-US/docs/Web/Manifest/icons
|
||||
if (imgs.size() == 0 || BuildConfig.DEBUG)
|
||||
if (imgs.size() == 0 || favicons_manifest)
|
||||
for (Element manifest : doc.head().select("link[rel=manifest]"))
|
||||
try {
|
||||
String href = manifest.attr("href");
|
||||
|
|
|
@ -121,6 +121,7 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
|
|||
private TextView tvLibravatarPrivacy;
|
||||
private SwitchCompat swFavicons;
|
||||
private SwitchCompat swFaviconsPartial;
|
||||
private SwitchCompat swFaviconsManifest;
|
||||
private TextView tvFaviconsHint;
|
||||
private SwitchCompat swGeneratedIcons;
|
||||
private SwitchCompat swIdenticons;
|
||||
|
@ -205,7 +206,7 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
|
|||
"hide_toolbar", "nav_options", "nav_categories", "nav_last_sync", "nav_count", "nav_unseen_drafts", "nav_count_pinned", "navbar_colorize",
|
||||
"threading", "threading_unread", "indentation", "seekbar", "actionbar", "actionbar_swap", "actionbar_color",
|
||||
"highlight_unread", "highlight_color", "color_stripe", "color_stripe_wide",
|
||||
"avatars", "bimi", "gravatars", "libravatars", "favicons", "favicons_partial", "generated_icons", "identicons",
|
||||
"avatars", "bimi", "gravatars", "libravatars", "favicons", "favicons_partial", "favicons_manifest", "generated_icons", "identicons",
|
||||
"circular", "saturation", "brightness", "threshold",
|
||||
"email_format", "prefer_contact", "only_contact", "distinguish_contacts", "show_recipients",
|
||||
"font_size_sender", "sender_ellipsize",
|
||||
|
@ -290,6 +291,7 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
|
|||
tvLibravatarPrivacy = view.findViewById(R.id.tvLibravatarPrivacy);
|
||||
swFavicons = view.findViewById(R.id.swFavicons);
|
||||
swFaviconsPartial = view.findViewById(R.id.swFaviconsPartial);
|
||||
swFaviconsManifest = view.findViewById(R.id.swFaviconsManifest);
|
||||
tvFaviconsHint = view.findViewById(R.id.tvFaviconsHint);
|
||||
swGeneratedIcons = view.findViewById(R.id.swGeneratedIcons);
|
||||
swIdenticons = view.findViewById(R.id.swIdenticons);
|
||||
|
@ -849,6 +851,7 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
|
|||
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
|
||||
prefs.edit().putBoolean("favicons", checked).apply();
|
||||
swFaviconsPartial.setEnabled(checked);
|
||||
swFaviconsManifest.setEnabled(checked);
|
||||
ContactInfo.clearCache(compoundButton.getContext());
|
||||
}
|
||||
});
|
||||
|
@ -861,6 +864,14 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
|
|||
}
|
||||
});
|
||||
|
||||
swFaviconsManifest.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
|
||||
prefs.edit().putBoolean("favicons_manifest", checked).apply();
|
||||
ContactInfo.clearCache(compoundButton.getContext());
|
||||
}
|
||||
});
|
||||
|
||||
tvFaviconsHint.getPaint().setUnderlineText(true);
|
||||
tvFaviconsHint.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
|
@ -1498,6 +1509,8 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
|
|||
swFavicons.setChecked(prefs.getBoolean("favicons", false));
|
||||
swFaviconsPartial.setChecked(prefs.getBoolean("favicons_partial", true));
|
||||
swFaviconsPartial.setEnabled(swFavicons.isChecked());
|
||||
swFaviconsManifest.setChecked(prefs.getBoolean("favicons_manifest", false));
|
||||
swFaviconsManifest.setEnabled(swFavicons.isChecked());
|
||||
swGeneratedIcons.setChecked(prefs.getBoolean("generated_icons", true));
|
||||
swIdenticons.setChecked(prefs.getBoolean("identicons", false));
|
||||
swIdenticons.setEnabled(swGeneratedIcons.isChecked());
|
||||
|
|
|
@ -1103,6 +1103,20 @@
|
|||
app:layout_constraintTop_toBottomOf="@id/tvFaviconsHint"
|
||||
app:switchPadding="12dp" />
|
||||
|
||||
<androidx.appcompat.widget.SwitchCompat
|
||||
android:id="@+id/swFaviconsManifest"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="12dp"
|
||||
android:layout_marginTop="12dp"
|
||||
android:checked="true"
|
||||
android:tag="nosuggest"
|
||||
android:text="@string/title_advanced_favicons_manifest"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/swFaviconsPartial"
|
||||
app:switchPadding="12dp" />
|
||||
|
||||
<androidx.appcompat.widget.SwitchCompat
|
||||
android:id="@+id/swGeneratedIcons"
|
||||
android:layout_width="0dp"
|
||||
|
@ -1112,7 +1126,7 @@
|
|||
android:text="@string/title_advanced_generated_icons"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/swFaviconsPartial"
|
||||
app:layout_constraintTop_toBottomOf="@id/swFaviconsManifest"
|
||||
app:switchPadding="12dp" />
|
||||
|
||||
<androidx.appcompat.widget.SwitchCompat
|
||||
|
|
|
@ -575,6 +575,7 @@
|
|||
<string name="title_advanced_libravatars">Show Libravatars</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_manifest">Scan web app manifests</string>
|
||||
<string name="title_advanced_generated_icons">Show generated icons</string>
|
||||
<string name="title_advanced_identicons">Show identicons</string>
|
||||
<string name="title_advanced_circular">Show round icons</string>
|
||||
|
|
Loading…
Reference in a new issue