Show IP country flag

This commit is contained in:
M66B 2020-06-23 19:43:00 +02:00
parent 3e4fa62284
commit b73cd30e3e
2 changed files with 28 additions and 5 deletions

View File

@ -5579,6 +5579,7 @@ 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);
@ -5728,8 +5729,18 @@ 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);
tvHost.setText(data.first);
tvOwner.setText(data.second.name == null ? "?" : data.second.name);
tvOwner.setText(TextUtils.isEmpty(data.second.name) ? "?" : data.second.name);
new Handler().post(new Runnable() {
@Override
public void run() {

View File

@ -149,23 +149,35 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvOwnerRemark" />
<eu.faircode.email.FixedTextView
android:id="@+id/tvHost"
<ImageView
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_ad" />
<eu.faircode.email.FixedTextView
android:id="@+id/tvHost"
android:layout_width="0dp"
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="wrap_content"
android:layout_width="0dp"
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" />
@ -189,6 +201,6 @@
android:id="@+id/grpOwner"
android:layout_width="0dp"
android:layout_height="0dp"
app:constraint_referenced_ids="tvOwnerTitle,tvHost,tvOwner" />
app:constraint_referenced_ids="tvOwnerTitle,ivFlag,tvHost,tvOwner" />
</androidx.constraintlayout.widget.ConstraintLayout>
</eu.faircode.email.ScrollViewEx>