From 9fc7a1b980863955a139193ded0fef5edfbad296 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Sat, 5 Apr 2014 21:06:10 +0200 Subject: added button to open images --- src/eu/siacs/conversations/utils/PhoneHelper.java | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) (limited to 'src/eu/siacs/conversations/utils') diff --git a/src/eu/siacs/conversations/utils/PhoneHelper.java b/src/eu/siacs/conversations/utils/PhoneHelper.java index 5c652afe..dd3e0e19 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 phoneContacts = new Hashtable(); - - 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(); @@ -77,12 +78,12 @@ public class PhoneHelper { Cursor mProfileCursor = activity.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); -- cgit v1.2.3