From c666b086d6be3d993b0b9c52a6aab916cd6942ab Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Thu, 6 Mar 2014 20:00:46 +0100 Subject: [PATCH] display keys in contact details --- res/layout/activity_contact_details.xml | 15 ++++++++ res/layout/contact_key.xml | 22 +++++++++++ .../ui/ContactDetailsActivity.java | 37 ++++++++++++++++++- 3 files changed, 73 insertions(+), 1 deletion(-) create mode 100644 res/layout/contact_key.xml diff --git a/res/layout/activity_contact_details.xml b/res/layout/activity_contact_details.xml index cd49f1bf3..1c38f4a33 100644 --- a/res/layout/activity_contact_details.xml +++ b/res/layout/activity_contact_details.xml @@ -91,5 +91,20 @@ android:text="Receive presence updates" android:textSize="18sp" android:textColor="#5b5b5b" /> + + + + \ No newline at end of file diff --git a/res/layout/contact_key.xml b/res/layout/contact_key.xml new file mode 100644 index 000000000..dcac42e98 --- /dev/null +++ b/res/layout/contact_key.xml @@ -0,0 +1,22 @@ + + + + + + \ No newline at end of file diff --git a/src/eu/siacs/conversations/ui/ContactDetailsActivity.java b/src/eu/siacs/conversations/ui/ContactDetailsActivity.java index 23fb68a16..e1fb25d4a 100644 --- a/src/eu/siacs/conversations/ui/ContactDetailsActivity.java +++ b/src/eu/siacs/conversations/ui/ContactDetailsActivity.java @@ -1,6 +1,11 @@ package eu.siacs.conversations.ui; +import java.math.BigInteger; +import java.util.Iterator; +import java.util.zip.Inflater; + import android.app.AlertDialog; +import android.content.Context; import android.content.DialogInterface; import android.content.Intent; import android.net.Uri; @@ -8,12 +13,15 @@ import android.os.Bundle; import android.provider.ContactsContract.CommonDataKinds; import android.provider.ContactsContract.Contacts; import android.provider.ContactsContract.Intents; +import android.util.Log; +import android.view.LayoutInflater; import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.view.View.OnClickListener; import android.widget.CheckBox; import android.widget.EditText; +import android.widget.LinearLayout; import android.widget.QuickContactBadge; import android.widget.TextView; import eu.siacs.conversations.R; @@ -83,6 +91,8 @@ public class ContactDetailsActivity extends XmppActivity { } }; + private LinearLayout keys; + @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -97,7 +107,7 @@ public class ContactDetailsActivity extends XmppActivity { send = (CheckBox) findViewById(R.id.details_send_presence); receive = (CheckBox) findViewById(R.id.details_receive_presence); badge = (QuickContactBadge) findViewById(R.id.details_contact_badge); - + keys = (LinearLayout) findViewById(R.id.details_contact_keys); getActionBar().setHomeButtonEnabled(true); getActionBar().setDisplayHomeAsUpEnabled(true); @@ -211,6 +221,31 @@ public class ContactDetailsActivity extends XmppActivity { if (contact.getSystemAccount() == null) { badge.setOnClickListener(onBadgeClick); } + + keys.removeAllViews(); + LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); + for (Iterator iterator = contact.getOtrFingerprints().iterator(); iterator + .hasNext();) { + String otrFingerprint = iterator.next(); + View view = (View) inflater.inflate(R.layout.contact_key, null); + TextView key = (TextView) view.findViewById(R.id.key); + TextView keyType =(TextView) view.findViewById(R.id.key_type); + keyType.setText("OTR Fingerprint"); + key.setText(otrFingerprint); + keys.addView(view); + } + Log.d("gultsch","pgp key id "+contact.getPgpKeyId()); + if (contact.getPgpKeyId()!=0) { + View view = (View) inflater.inflate(R.layout.contact_key, null); + TextView key = (TextView) view.findViewById(R.id.key); + TextView keyType =(TextView) view.findViewById(R.id.key_type); + keyType.setText("PGP Key ID"); + BigInteger bi = new BigInteger(""+contact.getPgpKeyId()); + StringBuilder builder = new StringBuilder(bi.toString(16).toUpperCase()); + builder.insert(8, " "); + key.setText(builder.toString()); + keys.addView(view); + } } @Override