show keys with no uids in their own "anonymous" category

Fixes #2373
This commit is contained in:
Vincent Breitmoser 2018-07-12 13:17:39 +02:00
parent b5d49f9ae8
commit e8bec994bf
3 changed files with 20 additions and 15 deletions

View file

@ -14,10 +14,12 @@ import org.sufficientlysecure.keychain.model.SubKey.UnifiedKeyInfo;
public class FlexibleKeyItemFactory {
private final Resources resources;
private Map<String, FlexibleKeyHeader> initialsHeaderMap = new HashMap<>();
private FlexibleKeyHeader myKeysHeader;
public FlexibleKeyItemFactory(Resources resources) {
this.resources = resources;
String myKeysHeaderText = resources.getString(R.string.my_keys);
myKeysHeader = new FlexibleKeyHeader(myKeysHeaderText);
}
@ -62,10 +64,10 @@ public class FlexibleKeyItemFactory {
headerText = unifiedKeyInfo.email();
}
if (headerText == null || headerText.isEmpty()) {
return "";
return resources.getString(R.string.keylist_header_anonymous);
}
if (!Character.isLetter(headerText.codePointAt(0))) {
return "#";
return resources.getString(R.string.keylist_header_special);
}
return headerText.substring(0, 1).toUpperCase();
}

View file

@ -37,21 +37,20 @@ public class KeyInfoFormatter {
}
public void formatUserId(TextView name, TextView email) {
if (keyInfo.name() == null) {
if (keyInfo.email() != null) {
name.setText(highlighter.highlight(keyInfo.email()));
email.setVisibility(View.GONE);
} else {
name.setText(R.string.user_id_no_name);
}
if (keyInfo.name() == null && keyInfo.email() == null) {
String readableKeyId = KeyFormattingUtils.beautifyKeyId(keyInfo.master_key_id());
name.setText(context.getString(R.string.keylist_item_key_id, readableKeyId));
email.setVisibility(View.GONE);
} else if (keyInfo.name() == null) {
name.setText(highlighter.highlight(keyInfo.email()));
email.setVisibility(View.GONE);
} else if (keyInfo.email() == null) {
name.setText(highlighter.highlight(keyInfo.name()));
email.setVisibility(View.GONE);
} else {
name.setText(highlighter.highlight(keyInfo.name()));
if (keyInfo.email() != null) {
email.setText(highlighter.highlight(keyInfo.email()));
email.setVisibility(View.VISIBLE);
} else {
email.setVisibility(View.GONE);
}
email.setText(highlighter.highlight(keyInfo.email()));
email.setVisibility(View.VISIBLE);
}
}

View file

@ -2040,4 +2040,8 @@
<string name="keychoice_revoked">This key cannot be used because it is revoked!</string>
<string name="keychoice_expired">This key cannot be used because it is expired!</string>
<string name="keylist_item_key_id">Key ID: %s</string>
<string name="keylist_header_anonymous">Anonymous</string>
<string name="keylist_header_special">#</string>
</resources>