mirror of
https://gitlab.linphone.org/BC/public/linphone-android.git
synced 2026-01-17 11:28:06 +00:00
[Presence] updated + history details fixed
This commit is contained in:
parent
88f9a5f886
commit
07d5755739
8 changed files with 148 additions and 124 deletions
BIN
res/drawable-xhdpi/presence_away.png
Normal file
BIN
res/drawable-xhdpi/presence_away.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 956 B |
|
|
@ -43,7 +43,7 @@
|
|||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_vertical"
|
||||
/>
|
||||
/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/contact_picture"
|
||||
|
|
@ -89,89 +89,97 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:text="@string/address_sip"
|
||||
style="@style/font8"
|
||||
android:textStyle="bold"
|
||||
android:background="@color/colorA"
|
||||
android:textAllCaps="true"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="40dp"
|
||||
android:gravity="center"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/contact_address"
|
||||
style="@style/font2"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="2dp"
|
||||
android:layout_gravity="center"/>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/call"
|
||||
android:src="@drawable/call_start_button"
|
||||
android:contentDescription="@string/content_description_dial_back"
|
||||
android:layout_width="60dp"
|
||||
android:layout_height="60dp"
|
||||
android:layout_margin="10dp"
|
||||
android:adjustViewBounds="true"
|
||||
android:layout_centerInParent="true"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/chat"
|
||||
android:src="@drawable/chat_start_button"
|
||||
android:contentDescription="@string/content_description_chat"
|
||||
android:layout_width="60dp"
|
||||
android:layout_height="60dp"
|
||||
android:layout_margin="10dp"
|
||||
android:adjustViewBounds="true"
|
||||
android:layout_centerInParent="true" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/log_row"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:paddingTop="5dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/direction"
|
||||
android:text="@string/history_log_label"
|
||||
style="@style/font9"
|
||||
android:layout_marginTop="2dp"
|
||||
android:layout_gravity="center"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"/>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:gravity="center"
|
||||
android:padding="10dp">
|
||||
<TextView
|
||||
android:text="@string/address_sip"
|
||||
style="@style/font8"
|
||||
android:textStyle="bold"
|
||||
android:background="@color/colorA"
|
||||
android:textAllCaps="true"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="40dp"
|
||||
android:gravity="center"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/date"
|
||||
android:id="@+id/contact_address"
|
||||
style="@style/font2"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"/>
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="2dp"
|
||||
android:layout_gravity="center"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/time"
|
||||
style="@style/font2"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"/>
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/call"
|
||||
android:src="@drawable/call_start_button"
|
||||
android:contentDescription="@string/content_description_dial_back"
|
||||
android:layout_width="60dp"
|
||||
android:layout_height="60dp"
|
||||
android:layout_margin="10dp"
|
||||
android:adjustViewBounds="true"
|
||||
android:layout_centerInParent="true"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/chat"
|
||||
android:src="@drawable/chat_start_button"
|
||||
android:contentDescription="@string/content_description_chat"
|
||||
android:layout_width="60dp"
|
||||
android:layout_height="60dp"
|
||||
android:layout_margin="10dp"
|
||||
android:adjustViewBounds="true"
|
||||
android:layout_centerInParent="true" />
|
||||
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/log_row"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:paddingTop="5dp">
|
||||
|
||||
<TextView
|
||||
android:text="@string/call"
|
||||
style="@style/font9"
|
||||
android:textAllCaps="true"
|
||||
android:layout_marginTop="2dp"
|
||||
android:layout_gravity="center"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"/>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:gravity="center"
|
||||
android:padding="10dp">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/direction"
|
||||
android:paddingLeft="10dp"
|
||||
android:paddingRight="10dp"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/date"
|
||||
style="@style/font10"
|
||||
android:paddingRight="10dp"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/time"
|
||||
style="@style/font10"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"/>
|
||||
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
</ScrollView>
|
||||
</LinearLayout>
|
||||
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}*/
|
||||
}
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<LinphoneContact
|
|||
if(getFriendPresenceModel() == null){
|
||||
friend.enableSubscribes(true);
|
||||
friend.setIncSubscribePolicy(SubscribePolicy.SPAccept);
|
||||
PresenceModel model = LinphoneCoreFactory.instance().createPresenceModel(PresenceActivityType.Offline, null);
|
||||
PresenceModel model = LinphoneCoreFactory.instance().createPresenceModel();
|
||||
model.setBasicStatus(PresenceBasicStatus.Closed);
|
||||
friend.setPresenceModel(model);
|
||||
}
|
||||
fullName = friend.getName();
|
||||
|
|
|
|||
|
|
@ -372,11 +372,7 @@ public class LinphoneManager implements LinphoneCoreListener, LinphoneChatMessag
|
|||
LinphoneCore lc = getLcIfManagerNotDestroyedOrNull();
|
||||
if(lc != null ) {
|
||||
LinphoneFriendList mFriendList = (lc.getFriendLists())[0];
|
||||
if (enabled) {
|
||||
//mFriendList.updateSubscriptions(lc.getDefaultProxyConfig(), true);
|
||||
} else {
|
||||
mFriendList.closeSubscriptions();
|
||||
}
|
||||
mFriendList.enableSubscriptions(enabled);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -878,8 +874,9 @@ public class LinphoneManager implements LinphoneCoreListener, LinphoneChatMessag
|
|||
|
||||
public void notifyPresenceReceived(LinphoneCore lc, LinphoneFriend lf) {
|
||||
for(AvatarWithPresenceImage listener : listeners){
|
||||
Log.e("===>> 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);
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
Subproject commit 9efcd5f61079571ddd220d97f10bc4543b99f09e
|
||||
Subproject commit ad382a060c447e134abe2e91e444d3b71e6590c5
|
||||
Loading…
Add table
Reference in a new issue