mirror of https://github.com/M66B/FairEmail.git
Recognize links without protocol
This commit is contained in:
parent
2a588443f2
commit
683087bfe4
|
@ -1768,7 +1768,11 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
||||||
@Override
|
@Override
|
||||||
protected String onExecute(Context context, Bundle args) throws Throwable {
|
protected String onExecute(Context context, Bundle args) throws Throwable {
|
||||||
Uri uri = args.getParcelable("uri");
|
Uri uri = args.getParcelable("uri");
|
||||||
String host = uri.getHost();
|
String host;
|
||||||
|
if (TextUtils.isEmpty(uri.getScheme()))
|
||||||
|
host = Uri.parse("https://" + uri.toString()).getHost();
|
||||||
|
else
|
||||||
|
host = uri.getHost();
|
||||||
return (TextUtils.isEmpty(host) ? null : Helper.getOrganization(host));
|
return (TextUtils.isEmpty(host) ? null : Helper.getOrganization(host));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1140,6 +1140,7 @@ public class Helper {
|
||||||
}
|
}
|
||||||
InetAddress address = InetAddress.getByName(host);
|
InetAddress address = InetAddress.getByName(host);
|
||||||
URL url = new URL("https://ipinfo.io/" + address.getHostAddress() + "/org");
|
URL url = new URL("https://ipinfo.io/" + address.getHostAddress() + "/org");
|
||||||
|
Log.i("GET " + url);
|
||||||
HttpsURLConnection connection = (HttpsURLConnection) url.openConnection();
|
HttpsURLConnection connection = (HttpsURLConnection) url.openConnection();
|
||||||
connection.setRequestMethod("GET");
|
connection.setRequestMethod("GET");
|
||||||
connection.setReadTimeout(15 * 1000);
|
connection.setReadTimeout(15 * 1000);
|
||||||
|
|
|
@ -291,7 +291,7 @@ public class HtmlHelper {
|
||||||
if (BuildConfig.DEBUG)
|
if (BuildConfig.DEBUG)
|
||||||
Log.i("Web url=" + matcher.group() + " linked=" + linked + " scheme=" + scheme);
|
Log.i("Web url=" + matcher.group() + " linked=" + linked + " scheme=" + scheme);
|
||||||
|
|
||||||
if (linked || scheme == null)
|
if (linked)
|
||||||
span.appendText(text.substring(pos, matcher.end()));
|
span.appendText(text.substring(pos, matcher.end()));
|
||||||
else {
|
else {
|
||||||
span.appendText(text.substring(pos, matcher.start()));
|
span.appendText(text.substring(pos, matcher.start()));
|
||||||
|
|
Loading…
Reference in New Issue