MCPcopy Create free account
hub / github.com/M66B/FairEmail / getShortcut

Method getShortcut

app/src/main/java/eu/faircode/email/Shortcuts.java:172–206  ·  view source on GitHub ↗
(Context context, InternetAddress address)

Source from the content-addressed store, hash-verified

170 }
171
172 @NonNull
173 static ShortcutInfoCompat.Builder getShortcut(Context context, InternetAddress address) {
174 String name = address.getPersonal();
175 String email = address.getAddress();
176
177 Uri lookupUri = null;
178 boolean contacts = Helper.hasPermission(context, Manifest.permission.READ_CONTACTS);
179 if (contacts) {
180 ContentResolver resolver = context.getContentResolver();
181 try (Cursor cursor = resolver.query(ContactsContract.CommonDataKinds.Email.CONTENT_URI,
182 new String[]{
183 ContactsContract.CommonDataKinds.Photo.CONTACT_ID,
184 ContactsContract.Contacts.LOOKUP_KEY,
185 ContactsContract.Contacts.DISPLAY_NAME
186 },
187 ContactsContract.CommonDataKinds.Email.ADDRESS + " = ?",
188 new String[]{email}, ContactsContract.Contacts.DISPLAY_NAME)) {
189 if (cursor != null && cursor.moveToNext()) {
190 int colContactId = cursor.getColumnIndex(ContactsContract.CommonDataKinds.Photo.CONTACT_ID);
191 int colLookupKey = cursor.getColumnIndex(ContactsContract.Contacts.LOOKUP_KEY);
192 int colDisplayName = cursor.getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME);
193
194 long contactId = cursor.getLong(colContactId);
195 String lookupKey = cursor.getString(colLookupKey);
196 String displayName = cursor.getString(colDisplayName);
197
198 lookupUri = ContactsContract.Contacts.getLookupUri(contactId, lookupKey);
199 if (!TextUtils.isEmpty(displayName))
200 name = displayName;
201 }
202 }
203 }
204
205 return getShortcut(context, email, name, lookupUri);
206 }
207
208 @NonNull
209 static ShortcutInfoCompat.Builder getShortcut(Context context, EntityContact contact) {

Callers 5

onExecuteMethod · 0.95
onActionPinMethod · 0.95
onPinContactMethod · 0.95
onExecutedMethod · 0.95
onActionPinFolderMethod · 0.95

Calls 15

hasPermissionMethod · 0.95
eMethod · 0.95
dp2pixelsMethod · 0.95
generateIdenticonMethod · 0.95
generateLetterIconMethod · 0.95
makeCircularMethod · 0.95
getIconMethod · 0.95
moveToNextMethod · 0.80
getLongMethod · 0.80
getLookupUriMethod · 0.80
getBooleanMethod · 0.80
setActionMethod · 0.80

Tested by

no test coverage detected