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;
}
case EditSubkeyDialogFragment.MESSAGE_KEYTOCARD: {
Activity activity = EditKeyFragment.this.getActivity();
SecretKeyType secretKeyType = mSubkeysAdapter.getSecretKeyType(position);
if (secretKeyType == SecretKeyType.DIVERT_TO_CARD ||
secretKeyType == SecretKeyType.GNU_DUMMY) {
Notify.create(activity, R.string.edit_key_error_bad_nfc_stripped, Notify.Style.ERROR)
.show((ViewGroup) activity.findViewById(R.id.import_snackbar));
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;
}
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;
}
case EditSubkeyDialogFragment.MESSAGE_MOVE_KEY_TO_CARD: {
// TODO: enable later when Admin PIN handling is resolved
Notify.create(getActivity(),
"This feature will be available in an upcoming OpenKeychain version.",
Notify.Style.WARN).show();
break;
// Activity activity = EditKeyFragment.this.getActivity();
// SecretKeyType secretKeyType = mSubkeysAdapter.getSecretKeyType(position);
// if (secretKeyType == SecretKeyType.DIVERT_TO_CARD ||
// secretKeyType == SecretKeyType.GNU_DUMMY) {
// Notify.create(activity, R.string.edit_key_error_bad_nfc_stripped, Notify.Style.ERROR)
// .show((ViewGroup) activity.findViewById(R.id.import_snackbar));
// 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;
// }
//
//
// 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();

View File

@@ -35,7 +35,7 @@ public class EditSubkeyDialogFragment extends DialogFragment {
public static final int MESSAGE_CHANGE_EXPIRY = 1;
public static final int MESSAGE_REVOKE = 2;
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;
@@ -78,7 +78,7 @@ public class EditSubkeyDialogFragment extends DialogFragment {
sendMessageToHandler(MESSAGE_STRIP, null);
break;
case 3:
sendMessageToHandler(MESSAGE_KEYTOCARD, null);
sendMessageToHandler(MESSAGE_MOVE_KEY_TO_CARD, null);
break;
default:
break;