Added optional DDG icons

pull/215/head
M66B 4 months ago
parent da0ab65211
commit 1873b57096

@ -26,6 +26,8 @@ import java.util.concurrent.Callable;
public class Avatar {
static final String GRAVATAR_PRIVACY_URI = "";
static final String LIBRAVATAR_PRIVACY_URI = "";
static final String DDG_URI = "";
static final String DDG_PRIVACY_URI = "";
static Callable<ContactInfo.Favicon> getGravatar(String email, int scaleToPixels, Context context) {
return new Callable<ContactInfo.Favicon>() {

@ -31,6 +31,8 @@ import javax.net.ssl.HttpsURLConnection;
public class Avatar {
static final String GRAVATAR_PRIVACY_URI = "https://automattic.com/privacy/";
static final String LIBRAVATAR_PRIVACY_URI = "https://www.libravatar.org/privacy/";
static final String DDG_URI = "https://icons.duckduckgo.com/ip3/";
static final String DDG_PRIVACY_URI = "https://duckduckgo.com/privacy";
private static final String GRAVATAR_URI = "https://www.gravatar.com/avatar/";
private static final int GRAVATAR_CONNECT_TIMEOUT = 5 * 1000; // milliseconds

@ -285,6 +285,7 @@ public class ContactInfo {
boolean gravatars = (prefs.getBoolean("gravatars", false) && (!favicons_dmarc || dmarc) && !BuildConfig.PLAY_STORE_RELEASE);
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);
boolean generated = prefs.getBoolean("generated_icons", true);
boolean identicons = prefs.getBoolean("identicons", false);
boolean circular = prefs.getBoolean("circular", true);
@ -475,6 +476,18 @@ public class ContactInfo {
}
}
if (ddg_icons && !TextUtils.isEmpty(Avatar.DDG_URI))
futures.add(Helper.getDownloadTaskExecutor().submit(new Callable<Favicon>() {
@Override
public Favicon call() throws Exception {
String parent = UriHelper.getRootDomain(context, domain);
String uri = Avatar.DDG_URI + Uri.encode(parent) + ".ico";
Favicon ddg = getFavicon(new URL(uri), null, scaleToPixels, context);
ddg.type = "ddg";
return ddg;
}
}));
Throwable ex = null;
for (Future<Favicon> future : futures)
try {

@ -124,9 +124,11 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
private SwitchCompat swLibravatars;
private TextView tvLibravatarPrivacy;
private SwitchCompat swFavicons;
private TextView tvFaviconsHint;
private SwitchCompat swFaviconsPartial;
private SwitchCompat swFaviconsManifest;
private TextView tvFaviconsHint;
private SwitchCompat swDdg;
private TextView tvDdgPrivacy;
private SwitchCompat swFaviconsDmarc;
private SwitchCompat swGeneratedIcons;
private SwitchCompat swIdenticons;
@ -218,7 +220,7 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
"hide_toolbar", "edge_to_edge", "nav_options", "nav_categories", "nav_last_sync", "nav_count", "nav_unseen_drafts", "nav_count_pinned", "show_unexposed",
"threading", "threading_unread", "indentation", "seekbar", "actionbar", "actionbar_swap", "actionbar_color",
"highlight_unread", "highlight_color", "color_stripe", "color_stripe_wide",
"avatars", "bimi", "bimi_vmc", "gravatars", "libravatars", "favicons", "favicons_partial", "favicons_manifest", "favicons_dmarc", "generated_icons", "identicons",
"avatars", "bimi", "bimi_vmc", "gravatars", "libravatars", "favicons", "favicons_partial", "favicons_manifest", "ddg_icons", "favicons_dmarc", "generated_icons", "identicons",
"circular", "saturation", "brightness", "threshold",
"email_format", "prefer_contact", "only_contact", "distinguish_contacts", "show_recipients", "reverse_addresses",
"font_size_sender", "sender_ellipsize",
@ -304,9 +306,11 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
swLibravatars = view.findViewById(R.id.swLibravatars);
tvLibravatarPrivacy = view.findViewById(R.id.tvLibravatarPrivacy);
swFavicons = view.findViewById(R.id.swFavicons);
tvFaviconsHint = view.findViewById(R.id.tvFaviconsHint);
swFaviconsPartial = view.findViewById(R.id.swFaviconsPartial);
swFaviconsManifest = view.findViewById(R.id.swFaviconsManifest);
tvFaviconsHint = view.findViewById(R.id.tvFaviconsHint);
swDdg = view.findViewById(R.id.swDdg);
tvDdgPrivacy = view.findViewById(R.id.tvDdgPrivacy);
swFaviconsDmarc = view.findViewById(R.id.swFaviconsDmarc);
swGeneratedIcons = view.findViewById(R.id.swGeneratedIcons);
swIdenticons = view.findViewById(R.id.swIdenticons);
@ -894,6 +898,14 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
}
});
tvFaviconsHint.getPaint().setUnderlineText(true);
tvFaviconsHint.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Helper.view(v.getContext(), Uri.parse(Helper.FAVICON_PRIVACY_URI), true);
}
});
swFaviconsPartial.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
@ -910,11 +922,19 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
}
});
tvFaviconsHint.getPaint().setUnderlineText(true);
tvFaviconsHint.setOnClickListener(new View.OnClickListener() {
swDdg.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("ddg_icons", checked).apply();
ContactInfo.clearCache(compoundButton.getContext());
}
});
tvDdgPrivacy.getPaint().setUnderlineText(true);
tvDdgPrivacy.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Helper.view(v.getContext(), Uri.parse(Helper.FAVICON_PRIVACY_URI), true);
Helper.view(v.getContext(), Uri.parse(Avatar.DDG_PRIVACY_URI), true);
}
});
@ -1625,6 +1645,7 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
swFaviconsPartial.setEnabled(swFavicons.isChecked());
swFaviconsManifest.setChecked(prefs.getBoolean("favicons_manifest", false));
swFaviconsManifest.setEnabled(swFavicons.isChecked());
swDdg.setChecked(prefs.getBoolean("ddg_icons", false));
swFaviconsDmarc.setChecked(prefs.getBoolean("favicons_dmarc", false));
swGeneratedIcons.setChecked(prefs.getBoolean("generated_icons", true));
swIdenticons.setChecked(prefs.getBoolean("identicons", false));

