Chip: show key type

pull/194/merge
M66B 3 years ago
parent 6686a844aa
commit 6f98900950

@ -70,10 +70,16 @@ public class EditTextMultiAutoComplete extends AppCompatMultiAutoCompleteTextVie
private int colorAccent;
private ContextThemeWrapper ctx;
private Tokenizer tokenizer;
private Map<String, Boolean> encryption = new ConcurrentHashMap<>();
private Map<String, Integer> 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<Address> 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);
}

@ -0,0 +1,27 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:tint="?attr/colorControlNormal"
android:viewportWidth="24"
android:viewportHeight="24">
<group android:translateY="-2">
<path
android:fillAlpha="0.3"
android:fillColor="@android:color/white"
android:pathData="M11.71,10.33C11.01,8.34 9.11,7 7,7c-2.76,0 -5,2.24 -5,5s2.24,5 5,5c2.11,0 4.01,-1.34 4.71,-3.33l0.23,-0.67H18v4h2v-4h2v-2H11.94l-0.23,-0.67zM7,15c-1.65,0 -3,-1.35 -3,-3s1.35,-3 3,-3 3,1.35 3,3 -1.35,3 -3,3z"
android:strokeAlpha="0.3" />
<path
android:fillColor="@android:color/white"
android:pathData="M7,5c-3.86,0 -7,3.14 -7,7s3.14,7 7,7c2.72,0 5.17,-1.58 6.32,-4L16,15v4h6v-4h2L24,9L13.32,9C12.17,6.58 9.72,5 7,5zM22,13h-2v4h-2v-4h-6.06l-0.23,0.67C11.01,15.66 9.11,17 7,17c-2.76,0 -5,-2.24 -5,-5s2.24,-5 5,-5c2.11,0 4.01,1.34 4.71,3.33l0.23,0.67L22,11v2zM7,9c-1.65,0 -3,1.35 -3,3s1.35,3 3,3 3,-1.35 3,-3 -1.35,-3 -3,-3zM7,13c-0.55,0 -1,-0.45 -1,-1s0.45,-1 1,-1 1,0.45 1,1 -0.45,1 -1,1z" />
</group>
<path
android:pathData="M0,24 L10,24z"
android:strokeWidth="5"
android:strokeColor="@android:color/white" />
<path
android:pathData="M14,24 L24,24z"
android:strokeWidth="5"
android:strokeColor="@android:color/white" />
</vector>

@ -0,0 +1,22 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:tint="?attr/colorControlNormal"
android:viewportWidth="24"
android:viewportHeight="24">
<group android:translateY="-2">
<path
android:fillAlpha="0.3"
android:fillColor="@android:color/white"
android:pathData="M11.71,10.33C11.01,8.34 9.11,7 7,7c-2.76,0 -5,2.24 -5,5s2.24,5 5,5c2.11,0 4.01,-1.34 4.71,-3.33l0.23,-0.67H18v4h2v-4h2v-2H11.94l-0.23,-0.67zM7,15c-1.65,0 -3,-1.35 -3,-3s1.35,-3 3,-3 3,1.35 3,3 -1.35,3 -3,3z"
android:strokeAlpha="0.3" />
<path
android:fillColor="@android:color/white"
android:pathData="M7,5c-3.86,0 -7,3.14 -7,7s3.14,7 7,7c2.72,0 5.17,-1.58 6.32,-4L16,15v4h6v-4h2L24,9L13.32,9C12.17,6.58 9.72,5 7,5zM22,13h-2v4h-2v-4h-6.06l-0.23,0.67C11.01,15.66 9.11,17 7,17c-2.76,0 -5,-2.24 -5,-5s2.24,-5 5,-5c2.11,0 4.01,1.34 4.71,3.33l0.23,0.67L22,11v2zM7,9c-1.65,0 -3,1.35 -3,3s1.35,3 3,3 3,-1.35 3,-3 -1.35,-3 -3,-3zM7,13c-0.55,0 -1,-0.45 -1,-1s0.45,-1 1,-1 1,0.45 1,1 -0.45,1 -1,1z" />
</group>
<path
android:pathData="M0,24 L10,24z"
android:strokeWidth="5"
android:strokeColor="@android:color/white" />
</vector>

@ -0,0 +1,22 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:tint="?attr/colorControlNormal"
android:viewportWidth="24"
android:viewportHeight="24">
<group android:translateY="-2">
<path
android:fillAlpha="0.3"
android:fillColor="@android:color/white"
android:pathData="M11.71,10.33C11.01,8.34 9.11,7 7,7c-2.76,0 -5,2.24 -5,5s2.24,5 5,5c2.11,0 4.01,-1.34 4.71,-3.33l0.23,-0.67H18v4h2v-4h2v-2H11.94l-0.23,-0.67zM7,15c-1.65,0 -3,-1.35 -3,-3s1.35,-3 3,-3 3,1.35 3,3 -1.35,3 -3,3z"
android:strokeAlpha="0.3" />
<path
android:fillColor="@android:color/white"
android:pathData="M7,5c-3.86,0 -7,3.14 -7,7s3.14,7 7,7c2.72,0 5.17,-1.58 6.32,-4L16,15v4h6v-4h2L24,9L13.32,9C12.17,6.58 9.72,5 7,5zM22,13h-2v4h-2v-4h-6.06l-0.23,0.67C11.01,15.66 9.11,17 7,17c-2.76,0 -5,-2.24 -5,-5s2.24,-5 5,-5c2.11,0 4.01,1.34 4.71,3.33l0.23,0.67L22,11v2zM7,9c-1.65,0 -3,1.35 -3,3s1.35,3 3,3 3,-1.35 3,-3 -1.35,-3 -3,-3zM7,13c-0.55,0 -1,-0.45 -1,-1s0.45,-1 1,-1 1,0.45 1,1 -0.45,1 -1,1z" />
</group>
<path
android:pathData="M14,24 L24,24z"
android:strokeWidth="5"
android:strokeColor="@android:color/white" />
</vector>
Loading…
Cancel
Save