diff --git a/app/src/main/java/eu/faircode/email/FragmentCompose.java b/app/src/main/java/eu/faircode/email/FragmentCompose.java index 79005d009a..1c1f5dbfd5 100644 --- a/app/src/main/java/eu/faircode/email/FragmentCompose.java +++ b/app/src/main/java/eu/faircode/email/FragmentCompose.java @@ -1118,6 +1118,17 @@ public class FragmentCompose extends FragmentBase { String wildcard = "%" + typed + "%"; Map map = new HashMap<>(); + String glob = "*" + + typed.toString().toLowerCase() + .replaceAll("[aáàäâã]", "\\[aáàäâã\\]") + .replaceAll("[eéèëê]", "\\[eéèëê\\]") + .replaceAll("[iíìî]", "\\[iíìî\\]") + .replaceAll("[oóòöôõ]", "\\[oóòöôõ\\]") + .replaceAll("[uúùüû]", "\\[uúùüû\\]") + .replace("*", "[*]") + .replace("?", "[?]") + + "*"; + boolean contacts = Helper.hasPermission(getContext(), Manifest.permission.READ_CONTACTS); if (contacts) { Cursor cursor = resolver.query( @@ -1130,8 +1141,9 @@ public class FragmentCompose extends FragmentBase { }, ContactsContract.CommonDataKinds.Email.DATA + " <> ''" + " AND (" + ContactsContract.Contacts.DISPLAY_NAME + " LIKE ?" + + " OR LOWER(" + ContactsContract.Contacts.DISPLAY_NAME + ") GLOB ?" + " OR " + ContactsContract.CommonDataKinds.Email.DATA + " LIKE ?)", - new String[]{wildcard, wildcard}, + new String[]{wildcard, glob, wildcard}, null); while (cursor != null && cursor.moveToNext()) {