org.openintents.openpgp.util.OpenPgpApi Java Examples
The following examples show how to use
org.openintents.openpgp.util.OpenPgpApi.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ManageAccountActivity.java From Conversations with GNU General Public License v3.0 | 6 votes |
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (resultCode == RESULT_OK) { if (xmppConnectionServiceBound) { 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, null, onOpenPGPKeyPublished); } else { choosePgpSignId(selectedAccount); } } else if (requestCode == REQUEST_ANNOUNCE_PGP) { announcePgp(selectedAccount, null, data, onOpenPGPKeyPublished); } this.mPostponedActivityResult = null; } else { this.mPostponedActivityResult = new Pair<>(requestCode, data); } } }
Example #2
Source File: ConversationsActivity.java From Conversations with GNU General Public License v3.0 | 6 votes |
private void handlePositiveActivityResult(int requestCode, final Intent data) { Conversation conversation = ConversationFragment.getConversationReliable(this); if (conversation == null) { Log.d(Config.LOGTAG, "conversation not found"); return; } switch (requestCode) { case REQUEST_DECRYPT_PGP: conversation.getAccount().getPgpDecryptionService().continueDecryption(data); break; case REQUEST_CHOOSE_PGP_ID: long id = data.getLongExtra(OpenPgpApi.EXTRA_SIGN_KEY_ID, 0); if (id != 0) { conversation.getAccount().setPgpSignId(id); announcePgp(conversation.getAccount(), null, null, onOpenPGPKeyPublished); } else { choosePgpSignId(conversation.getAccount()); } break; case REQUEST_ANNOUNCE_PGP: announcePgp(conversation.getAccount(), conversation, data, onOpenPGPKeyPublished); break; } }
Example #3
Source File: PgpEngine.java From Conversations with GNU General Public License v3.0 | 6 votes |
public void hasKey(final Contact contact, final UiCallback<Contact> callback) { Intent params = new Intent(); params.setAction(OpenPgpApi.ACTION_GET_KEY); params.putExtra(OpenPgpApi.EXTRA_KEY_ID, contact.getPgpKeyId()); api.executeApiAsync(params, null, null, new IOpenPgpCallback() { @Override public void onReturn(Intent result) { switch (result.getIntExtra(OpenPgpApi.RESULT_CODE, 0)) { case OpenPgpApi.RESULT_CODE_SUCCESS: callback.success(contact); return; case OpenPgpApi.RESULT_CODE_USER_INTERACTION_REQUIRED: callback.userInputRequired(result.getParcelableExtra(OpenPgpApi.RESULT_INTENT), contact); return; case OpenPgpApi.RESULT_CODE_ERROR: logError(contact.getAccount(), result.getParcelableExtra(OpenPgpApi.RESULT_ERROR)); callback.error(R.string.openpgp_error, contact); } } }); }
Example #4
Source File: PgpEngine.java From Conversations with GNU General Public License v3.0 | 6 votes |
public void chooseKey(final Account account, final UiCallback<Account> callback) { Intent p = new Intent(); p.setAction(OpenPgpApi.ACTION_GET_SIGN_KEY_ID); api.executeApiAsync(p, null, null, result -> { switch (result.getIntExtra(OpenPgpApi.RESULT_CODE, 0)) { case OpenPgpApi.RESULT_CODE_SUCCESS: callback.success(account); return; case OpenPgpApi.RESULT_CODE_USER_INTERACTION_REQUIRED: callback.userInputRequired(result.getParcelableExtra(OpenPgpApi.RESULT_INTENT), account); return; case OpenPgpApi.RESULT_CODE_ERROR: logError(account, result.getParcelableExtra(OpenPgpApi.RESULT_ERROR)); callback.error(R.string.openpgp_error, account); } }); }
Example #5
Source File: PgpEngine.java From Pix-Art-Messenger with GNU General Public License v3.0 | 6 votes |
public void chooseKey(final Account account, final UiCallback<Account> callback) { Intent p = new Intent(); p.setAction(OpenPgpApi.ACTION_GET_SIGN_KEY_ID); api.executeApiAsync(p, null, null, result -> { switch (result.getIntExtra(OpenPgpApi.RESULT_CODE, 0)) { case OpenPgpApi.RESULT_CODE_SUCCESS: callback.success(account); return; case OpenPgpApi.RESULT_CODE_USER_INTERACTION_REQUIRED: callback.userInputRequired(result.getParcelableExtra(OpenPgpApi.RESULT_INTENT), account); return; case OpenPgpApi.RESULT_CODE_ERROR: logError(account, result.getParcelableExtra(OpenPgpApi.RESULT_ERROR)); callback.error(R.string.openpgp_error, account); } }); }
Example #6
Source File: PgpEngine.java From Pix-Art-Messenger with GNU General Public License v3.0 | 6 votes |
public void hasKey(final Contact contact, final UiCallback<Contact> callback) { Intent params = new Intent(); params.setAction(OpenPgpApi.ACTION_GET_KEY); params.putExtra(OpenPgpApi.EXTRA_KEY_ID, contact.getPgpKeyId()); api.executeApiAsync(params, null, null, new IOpenPgpCallback() { @Override public void onReturn(Intent result) { switch (result.getIntExtra(OpenPgpApi.RESULT_CODE, 0)) { case OpenPgpApi.RESULT_CODE_SUCCESS: callback.success(contact); return; case OpenPgpApi.RESULT_CODE_USER_INTERACTION_REQUIRED: callback.userInputRequired(result.getParcelableExtra(OpenPgpApi.RESULT_INTENT), contact); return; case OpenPgpApi.RESULT_CODE_ERROR: logError(contact.getAccount(), result.getParcelableExtra(OpenPgpApi.RESULT_ERROR)); callback.error(R.string.openpgp_error, contact); } } }); }
Example #7
Source File: ManageAccountActivity.java From Pix-Art-Messenger with GNU General Public License v3.0 | 6 votes |
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (resultCode == RESULT_OK) { if (xmppConnectionServiceBound) { 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, null, onOpenPGPKeyPublished); } else { choosePgpSignId(selectedAccount); } } else if (requestCode == REQUEST_ANNOUNCE_PGP) { announcePgp(selectedAccount, null, data, onOpenPGPKeyPublished); } this.mPostponedActivityResult = null; } else { this.mPostponedActivityResult = new Pair<>(requestCode, data); } } }
Example #8
Source File: ConversationsActivity.java From Pix-Art-Messenger with GNU General Public License v3.0 | 6 votes |
private void handlePositiveActivityResult(int requestCode, final Intent data) { Log.d(Config.LOGTAG, "positive activity result"); Conversation conversation = ConversationFragment.getConversationReliable(this); if (conversation == null) { Log.d(Config.LOGTAG, "conversation not found"); return; } switch (requestCode) { case REQUEST_DECRYPT_PGP: conversation.getAccount().getPgpDecryptionService().continueDecryption(data); break; case REQUEST_CHOOSE_PGP_ID: long id = data.getLongExtra(OpenPgpApi.EXTRA_SIGN_KEY_ID, 0); if (id != 0) { conversation.getAccount().setPgpSignId(id); announcePgp(conversation.getAccount(), null, null, onOpenPGPKeyPublished); } else { choosePgpSignId(conversation.getAccount()); } break; case REQUEST_ANNOUNCE_PGP: announcePgp(conversation.getAccount(), conversation, data, onOpenPGPKeyPublished); break; } }
Example #9
Source File: OpenPgpApiActivity.java From openpgp-api with Apache License 2.0 | 5 votes |
public void signAndEncrypt(Intent data) { data.setAction(OpenPgpApi.ACTION_SIGN_AND_ENCRYPT); data.putExtra(OpenPgpApi.EXTRA_SIGN_KEY_ID, mSignKeyId); if (!TextUtils.isEmpty(mEncryptUserIds.getText().toString())) { data.putExtra(OpenPgpApi.EXTRA_USER_IDS, mEncryptUserIds.getText().toString().split(",")); } data.putExtra(OpenPgpApi.EXTRA_REQUEST_ASCII_ARMOR, true); InputStream is = getInputstream(false); ByteArrayOutputStream os = new ByteArrayOutputStream(); OpenPgpApi api = new OpenPgpApi(this, mServiceConnection.getService()); api.executeApiAsync(data, is, os, new MyCallback(true, os, REQUEST_CODE_SIGN_AND_ENCRYPT)); }
Example #10
Source File: PgpEngine.java From Conversations with GNU General Public License v3.0 | 5 votes |
public PendingIntent getIntentForKey(long pgpKeyId) { Intent params = new Intent(); params.setAction(OpenPgpApi.ACTION_GET_KEY); params.putExtra(OpenPgpApi.EXTRA_KEY_ID, pgpKeyId); Intent result = api.executeApi(params, null, null); return (PendingIntent) result.getParcelableExtra(OpenPgpApi.RESULT_INTENT); }
Example #11
Source File: OpenPgpApiActivity.java From openpgp-api with Apache License 2.0 | 5 votes |
public void backup(Intent data) { data.setAction(OpenPgpApi.ACTION_BACKUP); data.putExtra(OpenPgpApi.EXTRA_KEY_IDS, new long[]{Long.decode(mGetKeyEdit.getText().toString())}); data.putExtra(OpenPgpApi.EXTRA_BACKUP_SECRET, true); data.putExtra(OpenPgpApi.EXTRA_REQUEST_ASCII_ARMOR, true); ByteArrayOutputStream os = new ByteArrayOutputStream(); OpenPgpApi api = new OpenPgpApi(this, mServiceConnection.getService()); api.executeApiAsync(data, null, os, new MyCallback(true, os, REQUEST_CODE_BACKUP)); }
Example #12
Source File: OpenPgpApiActivity.java From openpgp-api with Apache License 2.0 | 5 votes |
public void getKeyIds(Intent data) { data.setAction(OpenPgpApi.ACTION_GET_KEY_IDS); data.putExtra(OpenPgpApi.EXTRA_USER_IDS, mGetKeyIdsEdit.getText().toString().split(",")); OpenPgpApi api = new OpenPgpApi(this, mServiceConnection.getService()); api.executeApiAsync(data, null, null, new MyCallback(false, null, REQUEST_CODE_GET_KEY_IDS)); }
Example #13
Source File: OpenPgpApiActivity.java From openpgp-api with Apache License 2.0 | 5 votes |
public void getKey(Intent data) { data.setAction(OpenPgpApi.ACTION_GET_KEY); data.putExtra(OpenPgpApi.EXTRA_KEY_ID, Long.decode(mGetKeyEdit.getText().toString())); OpenPgpApi api = new OpenPgpApi(this, mServiceConnection.getService()); api.executeApiAsync(data, null, null, new MyCallback(false, null, REQUEST_CODE_GET_KEY)); }
Example #14
Source File: OpenPgpApiActivity.java From openpgp-api with Apache License 2.0 | 5 votes |
public void decryptAndVerifyDetached(Intent data) { data.setAction(OpenPgpApi.ACTION_DECRYPT_VERIFY); data.putExtra(OpenPgpApi.EXTRA_DETACHED_SIGNATURE, mDetachedSignature.getText().toString().getBytes()); // use from text from mMessage InputStream is = getInputstream(false); OpenPgpApi api = new OpenPgpApi(this, mServiceConnection.getService()); api.executeApiAsync(data, is, null, new MyCallback(false, null, REQUEST_CODE_DECRYPT_AND_VERIFY_DETACHED)); }
Example #15
Source File: OpenPgpApiActivity.java From openpgp-api with Apache License 2.0 | 5 votes |
public void decryptAndVerify(Intent data) { data.setAction(OpenPgpApi.ACTION_DECRYPT_VERIFY); InputStream is = getInputstream(true); ByteArrayOutputStream os = new ByteArrayOutputStream(); OpenPgpApi api = new OpenPgpApi(this, mServiceConnection.getService()); api.executeApiAsync(data, is, os, new MyCallback(false, os, REQUEST_CODE_DECRYPT_AND_VERIFY)); }
Example #16
Source File: Helper.java From FairEmail with GNU General Public License v3.0 | 5 votes |
static boolean isOpenKeychainInstalled(Context context) { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); String provider = prefs.getString("openpgp_provider", "org.sufficientlysecure.keychain"); PackageManager pm = context.getPackageManager(); Intent intent = new Intent(OpenPgpApi.SERVICE_INTENT_2); intent.setPackage(provider); List<ResolveInfo> ris = pm.queryIntentServices(intent, 0); return (ris.size() > 0); }
Example #17
Source File: OpenPgpApiActivity.java From openpgp-api with Apache License 2.0 | 5 votes |
public void encrypt(Intent data) { data.setAction(OpenPgpApi.ACTION_ENCRYPT); if (!TextUtils.isEmpty(mEncryptUserIds.getText().toString())) { data.putExtra(OpenPgpApi.EXTRA_USER_IDS, mEncryptUserIds.getText().toString().split(",")); } data.putExtra(OpenPgpApi.EXTRA_REQUEST_ASCII_ARMOR, true); InputStream is = getInputstream(false); ByteArrayOutputStream os = new ByteArrayOutputStream(); OpenPgpApi api = new OpenPgpApi(this, mServiceConnection.getService()); api.executeApiAsync(data, is, os, new MyCallback(true, os, REQUEST_CODE_ENCRYPT)); }
Example #18
Source File: OpenPgpApiActivity.java From openpgp-api with Apache License 2.0 | 5 votes |
public void detachedSign(Intent data) { data.setAction(OpenPgpApi.ACTION_DETACHED_SIGN); data.putExtra(OpenPgpApi.EXTRA_SIGN_KEY_ID, mSignKeyId); InputStream is = getInputstream(false); // no output stream needed, detached signature is returned as RESULT_DETACHED_SIGNATURE OpenPgpApi api = new OpenPgpApi(this, mServiceConnection.getService()); api.executeApiAsync(data, is, null, new MyCallback(true, null, REQUEST_CODE_DETACHED_SIGN)); }
Example #19
Source File: OpenPgpApiActivity.java From openpgp-api with Apache License 2.0 | 5 votes |
public void cleartextSign(Intent data) { data.setAction(OpenPgpApi.ACTION_CLEARTEXT_SIGN); data.putExtra(OpenPgpApi.EXTRA_SIGN_KEY_ID, mSignKeyId); InputStream is = getInputstream(false); ByteArrayOutputStream os = new ByteArrayOutputStream(); OpenPgpApi api = new OpenPgpApi(this, mServiceConnection.getService()); api.executeApiAsync(data, is, os, new MyCallback(true, os, REQUEST_CODE_CLEARTEXT_SIGN)); }
Example #20
Source File: PgpEngine.java From Pix-Art-Messenger with GNU General Public License v3.0 | 5 votes |
public PendingIntent getIntentForKey(long pgpKeyId) { Intent params = new Intent(); params.setAction(OpenPgpApi.ACTION_GET_KEY); params.putExtra(OpenPgpApi.EXTRA_KEY_ID, pgpKeyId); Intent result = api.executeApi(params, null, null); return (PendingIntent) result.getParcelableExtra(OpenPgpApi.RESULT_INTENT); }
Example #21
Source File: BackupActivity.java From andOTP with MIT License | 5 votes |
public void handleOpenPGPResult(Intent result, ByteArrayOutputStream os, Uri file, int requestCode) { if (result.getIntExtra(OpenPgpApi.RESULT_CODE, OpenPgpApi.RESULT_CODE_ERROR) == OpenPgpApi.RESULT_CODE_SUCCESS) { if (requestCode == Constants.INTENT_BACKUP_ENCRYPT_PGP) { if (os != null) doBackupEncrypted(file, outputStreamToString(os)); } else if (requestCode == Constants.INTENT_BACKUP_DECRYPT_PGP) { if (os != null) { if (settings.getOpenPGPVerify()) { OpenPgpSignatureResult sigResult = result.getParcelableExtra(OpenPgpApi.RESULT_SIGNATURE); if (sigResult.getResult() == OpenPgpSignatureResult.RESULT_VALID_KEY_CONFIRMED) { restoreEntries(outputStreamToString(os)); } else { Toast.makeText(this, R.string.backup_toast_openpgp_not_verified, Toast.LENGTH_LONG).show(); } } else { restoreEntries(outputStreamToString(os)); } } } } else if (result.getIntExtra(OpenPgpApi.RESULT_CODE, OpenPgpApi.RESULT_CODE_ERROR) == OpenPgpApi.RESULT_CODE_USER_INTERACTION_REQUIRED) { PendingIntent pi = result.getParcelableExtra(OpenPgpApi.RESULT_INTENT); // Small hack to keep the target file even after user interaction if (requestCode == Constants.INTENT_BACKUP_ENCRYPT_PGP) { encryptTargetFile = file; } else if (requestCode == Constants.INTENT_BACKUP_DECRYPT_PGP) { decryptSourceFile = file; } try { startIntentSenderForResult(pi.getIntentSender(), requestCode, null, 0, 0, 0); } catch (IntentSender.SendIntentException e) { e.printStackTrace(); } } else if (result.getIntExtra(OpenPgpApi.RESULT_CODE, OpenPgpApi.RESULT_CODE_ERROR) == OpenPgpApi.RESULT_CODE_ERROR) { OpenPgpError error = result.getParcelableExtra(OpenPgpApi.RESULT_ERROR); Toast.makeText(this, String.format(getString(R.string.backup_toast_openpgp_error), error.getMessage()), Toast.LENGTH_LONG).show(); } }
Example #22
Source File: OpenPgpApiActivity.java From openpgp-api with Apache License 2.0 | 4 votes |
public void getAnyKeyIds(Intent data) { data.setAction(OpenPgpApi.ACTION_GET_KEY_IDS); OpenPgpApi api = new OpenPgpApi(this, mServiceConnection.getService()); api.executeApiAsync(data, null, null, new MyCallback(false, null, REQUEST_CODE_GET_KEY_IDS)); }
Example #23
Source File: PgpDecryptionService.java From Conversations with GNU General Public License v3.0 | 4 votes |
private synchronized OpenPgpApi getOpenPgpApi() { if (openPgpApi == null) { this.openPgpApi = mXmppConnectionService.getOpenPgpApi(); } return this.openPgpApi; }
Example #24
Source File: PgpEngine.java From Conversations with GNU General Public License v3.0 | 4 votes |
public PgpEngine(OpenPgpApi api, XmppConnectionService service) { this.api = api; this.mXmppConnectionService = service; }
Example #25
Source File: PgpEngine.java From Conversations with GNU General Public License v3.0 | 4 votes |
public long fetchKeyId(Account account, String status, String signature) { if ((signature == null) || (api == null)) { return 0; } if (status == null) { status = ""; } final StringBuilder pgpSig = new StringBuilder(); pgpSig.append("-----BEGIN PGP SIGNED MESSAGE-----"); pgpSig.append('\n'); pgpSig.append('\n'); pgpSig.append(status); pgpSig.append('\n'); pgpSig.append("-----BEGIN PGP SIGNATURE-----"); pgpSig.append('\n'); pgpSig.append('\n'); pgpSig.append(signature.replace("\n", "").trim()); pgpSig.append('\n'); pgpSig.append("-----END PGP SIGNATURE-----"); Intent params = new Intent(); params.setAction(OpenPgpApi.ACTION_DECRYPT_VERIFY); params.putExtra(OpenPgpApi.EXTRA_REQUEST_ASCII_ARMOR, true); InputStream is = new ByteArrayInputStream(pgpSig.toString().getBytes()); ByteArrayOutputStream os = new ByteArrayOutputStream(); Intent result = api.executeApi(params, is, os); switch (result.getIntExtra(OpenPgpApi.RESULT_CODE, OpenPgpApi.RESULT_CODE_ERROR)) { case OpenPgpApi.RESULT_CODE_SUCCESS: OpenPgpSignatureResult sigResult = result .getParcelableExtra(OpenPgpApi.RESULT_SIGNATURE); if (sigResult != null) { return sigResult.getKeyId(); } else { return 0; } case OpenPgpApi.RESULT_CODE_USER_INTERACTION_REQUIRED: return 0; case OpenPgpApi.RESULT_CODE_ERROR: logError(account, result.getParcelableExtra(OpenPgpApi.RESULT_ERROR)); return 0; } return 0; }
Example #26
Source File: PgpEngine.java From Pix-Art-Messenger with GNU General Public License v3.0 | 4 votes |
public long fetchKeyId(Account account, String status, String signature) { if ((signature == null) || (api == null)) { return 0; } if (status == null) { status = ""; } final StringBuilder pgpSig = new StringBuilder(); pgpSig.append("-----BEGIN PGP SIGNED MESSAGE-----"); pgpSig.append('\n'); pgpSig.append('\n'); pgpSig.append(status); pgpSig.append('\n'); pgpSig.append("-----BEGIN PGP SIGNATURE-----"); pgpSig.append('\n'); pgpSig.append('\n'); pgpSig.append(signature.replace("\n", "").trim()); pgpSig.append('\n'); pgpSig.append("-----END PGP SIGNATURE-----"); Intent params = new Intent(); params.setAction(OpenPgpApi.ACTION_DECRYPT_VERIFY); params.putExtra(OpenPgpApi.EXTRA_REQUEST_ASCII_ARMOR, true); InputStream is = new ByteArrayInputStream(pgpSig.toString().getBytes()); ByteArrayOutputStream os = new ByteArrayOutputStream(); Intent result = api.executeApi(params, is, os); switch (result.getIntExtra(OpenPgpApi.RESULT_CODE, OpenPgpApi.RESULT_CODE_ERROR)) { case OpenPgpApi.RESULT_CODE_SUCCESS: OpenPgpSignatureResult sigResult = result .getParcelableExtra(OpenPgpApi.RESULT_SIGNATURE); if (sigResult != null) { return sigResult.getKeyId(); } else { return 0; } case OpenPgpApi.RESULT_CODE_USER_INTERACTION_REQUIRED: return 0; case OpenPgpApi.RESULT_CODE_ERROR: logError(account, result.getParcelableExtra(OpenPgpApi.RESULT_ERROR)); return 0; } return 0; }
Example #27
Source File: PgpEngine.java From Pix-Art-Messenger with GNU General Public License v3.0 | 4 votes |
public PgpEngine(OpenPgpApi api, XmppConnectionService service) { this.api = api; this.mXmppConnectionService = service; }
Example #28
Source File: PgpDecryptionService.java From Pix-Art-Messenger with GNU General Public License v3.0 | 4 votes |
private synchronized OpenPgpApi getOpenPgpApi() { if (openPgpApi == null) { this.openPgpApi = mXmppConnectionService.getOpenPgpApi(); } return this.openPgpApi; }
Example #29
Source File: GpgEncryptionParamsFragment.java From oversec with GNU General Public License v3.0 | 4 votes |
private void handleActivityResult() { if (mTempActivityResult != null) { int requestCode = mTempActivityResult.getRequestCode(); int resultCode = mTempActivityResult.getResultCode(); Intent data = mTempActivityResult.getData(); mTempActivityResult = null; if (requestCode == EncryptionParamsActivityContract.REQUEST_CODE_DOWNLOAD_KEY) { if (resultCode == Activity.RESULT_OK) { handleDownloadedKey(getActivity(), mTempDownloadKeyId, data); } else { // Ln.w("user cancelled pendingintent activity"); } } else if (requestCode == EncryptionParamsActivityContract.REQUEST_CODE_RECIPIENT_SELECTION) { if (resultCode == Activity.RESULT_OK) { if (data != null) { if (data.hasExtra(OpenPgpApi.EXTRA_KEY_IDS) || data.hasExtra("key_ids_selected"/*OpenPgpApi.EXTRA_KEY_IDS_SELECTED*/)) { long[] keyIds = new long[0]; if (data.hasExtra(OpenPgpApi.EXTRA_KEY_IDS)) { keyIds = data.getLongArrayExtra(OpenPgpApi.EXTRA_KEY_IDS); } else if (data.hasExtra("key_ids_selected"/*OpenPgpApi.EXTRA_KEY_IDS_SELECTED*/)) { keyIds = data.getLongArrayExtra("key_ids_selected"/*OpenPgpApi.EXTRA_KEY_IDS_SELECTED*/); } //not sure why Anal Studio / Gradle can't find the new EXTRA_KEY_IDS_SELECTED constant //also not sure why they had to change it, but well, need to check for both Long[] keys = new Long[keyIds.length]; for (int i = 0; i < keyIds.length; i++) { keys[i] = keyIds[i]; } if (keyIds != null && keyIds.length > 0) { mEditorPgpEncryptionParams.addPublicKeyIds(keys, getGpgEncryptionHandler(getActivity()).getGpgOwnPublicKeyId()); updatePgpRecipientsList(); } } else { triggerRecipientSelection(EncryptionParamsActivityContract.REQUEST_CODE_RECIPIENT_SELECTION, data); } } else { //Ln.w("REQUEST_CODE_RECIPIENT_SELECTION returned without data"); } } else { // Ln.w("REQUEST_CODE_RECIPIENT_SELECTION returned with result code %s" , resultCode); } } else if (requestCode == EncryptionParamsActivityContract.REQUEST_CODE_OWNSIGNATUREKEY_SELECTION) { if (resultCode == Activity.RESULT_OK) { if (data != null) { if (data.hasExtra(OpenPgpApi.EXTRA_SIGN_KEY_ID)) { long signKeyId = data.getLongExtra(OpenPgpApi.EXTRA_SIGN_KEY_ID, 0); mEditorPgpEncryptionParams.setOwnPublicKey(signKeyId); getGpgEncryptionHandler(getActivity()).setGpgOwnPublicKeyId(signKeyId); updatePgpOwnKey(); updatePgpRecipientsList(); } else { triggerSigningKeySelection(data); } } else { // Ln.w("ACTION_GET_SIGN_KEY_ID returned without data"); } } else { // Ln.w("ACTION_GET_SIGN_KEY_ID returned with result code %s", resultCode); } } } }