mirror of https://github.com/M66B/FairEmail.git
parent
a817bddb5f
commit
1c35a77897
|
@ -5579,7 +5579,6 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
||||||
final Button btnOwner = dview.findViewById(R.id.btnOwner);
|
final Button btnOwner = dview.findViewById(R.id.btnOwner);
|
||||||
final TextView tvOwnerRemark = dview.findViewById(R.id.tvOwnerRemark);
|
final TextView tvOwnerRemark = dview.findViewById(R.id.tvOwnerRemark);
|
||||||
final ContentLoadingProgressBar pbWait = dview.findViewById(R.id.pbWait);
|
final ContentLoadingProgressBar pbWait = dview.findViewById(R.id.pbWait);
|
||||||
final ImageView ivFlag = dview.findViewById(R.id.ivFlag);
|
|
||||||
final TextView tvHost = dview.findViewById(R.id.tvHost);
|
final TextView tvHost = dview.findViewById(R.id.tvHost);
|
||||||
final TextView tvOwner = dview.findViewById(R.id.tvOwner);
|
final TextView tvOwner = dview.findViewById(R.id.tvOwner);
|
||||||
final CheckBox cbNotAgain = dview.findViewById(R.id.cbNotAgain);
|
final CheckBox cbNotAgain = dview.findViewById(R.id.cbNotAgain);
|
||||||
|
@ -5729,21 +5728,8 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onExecuted(Bundle args, Pair<String, IPInfo.Organization> data) {
|
protected void onExecuted(Bundle args, Pair<String, IPInfo.Organization> 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);
|
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() {
|
new Handler().post(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
|
|
@ -25,9 +25,6 @@ import android.net.ParseException;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.util.Pair;
|
import android.util.Pair;
|
||||||
|
|
||||||
import org.json.JSONException;
|
|
||||||
import org.json.JSONObject;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
@ -70,34 +67,19 @@ public class IPInfo {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://ipinfo.io/developers
|
// 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);
|
Log.i("GET " + url);
|
||||||
HttpsURLConnection connection = (HttpsURLConnection) url.openConnection();
|
HttpsURLConnection connection = (HttpsURLConnection) url.openConnection();
|
||||||
connection.setRequestMethod("GET");
|
connection.setRequestMethod("GET");
|
||||||
connection.setRequestProperty("Accept", "application/json");
|
|
||||||
connection.setReadTimeout(FETCH_TIMEOUT);
|
connection.setReadTimeout(FETCH_TIMEOUT);
|
||||||
connection.connect();
|
connection.connect();
|
||||||
|
|
||||||
Organization organization = new Organization();
|
Organization organization = new Organization();
|
||||||
try {
|
try {
|
||||||
String json = Helper.readStream(connection.getInputStream(), StandardCharsets.UTF_8.name());
|
String response = Helper.readStream(connection.getInputStream(), StandardCharsets.UTF_8.name());
|
||||||
/* {
|
organization.name = response.trim();
|
||||||
"ip": "8.8.8.8",
|
if ("".equals(organization.name) || "undefined".equals(organization.name))
|
||||||
"hostname": "dns.google",
|
organization.name = null;
|
||||||
"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);
|
|
||||||
} finally {
|
} finally {
|
||||||
connection.disconnect();
|
connection.disconnect();
|
||||||
}
|
}
|
||||||
|
@ -111,6 +93,5 @@ public class IPInfo {
|
||||||
|
|
||||||
static class Organization {
|
static class Organization {
|
||||||
String name;
|
String name;
|
||||||
String country;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -149,35 +149,23 @@
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@id/tvOwnerRemark" />
|
app:layout_constraintTop_toBottomOf="@id/tvOwnerRemark" />
|
||||||
|
|
||||||
<eu.faircode.email.ViewImageHint
|
|
||||||
android:id="@+id/ivFlag"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
|
||||||
app:layout_constraintTop_toBottomOf="@id/tvOwnerTitle"
|
|
||||||
app:srcCompat="@drawable/flag_nl" />
|
|
||||||
|
|
||||||
<eu.faircode.email.FixedTextView
|
<eu.faircode.email.FixedTextView
|
||||||
android:id="@+id/tvHost"
|
android:id="@+id/tvHost"
|
||||||
android:layout_width="0dp"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginEnd="6dp"
|
|
||||||
android:text="example.org"
|
android:text="example.org"
|
||||||
android:textAppearance="@style/TextAppearance.AppCompat.Small"
|
android:textAppearance="@style/TextAppearance.AppCompat.Small"
|
||||||
android:textColor="?android:textColorPrimary"
|
android:textColor="?android:textColorPrimary"
|
||||||
app:layout_constraintEnd_toStartOf="@id/ivFlag"
|
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@id/tvOwnerTitle" />
|
app:layout_constraintTop_toBottomOf="@id/tvOwnerTitle" />
|
||||||
|
|
||||||
<eu.faircode.email.FixedTextView
|
<eu.faircode.email.FixedTextView
|
||||||
android:id="@+id/tvOwner"
|
android:id="@+id/tvOwner"
|
||||||
android:layout_width="0dp"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginEnd="6dp"
|
|
||||||
android:text="Cloudflare"
|
android:text="Cloudflare"
|
||||||
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
|
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
|
||||||
android:textColor="?android:textColorPrimary"
|
android:textColor="?android:textColorPrimary"
|
||||||
app:layout_constraintEnd_toStartOf="@id/ivFlag"
|
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@id/tvHost" />
|
app:layout_constraintTop_toBottomOf="@id/tvHost" />
|
||||||
|
|
||||||
|
@ -201,6 +189,6 @@
|
||||||
android:id="@+id/grpOwner"
|
android:id="@+id/grpOwner"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="0dp"
|
android:layout_height="0dp"
|
||||||
app:constraint_referenced_ids="tvOwnerTitle,ivFlag,tvHost,tvOwner" />
|
app:constraint_referenced_ids="tvOwnerTitle,tvHost,tvOwner" />
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
</eu.faircode.email.ScrollViewEx>
|
</eu.faircode.email.ScrollViewEx>
|
Loading…
Reference in New Issue