Manage linphone contact from presence model

This commit is contained in:
Margaux Clerc 2016-09-15 15:11:29 +02:00
parent 11e0181e6f
commit 698a136a12
4 changed files with 56 additions and 12 deletions

View file

@ -17,14 +17,33 @@
android:layout_marginRight="10dp"
android:background="@color/colorE"/>
<TextView
android:id="@+id/address_label"
android:layout_marginTop="10dp"
android:layout_gravity="center"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAllCaps="true"
android:textColor="@color/colorE" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/address_label"
android:layout_marginTop="10dp"
android:layout_centerInParent="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAllCaps="true"
android:textColor="@color/colorE" />
<ImageView
android:id="@+id/friendLinphone"
android:visibility="gone"
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:adjustViewBounds="true"
android:layout_marginRight="10dp"
android:scaleType="centerInside"
android:src="@drawable/linphone_user" />
</RelativeLayout>
<TextView
android:id="@+id/numeroOrAddress"

View file

@ -133,10 +133,19 @@ public class ContactDetailsFragment extends Fragment implements OnClickListener
TextView tv = (TextView) v.findViewById(R.id.numeroOrAddress);
tv.setText(displayednumberOrAddress);
tv.setSelected(true);
String contactAddress = contact.getPresenceModelForUri(noa.getValue());
if(contactAddress != null) {
v.findViewById(R.id.friendLinphone).setVisibility(View.VISIBLE);
}
if (!displayChatAddressOnly) {
v.findViewById(R.id.contact_call).setOnClickListener(dialListener);
v.findViewById(R.id.contact_call).setTag(displayednumberOrAddress);
if(contactAddress != null){
v.findViewById(R.id.contact_call).setTag(contact.getPresenceModelForUri(noa.getValue()));
} else {
v.findViewById(R.id.contact_call).setTag(displayednumberOrAddress);
}
} else {
v.findViewById(R.id.contact_call).setVisibility(View.GONE);
}
@ -146,9 +155,18 @@ public class ContactDetailsFragment extends Fragment implements OnClickListener
if (lpc != null) {
String username = lpc.normalizePhoneNumber(LinphoneUtils.getUsernameFromAddress(noa.getValue()));
String tag = LinphoneUtils.getFullAddressFromUsername(username);
v.findViewById(R.id.contact_chat).setTag(tag);
if(contactAddress != null){
v.findViewById(R.id.contact_chat).setTag(contact.getPresenceModelForUri(noa.getValue()));
} else {
v.findViewById(R.id.contact_chat).setTag(tag);
}
} else {
v.findViewById(R.id.contact_chat).setTag(noa.getValue());
if(contactAddress != null){
v.findViewById(R.id.contact_chat).setTag(contact.getPresenceModelForUri(noa.getValue()));
} else {
v.findViewById(R.id.contact_chat).setTag(noa.getValue());
}
}
if (getResources().getBoolean(R.bool.disable_chat)) {

View file

@ -217,7 +217,7 @@ public class ContactsManager extends ContentObserver {
contacts = c;
sipContacts = new ArrayList<LinphoneContact>();
for (LinphoneContact contact : contacts) {
if (contact.hasAddress()) {
if (contact.hasAddress() || contact.isInLinphoneFriendList()) {
sipContacts.add(contact);
}
}

View file

@ -635,6 +635,13 @@ public class LinphoneContact implements Serializable, Comparable<LinphoneContact
return (friend != null && friend.getPresenceModel() != null && friend.getPresenceModel().getBasicStatus().equals(PresenceBasicStatus.Open));
}
public String getPresenceModelForUri(String uri) {
if (friend != null && friend.getPresenceModelForUri(uri) != null){
return friend.getPresenceModelForUri(uri).getContact();
}
return null;
}
public void setFriend(LinphoneFriend f) {
friend = f;
}