Allow disable confirming email addreesses

pull/212/head
M66B 3 years ago
parent 7f022c31a0
commit b6fd01f752

@ -5937,10 +5937,9 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
String scheme = guri.getScheme(); String scheme = guri.getScheme();
String host = guri.getHost(); String host = guri.getHost();
String chost = FragmentDialogOpenLink.getConfirmHost(uri);
boolean sanitize_links = prefs.getBoolean("sanitize_links", false); boolean sanitize_links = prefs.getBoolean("sanitize_links", false);
boolean confirm_link = boolean confirm_link = (chost != null && prefs.getBoolean(chost + ".confirm_link", true));
!"https".equalsIgnoreCase(scheme) || TextUtils.isEmpty(host) ||
prefs.getBoolean(host + ".confirm_link", true);
if (always_confirm || sanitize_links || (confirm_links && confirm_link)) { if (always_confirm || sanitize_links || (confirm_links && confirm_link)) {
Bundle args = new Bundle(); Bundle args = new Bundle();
args.putParcelable("uri", uri); args.putParcelable("uri", uri);

@ -334,7 +334,7 @@ public class FragmentDialogOpenLink extends FragmentDialogBase {
cbNotAgain.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { cbNotAgain.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override @Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
prefs.edit().putBoolean(uri.getHost() + ".confirm_link", !isChecked).apply(); prefs.edit().putBoolean(getConfirmHost(uri) + ".confirm_link", !isChecked).apply();
} }
}); });
@ -581,13 +581,9 @@ public class FragmentDialogOpenLink extends FragmentDialogBase {
cbSanitize.setChecked(sanitize_links); cbSanitize.setChecked(sanitize_links);
cbNotAgain.setText(context.getString(R.string.title_no_ask_for_again, uri.getHost())); String chost = getConfirmHost(uri);
cbNotAgain.setVisibility( cbNotAgain.setText(context.getString(R.string.title_no_ask_for_again, chost));
!always_confirm && cbNotAgain.setVisibility(!always_confirm && chost != null ? View.VISIBLE : View.GONE);
!sanitize_links &&
UriHelper.isSecure(uri) &&
!TextUtils.isEmpty(uri.getHost())
? View.VISIBLE : View.GONE);
setMore(false); setMore(false);
@ -862,6 +858,19 @@ public class FragmentDialogOpenLink extends FragmentDialogBase {
} }
} }
public static String getConfirmHost(Uri uri) {
String scheme = uri.getScheme();
if ("https".equals(scheme)) {
String host = uri.getHost();
return (TextUtils.isEmpty(host) ? null : host);
} else if ("mailto".equals(scheme)) {
MailTo mailto = MailTo.parse(uri);
String to = mailto.getTo();
return (TextUtils.isEmpty(to) ? null : to);
} else
return null;
}
public static class AdapterPackage extends ArrayAdapter<Package> { public static class AdapterPackage extends ArrayAdapter<Package> {
private final Context context; private final Context context;
private final List<Package> pkgs; private final List<Package> pkgs;

Loading…
Cancel
Save