Added insecure warning to import card
This commit is contained in:
parent
015ef4aaae
commit
ba1bd8d48a
|
@ -70,6 +70,10 @@ public class ImportKeysList extends ArrayList<ImportKeysListEntry> {
|
|||
existing.setExpired(true);
|
||||
modified = true;
|
||||
}
|
||||
if (!incoming.isSecure()) {
|
||||
existing.setSecure(false);
|
||||
modified = true;
|
||||
}
|
||||
|
||||
if (incoming.getKeyserver() != null) {
|
||||
existing.setKeyserver(incoming.getKeyserver());
|
||||
|
|
|
@ -52,6 +52,7 @@ public class ImportKeysListEntry implements Serializable, Parcelable {
|
|||
private boolean mSecretKey;
|
||||
private boolean mRevoked;
|
||||
private boolean mExpired;
|
||||
private boolean mSecure;
|
||||
private boolean mUpdated;
|
||||
|
||||
private Date mDate;
|
||||
|
@ -111,8 +112,16 @@ public class ImportKeysListEntry implements Serializable, Parcelable {
|
|||
mRevoked = revoked;
|
||||
}
|
||||
|
||||
public boolean isRevokedOrExpired() {
|
||||
return mRevoked || mExpired;
|
||||
public boolean isSecure() {
|
||||
return mSecure;
|
||||
}
|
||||
|
||||
public void setSecure(boolean secure) {
|
||||
mSecure = secure;
|
||||
}
|
||||
|
||||
public boolean isRevokedOrExpiredOrInsecure() {
|
||||
return mRevoked || mExpired || !mSecure;
|
||||
}
|
||||
|
||||
public Date getDate() {
|
||||
|
@ -284,6 +293,7 @@ public class ImportKeysListEntry implements Serializable, Parcelable {
|
|||
// NOTE: Dont use maybe methods for now, they can be wrong.
|
||||
mRevoked = false; //key.isMaybeRevoked();
|
||||
mExpired = false; //key.isMaybeExpired();
|
||||
mSecure = true;
|
||||
|
||||
mBitStrength = key.getBitStrength();
|
||||
mCurveOid = key.getCurveOid();
|
||||
|
|
|
@ -82,6 +82,10 @@ public abstract class CanonicalizedKeyRing extends KeyRing {
|
|||
return getRing().getPublicKey().hasRevocation();
|
||||
}
|
||||
|
||||
public boolean isSecure() {
|
||||
return getPublicKey().isSecure();
|
||||
}
|
||||
|
||||
public Date getCreationDate() {
|
||||
return getPublicKey().getCreationTime();
|
||||
}
|
||||
|
|
|
@ -252,7 +252,8 @@ public class ImportKeysAdapter extends RecyclerView.Adapter<ImportKeysAdapter.Vi
|
|||
if (canKeyRings.size() == 1) {
|
||||
CanonicalizedKeyRing keyRing = canKeyRings.get(0);
|
||||
Log.e(Constants.TAG, "Key ID: " + keyRing.getMasterKeyId() +
|
||||
"| isRev: " + keyRing.isRevoked() + "| isExp: " + keyRing.isExpired());
|
||||
"| isRev: " + keyRing.isRevoked() + "| isExp: " + keyRing.isExpired()
|
||||
+ "| isSec: " + keyRing.isSecure());
|
||||
|
||||
ImportKeysListEntry entry = mData.get(position);
|
||||
entry.setUpdated(result.isOkUpdated());
|
||||
|
@ -275,6 +276,7 @@ public class ImportKeysAdapter extends RecyclerView.Adapter<ImportKeysAdapter.Vi
|
|||
private void mergeEntryWithKey(ImportKeysListEntry entry, CanonicalizedKeyRing keyRing) {
|
||||
entry.setRevoked(keyRing.isRevoked());
|
||||
entry.setExpired(keyRing.isExpired());
|
||||
entry.setSecure(keyRing.isSecure());
|
||||
|
||||
Date expectedDate = entry.getDate();
|
||||
Date creationDate = keyRing.getCreationDate();
|
||||
|
|
|
@ -31,9 +31,9 @@ import java.util.Date;
|
|||
|
||||
public class ImportKeysBindings {
|
||||
|
||||
@BindingAdapter({"keyUserId", "keySecret", "keyRevokedOrExpired", "query"})
|
||||
@BindingAdapter({"keyUserId", "keySecret", "keyRevokedOrExpiredOrInsecure", "query"})
|
||||
public static void setUserId(TextView textView, CharSequence userId, boolean secret,
|
||||
boolean revokedOrExpired, String query) {
|
||||
boolean revokedOrExpiredOrInsecure, String query) {
|
||||
|
||||
Context context = textView.getContext();
|
||||
Resources resources = context.getResources();
|
||||
|
@ -49,16 +49,16 @@ public class ImportKeysBindings {
|
|||
userId = highlighter.highlight(userId);
|
||||
}
|
||||
textView.setText(userId);
|
||||
textView.setTextColor(ImportKeysBindingsUtils.getColor(context, revokedOrExpired));
|
||||
textView.setTextColor(ImportKeysBindingsUtils.getColor(context, revokedOrExpiredOrInsecure));
|
||||
|
||||
if (secret) {
|
||||
textView.setTextColor(Color.RED);
|
||||
}
|
||||
}
|
||||
|
||||
@BindingAdapter({"keyUserEmail", "keyRevokedOrExpired", "query"})
|
||||
@BindingAdapter({"keyUserEmail", "keyRevokedOrExpiredOrInsecure", "query"})
|
||||
public static void setUserEmail(TextView textView, CharSequence userEmail,
|
||||
boolean revokedOrExpired, String query) {
|
||||
boolean revokedOrExpiredOrInsecure, String query) {
|
||||
|
||||
Context context = textView.getContext();
|
||||
|
||||
|
@ -68,11 +68,11 @@ public class ImportKeysBindings {
|
|||
|
||||
Highlighter highlighter = ImportKeysBindingsUtils.getHighlighter(context, query);
|
||||
textView.setText(highlighter.highlight(userEmail));
|
||||
textView.setTextColor(ImportKeysBindingsUtils.getColor(context, revokedOrExpired));
|
||||
textView.setTextColor(ImportKeysBindingsUtils.getColor(context, revokedOrExpiredOrInsecure));
|
||||
}
|
||||
|
||||
@BindingAdapter({"keyCreation", "keyRevokedOrExpired"})
|
||||
public static void setCreation(TextView textView, Date creationDate, boolean revokedOrExpired) {
|
||||
@BindingAdapter({"keyCreation", "keyRevokedOrExpiredOrInsecure"})
|
||||
public static void setCreation(TextView textView, Date creationDate, boolean revokedOrExpiredOrInsecure) {
|
||||
Context context = textView.getContext();
|
||||
|
||||
String text = "";
|
||||
|
@ -81,7 +81,7 @@ public class ImportKeysBindings {
|
|||
}
|
||||
|
||||
textView.setText(text);
|
||||
textView.setTextColor(ImportKeysBindingsUtils.getColor(context, revokedOrExpired));
|
||||
textView.setTextColor(ImportKeysBindingsUtils.getColor(context, revokedOrExpiredOrInsecure));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -36,8 +36,8 @@ import java.util.Map;
|
|||
|
||||
public class ImportKeysExtraBindings {
|
||||
|
||||
@BindingAdapter({"keyRevoked", "keyExpired"})
|
||||
public static void setStatus(ImageView imageView, boolean revoked, boolean expired) {
|
||||
@BindingAdapter({"keyRevoked", "keyExpired", "keySecure"})
|
||||
public static void setStatus(ImageView imageView, boolean revoked, boolean expired, boolean secure) {
|
||||
Context context = imageView.getContext();
|
||||
|
||||
if (revoked) {
|
||||
|
@ -46,6 +46,9 @@ public class ImportKeysExtraBindings {
|
|||
} else if (expired) {
|
||||
KeyFormattingUtils.setStatusImage(context, imageView, null,
|
||||
KeyFormattingUtils.State.EXPIRED, R.color.key_flag_gray);
|
||||
} else if (!secure) {
|
||||
KeyFormattingUtils.setStatusImage(context, imageView, null,
|
||||
KeyFormattingUtils.State.INSECURE, R.color.key_flag_gray);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -98,7 +98,7 @@ public class EmailKeyHelper {
|
|||
Set<ImportKeysListEntry> keys = new HashSet<>();
|
||||
try {
|
||||
for (ImportKeysListEntry key : keyServer.search(mail, proxy)) {
|
||||
if (key.isRevokedOrExpired()) continue;
|
||||
if (key.isRevokedOrExpiredOrInsecure()) continue;
|
||||
for (String userId : key.getUserIds()) {
|
||||
if (userId.toLowerCase().contains(mail.toLowerCase(Locale.ENGLISH))) {
|
||||
keys.add(key);
|
||||
|
|
|
@ -41,7 +41,7 @@
|
|||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||
app:keyRevokedOrExpired="@{entry.revokedOrExpired}"
|
||||
app:keyRevokedOrExpiredOrInsecure="@{entry.revokedOrExpiredOrInsecure}"
|
||||
app:keySecret="@{entry.secretKey}"
|
||||
app:keyUserId="@{entry.primaryUserId.name}"
|
||||
app:query="@{entry.query}" />
|
||||
|
@ -51,7 +51,7 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="4dp"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
app:keyRevokedOrExpired="@{entry.revokedOrExpired}"
|
||||
app:keyRevokedOrExpiredOrInsecure="@{entry.revokedOrExpiredOrInsecure}"
|
||||
app:keyUserEmail="@{entry.primaryUserId.email}"
|
||||
app:query="@{entry.query}" />
|
||||
|
||||
|
@ -60,7 +60,7 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
app:keyCreation="@{entry.date}"
|
||||
app:keyRevokedOrExpired="@{entry.revokedOrExpired}" />
|
||||
app:keyRevokedOrExpiredOrInsecure="@{entry.revokedOrExpiredOrInsecure}" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
|
|
@ -85,9 +85,10 @@
|
|||
android:layout_centerVertical="true"
|
||||
android:paddingLeft="8dp"
|
||||
android:paddingRight="8dp"
|
||||
android:visibility="@{entry.revokedOrExpired ? V.VISIBLE : V.GONE}"
|
||||
android:visibility="@{entry.revokedOrExpiredOrInsecure ? V.VISIBLE : V.GONE}"
|
||||
app:keyExpired="@{entry.expired}"
|
||||
app:keyRevoked="@{entry.revoked}" />
|
||||
app:keyRevoked="@{entry.revoked}"
|
||||
app:keySecure="@{entry.secure}"/>
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
|
|
Loading…
Reference in a new issue