@ -1085,6 +1085,7 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvLibravatarsHint" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swFavicons"
android:layout_width="0dp"
@ -1141,6 +1142,48 @@
app:layout_constraintTop_toBottomOf="@id/swFaviconsPartial"
app:switchPadding="12dp" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swDdg"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:tag="nosuggest"
android:text="@string/title_advanced_ddg"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swFaviconsManifest"
app:switchPadding="12dp" />
<TextView
android:id="@+id/tvDdgHint"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="12dp"
android:layout_marginTop="6dp"
android:tag="nosuggest"
android:text="@string/title_advanced_privacy_risk"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
android:textColor="?attr/colorWarning"
app:drawableTint="?attr/colorWarning"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swDdg" />
<TextView
android:id="@+id/tvDdgPrivacy"
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:tag="nosuggest"
android:text="@string/title_privacy_policy"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
android:textColor="?android:attr/textColorLink"
app:drawableTint="?android:attr/textColorLink"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvDdgHint" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swFaviconsDmarc"
android:layout_width="0dp"
@ -1149,7 +1192,7 @@
android:text="@string/title_advanced_favicons_dmarc"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swFaviconsManifest"
app:layout_constraintTop_toBottomOf="@id/tvDdgPrivacy"
app:switchPadding="12dp" />
<androidx.appcompat.widget.SwitchCompat
@ -1712,9 +1755,10 @@
android:layout_width="0dp"
android:layout_height="0dp"
app:constraint_referenced_ids="
swBimi,swBimiVmc,BtvBimiHint,tvBimiVerified,ibBimi,
swBimi,swBimiVmc,tvBimiHint,tvBimiVerified,ibBimi,
swGravatars,tvGravatarsHint,tvGravatarPrivacy,
swLibravatars,tvLibravatarsHint,tvLibravatarPrivacy" />
swLibravatars,tvLibravatarsHint,tvLibravatarPrivacy,
swDdg,tvDdgHint,tvDdgPrivacy" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.cardview.widget.CardView>

@ -619,6 +619,7 @@
<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_ddg">Show DuckDuckGo icons</string>
<string name="title_advanced_favicons_dmarc">Require DMARC verification for external images</string>
<string name="title_advanced_generated_icons">Show generated icons</string>
<string name="title_advanced_identicons">Show identicons</string>

Loading…
Cancel
Save