aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoriNPUTmice <daniel@gultsch.de>2014-06-01 10:22:42 +0200
committeriNPUTmice <daniel@gultsch.de>2014-06-01 10:22:42 +0200
commit5d0e1374b27022d41e0ff59449191422aeaf2974 (patch)
treea52444737f261df131f331931e1ad4351f5cac8f
parentca49603c8575f965f3b096ba65a53af214429cb8 (diff)
OpenPGP key display in muc details is now prettier and linked to openkeychain
-rw-r--r--res/layout/contact.xml9
-rw-r--r--src/eu/siacs/conversations/crypto/PgpEngine.java9
-rw-r--r--src/eu/siacs/conversations/ui/MucDetailsActivity.java37
3 files changed, 46 insertions, 9 deletions
diff --git a/res/layout/contact.xml b/res/layout/contact.xml
index fcf8e8b9..7303d2ba 100644
--- a/res/layout/contact.xml
+++ b/res/layout/contact.xml
@@ -35,6 +35,15 @@
android:textColor="#5b5b5b"
android:singleLine="true"
/>
+ <TextView
+ android:id="@+id/key"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:textSize="18sp"
+ android:textColor="#5b5b5b"
+ android:typeface="monospace"
+ android:visibility="gone"
+ />
</LinearLayout>
</RelativeLayout> \ No newline at end of file
diff --git a/src/eu/siacs/conversations/crypto/PgpEngine.java b/src/eu/siacs/conversations/crypto/PgpEngine.java
index b10275f6..3b78db5e 100644
--- a/src/eu/siacs/conversations/crypto/PgpEngine.java
+++ b/src/eu/siacs/conversations/crypto/PgpEngine.java
@@ -303,4 +303,13 @@ public class PgpEngine {
Intent result = api.executeApi(params, null, null);
return (PendingIntent) result.getParcelableExtra(OpenPgpApi.RESULT_INTENT);
}
+
+ public PendingIntent getIntentForKey(Account account, long pgpKeyId) {
+ Intent params = new Intent();
+ params.setAction(OpenPgpApi.ACTION_GET_KEY);
+ params.putExtra(OpenPgpApi.EXTRA_KEY_ID, pgpKeyId);
+ params.putExtra(OpenPgpApi.EXTRA_ACCOUNT_NAME, account.getJid());
+ Intent result = api.executeApi(params, null, null);
+ return (PendingIntent) result.getParcelableExtra(OpenPgpApi.RESULT_INTENT);
+ }
}
diff --git a/src/eu/siacs/conversations/ui/MucDetailsActivity.java b/src/eu/siacs/conversations/ui/MucDetailsActivity.java
index 48cf6e81..cb994137 100644
--- a/src/eu/siacs/conversations/ui/MucDetailsActivity.java
+++ b/src/eu/siacs/conversations/ui/MucDetailsActivity.java
@@ -6,13 +6,16 @@ import java.util.List;
import org.openintents.openpgp.util.OpenPgpUtils;
import eu.siacs.conversations.R;
+import eu.siacs.conversations.crypto.PgpEngine;
import eu.siacs.conversations.entities.Conversation;
import eu.siacs.conversations.entities.MucOptions;
import eu.siacs.conversations.entities.MucOptions.User;
import eu.siacs.conversations.utils.UIHelper;
+import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
+import android.content.IntentSender.SendIntentException;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.util.Log;
@@ -169,19 +172,35 @@ public class MucDetailsActivity extends XmppActivity {
}
this.users.clear();
this.users.addAll(conversation.getMucOptions().getUsers());
- //contactsAdapter.notifyDataSetChanged();
LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
membersView.removeAllViews();
- for(User contact : conversation.getMucOptions().getUsers()) {
+ for(final User contact : conversation.getMucOptions().getUsers()) {
View view = (View) inflater.inflate(R.layout.contact, null);
-
- ((TextView) view.findViewById(R.id.contact_display_name))
- .setText(contact.getName());
+ TextView displayName = (TextView) view.findViewById(R.id.contact_display_name);
+ TextView key = (TextView) view.findViewById(R.id.key);
+ displayName.setText(contact.getName());
TextView role = (TextView) view.findViewById(R.id.contact_jid);
- if (contact.getPgpKeyId()==0) {
- role.setText(getReadableRole(contact.getRole()));
- } else {
- role.setText(getReadableRole(contact.getRole())+" \u00B7 "+OpenPgpUtils.convertKeyIdToHex(contact.getPgpKeyId()));
+ role.setText(getReadableRole(contact.getRole()));
+ if (contact.getPgpKeyId()!=0) {
+ key.setVisibility(View.VISIBLE);
+ key.setOnClickListener(new OnClickListener() {
+
+ @Override
+ public void onClick(View v) {
+ PgpEngine pgp = xmppConnectionService.getPgpEngine();
+ if (pgp!=null) {
+ PendingIntent intent = pgp.getIntentForKey(conversation.getAccount(), contact.getPgpKeyId());
+ if (intent!=null) {
+ try {
+ startIntentSenderForResult(intent.getIntentSender(), 0, null, 0, 0, 0);
+ } catch (SendIntentException e) {
+
+ }
+ }
+ }
+ }
+ });
+ key.setText(OpenPgpUtils.convertKeyIdToHex(contact.getPgpKeyId()));
}
ImageView imageView = (ImageView) view
.findViewById(R.id.contact_photo);