mirror of
https://github.com/moparisthebest/open-keychain
synced 2024-11-23 17:22:16 -05:00
Merge pull request #482 from uberspot/master
Fix style for expired/revoked keys
This commit is contained in:
commit
de718c24c4
@ -17,18 +17,14 @@
|
|||||||
|
|
||||||
package org.sufficientlysecure.keychain.helper;
|
package org.sufficientlysecure.keychain.helper;
|
||||||
|
|
||||||
import android.graphics.Color;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.text.Spannable;
|
|
||||||
import android.text.SpannableStringBuilder;
|
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.Constants;
|
||||||
import org.sufficientlysecure.keychain.util.Log;
|
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.Iterator;
|
||||||
import java.util.Set;
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -29,6 +29,7 @@ import android.view.ViewGroup;
|
|||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import org.sufficientlysecure.keychain.R;
|
import org.sufficientlysecure.keychain.R;
|
||||||
|
import org.sufficientlysecure.keychain.helper.OtherHelper;
|
||||||
import org.sufficientlysecure.keychain.pgp.PgpKeyHelper;
|
import org.sufficientlysecure.keychain.pgp.PgpKeyHelper;
|
||||||
import org.sufficientlysecure.keychain.provider.KeychainContract.Keys;
|
import org.sufficientlysecure.keychain.provider.KeychainContract.Keys;
|
||||||
|
|
||||||
@ -126,28 +127,42 @@ public class ViewKeyKeysAdapter extends CursorAdapter {
|
|||||||
signIcon.setVisibility(View.VISIBLE);
|
signIcon.setVisibility(View.VISIBLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boolean valid = true;
|
||||||
if (cursor.getInt(mIndexRevokedKey) > 0) {
|
if (cursor.getInt(mIndexRevokedKey) > 0) {
|
||||||
revokedKeyIcon.setVisibility(View.VISIBLE);
|
revokedKeyIcon.setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
keyId.setTextColor(Color.RED);
|
keyId.setTextColor(Color.RED);
|
||||||
keyDetails.setTextColor(Color.RED);
|
keyDetails.setTextColor(Color.RED);
|
||||||
|
keyExpiry.setTextColor(Color.RED);
|
||||||
|
|
||||||
|
valid = false;
|
||||||
} else {
|
} else {
|
||||||
keyId.setTextColor(mDefaultTextColor);
|
keyId.setTextColor(mDefaultTextColor);
|
||||||
keyDetails.setTextColor(mDefaultTextColor);
|
keyDetails.setTextColor(mDefaultTextColor);
|
||||||
|
keyExpiry.setTextColor(mDefaultTextColor);
|
||||||
|
|
||||||
revokedKeyIcon.setVisibility(View.GONE);
|
revokedKeyIcon.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean valid = true;
|
|
||||||
if (!cursor.isNull(mIndexExpiry)) {
|
if (!cursor.isNull(mIndexExpiry)) {
|
||||||
Date expiryDate = new Date(cursor.getLong(mIndexExpiry) * 1000);
|
Date expiryDate = new Date(cursor.getLong(mIndexExpiry) * 1000);
|
||||||
valid = expiryDate.after(new Date());
|
|
||||||
|
valid = valid && expiryDate.after(new Date());
|
||||||
keyExpiry.setText("(" +
|
keyExpiry.setText("(" +
|
||||||
context.getString(R.string.label_expiry) + ": " +
|
context.getString(R.string.label_expiry) + ": " +
|
||||||
DateFormat.getDateFormat(context).format(expiryDate) + ")");
|
DateFormat.getDateFormat(context).format(expiryDate) + ")");
|
||||||
|
|
||||||
keyExpiry.setVisibility(View.VISIBLE);
|
keyExpiry.setVisibility(View.VISIBLE);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
keyExpiry.setVisibility(View.GONE);
|
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);
|
keyId.setEnabled(valid);
|
||||||
keyDetails.setEnabled(valid);
|
keyDetails.setEnabled(valid);
|
||||||
keyExpiry.setEnabled(valid);
|
keyExpiry.setEnabled(valid);
|
||||||
|
@ -4,8 +4,7 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
android:paddingLeft="8dip"
|
android:paddingLeft="8dip"
|
||||||
android:paddingRight="3dip"
|
android:paddingRight="3dip" >
|
||||||
android:singleLine="true" >
|
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/ic_masterKey"
|
android:id="@+id/ic_masterKey"
|
||||||
@ -24,20 +23,28 @@
|
|||||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||||
android:typeface="monospace" />
|
android:typeface="monospace" />
|
||||||
|
|
||||||
<TextView
|
<LinearLayout
|
||||||
android:id="@+id/keyDetails"
|
android:layout_width="match_parent"
|
||||||
android:layout_width="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:orientation="vertical"
|
||||||
android:paddingRight="5dip"
|
android:paddingBottom="2dip"
|
||||||
android:text="(RSA, 1024bit)"
|
android:paddingTop="2dip" >
|
||||||
android:textAppearance="?android:attr/textAppearanceSmall" />
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/keyExpiry"
|
android:id="@+id/keyDetails"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="@string/label_expiry"
|
android:paddingRight="5dip"
|
||||||
android:textAppearance="?android:attr/textAppearanceSmall" />
|
android:text="(RSA, 1024bit)"
|
||||||
|
android:textAppearance="?android:attr/textAppearanceSmall" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/keyExpiry"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/label_expiry"
|
||||||
|
android:textAppearance="?android:attr/textAppearanceSmall" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
Loading…
Reference in New Issue
Block a user