From 07d57557391b074fc35551739ddb46d2b10f29b6 Mon Sep 17 00:00:00 2001 From: Brieuc Viel Date: Wed, 27 Apr 2016 15:27:15 +0200 Subject: [PATCH] [Presence] updated + history details fixed --- res/drawable-xhdpi/presence_away.png | Bin 0 -> 956 bytes res/layout/history_detail.xml | 164 +++++++++--------- src/org/linphone/ContactsListFragment.java | 1 + src/org/linphone/HistoryDetailFragment.java | 65 +++---- src/org/linphone/LinphoneContact.java | 4 +- src/org/linphone/LinphoneManager.java | 13 +- .../linphone/ui/AvatarWithPresenceImage.java | 23 ++- submodules/linphone | 2 +- 8 files changed, 148 insertions(+), 124 deletions(-) create mode 100644 res/drawable-xhdpi/presence_away.png diff --git a/res/drawable-xhdpi/presence_away.png b/res/drawable-xhdpi/presence_away.png new file mode 100644 index 0000000000000000000000000000000000000000..1495008b3ab1fa78deffc75d4a5ee863a68ecfe0 GIT binary patch literal 956 zcmV;t14I0YP)500006VoOIv0RI60 z0RN!9r;`8x010qNS#tmY4c7nw4c7reD4Tcy000McNliru-~<~8A|s>Dp_Tvu14&6l zK~z}7)tFCc6n7NIKW~zlGzTqdqHQfjMO(1cOD+~eLAo9MQ9^> z?m;|M428DIY?{!ElEUsRQ4#}Qt%4x*53w;-s|ht$H*tL)c4oVq-K5!dcc9OQaZ5ruHmJg$`2y!s9fqrklN)1PV zeZafG8!IgR8@L5b0{vpV8^toaY8Z8G#CXByZr}v44QME_6sCXy7U+{tyhR=P5a}E* zBQvhO2KWLv4%G2-N}yJ+MB{gLxD)9bDG0ENJsKaR5jgE<nU+_+ODGpS}jT>F3)sw)dPrtaQ)F^NJL>A8ry_9nnC)tSrG7I@Yj z_)iu__1hqz!*|p$v=(rHtPxrOB8P*3oxZh)rFYbgY%VO|n9~BhMY!4s@^)bXt2P5o zA;UBQ&Bc7C5qKqJn1TL^Q{ng(V< zhWQhiE_C3};|l!jr!Fl0Mh&;}VDvjDI8zhAgOET{z@&70i+M28n>nl`>Rt7-qancD z0b<2lh#)&yr*bR2N>X50j5no&yNjIKy$Lk-5n|#Kz&BNfxej~@Kwa}Po!;}H@lPKG z;yHIwN&N-%it$qF+Ifw69*jgsQ8$8^v8TXiz<7mwn@2#m81I_?(4HNImYoj7B!ijh zHb@VUs1V3qpabC&0RN=^dsN8)d8q3kCNTx<2fhZLl=;Zgz!hMZ7;l2~f&$2=mrEYv za;M7O{tWd#@ETCF3akGEI3vb8zjVK{27is&kOn!Fg=z!#0`CDEfOWtc-?<+H_x-_t zjJmoD()rV3W?egC;+6SJM28&Yz`y0A10UC7r8fF7^*+oz=!}@;d`<_6986Tntp@h2 eF3yeczt#&yaUJVe3w<{L0000 + /> - - - - - - - - - - - - - - - - - + + android:layout_height="wrap_content" + android:padding="2dp" + android:layout_gravity="center"/> - + + + + + - - + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/org/linphone/ContactsListFragment.java b/src/org/linphone/ContactsListFragment.java index 0be52ce8d..88fb6ad05 100644 --- a/src/org/linphone/ContactsListFragment.java +++ b/src/org/linphone/ContactsListFragment.java @@ -356,6 +356,7 @@ public class ContactsListFragment extends Fragment implements OnClickListener, O public void onPause() { instance = null; ContactsManager.removeContactsListener(this); + LinphoneManager.getInstance().removePresenceUpdatedListener(); super.onPause(); } diff --git a/src/org/linphone/HistoryDetailFragment.java b/src/org/linphone/HistoryDetailFragment.java index d8ef6b291..5b833d91e 100644 --- a/src/org/linphone/HistoryDetailFragment.java +++ b/src/org/linphone/HistoryDetailFragment.java @@ -23,13 +23,12 @@ import java.util.Calendar; import org.linphone.core.LinphoneAddress; import org.linphone.core.LinphoneCoreException; import org.linphone.core.LinphoneCoreFactory; -import org.linphone.core.LinphoneFriend; import org.linphone.ui.AvatarWithPresenceImage; import android.annotation.SuppressLint; -import android.app.Fragment; import android.net.Uri; import android.os.Bundle; +import android.app.Fragment; import android.view.LayoutInflater; import android.view.View; import android.view.View.OnClickListener; @@ -43,9 +42,9 @@ import android.widget.TextView; public class HistoryDetailFragment extends Fragment implements OnClickListener { private ImageView dialBack, chat, addToContacts, back; private View view; - private ImageView contactPicture; + private ImageView contactPicture, callDirection; private AvatarWithPresenceImage avatarWithPresenceImage; - private TextView contactName, contactAddress, time, date, callDirection; + private TextView contactName, contactAddress, time, date; private String sipUri, displayName, pictureUri; @Override @@ -75,17 +74,20 @@ public class HistoryDetailFragment extends Fragment implements OnClickListener { if (getResources().getBoolean(R.bool.disable_chat)) view.findViewById(R.id.chat).setVisibility(View.GONE); - //addToContacts = (ImageView) view.findViewById(R.id.add_contact); - //addToContacts.setOnClickListener(this); - - contactPicture = (ImageView) view.findViewById(R.id.contact_picture); - contactName = (TextView) view.findViewById(R.id.contact_name); - contactAddress = (TextView) view.findViewById(R.id.contact_address); + // addToContacts = (ImageView) view.findViewById(R.id.add_contact); + // addToContacts.setOnClickListener(this); + contactPicture = (ImageView) view.findViewById(R.id.contact_picture); + + contactName = (TextView) view.findViewById(R.id.contact_name); + if (displayName == null) { + displayName = LinphoneUtils.getUsernameFromAddress(sipUri); + } avatarWithPresenceImage = (AvatarWithPresenceImage) view.findViewById(R.id.avatar_with_presence); avatarWithPresenceImage.setFormatAvatarImage(AvatarWithPresenceImage.AVATAR_BIG); - - callDirection = (TextView) view.findViewById(R.id.direction); + contactAddress = (TextView) view.findViewById(R.id.contact_address); + + callDirection = (ImageView) view.findViewById(R.id.direction); time = (TextView) view.findViewById(R.id.time); date = (TextView) view.findViewById(R.id.date); @@ -96,6 +98,21 @@ public class HistoryDetailFragment extends Fragment implements OnClickListener { } private void displayHistory(String status, String callTime, String callDate) { + contactName.setText(displayName == null ? sipUri : displayName); + if (displayName == null) { + contactAddress.setText(LinphoneUtils.getUsernameFromAddress(sipUri)); + } else { + contactAddress.setText(sipUri); + } + + if (status.equals(getResources().getString(R.string.missed))) { + callDirection.setImageResource(R.drawable.call_status_missed); + } else if (status.equals(getResources().getString(R.string.incoming))) { + callDirection.setImageResource(R.drawable.call_status_incoming); + } else if (status.equals(getResources().getString(R.string.outgoing))) { + callDirection.setImageResource(R.drawable.call_status_outgoing); + } + time.setText(callTime == null ? "" : callTime); Long longDate = Long.parseLong(callDate); date.setText(LinphoneUtils.timestampToHumanDate(getActivity(), longDate, getString(R.string.history_detail_date_format), false)); @@ -110,23 +127,7 @@ public class HistoryDetailFragment extends Fragment implements OnClickListener { } catch(LinphoneCoreException e) { e.printStackTrace(); } - - /*LinphoneAddress lAddress = null; - try { - lAddress = LinphoneCoreFactory.instance().createLinphoneAddress(sipUri); - Contact contact = ContactsManager.getInstance().findContactWithAddress(getActivity().getContentResolver(), lAddress); - - if (contact != null) { - LinphoneUtils.setImagePictureFromUri(view.getContext(),contactPicture,contact.getPhotoUri(),contact.getThumbnailUri()); - view.findViewById(R.id.add_contact).setVisibility(View.GONE); - } else { - contactPicture.setImageResource(R.drawable.avatar); - view.findViewById(R.id.add_contact).setVisibility(View.VISIBLE); - } - - } catch (LinphoneCoreException e) { - e.printStackTrace(); - }*/ + } public void changeDisplayedHistory(String sipUri, String displayName, String pictureUri, String status, String callTime, String callDate) { @@ -160,9 +161,11 @@ public class HistoryDetailFragment extends Fragment implements OnClickListener { LinphoneActivity.instance().setAddresGoToDialerAndCall(sipUri, displayName, pictureUri == null ? null : Uri.parse(pictureUri)); } else if (id == R.id.chat) { LinphoneActivity.instance().displayChat(sipUri); - } /* else if (id == R.id.add_contact) { + } + /*else if (id == R.id.add_contact) { String uriToAdd = sipUri; LinphoneActivity.instance().displayContactsForEdition(uriToAdd); - }*/ + } + */ } } diff --git a/src/org/linphone/LinphoneContact.java b/src/org/linphone/LinphoneContact.java index b2388c0d6..36993f483 100644 --- a/src/org/linphone/LinphoneContact.java +++ b/src/org/linphone/LinphoneContact.java @@ -30,6 +30,7 @@ import org.linphone.core.LinphoneCoreFactory; import org.linphone.core.LinphoneFriend; import org.linphone.core.LinphoneFriend.SubscribePolicy; import org.linphone.core.PresenceActivityType; +import org.linphone.core.PresenceBasicStatus; import org.linphone.core.PresenceModel; import org.linphone.mediastream.Log; @@ -374,7 +375,8 @@ public class LinphoneContact implements Serializable, Comparable> LinphoneManager : notifyPresenceReceived : "+listener.getFriendName()+" vs "+lf.getName().toString()+" - "+lf.getPresenceModel().getActivity().getType()); if(listener.isThisFriend(lf)){ - //Log.e("===>> LinphoneManager : notifyPresenceReceived : "+lf.getName().toString()+" - "+lf.getPresenceModel().getActivity().getType()); + Log.e("===>> LinphoneManager : notifyPresenceReceived 2: "+lf.getName().toString()+" - "+lf.getPresenceModel().getActivity().getType()); listener.updatePresenceIcon(lc, lf); } } @@ -889,6 +886,10 @@ public class LinphoneManager implements LinphoneCoreListener, LinphoneChatMessag listeners.add(aWPI); } + public void removePresenceUpdatedListener(){ + listeners.clear(); + } + @Override public void dtmfReceived(LinphoneCore lc, LinphoneCall call, int dtmf) { Log.d("DTMF received: " + dtmf); diff --git a/src/org/linphone/ui/AvatarWithPresenceImage.java b/src/org/linphone/ui/AvatarWithPresenceImage.java index 4d7fc35f7..f64e71cb5 100644 --- a/src/org/linphone/ui/AvatarWithPresenceImage.java +++ b/src/org/linphone/ui/AvatarWithPresenceImage.java @@ -47,7 +47,6 @@ public class AvatarWithPresenceImage extends RelativeLayout implements onPresenc init(); } - private void init() { this.inflate(getContext(), R.layout.avatar_with_presence, this); friendStatusSmall = (ImageView) this.findViewById(R.id.friend_status_small); @@ -83,6 +82,15 @@ public class AvatarWithPresenceImage extends RelativeLayout implements onPresenc return this.contact.compareFriend(myFriend); } + public String getFriendName(){ + return this.contact.getFullName(); + } + + //TODO + public boolean isThisFriendByName(LinphoneFriend myFriend){ + return this.contact.compareFriend(myFriend); + } + @Override public void updatePresenceIcon (LinphoneCore lc, LinphoneFriend friend){ @@ -95,16 +103,17 @@ public class AvatarWithPresenceImage extends RelativeLayout implements onPresenc if (basicStatus == PresenceBasicStatus.Closed) { friendStatusSmall.setImageResource(R.drawable.presence_unregistered); friendStatusBig.setImageResource(R.drawable.presence_unregistered); - } else if ((presenceModel.getActivity().getType() == PresenceActivityType.TV ) || (presenceModel.getActivity().getType() == PresenceActivityType.Online)) { + } else if ((presenceModel.getActivity().getType() == PresenceActivityType.TV )) { friendStatusSmall.setImageResource(R.drawable.presence_online); friendStatusBig.setImageResource(R.drawable.presence_online); } else { - friendStatusSmall.setImageResource(R.drawable.presence_offline); - friendStatusBig.setImageResource(R.drawable.presence_offline); + friendStatusSmall.setImageResource(R.drawable.presence_away); + friendStatusBig.setImageResource(R.drawable.presence_away); } - } else if(contact.isLinphoneFriend()){ - friendStatusSmall.setImageResource(R.drawable.presence_offline); - friendStatusBig.setImageResource(R.drawable.presence_offline); + /*} else if(contact.isLinphoneFriend()){ + friendStatusSmall.setImageResource(R.drawable.presence_away); + friendStatusBig.setImageResource(R.drawable.presence_away); + */ } else{ friendStatusSmall.setImageResource(R.drawable.presence_unregistered); friendStatusSmall.setImageResource(R.drawable.presence_unregistered); diff --git a/submodules/linphone b/submodules/linphone index 9efcd5f61..ad382a060 160000 --- a/submodules/linphone +++ b/submodules/linphone @@ -1 +1 @@ -Subproject commit 9efcd5f61079571ddd220d97f10bc4543b99f09e +Subproject commit ad382a060c447e134abe2e91e444d3b71e6590c5