diff --git a/src/main/java/eu/siacs/conversations/crypto/PgpEngine.java b/src/main/java/eu/siacs/conversations/crypto/PgpEngine.java index 3c406973e..ce04508f4 100644 --- a/src/main/java/eu/siacs/conversations/crypto/PgpEngine.java +++ b/src/main/java/eu/siacs/conversations/crypto/PgpEngine.java @@ -209,12 +209,11 @@ public class PgpEngine { }); } - public void generateSignature(final Account account, String status, - final UiCallback callback) { + public void generateSignature(Intent intent, final Account account, String status, final UiCallback callback) { if (account.getPgpId() == 0) { return; } - Intent params = new Intent(); + Intent params = intent == null ? new Intent() : intent; params.setAction(OpenPgpApi.ACTION_CLEARTEXT_SIGN); params.putExtra(OpenPgpApi.EXTRA_REQUEST_ASCII_ARMOR, true); params.putExtra(OpenPgpApi.EXTRA_SIGN_KEY_ID, account.getPgpId()); diff --git a/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java b/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java index f8f515981..3e161f9b1 100644 --- a/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java @@ -913,7 +913,7 @@ public class ConversationActivity extends XmppActivity conversation.setNextEncryption(Message.ENCRYPTION_PGP); item.setChecked(true); } else { - announcePgp(conversation.getAccount(), conversation, onOpenPGPKeyPublished); + announcePgp(conversation.getAccount(), conversation,null, onOpenPGPKeyPublished); } } else { showInstallPgpDialog(); @@ -1420,7 +1420,7 @@ public class ConversationActivity extends XmppActivity // associate selected PGP keyId with the account mSelectedConversation.getAccount().setPgpSignId(data.getExtras().getLong(OpenPgpApi.EXTRA_SIGN_KEY_ID)); // we need to announce the key as described in XEP-027 - announcePgp(mSelectedConversation.getAccount(), null, onOpenPGPKeyPublished); + announcePgp(mSelectedConversation.getAccount(), null, null, onOpenPGPKeyPublished); } else { choosePgpSignId(mSelectedConversation.getAccount()); } @@ -1430,7 +1430,7 @@ public class ConversationActivity extends XmppActivity } } else if (requestCode == REQUEST_ANNOUNCE_PGP) { if (xmppConnectionServiceBound) { - announcePgp(mSelectedConversation.getAccount(), mSelectedConversation, onOpenPGPKeyPublished); + announcePgp(mSelectedConversation.getAccount(), mSelectedConversation,data, onOpenPGPKeyPublished); this.mPostponedActivityResult = null; } else { this.mPostponedActivityResult = new Pair<>(requestCode, data); diff --git a/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java b/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java index 4dd7f84b9..897bd7cbc 100644 --- a/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java +++ b/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java @@ -1510,7 +1510,7 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa return; } if (conversation.getAccount().getPgpSignature() == null) { - activity.announcePgp(conversation.getAccount(), conversation, activity.onOpenPGPKeyPublished); + activity.announcePgp(conversation.getAccount(), conversation, null, activity.onOpenPGPKeyPublished); return; } if (!mSendingPgpMessage.compareAndSet(false, true)) { diff --git a/src/main/java/eu/siacs/conversations/ui/ManageAccountActivity.java b/src/main/java/eu/siacs/conversations/ui/ManageAccountActivity.java index 378351958..defffd81a 100644 --- a/src/main/java/eu/siacs/conversations/ui/ManageAccountActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/ManageAccountActivity.java @@ -346,7 +346,7 @@ public class ManageAccountActivity extends XmppActivity implements OnAccountUpda private void publishOpenPGPPublicKey(Account account) { if (ManageAccountActivity.this.hasPgp()) { - announcePgp(selectedAccount, null, onOpenPGPKeyPublished); + announcePgp(selectedAccount, null,null, onOpenPGPKeyPublished); } else { this.showInstallPgpDialog(); } @@ -378,12 +378,12 @@ public class ManageAccountActivity extends XmppActivity implements OnAccountUpda if (requestCode == REQUEST_CHOOSE_PGP_ID) { if (data.getExtras().containsKey(OpenPgpApi.EXTRA_SIGN_KEY_ID)) { selectedAccount.setPgpSignId(data.getExtras().getLong(OpenPgpApi.EXTRA_SIGN_KEY_ID)); - announcePgp(selectedAccount, null, onOpenPGPKeyPublished); + announcePgp(selectedAccount, null, null, onOpenPGPKeyPublished); } else { choosePgpSignId(selectedAccount); } } else if (requestCode == REQUEST_ANNOUNCE_PGP) { - announcePgp(selectedAccount, null, onOpenPGPKeyPublished); + announcePgp(selectedAccount, null, data, onOpenPGPKeyPublished); } this.mPostponedActivityResult = null; } else { diff --git a/src/main/java/eu/siacs/conversations/ui/SetPresenceActivity.java b/src/main/java/eu/siacs/conversations/ui/SetPresenceActivity.java index ca1fb8f7c..38f51d4db 100644 --- a/src/main/java/eu/siacs/conversations/ui/SetPresenceActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/SetPresenceActivity.java @@ -94,7 +94,7 @@ public class SetPresenceActivity extends XmppActivity implements View.OnClickLis if (resultCode == RESULT_OK) { if (xmppConnectionServiceBound && mAccount != null) { if (requestCode == REQUEST_ANNOUNCE_PGP) { - announcePgp(mAccount, null, onPresenceChanged); + announcePgp(mAccount, null,data, onPresenceChanged); } this.mPostponedActivityResult = null; } else { @@ -116,7 +116,7 @@ public class SetPresenceActivity extends XmppActivity implements View.OnClickLis finish(); } else { xmppConnectionService.changeStatus(mAccount, status, statusMessage, false); - announcePgp(mAccount, null, onPresenceChanged); + announcePgp(mAccount, null,null, onPresenceChanged); } } } diff --git a/src/main/java/eu/siacs/conversations/ui/XmppActivity.java b/src/main/java/eu/siacs/conversations/ui/XmppActivity.java index e23dfd568..8bf84af0c 100644 --- a/src/main/java/eu/siacs/conversations/ui/XmppActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/XmppActivity.java @@ -543,7 +543,7 @@ public abstract class XmppActivity extends Activity { startActivityForResult(intent, REQUEST_INVITE_TO_CONVERSATION); } - protected void announcePgp(Account account, final Conversation conversation, final Runnable onSuccess) { + protected void announcePgp(Account account, final Conversation conversation, Intent intent, final Runnable onSuccess) { if (account.getPgpId() == 0) { choosePgpSignId(account); } else { @@ -554,7 +554,7 @@ public abstract class XmppActivity extends Activity { if (status == null) { status = ""; } - xmppConnectionService.getPgpEngine().generateSignature(account, status, new UiCallback() { + xmppConnectionService.getPgpEngine().generateSignature(intent, account, status, new UiCallback() { @Override public void userInputRequried(PendingIntent pi, Account account) {