mirror of
https://github.com/M66B/FairEmail.git
synced 2026-04-28 19:56:33 +02:00
Show link host name
This commit is contained in:
@@ -3387,6 +3387,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
||||
final CheckBox cbSecure = view.findViewById(R.id.cbSecure);
|
||||
CheckBox cbSanitize = view.findViewById(R.id.cbSanitize);
|
||||
final TextView tvOwner = view.findViewById(R.id.tvOwner);
|
||||
final TextView tvHost = view.findViewById(R.id.tvHost);
|
||||
final Group grpOwner = view.findViewById(R.id.grpOwner);
|
||||
|
||||
tvTitle.setText(title);
|
||||
@@ -3463,7 +3464,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
||||
Bundle args = new Bundle();
|
||||
args.putParcelable("uri", uri);
|
||||
|
||||
new SimpleTask<String>() {
|
||||
new SimpleTask<String[]>() {
|
||||
@Override
|
||||
protected void onPreExecute(Bundle args) {
|
||||
tvOwner.setText("…");
|
||||
@@ -3471,13 +3472,16 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String onExecute(Context context, Bundle args) throws Throwable {
|
||||
protected String[] onExecute(Context context, Bundle args) throws Throwable {
|
||||
Uri uri = args.getParcelable("uri");
|
||||
return IPInfo.getOrganization(uri);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onExecuted(Bundle args, String organization) {
|
||||
protected void onExecuted(Bundle args, String[] data) {
|
||||
String host = data[0];
|
||||
String organization = data[1];
|
||||
tvHost.setText(host);
|
||||
tvOwner.setText(organization == null ? "?" : organization);
|
||||
}
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ import javax.net.ssl.HttpsURLConnection;
|
||||
public class IPInfo {
|
||||
private static Map<String, String> hostOrganization = new HashMap<>();
|
||||
|
||||
static String getOrganization(Uri uri) throws IOException, ParseException {
|
||||
static String[] getOrganization(Uri uri) throws IOException, ParseException {
|
||||
if ("mailto".equals(uri.getScheme())) {
|
||||
MailTo email = MailTo.parse(uri.toString());
|
||||
String to = email.getTo();
|
||||
@@ -53,10 +53,10 @@ public class IPInfo {
|
||||
}
|
||||
}
|
||||
|
||||
private static String getOrganization(String host) throws IOException {
|
||||
private static String[] getOrganization(String host) throws IOException {
|
||||
synchronized (hostOrganization) {
|
||||
if (hostOrganization.containsKey(host))
|
||||
return hostOrganization.get(host);
|
||||
return new String[]{host, hostOrganization.get(host)};
|
||||
}
|
||||
InetAddress address = InetAddress.getByName(host);
|
||||
URL url = new URL("https://ipinfo.io/" + address.getHostAddress() + "/org");
|
||||
@@ -72,7 +72,7 @@ public class IPInfo {
|
||||
synchronized (hostOrganization) {
|
||||
hostOrganization.put(host, organization);
|
||||
}
|
||||
return organization;
|
||||
return new String[]{host, organization};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user