diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AccountSettingsFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AccountSettingsFragment.java index 8468f5eca..2cab23e51 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AccountSettingsFragment.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AccountSettingsFragment.java @@ -36,6 +36,8 @@ import org.sufficientlysecure.keychain.pgp.KeyRing; import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralException; import org.sufficientlysecure.keychain.provider.ProviderHelper; import org.sufficientlysecure.keychain.remote.AccountSettings; +import org.sufficientlysecure.keychain.service.OperationResultParcel; +import org.sufficientlysecure.keychain.service.OperationResults; import org.sufficientlysecure.keychain.ui.CreateKeyActivity; import org.sufficientlysecure.keychain.ui.SelectSecretKeyLayoutFragment; import org.sufficientlysecure.keychain.ui.adapter.KeyValueSpinnerAdapter; @@ -177,24 +179,19 @@ public class AccountSettingsFragment extends Fragment implements switch (requestCode) { case REQUEST_CODE_CREATE_KEY: { if (resultCode == Activity.RESULT_OK) { - // select newly created key - try { - long masterKeyId = new ProviderHelper(getActivity()) - .getCachedPublicKeyRing(data.getData()) - .extractOrGetMasterKeyId(); - mSelectKeyFragment.selectKey(masterKeyId); - } catch (PgpGeneralException e) { - Log.e(Constants.TAG, "key not found!", e); + if (data != null && data.hasExtra(OperationResultParcel.EXTRA_RESULT)) { + OperationResults.SaveKeyringResult result = data.getParcelableExtra(OperationResultParcel.EXTRA_RESULT); + mSelectKeyFragment.selectKey(result.mRingMasterKeyId); + } else { + Log.e(Constants.TAG, "missing result!"); } } break; } - - default: - super.onActivityResult(requestCode, resultCode, data); - - break; } + + // execute activity's onActivityResult to show log notify + super.onActivityResult(requestCode, resultCode, data); } /** diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/CreateKeyFinalFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/CreateKeyFinalFragment.java index 076f52a10..d804b9b70 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/CreateKeyFinalFragment.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/CreateKeyFinalFragment.java @@ -187,7 +187,7 @@ public class CreateKeyFinalFragment extends Fragment { getActivity().startService(intent); } - private void uploadKey(final OperationResults.SaveKeyringResult editKeyResult) { + private void uploadKey(final OperationResults.SaveKeyringResult saveKeyResult) { // Send all information needed to service to upload key in other thread final Intent intent = new Intent(getActivity(), KeychainIntentService.class); @@ -195,7 +195,7 @@ public class CreateKeyFinalFragment extends Fragment { // set data uri as path to keyring Uri blobUri = KeychainContract.KeyRings.buildUnifiedKeyRingUri( - editKeyResult.mRingMasterKeyId); + saveKeyResult.mRingMasterKeyId); intent.setData(blobUri); // fill values for this action @@ -221,7 +221,7 @@ public class CreateKeyFinalFragment extends Fragment { //Notify.Style.INFO); Intent data = new Intent(); - data.putExtra(OperationResultParcel.EXTRA_RESULT, editKeyResult); + data.putExtra(OperationResultParcel.EXTRA_RESULT, saveKeyResult); getActivity().setResult(Activity.RESULT_OK, data); getActivity().finish(); }