mirror of https://github.com/M66B/FairEmail.git
Small improvement
This commit is contained in:
parent
3704960fd4
commit
d2f673dafc
|
@ -119,8 +119,7 @@ public class ContactInfo {
|
||||||
|
|
||||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||||
|
|
||||||
if (Helper.hasPermission(context, Manifest.permission.READ_CONTACTS))
|
if (Helper.hasPermission(context, Manifest.permission.READ_CONTACTS)) {
|
||||||
try {
|
|
||||||
ContentResolver resolver = context.getContentResolver();
|
ContentResolver resolver = context.getContentResolver();
|
||||||
try (Cursor cursor = resolver.query(ContactsContract.CommonDataKinds.Email.CONTENT_URI,
|
try (Cursor cursor = resolver.query(ContactsContract.CommonDataKinds.Email.CONTENT_URI,
|
||||||
new String[]{
|
new String[]{
|
||||||
|
@ -151,10 +150,10 @@ public class ContactInfo {
|
||||||
info.displayName = cursor.getString(colDisplayName);
|
info.displayName = cursor.getString(colDisplayName);
|
||||||
info.lookupUri = lookupUri;
|
info.lookupUri = lookupUri;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
} catch (Throwable ex) {
|
} catch (Throwable ex) {
|
||||||
Log.e(ex);
|
Log.e(ex);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (info.bitmap == null) {
|
if (info.bitmap == null) {
|
||||||
int dp = Helper.dp2pixels(context, 48);
|
int dp = Helper.dp2pixels(context, 48);
|
||||||
|
@ -213,7 +212,8 @@ public class ContactInfo {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void init(final Context context, Handler handler) {
|
static void init(final Context context, Handler handler) {
|
||||||
if (Helper.hasPermission(context, Manifest.permission.READ_CONTACTS)) {
|
if (Helper.hasPermission(context, Manifest.permission.READ_CONTACTS))
|
||||||
|
try {
|
||||||
ContentObserver observer = new ContentObserver(handler) {
|
ContentObserver observer = new ContentObserver(handler) {
|
||||||
@Override
|
@Override
|
||||||
public void onChange(boolean selfChange, Uri uri) {
|
public void onChange(boolean selfChange, Uri uri) {
|
||||||
|
@ -226,15 +226,13 @@ public class ContactInfo {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
try {
|
|
||||||
emailLookup = getEmailLookup(context);
|
emailLookup = getEmailLookup(context);
|
||||||
} catch (Throwable ex) {
|
|
||||||
Log.e(ex);
|
|
||||||
}
|
|
||||||
|
|
||||||
Uri uri = ContactsContract.CommonDataKinds.Email.CONTENT_URI;
|
Uri uri = ContactsContract.CommonDataKinds.Email.CONTENT_URI;
|
||||||
Log.i("Observing uri=" + uri);
|
Log.i("Observing uri=" + uri);
|
||||||
context.getContentResolver().registerContentObserver(uri, true, observer);
|
context.getContentResolver().registerContentObserver(uri, true, observer);
|
||||||
|
} catch (Throwable ex) {
|
||||||
|
Log.e(ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -266,6 +264,8 @@ public class ContactInfo {
|
||||||
null)) {
|
null)) {
|
||||||
if (cursor != null && cursor.moveToNext())
|
if (cursor != null && cursor.moveToNext())
|
||||||
untrusted = cursor.getLong(0);
|
untrusted = cursor.getLong(0);
|
||||||
|
} catch (Throwable ex) {
|
||||||
|
Log.e(ex);
|
||||||
}
|
}
|
||||||
Log.i("Untrusted group=" + untrusted);
|
Log.i("Untrusted group=" + untrusted);
|
||||||
|
|
||||||
|
@ -303,6 +303,8 @@ public class ContactInfo {
|
||||||
Uri uri = ContactsContract.Contacts.getLookupUri(contactId, lookupKey);
|
Uri uri = ContactsContract.Contacts.getLookupUri(contactId, lookupKey);
|
||||||
all.put(email, uri);
|
all.put(email, uri);
|
||||||
}
|
}
|
||||||
|
} catch (Throwable ex) {
|
||||||
|
Log.e(ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue