Allow disable confirming email addreesses

This commit is contained in:
M66B 2023-01-15 17:48:25 +01:00
parent 7f022c31a0
commit b6fd01f752
2 changed files with 19 additions and 11 deletions

View File

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

View File

@ -334,7 +334,7 @@ public class FragmentDialogOpenLink extends FragmentDialogBase {
cbNotAgain.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
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);
cbNotAgain.setText(context.getString(R.string.title_no_ask_for_again, uri.getHost()));
cbNotAgain.setVisibility(
!always_confirm &&
!sanitize_links &&
UriHelper.isSecure(uri) &&
!TextUtils.isEmpty(uri.getHost())
? View.VISIBLE : View.GONE);
String chost = getConfirmHost(uri);
cbNotAgain.setText(context.getString(R.string.title_no_ask_for_again, chost));
cbNotAgain.setVisibility(!always_confirm && chost != null ? View.VISIBLE : View.GONE);
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> {
private final Context context;
private final List<Package> pkgs;