aboutsummaryrefslogtreecommitdiffstats
path: root/src/eu/siacs/conversations/utils/PhoneHelper.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/eu/siacs/conversations/utils/PhoneHelper.java')
-rw-r--r--src/eu/siacs/conversations/utils/PhoneHelper.java27
1 files changed, 14 insertions, 13 deletions
diff --git a/src/eu/siacs/conversations/utils/PhoneHelper.java b/src/eu/siacs/conversations/utils/PhoneHelper.java
index 5c652afe..6355e378 100644
--- a/src/eu/siacs/conversations/utils/PhoneHelper.java
+++ b/src/eu/siacs/conversations/utils/PhoneHelper.java
@@ -13,18 +13,19 @@ import android.os.Bundle;
import android.os.Looper;
import android.provider.ContactsContract;
import android.provider.ContactsContract.Profile;
+import android.provider.MediaStore;
public class PhoneHelper {
-
- public static void loadPhoneContacts(Context context, final OnPhoneContactsLoadedListener listener) {
- if (Looper.myLooper()==null) {
+
+ public static void loadPhoneContacts(Context context,
+ final OnPhoneContactsLoadedListener listener) {
+ if (Looper.myLooper() == null) {
Looper.prepare();
}
final Looper mLooper = Looper.myLooper();
final Hashtable<String, Bundle> phoneContacts = new Hashtable<String, Bundle>();
-
- final String[] PROJECTION = new String[] {
- ContactsContract.Data._ID,
+
+ final String[] PROJECTION = new String[] { ContactsContract.Data._ID,
ContactsContract.Data.DISPLAY_NAME,
ContactsContract.Data.PHOTO_THUMBNAIL_URI,
ContactsContract.Data.LOOKUP_KEY,
@@ -35,7 +36,7 @@ public class PhoneHelper {
+ "\") AND (" + ContactsContract.CommonDataKinds.Im.PROTOCOL
+ "=\"" + ContactsContract.CommonDataKinds.Im.PROTOCOL_JABBER
+ "\")";
-
+
CursorLoader mCursorLoader = new CursorLoader(context,
ContactsContract.Data.CONTENT_URI, PROJECTION, SELECTION, null,
null);
@@ -55,14 +56,14 @@ public class PhoneHelper {
"photouri",
cursor.getString(cursor
.getColumnIndex(ContactsContract.Data.PHOTO_THUMBNAIL_URI)));
- contact.putString("lookup",cursor.getString(cursor
+ contact.putString("lookup", cursor.getString(cursor
.getColumnIndex(ContactsContract.Data.LOOKUP_KEY)));
phoneContacts.put(
cursor.getString(cursor
.getColumnIndex(ContactsContract.CommonDataKinds.Im.DATA)),
contact);
}
- if (listener!=null) {
+ if (listener != null) {
listener.onPhoneContactsLoaded(phoneContacts);
}
mLooper.quit();
@@ -71,18 +72,18 @@ public class PhoneHelper {
mCursorLoader.startLoading();
}
- public static Uri getSefliUri(Activity activity) {
+ public static Uri getSefliUri(Context context) {
String[] mProjection = new String[] { Profile._ID,
Profile.PHOTO_THUMBNAIL_URI };
- Cursor mProfileCursor = activity.getContentResolver().query(
+ Cursor mProfileCursor = context.getContentResolver().query(
Profile.CONTENT_URI, mProjection, null, null, null);
- if (mProfileCursor.getCount()==0) {
+ if (mProfileCursor.getCount() == 0) {
return null;
} else {
mProfileCursor.moveToFirst();
String uri = mProfileCursor.getString(1);
- if (uri==null) {
+ if (uri == null) {
return null;
} else {
return Uri.parse(uri);