Check for any/all PGP or S/MIME keys

This commit is contained in:
M66B
2022-10-30 07:39:56 +01:00
parent 09cc268690
commit 388be88d0f
4 changed files with 14 additions and 13 deletions

View File

@@ -68,11 +68,11 @@ public class PgpHelper {
}
}
static boolean hasPgpKey(Context context, List<Address> recipients) {
return hasPgpKey(context, recipients, KEY_TIMEOUT); // milliseconds
static boolean hasPgpKey(Context context, List<Address> recipients, boolean all) {
return hasPgpKey(context, recipients, all, KEY_TIMEOUT); // milliseconds
}
private static boolean hasPgpKey(Context context, List<Address> recipients, long timeout) {
private static boolean hasPgpKey(Context context, List<Address> recipients, boolean all, long timeout) {
if (recipients == null || recipients.size() == 0)
return false;
@@ -90,7 +90,7 @@ public class PgpHelper {
int resultCode = result.getIntExtra(OpenPgpApi.RESULT_CODE, OpenPgpApi.RESULT_CODE_ERROR);
if (resultCode == OpenPgpApi.RESULT_CODE_SUCCESS) {
long[] keyIds = result.getLongArrayExtra(OpenPgpApi.EXTRA_KEY_IDS);
return (keyIds.length > 0);
return (all ? keyIds.length == recipients.size() : keyIds.length > 0);
}
} catch (OperationCanceledException ignored) {
// Do nothing