From 28fd55a639b299eca47752d2f47bef75b276d2ab Mon Sep 17 00:00:00 2001 From: M66B Date: Sat, 6 Jul 2019 13:17:04 +0200 Subject: [PATCH] Show link host name --- .../java/eu/faircode/email/AdapterMessage.java | 10 +++++++--- app/src/main/java/eu/faircode/email/IPInfo.java | 8 ++++---- app/src/main/res/layout/dialog_open_link.xml | 15 +++++++++++++-- 3 files changed, 24 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/AdapterMessage.java b/app/src/main/java/eu/faircode/email/AdapterMessage.java index 1b92a17b2f..974d702d73 100644 --- a/app/src/main/java/eu/faircode/email/AdapterMessage.java +++ b/app/src/main/java/eu/faircode/email/AdapterMessage.java @@ -3387,6 +3387,7 @@ public class AdapterMessage extends RecyclerView.Adapter() { + new SimpleTask() { @Override protected void onPreExecute(Bundle args) { tvOwner.setText("…"); @@ -3471,13 +3472,16 @@ public class AdapterMessage extends RecyclerView.Adapter 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}; } } } diff --git a/app/src/main/res/layout/dialog_open_link.xml b/app/src/main/res/layout/dialog_open_link.xml index 722a5aceba..a6e46db5f6 100644 --- a/app/src/main/res/layout/dialog_open_link.xml +++ b/app/src/main/res/layout/dialog_open_link.xml @@ -73,6 +73,16 @@ app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@id/cbSanitize" /> + + + app:layout_constraintTop_toBottomOf="@id/tvHost" /> + app:constraint_referenced_ids="tvOwnerTitle,tvHost,tvOwner" /> \ No newline at end of file