check for key status in legacy API key lists
This commit is contained in:
committed by
Vincent Breitmoser
parent
8a33fa8540
commit
035a62e920
@@ -66,6 +66,10 @@ public abstract class SubKey implements KeysModel {
|
||||
return has_encrypt_key_int() != 0;
|
||||
}
|
||||
|
||||
public boolean has_sign_key() {
|
||||
return has_sign_key_int() != 0;
|
||||
}
|
||||
|
||||
public String uidSearchString() {
|
||||
if (cachedUidSearchString == null) {
|
||||
cachedUidSearchString = user_id_list();
|
||||
|
||||
@@ -124,7 +124,17 @@ public class SelectPublicKeyFragment extends RecyclerFragment<KeyChoiceAdapter>
|
||||
public void onLoadUnifiedKeyData(List<UnifiedKeyInfo> data) {
|
||||
if (keyChoiceAdapter == null) {
|
||||
keyChoiceAdapter = KeyChoiceAdapter.createMultiChoiceAdapter(data, (keyInfo -> {
|
||||
return keyInfo.is_revoked() ? R.string.keychoice_cannot_encrypt : null;
|
||||
if (keyInfo.is_revoked()) {
|
||||
return R.string.keychoice_revoked;
|
||||
} else if (keyInfo.is_expired()) {
|
||||
return R.string.keychoice_expired;
|
||||
} else if (!keyInfo.is_secure()) {
|
||||
return R.string.keychoice_insecure;
|
||||
} else if (!keyInfo.has_encrypt_key()) {
|
||||
return R.string.keychoice_cannot_encrypt;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}));
|
||||
setAdapter(keyChoiceAdapter);
|
||||
keyChoiceAdapter.setSelectionByIds(selectedMasterKeyIds);
|
||||
|
||||
@@ -116,7 +116,19 @@ public class SelectSignKeyIdListFragment extends RecyclerFragment<KeyChoiceAdapt
|
||||
|
||||
public void onLoadUnifiedKeyData(List<UnifiedKeyInfo> data) {
|
||||
if (keyChoiceAdapter == null) {
|
||||
keyChoiceAdapter = KeyChoiceAdapter.createSingleClickableAdapter(data, this::onSelectKeyItemClicked);
|
||||
keyChoiceAdapter = KeyChoiceAdapter.createSingleClickableAdapter(data, this::onSelectKeyItemClicked, (keyInfo -> {
|
||||
if (keyInfo.is_revoked()) {
|
||||
return R.string.keychoice_revoked;
|
||||
} else if (keyInfo.is_expired()) {
|
||||
return R.string.keychoice_expired;
|
||||
} else if (!keyInfo.is_secure()) {
|
||||
return R.string.keychoice_insecure;
|
||||
} else if (!keyInfo.has_sign_key()) {
|
||||
return R.string.keychoice_cannot_sign;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}));
|
||||
setAdapter(keyChoiceAdapter);
|
||||
} else {
|
||||
keyChoiceAdapter.setUnifiedKeyInfoItems(data);
|
||||
|
||||
@@ -40,6 +40,12 @@ public class KeyChoiceAdapter extends FlexibleAdapter<KeyChoiceItem> {
|
||||
return new KeyChoiceAdapter(items, Objects.requireNonNull(onKeyClickListener), Mode.IDLE, null);
|
||||
}
|
||||
|
||||
public static KeyChoiceAdapter createSingleClickableAdapter(List<UnifiedKeyInfo> items,
|
||||
OnKeyClickListener onKeyClickListener,
|
||||
KeyDisabledPredicate keyDisabledPredicate) {
|
||||
return new KeyChoiceAdapter(items, Objects.requireNonNull(onKeyClickListener), Mode.IDLE, keyDisabledPredicate);
|
||||
}
|
||||
|
||||
public static KeyChoiceAdapter createSingleChoiceAdapter(List<UnifiedKeyInfo> items) {
|
||||
return new KeyChoiceAdapter(items, null, Mode.SINGLE, null);
|
||||
}
|
||||
|
||||
@@ -2035,4 +2035,9 @@
|
||||
<string name="snack_keysync_error">An error occurred while updating all keys</string>
|
||||
|
||||
<string name="keychoice_cannot_encrypt">This key cannot be used for encryption!</string>
|
||||
<string name="keychoice_cannot_sign">This key cannot be used for signing!</string>
|
||||
<string name="keychoice_insecure">This key cannot be used because it is insecure!</string>
|
||||
<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>
|
||||
|
||||
</resources>
|
||||
|
||||
Reference in New Issue
Block a user