diff --git a/app/src/main/java/eu/faircode/email/EditTextMultiAutoComplete.java b/app/src/main/java/eu/faircode/email/EditTextMultiAutoComplete.java index b58884b2eb..8b46b2876d 100644 --- a/app/src/main/java/eu/faircode/email/EditTextMultiAutoComplete.java +++ b/app/src/main/java/eu/faircode/email/EditTextMultiAutoComplete.java @@ -70,10 +70,16 @@ public class EditTextMultiAutoComplete extends AppCompatMultiAutoCompleteTextVie private int colorAccent; private ContextThemeWrapper ctx; private Tokenizer tokenizer; - private Map encryption = new ConcurrentHashMap<>(); + private Map encryption = new ConcurrentHashMap<>(); private static ExecutorService executor = Helper.getBackgroundExecutor(1, "chips"); + private static int[] icons = new int[]{ + R.drawable.twotone_vpn_key_24_r, + R.drawable.twotone_vpn_key_24_l, + R.drawable.twotone_vpn_key_24_b + }; + public EditTextMultiAutoComplete(@NonNull Context context) { super(context); init(context); @@ -321,18 +327,21 @@ public class EditTextMultiAutoComplete extends AppCompatMultiAutoCompleteTextVie if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) is.setContentDescription(email); - Boolean has = encryption.get(email); + Integer has = encryption.get(email); if (has == null) { final List
recipient = Arrays.asList(new Address[]{parsed[0]}); executor.submit(new Runnable() { @Override public void run() { try { - boolean has = - PgpHelper.hasPgpKey(context, recipient) || - SmimeHelper.hasSmimeKey(context, recipient); + int has = 0; + if (PgpHelper.hasPgpKey(context, recipient)) + has |= 1; + if (SmimeHelper.hasSmimeKey(context, recipient)) + has |= 2; encryption.put(email, has); - if (has) { + + if (has != 0) { is.invalidate(); post(update); } @@ -341,9 +350,9 @@ public class EditTextMultiAutoComplete extends AppCompatMultiAutoCompleteTextVie } } }); - } else if (has) { + } else if (has != 0) { cd.setTextEndPadding(dp3); - cd.setCloseIcon(context.getDrawable(R.drawable.twotone_vpn_key_24)); + cd.setCloseIcon(context.getDrawable(icons[has - 1])); cd.setCloseIconVisible(true); } diff --git a/app/src/main/res/drawable/twotone_vpn_key_24_b.xml b/app/src/main/res/drawable/twotone_vpn_key_24_b.xml new file mode 100644 index 0000000000..8b7290d8df --- /dev/null +++ b/app/src/main/res/drawable/twotone_vpn_key_24_b.xml @@ -0,0 +1,27 @@ + + + + + + + + + + diff --git a/app/src/main/res/drawable/twotone_vpn_key_24_l.xml b/app/src/main/res/drawable/twotone_vpn_key_24_l.xml new file mode 100644 index 0000000000..aadad08eda --- /dev/null +++ b/app/src/main/res/drawable/twotone_vpn_key_24_l.xml @@ -0,0 +1,22 @@ + + + + + + + + diff --git a/app/src/main/res/drawable/twotone_vpn_key_24_r.xml b/app/src/main/res/drawable/twotone_vpn_key_24_r.xml new file mode 100644 index 0000000000..e0192e9fa3 --- /dev/null +++ b/app/src/main/res/drawable/twotone_vpn_key_24_r.xml @@ -0,0 +1,22 @@ + + + + + + + +