Added option for alt favicon fetchers

pull/215/head
M66B 4 months ago
parent 9ee005281c
commit e1990aa845

@ -287,6 +287,7 @@ public class ContactInfo {
boolean libravatars = (prefs.getBoolean("libravatars", false) && (!favicons_dmarc || dmarc) && !BuildConfig.PLAY_STORE_RELEASE);
boolean favicons = (prefs.getBoolean("favicons", false) && (!favicons_dmarc || dmarc));
boolean ddg_icons = (prefs.getBoolean("ddg_icons", false) && (!favicons_dmarc || dmarc) && !BuildConfig.PLAY_STORE_RELEASE);
String favicon_uri = prefs.getString("favicon_uri", null);
boolean generated = prefs.getBoolean("generated_icons", true);
boolean identicons = prefs.getBoolean("identicons", false);
boolean circular = prefs.getBoolean("circular", true);
@ -490,6 +491,19 @@ public class ContactInfo {
}
}));
if (!TextUtils.isEmpty(favicon_uri) && (!favicons_dmarc || dmarc))
futures.add(Helper.getDownloadTaskExecutor().submit(new Callable<Favicon>() {
@Override
public Favicon call() throws Exception {
String parent = UriHelper.getRootDomain(context, domain);
String uri = favicon_uri.replace("{domain}", Uri.encode(parent));
Log.i("MMM uri=" + uri);
Favicon alt = getFavicon(new URL(uri), null, scaleToPixels, context);
alt.type = "uri";
return alt;
}
}));
Throwable ex = null;
for (Future<Favicon> future : futures)
try {

@ -227,6 +227,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
private SwitchCompat swAnimate;
private SwitchCompat swEasyCorrect;
private SwitchCompat swPastePlain;
private EditText etFaviconUri;
private SwitchCompat swInfra;
private SwitchCompat swTldFlags;
private SwitchCompat swJsonLd;
@ -304,7 +305,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
"exact_alarms",
"native_dkim", "native_arc", "native_arc_whitelist", "strict_alignment",
"webp", "animate_images",
"easy_correct", "paste_plain", "infra", "tld_flags", "json_ld", "dup_msgids", "thread_byref", "save_user_flags", "mdn",
"easy_correct", "paste_plain", "favicon_uri", "infra", "tld_flags", "json_ld", "dup_msgids", "thread_byref", "save_user_flags", "mdn",
"app_chooser", "app_chooser_share", "share_task",
"adjacent_links", "adjacent_documents", "adjacent_portrait", "adjacent_landscape",
"delete_confirmation", "delete_notification", "global_keywords", "test_iab"
@ -486,6 +487,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
swAnimate = view.findViewById(R.id.swAnimate);
swEasyCorrect = view.findViewById(R.id.swEasyCorrect);
swPastePlain = view.findViewById(R.id.swPastePlain);
etFaviconUri = view.findViewById(R.id.etFaviconUri);
swInfra = view.findViewById(R.id.swInfra);
swTldFlags = view.findViewById(R.id.swTldFlags);
swJsonLd = view.findViewById(R.id.swJsonLd);
@ -1647,6 +1649,27 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
}
});
etFaviconUri.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
}
@Override
public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
}
@Override
public void afterTextChanged(Editable edit) {
String uri = edit.toString().trim();
String prev = prefs.getString("favicon_uri", null);
prefs.edit().putString("favicon_uri", uri).apply();
if (uri.equals(prev))
ContactInfo.clearCache(getContext());
}
});
swInfra.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
@ -2215,6 +2238,9 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
if ("viewport_height".equals(key))
return;
if ("favicon_uri".equals(key))
return;
if ("global_keywords".equals(key))
return;
@ -2503,6 +2529,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
swAnimate.setChecked(prefs.getBoolean("animate_images", true));
swEasyCorrect.setChecked(prefs.getBoolean("easy_correct", false));
swPastePlain.setChecked(prefs.getBoolean("paste_plain", false));
etFaviconUri.setText(prefs.getString("favicon_uri", null));
swInfra.setChecked(prefs.getBoolean("infra", false));
swTldFlags.setChecked(prefs.getBoolean("tld_flags", false));
swJsonLd.setChecked(prefs.getBoolean("json_ld", false));

@ -1719,6 +1719,41 @@
app:layout_constraintTop_toBottomOf="@id/swEasyCorrect"
app:switchPadding="12dp" />
<TextView
android:id="@+id/tvFaviconUri"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:layout_marginEnd="48dp"
android:text="@string/title_advanced_favicon_uri"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
android:textColor="?android:attr/textColorPrimary"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swPastePlain" />
<EditText
android:id="@+id/etFaviconUri"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:inputType="textUri"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvFaviconUri" />
<TextView
android:id="@+id/tvFaviconUriHint"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="48dp"
android:text="@string/title_advanced_favicon_uri_hint"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
android:textStyle="italic"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/etFaviconUri" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swInfra"
android:layout_width="0dp"
@ -1727,7 +1762,7 @@
android:text="@string/title_advanced_infra"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swPastePlain"
app:layout_constraintTop_toBottomOf="@id/tvFaviconUriHint"
app:switchPadding="12dp" />
<androidx.constraintlayout.helper.widget.Flow

@ -985,6 +985,8 @@
<string name="title_advanced_animate" translatable="false">Animate images (GIF, etc.)</string>
<string name="title_advanced_easy_correct" translatable="false">Easy correct</string>
<string name="title_advanced_paste_plain" translatable="false">Add paste as plain text</string>
<string name="title_advanced_favicon_uri" translatable="false">Favicon alternative URI</string>
<string name="title_advanced_favicon_uri_hint" translatable="false">{domain} will be replaced</string>
<string name="title_advanced_infra" translatable="false">Show infrastructure</string>
<string name="title_advanced_tld_flags" translatable="false">Show TLD flags</string>
<string name="title_advanced_json_ld" translatable="false">Show Linked Data (JSON-LD)</string>

Loading…
Cancel
Save