Revert "Orange"

This reverts commit 329f2c7ebf.
pull/182/head
M66B 4 years ago
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 TextView tvOwnerRemark = dview.findViewById(R.id.tvOwnerRemark);
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 tvOwner = dview.findViewById(R.id.tvOwner);
final CheckBox cbNotAgain = dview.findViewById(R.id.cbNotAgain);
@ -5729,21 +5728,8 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
@Override
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);
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() {

@ -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;
}
}

@ -149,35 +149,23 @@
app:layout_constraintStart_toStartOf="parent"
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
android:id="@+id/tvHost"
android:layout_width="0dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="6dp"
android:text="example.org"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
android:textColor="?android:textColorPrimary"
app:layout_constraintEnd_toStartOf="@id/ivFlag"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvOwnerTitle" />
<eu.faircode.email.FixedTextView
android:id="@+id/tvOwner"
android:layout_width="0dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="6dp"
android:text="Cloudflare"
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
android:textColor="?android:textColorPrimary"
app:layout_constraintEnd_toStartOf="@id/ivFlag"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvHost" />
@ -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" />
</androidx.constraintlayout.widget.ConstraintLayout>
</eu.faircode.email.ScrollViewEx>
Loading…
Cancel
Save