link to openkeychain from contact details
This commit is contained in:
parent
a14a28973a
commit
3b8446e6d5
|
@ -274,9 +274,7 @@ public class PgpEngine {
|
||||||
params.setAction(OpenPgpApi.ACTION_GET_KEY);
|
params.setAction(OpenPgpApi.ACTION_GET_KEY);
|
||||||
params.putExtra(OpenPgpApi.EXTRA_KEY_ID, contact.getPgpKeyId());
|
params.putExtra(OpenPgpApi.EXTRA_KEY_ID, contact.getPgpKeyId());
|
||||||
params.putExtra(OpenPgpApi.EXTRA_ACCOUNT_NAME, contact.getAccount().getJid());
|
params.putExtra(OpenPgpApi.EXTRA_ACCOUNT_NAME, contact.getAccount().getJid());
|
||||||
InputStream is = new ByteArrayInputStream(new byte[0]);
|
api.executeApiAsync(params, null, null, new IOpenPgpCallback() {
|
||||||
OutputStream os = new ByteArrayOutputStream();
|
|
||||||
api.executeApiAsync(params, is, os, new IOpenPgpCallback() {
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onReturn(Intent result) {
|
public void onReturn(Intent result) {
|
||||||
|
@ -296,4 +294,13 @@ public class PgpEngine {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public PendingIntent getIntentForKey(Contact contact) {
|
||||||
|
Intent params = new Intent();
|
||||||
|
params.setAction(OpenPgpApi.ACTION_GET_KEY);
|
||||||
|
params.putExtra(OpenPgpApi.EXTRA_KEY_ID, contact.getPgpKeyId());
|
||||||
|
params.putExtra(OpenPgpApi.EXTRA_ACCOUNT_NAME, contact.getAccount().getJid());
|
||||||
|
Intent result = api.executeApi(params, null, null);
|
||||||
|
return (PendingIntent) result.getParcelableExtra(OpenPgpApi.RESULT_INTENT);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,10 +4,14 @@ import java.math.BigInteger;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
|
import org.openintents.openpgp.util.OpenPgpUtils;
|
||||||
|
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
|
import android.app.PendingIntent;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.content.IntentSender.SendIntentException;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.provider.ContactsContract.CommonDataKinds;
|
import android.provider.ContactsContract.CommonDataKinds;
|
||||||
|
@ -26,6 +30,7 @@ import android.widget.QuickContactBadge;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
import eu.siacs.conversations.R;
|
import eu.siacs.conversations.R;
|
||||||
|
import eu.siacs.conversations.crypto.PgpEngine;
|
||||||
import eu.siacs.conversations.entities.Contact;
|
import eu.siacs.conversations.entities.Contact;
|
||||||
import eu.siacs.conversations.entities.Presences;
|
import eu.siacs.conversations.entities.Presences;
|
||||||
import eu.siacs.conversations.utils.UIHelper;
|
import eu.siacs.conversations.utils.UIHelper;
|
||||||
|
@ -252,17 +257,29 @@ public class ContactDetailsActivity extends XmppActivity {
|
||||||
key.setText(otrFingerprint);
|
key.setText(otrFingerprint);
|
||||||
keys.addView(view);
|
keys.addView(view);
|
||||||
}
|
}
|
||||||
Log.d("gultsch", "pgp key id " + contact.getPgpKeyId());
|
|
||||||
if (contact.getPgpKeyId() != 0) {
|
if (contact.getPgpKeyId() != 0) {
|
||||||
View view = (View) inflater.inflate(R.layout.contact_key, null);
|
View view = (View) inflater.inflate(R.layout.contact_key, null);
|
||||||
TextView key = (TextView) view.findViewById(R.id.key);
|
TextView key = (TextView) view.findViewById(R.id.key);
|
||||||
TextView keyType = (TextView) view.findViewById(R.id.key_type);
|
TextView keyType = (TextView) view.findViewById(R.id.key_type);
|
||||||
keyType.setText("PGP Key ID");
|
keyType.setText("PGP Key ID");
|
||||||
BigInteger bi = new BigInteger("" + contact.getPgpKeyId());
|
key.setText(OpenPgpUtils.convertKeyIdToHex(contact.getPgpKeyId()));
|
||||||
StringBuilder builder = new StringBuilder(bi.toString(16)
|
view.setOnClickListener(new OnClickListener() {
|
||||||
.toUpperCase(Locale.US));
|
|
||||||
builder.insert(8, " ");
|
@Override
|
||||||
key.setText(builder.toString());
|
public void onClick(View v) {
|
||||||
|
PgpEngine pgp = activity.xmppConnectionService.getPgpEngine();
|
||||||
|
if (pgp!=null) {
|
||||||
|
PendingIntent intent = pgp.getIntentForKey(contact);
|
||||||
|
if (intent!=null) {
|
||||||
|
try {
|
||||||
|
startIntentSenderForResult(intent.getIntentSender(), 0, null, 0, 0, 0);
|
||||||
|
} catch (SendIntentException e) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
keys.addView(view);
|
keys.addView(view);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue