mirror of https://github.com/M66B/FairEmail.git
Show link host name
This commit is contained in:
parent
9341b166ba
commit
28fd55a639
|
@ -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};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -73,6 +73,16 @@
|
|||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/cbSanitize" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvHost"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="example.org"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Small"
|
||||
android:textColor="?android:textColorPrimary"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/tvOwnerTitle" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvOwner"
|
||||
android:layout_width="wrap_content"
|
||||
|
@ -80,12 +90,13 @@
|
|||
android:labelFor="@+id/etLink"
|
||||
android:text="Cloudflare"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
|
||||
android:textColor="?android:textColorPrimary"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/tvOwnerTitle" />
|
||||
app:layout_constraintTop_toBottomOf="@id/tvHost" />
|
||||
|
||||
<androidx.constraintlayout.widget.Group
|
||||
android:id="@+id/grpOwner"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
app:constraint_referenced_ids="tvOwnerTitle,tvOwner" />
|
||||
app:constraint_referenced_ids="tvOwnerTitle,tvHost,tvOwner" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
Loading…
Reference in New Issue