aboutsummaryrefslogtreecommitdiffstats
path: root/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyYubiKeyFragment.java
diff options
context:
space:
mode:
authorAdithya Abraham Philip <adithyaphilip@gmail.com>2015-06-24 01:46:34 +0530
committerAdithya Abraham Philip <adithyaphilip@gmail.com>2015-06-27 01:20:23 +0530
commitde4b203150cfe542cdba7003bc9cc249b5d22b7f (patch)
tree402e6476ef4125821a46538df172695652ebd236 /OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyYubiKeyFragment.java
parent6e425e95f55c16cbc61dd60a4f84aca60af71215 (diff)
downloadopen-keychain-de4b203150cfe542cdba7003bc9cc249b5d22b7f.tar.gz
open-keychain-de4b203150cfe542cdba7003bc9cc249b5d22b7f.tar.bz2
open-keychain-de4b203150cfe542cdba7003bc9cc249b5d22b7f.zip
migrated promote op to KeychainNewService
Diffstat (limited to 'OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyYubiKeyFragment.java')
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyYubiKeyFragment.java58
1 files changed, 19 insertions, 39 deletions
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyYubiKeyFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyYubiKeyFragment.java
index ab25341d3..c2db5e018 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyYubiKeyFragment.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyYubiKeyFragment.java
@@ -44,11 +44,14 @@ import org.sufficientlysecure.keychain.operations.results.PromoteKeyResult;
import org.sufficientlysecure.keychain.pgp.CanonicalizedSecretKey.SecretKeyType;
import org.sufficientlysecure.keychain.provider.KeychainContract.Keys;
import org.sufficientlysecure.keychain.service.KeychainService;
+import org.sufficientlysecure.keychain.service.PromoteKeyringParcel;
import org.sufficientlysecure.keychain.service.ServiceProgressHandler;
+import org.sufficientlysecure.keychain.ui.base.CryptoOperationFragment;
import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils;
-public class ViewKeyYubiKeyFragment extends Fragment
+public class ViewKeyYubiKeyFragment
+ extends CryptoOperationFragment<PromoteKeyringParcel, PromoteKeyResult>
implements LoaderCallbacks<Cursor> {
public static final String ARG_MASTER_KEY_ID = "master_key_id";
@@ -60,6 +63,8 @@ public class ViewKeyYubiKeyFragment extends Fragment
private String mUserId;
private byte[] mCardAid;
private long mMasterKeyId;
+ private long[] mSubKeyIds;
+
private Button vButton;
private TextView vStatus;
@@ -127,50 +132,15 @@ public class ViewKeyYubiKeyFragment extends Fragment
}
public void promoteToSecretKey() {
-
- ServiceProgressHandler saveHandler = new ServiceProgressHandler(getActivity()) {
- @Override
- public void handleMessage(Message message) {
- // handle messages by standard KeychainIntentServiceHandler first
- super.handleMessage(message);
-
- if (message.arg1 == MessageStatus.OKAY.ordinal()) {
- // get returned data bundle
- Bundle returnData = message.getData();
-
- PromoteKeyResult result =
- returnData.getParcelable(DecryptVerifyResult.EXTRA_RESULT);
-
- result.createNotify(getActivity()).show();
- }
-
- }
- };
-
- // Send all information needed to service to decrypt in other thread
- Intent intent = new Intent(getActivity(), KeychainService.class);
-
- // fill values for this action
-
- intent.setAction(KeychainService.ACTION_PROMOTE_KEYRING);
-
- Bundle data = new Bundle();
- data.putLong(KeychainService.PROMOTE_MASTER_KEY_ID, mMasterKeyId);
- data.putByteArray(KeychainService.PROMOTE_CARD_AID, mCardAid);
long[] subKeyIds = new long[mFingerprints.length];
for (int i = 0; i < subKeyIds.length; i++) {
subKeyIds[i] = KeyFormattingUtils.getKeyIdFromFingerprint(mFingerprints[i]);
}
- data.putLongArray(KeychainService.PROMOTE_SUBKEY_IDS, subKeyIds);
- intent.putExtra(KeychainService.EXTRA_DATA, data);
-
- // Create a new Messenger for the communication back
- Messenger messenger = new Messenger(saveHandler);
- intent.putExtra(KeychainService.EXTRA_MESSENGER, messenger);
- // start service with intent
- getActivity().startService(intent);
+ // mMasterKeyId and mCardAid are already set
+ mSubKeyIds = subKeyIds;
+ cryptoOperation();
}
public static final String[] PROJECTION = new String[]{
@@ -240,4 +210,14 @@ public class ViewKeyYubiKeyFragment extends Fragment
public void onLoaderReset(Loader<Cursor> loader) {
}
+
+ @Override
+ protected PromoteKeyringParcel createOperationInput() {
+ return new PromoteKeyringParcel(mMasterKeyId, mCardAid, mSubKeyIds);
+ }
+
+ @Override
+ protected void onCryptoOperationResult(PromoteKeyResult result) {
+ result.createNotify(getActivity()).show();
+ }
}