Disable move to card from edit screen

This commit is contained in:
Dominik Schürmann
2015-07-02 17:39:03 +02:00
parent 195508ed92
commit 9dac8ddbac
2 changed files with 45 additions and 39 deletions

View File

@@ -437,44 +437,50 @@ public class EditKeyFragment extends CryptoOperationFragment<SaveKeyringParcel,
} }
break; break;
} }
case EditSubkeyDialogFragment.MESSAGE_KEYTOCARD: { case EditSubkeyDialogFragment.MESSAGE_MOVE_KEY_TO_CARD: {
Activity activity = EditKeyFragment.this.getActivity(); // TODO: enable later when Admin PIN handling is resolved
SecretKeyType secretKeyType = mSubkeysAdapter.getSecretKeyType(position); Notify.create(getActivity(),
if (secretKeyType == SecretKeyType.DIVERT_TO_CARD || "This feature will be available in an upcoming OpenKeychain version.",
secretKeyType == SecretKeyType.GNU_DUMMY) { Notify.Style.WARN).show();
Notify.create(activity, R.string.edit_key_error_bad_nfc_stripped, Notify.Style.ERROR)
.show((ViewGroup) activity.findViewById(R.id.import_snackbar));
break; break;
}
int algorithm = mSubkeysAdapter.getAlgorithm(position);
// these are the PGP constants for RSA_GENERAL, RSA_ENCRYPT and RSA_SIGN
if (algorithm != 1 && algorithm != 2 && algorithm != 3) {
Notify.create(activity, R.string.edit_key_error_bad_nfc_algo, Notify.Style.ERROR)
.show((ViewGroup) activity.findViewById(R.id.import_snackbar));
break;
}
if (mSubkeysAdapter.getKeySize(position) != 2048) {
Notify.create(activity, R.string.edit_key_error_bad_nfc_size, Notify.Style.ERROR)
.show((ViewGroup) activity.findViewById(R.id.import_snackbar));
break;
}
// Activity activity = EditKeyFragment.this.getActivity();
SubkeyChange change; // SecretKeyType secretKeyType = mSubkeysAdapter.getSecretKeyType(position);
change = mSaveKeyringParcel.getSubkeyChange(keyId); // if (secretKeyType == SecretKeyType.DIVERT_TO_CARD ||
if (change == null) { // secretKeyType == SecretKeyType.GNU_DUMMY) {
mSaveKeyringParcel.mChangeSubKeys.add( // Notify.create(activity, R.string.edit_key_error_bad_nfc_stripped, Notify.Style.ERROR)
new SubkeyChange(keyId, false, true) // .show((ViewGroup) activity.findViewById(R.id.import_snackbar));
); // break;
break; // }
} // int algorithm = mSubkeysAdapter.getAlgorithm(position);
// toggle // // these are the PGP constants for RSA_GENERAL, RSA_ENCRYPT and RSA_SIGN
change.mMoveKeyToCard = !change.mMoveKeyToCard; // if (algorithm != 1 && algorithm != 2 && algorithm != 3) {
if (change.mMoveKeyToCard && change.mDummyStrip) { // Notify.create(activity, R.string.edit_key_error_bad_nfc_algo, Notify.Style.ERROR)
// User had chosen to strip key, but now wants to divert it. // .show((ViewGroup) activity.findViewById(R.id.import_snackbar));
change.mDummyStrip = false; // break;
} // }
break; // if (mSubkeysAdapter.getKeySize(position) != 2048) {
// Notify.create(activity, R.string.edit_key_error_bad_nfc_size, Notify.Style.ERROR)
// .show((ViewGroup) activity.findViewById(R.id.import_snackbar));
// break;
// }
//
//
// SubkeyChange change;
// change = mSaveKeyringParcel.getSubkeyChange(keyId);
// if (change == null) {
// mSaveKeyringParcel.mChangeSubKeys.add(
// new SubkeyChange(keyId, false, true)
// );
// break;
// }
// // toggle
// change.mMoveKeyToCard = !change.mMoveKeyToCard;
// if (change.mMoveKeyToCard && change.mDummyStrip) {
// // User had chosen to strip key, but now wants to divert it.
// change.mDummyStrip = false;
// }
// break;
} }
} }
getLoaderManager().getLoader(LOADER_ID_SUBKEYS).forceLoad(); getLoaderManager().getLoader(LOADER_ID_SUBKEYS).forceLoad();

View File

@@ -35,7 +35,7 @@ public class EditSubkeyDialogFragment extends DialogFragment {
public static final int MESSAGE_CHANGE_EXPIRY = 1; public static final int MESSAGE_CHANGE_EXPIRY = 1;
public static final int MESSAGE_REVOKE = 2; public static final int MESSAGE_REVOKE = 2;
public static final int MESSAGE_STRIP = 3; public static final int MESSAGE_STRIP = 3;
public static final int MESSAGE_KEYTOCARD = 4; public static final int MESSAGE_MOVE_KEY_TO_CARD = 4;
private Messenger mMessenger; private Messenger mMessenger;
@@ -78,7 +78,7 @@ public class EditSubkeyDialogFragment extends DialogFragment {
sendMessageToHandler(MESSAGE_STRIP, null); sendMessageToHandler(MESSAGE_STRIP, null);
break; break;
case 3: case 3:
sendMessageToHandler(MESSAGE_KEYTOCARD, null); sendMessageToHandler(MESSAGE_MOVE_KEY_TO_CARD, null);
break; break;
default: default:
break; break;