ImportKeys: Add creation date and more check on keys's data
This commit is contained in:
@@ -83,13 +83,21 @@ public abstract class CanonicalizedKeyRing extends KeyRing {
|
||||
return getRing().getPublicKey().isRevoked();
|
||||
}
|
||||
|
||||
public Date getCreationDate() {
|
||||
return getPublicKey().getCreationTime();
|
||||
}
|
||||
|
||||
public Date getExpirationDate() {
|
||||
return getPublicKey().getExpiryTime();
|
||||
}
|
||||
|
||||
public boolean isExpired() {
|
||||
// Is the master key expired?
|
||||
Date creationDate = getPublicKey().getCreationTime();
|
||||
Date expiryDate = getPublicKey().getExpiryTime();
|
||||
Date creationDate = getCreationDate();
|
||||
Date expirationDate = getExpirationDate();
|
||||
|
||||
Date now = new Date();
|
||||
return creationDate.after(now) || (expiryDate != null && expiryDate.before(now));
|
||||
return creationDate.after(now) || (expirationDate != null && expirationDate.before(now));
|
||||
}
|
||||
|
||||
public boolean canCertify() throws PgpKeyNotFoundException {
|
||||
|
||||
@@ -236,6 +236,7 @@ public class ImportKeysAdapter extends RecyclerView.Adapter<ImportKeysAdapter.Vi
|
||||
|
||||
ImportKeysListEntry entry = mData.get(mCurrent);
|
||||
|
||||
entry.setDate(keyRing.getCreationDate());
|
||||
entry.setKeyId(keyRing.getMasterKeyId());
|
||||
|
||||
ArrayList<String> realUserIdsPlusKeybase = keyRing.getUnorderedUserIds();
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
package org.sufficientlysecure.keychain.ui.bindings;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import android.databinding.BindingAdapter;
|
||||
import android.text.format.DateFormat;
|
||||
import android.view.LayoutInflater;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
@@ -12,17 +14,36 @@ import org.sufficientlysecure.keychain.ui.util.Highlighter;
|
||||
import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
|
||||
public class ImportKeysExtraBindings {
|
||||
|
||||
@BindingAdapter({"app:keyCreation"})
|
||||
public static void setCreation(TextView textView, Date creationDate) {
|
||||
Context context = textView.getContext();
|
||||
String text;
|
||||
if (creationDate != null) {
|
||||
text = DateFormat.getDateFormat(context).format(creationDate);
|
||||
} else {
|
||||
Resources resources = context.getResources();
|
||||
text = resources.getString(R.string.unknown);
|
||||
}
|
||||
textView.setText(text);
|
||||
}
|
||||
|
||||
@BindingAdapter({"app:keyId"})
|
||||
public static void setKeyId(TextView textView, String keyId) {
|
||||
if (keyId == null)
|
||||
keyId = "";
|
||||
|
||||
textView.setText(KeyFormattingUtils.beautifyKeyIdWithPrefix(keyId));
|
||||
Context context = textView.getContext();
|
||||
String text;
|
||||
if (keyId != null){
|
||||
text = KeyFormattingUtils.beautifyKeyId(keyId);
|
||||
} else {
|
||||
Resources resources = context.getResources();
|
||||
text = resources.getString(R.string.unknown);
|
||||
}
|
||||
textView.setText(text);
|
||||
}
|
||||
|
||||
@BindingAdapter({"app:keyUserIds", "app:query"})
|
||||
|
||||
@@ -99,7 +99,7 @@ public class KeyFormattingUtils {
|
||||
|
||||
default: {
|
||||
if (context != null) {
|
||||
algorithmStr = context.getResources().getString(R.string.unknown_algorithm);
|
||||
algorithmStr = context.getResources().getString(R.string.unknown);
|
||||
} else {
|
||||
algorithmStr = "unknown";
|
||||
}
|
||||
@@ -154,7 +154,7 @@ public class KeyFormattingUtils {
|
||||
|
||||
default: {
|
||||
if (context != null) {
|
||||
algorithmStr = context.getResources().getString(R.string.unknown_algorithm);
|
||||
algorithmStr = context.getResources().getString(R.string.unknown);
|
||||
} else {
|
||||
algorithmStr = "unknown";
|
||||
}
|
||||
@@ -189,7 +189,7 @@ public class KeyFormattingUtils {
|
||||
*/
|
||||
}
|
||||
if (context != null) {
|
||||
return context.getResources().getString(R.string.unknown_algorithm);
|
||||
return context.getResources().getString(R.string.unknown);
|
||||
} else {
|
||||
return "unknown";
|
||||
}
|
||||
@@ -208,7 +208,7 @@ public class KeyFormattingUtils {
|
||||
return name;
|
||||
}
|
||||
if (context != null) {
|
||||
return context.getResources().getString(R.string.unknown_algorithm);
|
||||
return context.getResources().getString(R.string.unknown);
|
||||
} else {
|
||||
return "unknown";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user