Edit key: key flags

This commit is contained in:
Dominik Schürmann 2014-08-05 22:35:37 +02:00
parent f8a222983e
commit 1455af2eed
6 changed files with 28 additions and 17 deletions

View file

@ -769,7 +769,7 @@ public class PgpKeyOperation {
PGPSignatureSubpacketGenerator unhashedPacketsGen = new PGPSignatureSubpacketGenerator(); PGPSignatureSubpacketGenerator unhashedPacketsGen = new PGPSignatureSubpacketGenerator();
// If this key can sign, we need a primary key binding signature // 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 // cross-certify signing keys
PGPSignatureSubpacketGenerator subHashedPacketsGen = new PGPSignatureSubpacketGenerator(); PGPSignatureSubpacketGenerator subHashedPacketsGen = new PGPSignatureSubpacketGenerator();
subHashedPacketsGen.setSignatureCreationTime(false, todayDate); subHashedPacketsGen.setSignatureCreationTime(false, todayDate);

View file

@ -407,7 +407,6 @@ public class EditKeyFragment extends LoaderFragment implements
case EditSubkeyExpiryDialogFragment.MESSAGE_NEW_EXPIRY_DATE: case EditSubkeyExpiryDialogFragment.MESSAGE_NEW_EXPIRY_DATE:
Long expiry = (Long) message.getData(). Long expiry = (Long) message.getData().
getSerializable(EditSubkeyExpiryDialogFragment.MESSAGE_DATA_EXPIRY_DATE); getSerializable(EditSubkeyExpiryDialogFragment.MESSAGE_DATA_EXPIRY_DATE);
Log.d(Constants.TAG, "new expiry: " + expiry);
mSaveKeyringParcel.getOrCreateSubkeyChange(keyId).mExpiry = expiry; mSaveKeyringParcel.getOrCreateSubkeyChange(keyId).mExpiry = expiry;
break; break;
} }

View file

