From 1455af2eed0f5efa2bc3b3317334796516670970 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Tue, 5 Aug 2014 22:35:37 +0200 Subject: Edit key: key flags --- .../keychain/pgp/PgpKeyOperation.java | 2 +- .../keychain/ui/EditKeyFragment.java | 1 - .../keychain/ui/adapter/SubkeysAdapter.java | 1 + .../keychain/ui/adapter/SubkeysAddedAdapter.java | 31 +++++++++++++++------- .../ui/dialog/AddSubkeyDialogFragment.java | 8 +++--- 5 files changed, 27 insertions(+), 16 deletions(-) (limited to 'OpenKeychain/src/main/java/org/sufficientlysecure/keychain') diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java index 6cd020684..bb692555e 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java @@ -769,7 +769,7 @@ public class PgpKeyOperation { PGPSignatureSubpacketGenerator unhashedPacketsGen = new PGPSignatureSubpacketGenerator(); // If this key can sign, we need a primary key binding signature - if ((flags & KeyFlags.SIGN_DATA) != 0) { + if ((flags & KeyFlags.SIGN_DATA) > 0) { // cross-certify signing keys PGPSignatureSubpacketGenerator subHashedPacketsGen = new PGPSignatureSubpacketGenerator(); subHashedPacketsGen.setSignatureCreationTime(false, todayDate); diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyFragment.java index 1a37567eb..82206655f 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyFragment.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyFragment.java @@ -407,7 +407,6 @@ public class EditKeyFragment extends LoaderFragment implements case EditSubkeyExpiryDialogFragment.MESSAGE_NEW_EXPIRY_DATE: Long expiry = (Long) message.getData(). getSerializable(EditSubkeyExpiryDialogFragment.MESSAGE_DATA_EXPIRY_DATE); - Log.d(Constants.TAG, "new expiry: " + expiry); mSaveKeyringParcel.getOrCreateSubkeyChange(keyId).mExpiry = expiry; break; } diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/SubkeysAdapter.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/SubkeysAdapter.java index e845c7e42..d457e75bd 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/SubkeysAdapter.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/SubkeysAdapter.java @@ -162,6 +162,7 @@ public class SubkeysAdapter extends CursorAdapter { vCertifyIcon.setVisibility(cursor.getInt(INDEX_CAN_CERTIFY) != 0 ? View.VISIBLE : View.GONE); vEncryptIcon.setVisibility(cursor.getInt(INDEX_CAN_ENCRYPT) != 0 ? View.VISIBLE : View.GONE); vSignIcon.setVisibility(cursor.getInt(INDEX_CAN_SIGN) != 0 ? View.VISIBLE : View.GONE); + // TODO: missing icon for authenticate boolean isRevoked = cursor.getInt(INDEX_IS_REVOKED) > 0; diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/SubkeysAddedAdapter.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/SubkeysAddedAdapter.java index b3f87a4c4..be2e17c63 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/SubkeysAddedAdapter.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/SubkeysAddedAdapter.java @@ -28,6 +28,7 @@ import android.widget.ImageButton; import android.widget.ImageView; import android.widget.TextView; +import org.spongycastle.bcpg.sig.KeyFlags; import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.pgp.PgpKeyHelper; import org.sufficientlysecure.keychain.service.SaveKeyringParcel; @@ -56,7 +57,6 @@ public class SubkeysAddedAdapter extends ArrayAdapter 0) { + holder.vCertifyIcon.setVisibility(View.VISIBLE); + } else { + holder.vCertifyIcon.setVisibility(View.GONE); + } + if ((flags & KeyFlags.SIGN_DATA) > 0) { + holder.vSignIcon.setVisibility(View.VISIBLE); + } else { + holder.vSignIcon.setVisibility(View.GONE); + } + if (((flags & KeyFlags.ENCRYPT_COMMS) > 0) + || ((flags & KeyFlags.ENCRYPT_STORAGE) > 0)) { + holder.vEncryptIcon.setVisibility(View.VISIBLE); + } else { + holder.vEncryptIcon.setVisibility(View.GONE); + } + // TODO: missing icon for authenticate return convertView; } diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/AddSubkeyDialogFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/AddSubkeyDialogFragment.java index 53428f526..27c797a7d 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/AddSubkeyDialogFragment.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/AddSubkeyDialogFragment.java @@ -173,16 +173,16 @@ public class AddSubkeyDialogFragment extends DialogFragment { int flags = 0; if (mFlagCertify.isChecked()) { - flags += KeyFlags.CERTIFY_OTHER; + flags |= KeyFlags.CERTIFY_OTHER; } if (mFlagSign.isChecked()) { - flags += KeyFlags.SIGN_DATA; + flags |= KeyFlags.SIGN_DATA; } if (mFlagEncrypt.isChecked()) { - flags += KeyFlags.ENCRYPT_COMMS + KeyFlags.ENCRYPT_STORAGE; + flags |= KeyFlags.ENCRYPT_COMMS | KeyFlags.ENCRYPT_STORAGE; } if (mFlagAuthenticate.isChecked()) { - flags += KeyFlags.AUTHENTICATION; + flags |= KeyFlags.AUTHENTICATION; } Long expiry; -- cgit v1.2.3