From 91ad39553366b664bb2ed6489379fde52981f034 Mon Sep 17 00:00:00 2001 From: Erwan Croze Date: Thu, 15 Nov 2018 14:28:11 +0100 Subject: [PATCH] Fix picture contact in conference and call paused view --- .../org/linphone/call/CallActivity.java | 68 ++++++++++++++++++- 1 file changed, 66 insertions(+), 2 deletions(-) diff --git a/src/android/org/linphone/call/CallActivity.java b/src/android/org/linphone/call/CallActivity.java index 2dd0c78cf..d384da62c 100644 --- a/src/android/org/linphone/call/CallActivity.java +++ b/src/android/org/linphone/call/CallActivity.java @@ -60,6 +60,9 @@ import android.widget.RelativeLayout; import android.widget.TextView; import android.widget.Toast; +import org.linphone.core.ChatRoomSecurityLevel; +import org.linphone.core.PresenceModel; +import org.linphone.core.ProxyConfig; import org.linphone.core.ZrtpPeerStatus; import org.linphone.receivers.BluetoothManager; import org.linphone.contacts.ContactsManager; @@ -98,6 +101,7 @@ import java.util.List; import java.util.Timer; import java.util.TimerTask; +import static org.linphone.LinphoneUtils.getSecurityLevelForSipUri; import static org.linphone.LinphoneUtils.getZrtpStatus; public class CallActivity extends LinphoneGenericActivity implements OnClickListener, ActivityCompat.OnRequestPermissionsResultCallback { @@ -1523,7 +1527,6 @@ public class CallActivity extends LinphoneGenericActivity implements OnClickList TextView contactName = (TextView) callView.findViewById(R.id.contact_name); ImageView contactImage = (ImageView) callView.findViewById(R.id.contact_picture); - Address lAddress = call.getRemoteAddress(); setContactInformation(contactName, contactImage, lAddress); displayCallStatusIconAndReturnCallPaused(callView, call); @@ -1536,11 +1539,40 @@ public class CallActivity extends LinphoneGenericActivity implements OnClickList LinphoneContact lContact = ContactsManager.getInstance().findContactFromAddress(lAddress); if (lContact == null) { contactName.setText(LinphoneUtils.getAddressDisplayName(lAddress)); - //contactPicture.setImageBitmap(ContactsManager.getInstance().getDefaultAvatarBitmap()); } else { contactName.setText(lContact.getFullName()); //LinphoneUtils.setImagePictureFromUri(contactPicture.getContext(), contactPicture, lContact.getPhotoUri(), lContact.getThumbnailUri()); } + + //Obiane spec + ProxyConfig prx = LinphoneManager.getLc().getDefaultProxyConfig(); + Address ourUri = (prx != null) ? prx.getIdentityAddress() : null; + ChatRoomSecurityLevel securityLevel = getSecurityLevelForSipUri(LinphoneManager.getLc(), ourUri, lAddress); + if (securityLevel == ChatRoomSecurityLevel.Safe) { + contactPicture.setImageResource(R.drawable.avatar_big_secure2); + } else if (securityLevel == ChatRoomSecurityLevel.Unsafe) { + contactPicture.setImageResource(R.drawable.avatar_big_unsecure); + } else if (securityLevel == ChatRoomSecurityLevel.Encrypted) { + contactPicture.setImageResource(R.drawable.avatar_big_secure1); + } else { + ZrtpPeerStatus zrtpStatus = getZrtpStatus(LinphoneManager.getLc(), lAddress.asStringUriOnly()); + if (zrtpStatus == ZrtpPeerStatus.Valid) { + contactPicture.setImageResource(R.drawable.avatar_medium_secure2); + } else if (zrtpStatus == ZrtpPeerStatus.Invalid) { + contactPicture.setImageResource(R.drawable.avatar_medium_unsecure); + } else { + if (!ContactsManager.getInstance().isContactPresenceDisabled() && lContact != null && lContact.getFriend() != null) { + PresenceModel presenceModel = lContact.getFriend().getPresenceModel(); + if (presenceModel != null) { + contactPicture.setImageResource(R.drawable.avatar_medium_secure1); + } else { + contactPicture.setImageResource(R.drawable.avatar_medium_unregistered); + } + } else { + contactPicture.setImageResource(R.drawable.avatar_medium_unregistered); + } + } + } } private boolean displayCallStatusIconAndReturnCallPaused(LinearLayout callView, Call call) { @@ -1695,7 +1727,9 @@ public class CallActivity extends LinphoneGenericActivity implements OnClickList LinearLayout confView = (LinearLayout) inflater.inflate(R.layout.conf_call_control_row, container, false); conferenceList.setId(index + 1); TextView contact = (TextView) confView.findViewById(R.id.contactNameOrNumber); + ImageView picture = confView.findViewById(R.id.contactPicture); + Address lAddress = call.getRemoteAddress(); LinphoneContact lContact = ContactsManager.getInstance().findContactFromAddress(call.getRemoteAddress()); if (lContact == null) { contact.setText(call.getRemoteAddress().getUsername()); @@ -1703,6 +1737,36 @@ public class CallActivity extends LinphoneGenericActivity implements OnClickList contact.setText(lContact.getFullName()); } + //Obiane spec + ProxyConfig prx = LinphoneManager.getLc().getDefaultProxyConfig(); + Address ourUri = (prx != null) ? prx.getIdentityAddress() : null; + ChatRoomSecurityLevel securityLevel = getSecurityLevelForSipUri(LinphoneManager.getLc(), ourUri, lAddress); + if (securityLevel == ChatRoomSecurityLevel.Safe) { + picture.setImageResource(R.drawable.avatar_big_secure2); + } else if (securityLevel == ChatRoomSecurityLevel.Unsafe) { + picture.setImageResource(R.drawable.avatar_big_unsecure); + } else if (securityLevel == ChatRoomSecurityLevel.Encrypted) { + picture.setImageResource(R.drawable.avatar_big_secure1); + } else { + ZrtpPeerStatus zrtpStatus = getZrtpStatus(LinphoneManager.getLc(), lAddress.asStringUriOnly()); + if (zrtpStatus == ZrtpPeerStatus.Valid) { + picture.setImageResource(R.drawable.avatar_medium_secure2); + } else if (zrtpStatus == ZrtpPeerStatus.Invalid) { + picture.setImageResource(R.drawable.avatar_medium_unsecure); + } else { + if (!ContactsManager.getInstance().isContactPresenceDisabled() && lContact != null && lContact.getFriend() != null) { + PresenceModel presenceModel = lContact.getFriend().getPresenceModel(); + if (presenceModel != null) { + picture.setImageResource(R.drawable.avatar_medium_secure1); + } else { + picture.setImageResource(R.drawable.avatar_medium_unregistered); + } + } else { + picture.setImageResource(R.drawable.avatar_medium_unregistered); + } + } + } + registerCallDurationTimer(confView, call); ImageView quitConference = (ImageView) confView.findViewById(R.id.quitConference);