Fix result handling in account settings

This commit is contained in:
Dominik Schürmann 2014-08-21 00:29:49 +02:00
parent ad9339b23d
commit d1ef355f55
2 changed files with 13 additions and 16 deletions

View File

@ -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);
}
/**

View File

@ -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();
}