diff --git a/app/src/main/java/eu/faircode/email/AdapterMessage.java b/app/src/main/java/eu/faircode/email/AdapterMessage.java index 6f1adaab84..1ca2a6a2c7 100644 --- a/app/src/main/java/eu/faircode/email/AdapterMessage.java +++ b/app/src/main/java/eu/faircode/email/AdapterMessage.java @@ -5579,7 +5579,6 @@ public class AdapterMessage extends RecyclerView.Adapter data) { - int resid = 0; - if (data.second.country != null) - resid = getResources().getIdentifier( - "flag_" + data.second.country.toLowerCase(), - "drawable", getContext().getPackageName()); - - if (resid == 0) - ivFlag.setImageDrawable(null); - else - ivFlag.setImageResource(resid); - - ivFlag.setContentDescription(data.second.country); - tvHost.setText(data.first); - tvOwner.setText(TextUtils.isEmpty(data.second.name) ? "?" : data.second.name); + tvOwner.setText(data.second.name == null ? "?" : data.second.name); new Handler().post(new Runnable() { @Override public void run() { diff --git a/app/src/main/java/eu/faircode/email/IPInfo.java b/app/src/main/java/eu/faircode/email/IPInfo.java index 22282aa909..e446335769 100644 --- a/app/src/main/java/eu/faircode/email/IPInfo.java +++ b/app/src/main/java/eu/faircode/email/IPInfo.java @@ -25,9 +25,6 @@ import android.net.ParseException; import android.net.Uri; import android.util.Pair; -import org.json.JSONException; -import org.json.JSONObject; - import java.io.IOException; import java.net.InetAddress; import java.net.URL; @@ -70,34 +67,19 @@ public class IPInfo { } // https://ipinfo.io/developers - URL url = new URL("https://ipinfo.io/" + address.getHostAddress()); + URL url = new URL("https://ipinfo.io/" + address.getHostAddress() + "/org"); Log.i("GET " + url); HttpsURLConnection connection = (HttpsURLConnection) url.openConnection(); connection.setRequestMethod("GET"); - connection.setRequestProperty("Accept", "application/json"); connection.setReadTimeout(FETCH_TIMEOUT); connection.connect(); Organization organization = new Organization(); try { - String json = Helper.readStream(connection.getInputStream(), StandardCharsets.UTF_8.name()); - /* { - "ip": "8.8.8.8", - "hostname": "dns.google", - "city": "Mountain View", - "region": "California", - "country": "US", - "loc": "37.4056,-122.0775", - "org": "AS15169 Google LLC", - "postal": "94043", - "timezone": "America/Los_Angeles" - } */ - - JSONObject jinfo = new JSONObject(json); - organization.name = jinfo.optString("org"); - organization.country = jinfo.optString("country"); - } catch (JSONException ex) { - throw new IOException(ex); + String response = Helper.readStream(connection.getInputStream(), StandardCharsets.UTF_8.name()); + organization.name = response.trim(); + if ("".equals(organization.name) || "undefined".equals(organization.name)) + organization.name = null; } finally { connection.disconnect(); } @@ -111,6 +93,5 @@ public class IPInfo { static class Organization { String name; - String country; } } diff --git a/app/src/main/res/layout/dialog_open_link.xml b/app/src/main/res/layout/dialog_open_link.xml index f06873948b..a9e98419e9 100644 --- a/app/src/main/res/layout/dialog_open_link.xml +++ b/app/src/main/res/layout/dialog_open_link.xml @@ -149,35 +149,23 @@ app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@id/tvOwnerRemark" /> - - @@ -201,6 +189,6 @@ android:id="@+id/grpOwner" android:layout_width="0dp" android:layout_height="0dp" - app:constraint_referenced_ids="tvOwnerTitle,ivFlag,tvHost,tvOwner" /> + app:constraint_referenced_ids="tvOwnerTitle,tvHost,tvOwner" /> \ No newline at end of file