From b73cd30e3eb323cab2d19cdd222505fade8fef27 Mon Sep 17 00:00:00 2001 From: M66B Date: Tue, 23 Jun 2020 19:43:00 +0200 Subject: [PATCH] Show IP country flag --- .../eu/faircode/email/AdapterMessage.java | 13 +++++++++++- app/src/main/res/layout/dialog_open_link.xml | 20 +++++++++++++++---- 2 files changed, 28 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/AdapterMessage.java b/app/src/main/java/eu/faircode/email/AdapterMessage.java index 1ca2a6a2c7..24c203ba61 100644 --- a/app/src/main/java/eu/faircode/email/AdapterMessage.java +++ b/app/src/main/java/eu/faircode/email/AdapterMessage.java @@ -5579,6 +5579,7 @@ 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); + 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() { diff --git a/app/src/main/res/layout/dialog_open_link.xml b/app/src/main/res/layout/dialog_open_link.xml index a9e98419e9..65c4be5812 100644 --- a/app/src/main/res/layout/dialog_open_link.xml +++ b/app/src/main/res/layout/dialog_open_link.xml @@ -149,23 +149,35 @@ app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@id/tvOwnerRemark" /> - + + @@ -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" /> \ No newline at end of file