From 0e4b5d7d0b9ac131451ced2dc04a9299dcf97d41 Mon Sep 17 00:00:00 2001 From: Margaux Clerc Date: Wed, 25 Nov 2015 16:51:10 +0100 Subject: [PATCH] Put sip address before numbers in contact view --- src/org/linphone/ContactEditorFragment.java | 3 +-- .../linphone/compatibility/ApiFivePlus.java | 22 +++++++++---------- .../linphone/compatibility/ApiNinePlus.java | 22 +++++++++---------- 3 files changed, 23 insertions(+), 24 deletions(-) diff --git a/src/org/linphone/ContactEditorFragment.java b/src/org/linphone/ContactEditorFragment.java index d336fd3aa..9a2cc7a0e 100644 --- a/src/org/linphone/ContactEditorFragment.java +++ b/src/org/linphone/ContactEditorFragment.java @@ -27,7 +27,6 @@ import java.util.ArrayList; import java.util.List; import org.linphone.compatibility.Compatibility; import org.linphone.core.LinphoneProxyConfig; -import org.linphone.mediastream.Log; import org.linphone.mediastream.Version; import android.annotation.SuppressLint; import android.app.Activity; @@ -109,7 +108,7 @@ public class ContactEditorFragment extends Fragment { contactsManager = ContactsManager.getInstance(); - view = inflater.inflate(R.layout.edit_contact, container, false); + view = inflater.inflate(R.layout.contact_edit, container, false); ImageView back = (ImageView) view.findViewById(R.id.back); back.setOnClickListener(new OnClickListener() { diff --git a/src/org/linphone/compatibility/ApiFivePlus.java b/src/org/linphone/compatibility/ApiFivePlus.java index 0e2a3f5b7..fdbdb3462 100644 --- a/src/org/linphone/compatibility/ApiFivePlus.java +++ b/src/org/linphone/compatibility/ApiFivePlus.java @@ -102,16 +102,6 @@ public class ApiFivePlus { Uri uri = Data.CONTENT_URI; String[] projection = {ContactsContract.CommonDataKinds.Im.DATA}; - - // Phone Numbers - Cursor c = cr.query(Phone.CONTENT_URI, new String[] { Phone.NUMBER }, Phone.CONTACT_ID + " = " + id, null, null); - if (c != null) { - while (c.moveToNext()) { - String number = c.getString(c.getColumnIndex(Phone.NUMBER)); - list.add(number); - } - c.close(); - } // IM addresses String selection = new StringBuilder() @@ -122,7 +112,7 @@ public class ApiFivePlus { .append(ContactsContract.CommonDataKinds.Im.CUSTOM_PROTOCOL) .append(") = 'sip'") .toString(); - c = cr.query(uri, projection, selection, new String[]{id}, null); + Cursor c = cr.query(uri, projection, selection, new String[]{id}, null); if (c != null) { int nbId = c.getColumnIndex(ContactsContract.CommonDataKinds.Im.DATA); while (c.moveToNext()) { @@ -131,6 +121,16 @@ public class ApiFivePlus { c.close(); } + // Phone Numbers + c = cr.query(Phone.CONTENT_URI, new String[]{Phone.NUMBER}, Phone.CONTACT_ID + " = " + id, null, null); + if (c != null) { + while (c.moveToNext()) { + String number = c.getString(c.getColumnIndex(Phone.NUMBER)); + list.add(number); + } + c.close(); + } + return list; } diff --git a/src/org/linphone/compatibility/ApiNinePlus.java b/src/org/linphone/compatibility/ApiNinePlus.java index 1a586b42a..1bf125de6 100644 --- a/src/org/linphone/compatibility/ApiNinePlus.java +++ b/src/org/linphone/compatibility/ApiNinePlus.java @@ -99,16 +99,6 @@ public class ApiNinePlus { Uri uri = Data.CONTENT_URI; String[] projection; - // Phone Numbers - Cursor c = cr.query(Phone.CONTENT_URI, new String[] { Phone.NUMBER }, Phone.CONTACT_ID + " = " + id, null, null); - if (c != null) { - while (c.moveToNext()) { - String number = c.getString(c.getColumnIndex(Phone.NUMBER)); - list.add(number); - } - c.close(); - } - // SIP addresses String selection2 = new StringBuilder() .append(Data.CONTACT_ID) @@ -119,7 +109,7 @@ public class ApiNinePlus { .append("'") .toString(); projection = new String[] {ContactsContract.CommonDataKinds.SipAddress.SIP_ADDRESS}; - c = cr.query(uri, projection, selection2, new String[]{id}, null); + Cursor c = cr.query(uri, projection, selection2, new String[]{id}, null); if (c != null) { int nbid = c.getColumnIndex(ContactsContract.CommonDataKinds.SipAddress.SIP_ADDRESS); while (c.moveToNext()) { @@ -128,6 +118,16 @@ public class ApiNinePlus { c.close(); } + // Phone Numbers + c = cr.query(Phone.CONTENT_URI, new String[] { Phone.NUMBER }, Phone.CONTACT_ID + " = " + id, null, null); + if (c != null) { + while (c.moveToNext()) { + String number = c.getString(c.getColumnIndex(Phone.NUMBER)); + list.add(number); + } + c.close(); + } + return list; }