diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/helper/OtherHelper.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/helper/OtherHelper.java index d0ba20ea6..b31a889f0 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/helper/OtherHelper.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/helper/OtherHelper.java @@ -17,18 +17,14 @@ package org.sufficientlysecure.keychain.helper; -import android.graphics.Color; import android.os.Bundle; -import android.text.Spannable; import android.text.SpannableStringBuilder; -import android.text.style.ForegroundColorSpan; +import android.text.Spanned; +import android.text.style.StrikethroughSpan; import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.util.Log; -import java.security.DigestException; -import java.security.MessageDigest; -import java.security.NoSuchAlgorithmException; import java.util.Iterator; import java.util.Set; @@ -65,4 +61,10 @@ public class OtherHelper { } } + public static SpannableStringBuilder strikeOutText(CharSequence text) { + SpannableStringBuilder sb = new SpannableStringBuilder(text); + sb.setSpan(new StrikethroughSpan(), 0, text.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE); + return sb; + } + } diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ViewKeyKeysAdapter.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ViewKeyKeysAdapter.java index d925480e9..ed4113fb8 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ViewKeyKeysAdapter.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ViewKeyKeysAdapter.java @@ -29,6 +29,7 @@ import android.view.ViewGroup; import android.widget.ImageView; import android.widget.TextView; import org.sufficientlysecure.keychain.R; +import org.sufficientlysecure.keychain.helper.OtherHelper; import org.sufficientlysecure.keychain.pgp.PgpKeyHelper; import org.sufficientlysecure.keychain.provider.KeychainContract.Keys; @@ -126,28 +127,42 @@ public class ViewKeyKeysAdapter extends CursorAdapter { signIcon.setVisibility(View.VISIBLE); } + boolean valid = true; if (cursor.getInt(mIndexRevokedKey) > 0) { revokedKeyIcon.setVisibility(View.VISIBLE); + keyId.setTextColor(Color.RED); keyDetails.setTextColor(Color.RED); + keyExpiry.setTextColor(Color.RED); + + valid = false; } else { keyId.setTextColor(mDefaultTextColor); keyDetails.setTextColor(mDefaultTextColor); + keyExpiry.setTextColor(mDefaultTextColor); + revokedKeyIcon.setVisibility(View.GONE); } - boolean valid = true; if (!cursor.isNull(mIndexExpiry)) { Date expiryDate = new Date(cursor.getLong(mIndexExpiry) * 1000); - valid = expiryDate.after(new Date()); + + valid = valid && expiryDate.after(new Date()); keyExpiry.setText("(" + - context.getString(R.string.label_expiry) + ": " + - DateFormat.getDateFormat(context).format(expiryDate) + ")"); + context.getString(R.string.label_expiry) + ": " + + DateFormat.getDateFormat(context).format(expiryDate) + ")"); + keyExpiry.setVisibility(View.VISIBLE); } else { keyExpiry.setVisibility(View.GONE); } + // if key is expired or revoked, strike through text + if (!valid) { + keyId.setText(OtherHelper.strikeOutText(keyId.getText())); + keyDetails.setText(OtherHelper.strikeOutText(keyDetails.getText())); + keyExpiry.setText(OtherHelper.strikeOutText(keyExpiry.getText())); + } keyId.setEnabled(valid); keyDetails.setEnabled(valid); keyExpiry.setEnabled(valid); diff --git a/OpenPGP-Keychain/src/main/res/layout/view_key_keys_item.xml b/OpenPGP-Keychain/src/main/res/layout/view_key_keys_item.xml index 43f06e246..13813f7e7 100644 --- a/OpenPGP-Keychain/src/main/res/layout/view_key_keys_item.xml +++ b/OpenPGP-Keychain/src/main/res/layout/view_key_keys_item.xml @@ -4,8 +4,7 @@ android:layout_height="wrap_content" android:orientation="horizontal" android:paddingLeft="8dip" - android:paddingRight="3dip" - android:singleLine="true" > + android:paddingRight="3dip" > - + - + + + +