mirror of
https://github.com/M66B/FairEmail.git
synced 2024-12-25 01:06:04 +00:00
Behavior improvement
This commit is contained in:
parent
4a20ca9c06
commit
ceea8cd1f8
1 changed files with 19 additions and 15 deletions
|
@ -5870,17 +5870,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|||
return;
|
||||
|
||||
Uri uri = Uri.parse(etLink.getText().toString());
|
||||
Uri.Builder builder = uri.buildUpon();
|
||||
|
||||
builder.scheme(checked ? "https" : "http");
|
||||
|
||||
String authority = uri.getEncodedAuthority();
|
||||
if (authority != null) {
|
||||
authority = authority.replace(checked ? ":80" : ":443", checked ? ":443" : ":80");
|
||||
builder.encodedAuthority(authority);
|
||||
}
|
||||
|
||||
etLink.setText(builder.build().toString());
|
||||
etLink.setText(secure(uri, checked).toString());
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -5889,10 +5879,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|||
cbSanitize.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
|
||||
if (checked)
|
||||
etLink.setText(sanitized.toString());
|
||||
else
|
||||
etLink.setText(uri.toString());
|
||||
etLink.setText(secure(checked ? sanitized : uri, cbSecure.isChecked()).toString());
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -6065,6 +6052,23 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|||
|
||||
return (changed ? builder.build() : null);
|
||||
}
|
||||
|
||||
private static Uri secure(Uri uri, boolean https) {
|
||||
String scheme = uri.getScheme();
|
||||
if (https ? "http".equals(scheme) : "https".equals(scheme)) {
|
||||
Uri.Builder builder = uri.buildUpon();
|
||||
builder.scheme(https ? "https" : "http");
|
||||
|
||||
String authority = uri.getEncodedAuthority();
|
||||
if (authority != null) {
|
||||
authority = authority.replace(https ? ":80" : ":443", https ? ":443" : ":80");
|
||||
builder.encodedAuthority(authority);
|
||||
}
|
||||
|
||||
return builder.build();
|
||||
} else
|
||||
return uri;
|
||||
}
|
||||
}
|
||||
|
||||
public static class FragmentDialogJunk extends FragmentDialogBase {
|
||||
|
|
Loading…
Reference in a new issue