(
Context context,
long account, String folderType,
String selector, boolean dmarc, InternetAddress address, boolean cacheOnly)
| 258 | } |
| 259 | |
| 260 | private static ContactInfo _get( |
| 261 | Context context, |
| 262 | long account, String folderType, |
| 263 | String selector, boolean dmarc, InternetAddress address, boolean cacheOnly) { |
| 264 | String key = MessageHelper.formatAddresses(new Address[]{address}); |
| 265 | synchronized (emailContactInfo) { |
| 266 | ContactInfo info = emailContactInfo.get(key); |
| 267 | if (info != null && !info.isExpired()) |
| 268 | return info; |
| 269 | } |
| 270 | |
| 271 | if (cacheOnly) |
| 272 | return null; |
| 273 | |
| 274 | boolean cached = false; |
| 275 | ContactInfo info = new ContactInfo(); |
| 276 | info.email = address.getAddress(); |
| 277 | |
| 278 | final String ekey = (TextUtils.isEmpty(info.email) ? null : getKey(info.email)); |
| 279 | |
| 280 | SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); |
| 281 | boolean favicons_dmarc = prefs.getBoolean("favicons_dmarc", false); |
| 282 | boolean avatars = prefs.getBoolean("avatars", true); |
| 283 | boolean prefer_contact = prefs.getBoolean("prefer_contact", false); |
| 284 | boolean distinguish_contacts = prefs.getBoolean("distinguish_contacts", false); |
| 285 | boolean bimi = (prefs.getBoolean("bimi", false) && (!favicons_dmarc || dmarc) && !BuildConfig.PLAY_STORE_RELEASE); |
| 286 | boolean gravatars = (prefs.getBoolean("gravatars", false) && (!favicons_dmarc || dmarc) && !BuildConfig.PLAY_STORE_RELEASE); |
| 287 | boolean libravatars = (prefs.getBoolean("libravatars", false) && (!favicons_dmarc || dmarc) && !BuildConfig.PLAY_STORE_RELEASE); |
| 288 | boolean favicons = (prefs.getBoolean("favicons", false) && (!favicons_dmarc || dmarc)); |
| 289 | boolean ddg_icons = (prefs.getBoolean("ddg_icons", false) && (!favicons_dmarc || dmarc) && !BuildConfig.PLAY_STORE_RELEASE); |
| 290 | String favicon_uri = prefs.getString("favicon_uri", null); |
| 291 | boolean generated = prefs.getBoolean("generated_icons", true); |
| 292 | boolean identicons = prefs.getBoolean("identicons", false); |
| 293 | boolean circular = prefs.getBoolean("circular", true); |
| 294 | |
| 295 | // Contact photo |
| 296 | if (!TextUtils.isEmpty(info.email) && |
| 297 | (avatars || prefer_contact || distinguish_contacts) && |
| 298 | Helper.hasPermission(context, Manifest.permission.READ_CONTACTS)) { |
| 299 | File dir = Helper.ensureExists(context, "notcontact"); |
| 300 | File file = new File(dir, ekey); |
| 301 | if (file.exists()) { |
| 302 | file.setLastModified(new Date().getTime()); |
| 303 | Log.i("Contact negative cache key=" + ekey); |
| 304 | } else { |
| 305 | ContentResolver resolver = context.getContentResolver(); |
| 306 | Uri uri = Uri.withAppendedPath( |
| 307 | ContactsContract.CommonDataKinds.Email.CONTENT_LOOKUP_URI, |
| 308 | Uri.encode(info.email.toLowerCase(Locale.ROOT))); |
| 309 | try (Cursor cursor = resolver.query(uri, |
| 310 | new String[]{ |
| 311 | ContactsContract.CommonDataKinds.Photo.CONTACT_ID, |
| 312 | ContactsContract.Contacts.LOOKUP_KEY, |
| 313 | ContactsContract.Contacts.DISPLAY_NAME |
| 314 | }, |
| 315 | null, null, ContactsContract.Contacts.DISPLAY_NAME)) { |
| 316 | |
| 317 | if (cursor != null && cursor.moveToNext()) { |
no test coverage detected