stripped support: implement has_secret support, in ui and impot of secret keys
Closes #570
This commit is contained in:
@@ -117,6 +117,7 @@ public class SelectSecretKeyFragment extends ListFragment implements
|
||||
KeyRings.IS_REVOKED,
|
||||
KeyRings.CAN_CERTIFY,
|
||||
KeyRings.HAS_SIGN,
|
||||
KeyRings.HAS_SECRET,
|
||||
KeyRings.HAS_ANY_SECRET
|
||||
};
|
||||
|
||||
@@ -151,7 +152,7 @@ public class SelectSecretKeyFragment extends ListFragment implements
|
||||
|
||||
private class SelectSecretKeyCursorAdapter extends SelectKeyCursorAdapter {
|
||||
|
||||
private int mIndexHasSign, mIndexCanCertify;
|
||||
private int mIndexHasSecret, mIndexHasSign, mIndexCanCertify;
|
||||
|
||||
public SelectSecretKeyCursorAdapter(Context context, Cursor c, int flags, ListView listView) {
|
||||
super(context, c, flags, listView);
|
||||
@@ -161,6 +162,7 @@ public class SelectSecretKeyFragment extends ListFragment implements
|
||||
protected void initIndex(Cursor cursor) {
|
||||
super.initIndex(cursor);
|
||||
if (cursor != null) {
|
||||
mIndexHasSecret = cursor.getColumnIndexOrThrow(KeyRings.HAS_SECRET);
|
||||
mIndexCanCertify = cursor.getColumnIndexOrThrow(KeyRings.CAN_CERTIFY);
|
||||
mIndexHasSign = cursor.getColumnIndexOrThrow(KeyRings.HAS_SIGN);
|
||||
}
|
||||
@@ -177,8 +179,10 @@ public class SelectSecretKeyFragment extends ListFragment implements
|
||||
// Special from superclass: Te
|
||||
boolean enabled = false;
|
||||
if((Boolean) h.status.getTag()) {
|
||||
if (cursor.getInt(mIndexHasSecret) == 0) {
|
||||
h.status.setText(R.string.no_subkey);
|
||||
// Check if key is viable for our purposes (certify or sign)
|
||||
if(mFilterCertify) {
|
||||
} else if(mFilterCertify) {
|
||||
if (cursor.getInt(mIndexCanCertify) == 0) {
|
||||
h.status.setText(R.string.can_certify_not);
|
||||
} else {
|
||||
|
||||
@@ -174,11 +174,11 @@ public class ViewKeyMainFragment extends Fragment implements
|
||||
|
||||
static final String[] KEYS_PROJECTION = new String[] {
|
||||
Keys._ID,
|
||||
Keys.KEY_ID, Keys.RANK, Keys.ALGORITHM, Keys.KEY_SIZE,
|
||||
Keys.KEY_ID, Keys.RANK, Keys.ALGORITHM, Keys.KEY_SIZE, Keys.HAS_SECRET,
|
||||
Keys.CAN_CERTIFY, Keys.CAN_ENCRYPT, Keys.CAN_SIGN, Keys.IS_REVOKED,
|
||||
Keys.CREATION, Keys.EXPIRY, Keys.FINGERPRINT
|
||||
};
|
||||
static final int KEYS_INDEX_CAN_ENCRYPT = 6;
|
||||
static final int KEYS_INDEX_CAN_ENCRYPT = 7;
|
||||
|
||||
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
|
||||
switch (id) {
|
||||
|
||||
@@ -45,9 +45,12 @@ public class ViewKeyKeysAdapter extends CursorAdapter {
|
||||
private int mIndexCanCertify;
|
||||
private int mIndexCanEncrypt;
|
||||
private int mIndexCanSign;
|
||||
private int mIndexHasSecret;
|
||||
private int mIndexRevokedKey;
|
||||
private int mIndexExpiry;
|
||||
|
||||
private boolean hasAnySecret;
|
||||
|
||||
private ColorStateList mDefaultTextColor;
|
||||
|
||||
public ViewKeyKeysAdapter(Context context, Cursor c, int flags) {
|
||||
@@ -62,6 +65,17 @@ public class ViewKeyKeysAdapter extends CursorAdapter {
|
||||
public Cursor swapCursor(Cursor newCursor) {
|
||||
initIndex(newCursor);
|
||||
|
||||
hasAnySecret = false;
|
||||
if (newCursor != null) {
|
||||
newCursor.moveToFirst();
|
||||
do {
|
||||
if(newCursor.getInt(mIndexHasSecret) != 0) {
|
||||
hasAnySecret = true;
|
||||
break;
|
||||
}
|
||||
} while(newCursor.moveToNext());
|
||||
}
|
||||
|
||||
return super.swapCursor(newCursor);
|
||||
}
|
||||
|
||||
@@ -80,6 +94,7 @@ public class ViewKeyKeysAdapter extends CursorAdapter {
|
||||
mIndexCanCertify = cursor.getColumnIndexOrThrow(Keys.CAN_CERTIFY);
|
||||
mIndexCanEncrypt = cursor.getColumnIndexOrThrow(Keys.CAN_ENCRYPT);
|
||||
mIndexCanSign = cursor.getColumnIndexOrThrow(Keys.CAN_SIGN);
|
||||
mIndexHasSecret = cursor.getColumnIndexOrThrow(Keys.HAS_SECRET);
|
||||
mIndexRevokedKey = cursor.getColumnIndexOrThrow(Keys.IS_REVOKED);
|
||||
mIndexExpiry = cursor.getColumnIndexOrThrow(Keys.EXPIRY);
|
||||
}
|
||||
@@ -101,7 +116,13 @@ public class ViewKeyKeysAdapter extends CursorAdapter {
|
||||
cursor.getInt(mIndexKeySize));
|
||||
|
||||
keyId.setText(keyIdStr);
|
||||
keyDetails.setText("(" + algorithmStr + ")");
|
||||
// may be set with additional "stripped" later on
|
||||
if(hasAnySecret && cursor.getInt(mIndexHasSecret) == 0) {
|
||||
keyDetails.setText("(" + algorithmStr + ", " +
|
||||
context.getString(R.string.key_stripped) + ")");
|
||||
} else {
|
||||
keyDetails.setText("(" + algorithmStr + ")");
|
||||
}
|
||||
|
||||
if (cursor.getInt(mIndexRank) == 0) {
|
||||
masterKeyIcon.setVisibility(View.INVISIBLE);
|
||||
|
||||
Reference in New Issue
Block a user