diff options
Diffstat (limited to 'OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter')
-rw-r--r-- | OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/SubkeysAdapter.java | 36 |
1 files changed, 24 insertions, 12 deletions
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 25b3c0fc5..dd972866c 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 @@ -161,6 +161,11 @@ public class SubkeysAdapter extends CursorAdapter { boolean isRevoked = cursor.getInt(INDEX_IS_REVOKED) > 0; + Date expiryDate = null; + if (!cursor.isNull(INDEX_EXPIRY)) { + expiryDate = new Date(cursor.getLong(INDEX_EXPIRY) * 1000); + } + // for edit key if (mSaveKeyringParcel != null) { boolean revokeThisSubkey = (mSaveKeyringParcel.mRevokeSubKeys.contains(keyId)); @@ -171,24 +176,21 @@ public class SubkeysAdapter extends CursorAdapter { } } + SaveKeyringParcel.SubkeyChange subkeyChange = mSaveKeyringParcel.getSubkeyChange(keyId); + if (subkeyChange != null) { + // 0 is "no expiry" + if (subkeyChange.mExpiry != null && subkeyChange.mExpiry != 0) { + expiryDate = new Date(subkeyChange.mExpiry * 1000); + } + } + vEditImage.setVisibility(View.VISIBLE); } else { vEditImage.setVisibility(View.GONE); } - if (isRevoked) { - vRevokedIcon.setVisibility(View.VISIBLE); - } else { - vKeyId.setTextColor(mDefaultTextColor); - vKeyDetails.setTextColor(mDefaultTextColor); - vKeyExpiry.setTextColor(mDefaultTextColor); - - vRevokedIcon.setVisibility(View.GONE); - } - boolean isExpired; - if (!cursor.isNull(INDEX_EXPIRY)) { - Date expiryDate = new Date(cursor.getLong(INDEX_EXPIRY) * 1000); + if (expiryDate != null) { isExpired = expiryDate.before(new Date()); vKeyExpiry.setText(context.getString(R.string.label_expiry) + ": " @@ -199,6 +201,16 @@ public class SubkeysAdapter extends CursorAdapter { vKeyExpiry.setText(context.getString(R.string.label_expiry) + ": " + context.getString(R.string.none)); } + if (isRevoked) { + vRevokedIcon.setVisibility(View.VISIBLE); + } else { + vKeyId.setTextColor(mDefaultTextColor); + vKeyDetails.setTextColor(mDefaultTextColor); + vKeyExpiry.setTextColor(mDefaultTextColor); + + vRevokedIcon.setVisibility(View.GONE); + } + // if key is expired or revoked, strike through text boolean isInvalid = isRevoked || isExpired; if (isInvalid) { |