@ -162,6 +162,7 @@ public class SubkeysAdapter extends CursorAdapter {
vCertifyIcon.setVisibility(cursor.getInt(INDEX_CAN_CERTIFY) != 0 ? View.VISIBLE : View.GONE); vCertifyIcon.setVisibility(cursor.getInt(INDEX_CAN_CERTIFY) != 0 ? View.VISIBLE : View.GONE);
vEncryptIcon.setVisibility(cursor.getInt(INDEX_CAN_ENCRYPT) != 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); 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; boolean isRevoked = cursor.getInt(INDEX_IS_REVOKED) > 0;

View file

@ -28,6 +28,7 @@ import android.widget.ImageButton;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.TextView; import android.widget.TextView;
import org.spongycastle.bcpg.sig.KeyFlags;
import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.R;
import org.sufficientlysecure.keychain.pgp.PgpKeyHelper; import org.sufficientlysecure.keychain.pgp.PgpKeyHelper;
import org.sufficientlysecure.keychain.service.SaveKeyringParcel; import org.sufficientlysecure.keychain.service.SaveKeyringParcel;
@ -56,7 +57,6 @@ public class SubkeysAddedAdapter extends ArrayAdapter<SaveKeyringParcel.SubkeyAd
public ImageView vCertifyIcon; public ImageView vCertifyIcon;
public ImageView vEncryptIcon; public ImageView vEncryptIcon;
public ImageView vSignIcon; public ImageView vSignIcon;
public ImageView vRevokedIcon;
public ImageButton vDelete; public ImageButton vDelete;
// also hold a reference to the model item // also hold a reference to the model item
public SaveKeyringParcel.SubkeyAdd mModel; public SaveKeyringParcel.SubkeyAdd mModel;
@ -73,13 +73,14 @@ public class SubkeysAddedAdapter extends ArrayAdapter<SaveKeyringParcel.SubkeyAd
holder.vCertifyIcon = (ImageView) convertView.findViewById(R.id.subkey_item_ic_certify); holder.vCertifyIcon = (ImageView) convertView.findViewById(R.id.subkey_item_ic_certify);
holder.vEncryptIcon = (ImageView) convertView.findViewById(R.id.subkey_item_ic_encrypt); holder.vEncryptIcon = (ImageView) convertView.findViewById(R.id.subkey_item_ic_encrypt);
holder.vSignIcon = (ImageView) convertView.findViewById(R.id.subkey_item_ic_sign); holder.vSignIcon = (ImageView) convertView.findViewById(R.id.subkey_item_ic_sign);
holder.vRevokedIcon = (ImageView) convertView.findViewById(R.id.subkey_item_ic_revoked);
holder.vDelete = (ImageButton) convertView.findViewById(R.id.subkey_item_delete_button); holder.vDelete = (ImageButton) convertView.findViewById(R.id.subkey_item_delete_button);
holder.vDelete.setVisibility(View.VISIBLE); // always visible holder.vDelete.setVisibility(View.VISIBLE); // always visible
// not used: // not used:
ImageView editImage = (ImageView) convertView.findViewById(R.id.subkey_item_edit_image); ImageView editImage = (ImageView) convertView.findViewById(R.id.subkey_item_edit_image);
editImage.setVisibility(View.GONE); editImage.setVisibility(View.GONE);
ImageView revokedIcon = (ImageView) convertView.findViewById(R.id.subkey_item_ic_revoked);
revokedIcon.setVisibility(View.GONE);
convertView.setTag(holder); convertView.setTag(holder);
@ -115,14 +116,24 @@ public class SubkeysAddedAdapter extends ArrayAdapter<SaveKeyringParcel.SubkeyAd
+ getContext().getString(R.string.none)); + getContext().getString(R.string.none));
} }
// holder.mModel.mFlags int flags = holder.mModel.mFlags;
if ((flags & KeyFlags.CERTIFY_OTHER) > 0) {
// Set icons according to properties holder.vCertifyIcon.setVisibility(View.VISIBLE);
// holder.vMasterIcon.setVisibility(cursor.getInt(INDEX_RANK) == 0 ? View.VISIBLE : View.INVISIBLE); } else {
// holder.vCertifyIcon.setVisibility(cursor.getInt(INDEX_CAN_CERTIFY) != 0 ? View.VISIBLE : View.GONE); holder.vCertifyIcon.setVisibility(View.GONE);
// holder.vEncryptIcon.setVisibility(cursor.getInt(INDEX_CAN_ENCRYPT) != 0 ? View.VISIBLE : View.GONE); }
// holder.vSignIcon.setVisibility(cursor.getInt(INDEX_CAN_SIGN) != 0 ? View.VISIBLE : 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; return convertView;
} }

View file

@ -173,16 +173,16 @@ public class AddSubkeyDialogFragment extends DialogFragment {
int flags = 0; int flags = 0;
if (mFlagCertify.isChecked()) { if (mFlagCertify.isChecked()) {
flags += KeyFlags.CERTIFY_OTHER; flags |= KeyFlags.CERTIFY_OTHER;
} }
if (mFlagSign.isChecked()) { if (mFlagSign.isChecked()) {
flags += KeyFlags.SIGN_DATA; flags |= KeyFlags.SIGN_DATA;
} }
if (mFlagEncrypt.isChecked()) { if (mFlagEncrypt.isChecked()) {
flags += KeyFlags.ENCRYPT_COMMS + KeyFlags.ENCRYPT_STORAGE; flags |= KeyFlags.ENCRYPT_COMMS | KeyFlags.ENCRYPT_STORAGE;
} }
if (mFlagAuthenticate.isChecked()) { if (mFlagAuthenticate.isChecked()) {
flags += KeyFlags.AUTHENTICATION; flags |= KeyFlags.AUTHENTICATION;
} }
Long expiry; Long expiry;

View file

@ -69,7 +69,7 @@
android:layout_height="match_parent" android:layout_height="match_parent"
android:src="@drawable/ic_action_edit" android:src="@drawable/ic_action_edit"
android:padding="8dp" android:padding="8dp"
android:layout_gravity="center_horizontal" /> android:layout_gravity="center_vertical" />
<ImageButton <ImageButton
android:id="@+id/user_id_item_delete_button" android:id="@+id/user_id_item_delete_button"