Fixed contact lookup for history & chat
This commit is contained in:
parent
a75da820ed
commit
8d65fab06c
11 changed files with 16 additions and 22 deletions
|
@ -1557,7 +1557,7 @@ public class CallActivity extends Activity implements OnClickListener, SensorEve
|
|||
}
|
||||
|
||||
private void setContactInformation(TextView contactName, ImageView contactPicture, LinphoneAddress lAddress) {
|
||||
LinphoneContact lContact = ContactsManager.getInstance().findContactFromAddress(contactName.getContext().getContentResolver(), lAddress);
|
||||
LinphoneContact lContact = ContactsManager.getInstance().findContactFromAddress(lAddress);
|
||||
if (lContact == null) {
|
||||
contactName.setText(LinphoneUtils.getAddressDisplayName(lAddress));
|
||||
contactPicture.setImageResource(R.drawable.avatar);
|
||||
|
@ -1720,7 +1720,7 @@ public class CallActivity extends Activity implements OnClickListener, SensorEve
|
|||
conferenceList.setId(index + 1);
|
||||
TextView contact = (TextView) confView.findViewById(R.id.contactNameOrNumber);
|
||||
|
||||
LinphoneContact lContact = ContactsManager.getInstance().findContactFromAddress(getContentResolver(),call.getRemoteAddress());
|
||||
LinphoneContact lContact = ContactsManager.getInstance().findContactFromAddress(call.getRemoteAddress());
|
||||
if (lContact == null) {
|
||||
contact.setText(call.getRemoteAddress().getUserName());
|
||||
} else {
|
||||
|
|
|
@ -232,7 +232,7 @@ public class CallIncomingActivity extends Activity implements LinphoneSliderTrig
|
|||
return;
|
||||
}
|
||||
LinphoneAddress address = mCall.getRemoteAddress();
|
||||
LinphoneContact contact = ContactsManager.getInstance().findContactFromAddress(getContentResolver(), address);
|
||||
LinphoneContact contact = ContactsManager.getInstance().findContactFromAddress(address);
|
||||
if (contact != null) {
|
||||
LinphoneUtils.setImagePictureFromUri(this, contactPicture, contact.getPhotoUri(), contact.getThumbnailUri());
|
||||
name.setText(contact.getFullName());
|
||||
|
|
|
@ -143,7 +143,7 @@ public class CallOutgoingActivity extends Activity implements OnClickListener{
|
|||
}
|
||||
|
||||
LinphoneAddress address = mCall.getRemoteAddress();
|
||||
LinphoneContact contact = ContactsManager.getInstance().findContactFromAddress(getContentResolver(), address);
|
||||
LinphoneContact contact = ContactsManager.getInstance().findContactFromAddress(address);
|
||||
if (contact != null) {
|
||||
LinphoneUtils.setImagePictureFromUri(this, contactPicture, contact.getPhotoUri(), contact.getThumbnailUri());
|
||||
name.setText(contact.getFullName());
|
||||
|
|
|
@ -459,7 +459,7 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
|||
chatRoom = lc.getChatRoom(lAddress);
|
||||
chatRoom.markAsRead();
|
||||
LinphoneActivity.instance().updateMissedChatCount();
|
||||
contact = ContactsManager.getInstance().findContactFromAddress(getActivity().getContentResolver(), lAddress);
|
||||
contact = ContactsManager.getInstance().findContactFromAddress(lAddress);
|
||||
if (chatRoom != null) {
|
||||
displayChatHeader(lAddress);
|
||||
dispayMessageList();
|
||||
|
|
|
@ -348,7 +348,7 @@ public class ChatListFragment extends Fragment implements OnClickListener, OnIte
|
|||
return view;
|
||||
}
|
||||
|
||||
LinphoneContact contact = ContactsManager.getInstance().findContactFromAddress(getActivity().getContentResolver(), address);
|
||||
LinphoneContact contact = ContactsManager.getInstance().findContactFromAddress(address);
|
||||
String message = "";
|
||||
Long time;
|
||||
|
||||
|
|
|
@ -109,18 +109,12 @@ public class ContactsManager {
|
|||
}
|
||||
|
||||
public LinphoneContact findContactFromAddress(LinphoneAddress address) {
|
||||
return findContactFromAddress(null, address);
|
||||
}
|
||||
|
||||
public LinphoneContact findContactFromAddress(ContentResolver contentResolver, LinphoneAddress address) {
|
||||
String sipUri = address.asStringUriOnly();
|
||||
if (sipUri.startsWith("sip:")) {
|
||||
sipUri = sipUri.substring(4);
|
||||
}
|
||||
|
||||
String username = address.getUserName();
|
||||
|
||||
for (LinphoneContact c: getContacts()) {
|
||||
for (LinphoneNumberOrAddress noa: c.getNumbersOrAddresses()) {
|
||||
if (noa.getValue().equals(sipUri)) {
|
||||
if ((noa.isSIPAddress() && (noa.getValue().equals(sipUri) || noa.getValue().equals(sipUri.substring(4)))) || (!noa.isSIPAddress() && noa.getValue().equals(username))) {
|
||||
return c;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -108,7 +108,7 @@ public class HistoryDetailFragment extends Fragment implements OnClickListener {
|
|||
|
||||
if(lAddress != null) {
|
||||
contactAddress.setText(lAddress.asStringUriOnly());
|
||||
LinphoneContact contact = ContactsManager.getInstance().findContactFromAddress(getActivity().getContentResolver(), lAddress);
|
||||
LinphoneContact contact = ContactsManager.getInstance().findContactFromAddress(lAddress);
|
||||
if (contact != null) {
|
||||
contactName.setText(contact.getFullName());
|
||||
LinphoneUtils.setImagePictureFromUri(view.getContext(),contactPicture,contact.getPhotoUri(),contact.getThumbnailUri());
|
||||
|
|
|
@ -440,7 +440,7 @@ public class HistoryListFragment extends Fragment implements OnClickListener, On
|
|||
holder.callDirection.setImageResource(R.drawable.call_status_outgoing);
|
||||
}
|
||||
|
||||
LinphoneContact c = ContactsManager.getInstance().findContactFromAddress(getActivity().getContentResolver(), address);
|
||||
LinphoneContact c = ContactsManager.getInstance().findContactFromAddress(address);
|
||||
String displayName = null;
|
||||
final String sipUri = address.asString();
|
||||
if(c != null){
|
||||
|
|
|
@ -545,7 +545,7 @@ public class LinphoneActivity extends Activity implements OnClickListener, Conta
|
|||
//TODO display error message
|
||||
return;
|
||||
}
|
||||
LinphoneContact c = ContactsManager.getInstance().findContactFromAddress(getContentResolver(), lAddress);
|
||||
LinphoneContact c = ContactsManager.getInstance().findContactFromAddress(lAddress);
|
||||
|
||||
String displayName = c != null ? c.getFullName() : LinphoneUtils.getAddressDisplayName(sipUri);
|
||||
String pictureUri = c != null && c.getPhotoUri() != null ? c.getPhotoUri().toString() : null;
|
||||
|
@ -670,7 +670,7 @@ public class LinphoneActivity extends Activity implements OnClickListener, Conta
|
|||
Log.e("Cannot display chat", e);
|
||||
return;
|
||||
}
|
||||
LinphoneContact contact = ContactsManager.getInstance().findContactFromAddress(getContentResolver(), lAddress);
|
||||
LinphoneContact contact = ContactsManager.getInstance().findContactFromAddress(lAddress);
|
||||
displayName = contact != null ? contact.getFullName() : null;
|
||||
|
||||
if (contact != null && contact.getPhotoUri() != null) {
|
||||
|
|
|
@ -864,7 +864,7 @@ public class LinphoneManager implements LinphoneCoreListener, LinphoneChatMessag
|
|||
}
|
||||
|
||||
try {
|
||||
LinphoneContact contact = ContactsManager.getInstance().findContactFromAddress(mServiceContext.getContentResolver(), from);
|
||||
LinphoneContact contact = ContactsManager.getInstance().findContactFromAddress(from);
|
||||
if (!mServiceContext.getResources().getBoolean(R.bool.disable_chat_message_notification)) {
|
||||
if (LinphoneActivity.isInstanciated() && !LinphoneActivity.instance().displayChatMessageNotification(from.asStringUriOnly())) {
|
||||
return;
|
||||
|
|
|
@ -315,7 +315,7 @@ public final class LinphoneService extends Service {
|
|||
LinphoneAddress address = LinphoneCoreFactory.instance().createLinphoneAddress(userName,domain,null);
|
||||
address.setDisplayName(displayName);
|
||||
|
||||
LinphoneContact contact = ContactsManager.getInstance().findContactFromAddress(getContentResolver(), address);
|
||||
LinphoneContact contact = ContactsManager.getInstance().findContactFromAddress(address);
|
||||
Uri pictureUri = contact != null ? contact.getPhotoUri() : null;
|
||||
Bitmap bm = null;
|
||||
try {
|
||||
|
@ -393,7 +393,7 @@ public final class LinphoneService extends Service {
|
|||
|
||||
Uri pictureUri = null;
|
||||
try {
|
||||
LinphoneContact contact = ContactsManager.getInstance().findContactFromAddress(getContentResolver(), LinphoneCoreFactory.instance().createLinphoneAddress(fromSipUri));
|
||||
LinphoneContact contact = ContactsManager.getInstance().findContactFromAddress(LinphoneCoreFactory.instance().createLinphoneAddress(fromSipUri));
|
||||
if (contact != null)
|
||||
pictureUri = contact.getThumbnailUri();
|
||||
} catch (LinphoneCoreException e1) {
|
||||
|
|
Loading…
Reference in a new issue