mirror of
https://gitlab.linphone.org/BC/public/linphone-android.git
synced 2026-01-17 19:38:08 +00:00
[presence] merge bugs fixed + presenece in progress
This commit is contained in:
parent
1af500edbb
commit
2bfd16330e
10 changed files with 120 additions and 108 deletions
|
|
@ -23,15 +23,38 @@
|
|||
android:layout_margin="5dp"
|
||||
android:gravity="center_vertical">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/contact_picture"
|
||||
android:src="@drawable/avatar"
|
||||
android:contentDescription="@string/content_description_contact_picture"
|
||||
android:layout_width="35dp"
|
||||
android:layout_height="35dp"
|
||||
android:adjustViewBounds="true"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_marginLeft="5dp"/>
|
||||
<RelativeLayout
|
||||
android:id="@+id/contact_picture_layout"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="5dp"
|
||||
android:gravity="center_vertical">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/contact_picture"
|
||||
android:src="@drawable/avatar"
|
||||
android:contentDescription="@string/content_description_contact_picture"
|
||||
android:layout_width="35dp"
|
||||
android:layout_height="35dp"
|
||||
android:adjustViewBounds="true"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_marginLeft="5dp"/>
|
||||
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/friendStatus"
|
||||
android:visibility="visible"
|
||||
android:layout_width="15dp"
|
||||
android:layout_height="15dp"
|
||||
android:layout_alignRightOf="@id/contact_picture"
|
||||
android:layout_alignBottomOf="@id/contact_picture"
|
||||
android:adjustViewBounds="true"
|
||||
android:layout_marginRight="3dp"
|
||||
android:layout_marginBottom="3dp"
|
||||
android:scaleType="centerInside"
|
||||
android:src="@drawable/presence_unregistered"
|
||||
/>
|
||||
</RelativeLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/name"
|
||||
|
|
@ -39,22 +62,10 @@
|
|||
style="@style/font2"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_toRightOf="@id/contact_picture"
|
||||
android:layout_toRightOf="@id/contact_picture_layout"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_toLeftOf="@id/delete"
|
||||
android:layout_marginLeft="10dp" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/friendStatus"
|
||||
android:visibility="gone"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:adjustViewBounds="true"
|
||||
android:layout_marginRight="20dp"
|
||||
android:scaleType="centerInside"
|
||||
android:src="@drawable/led_connected" />
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/delete"
|
||||
|
|
|
|||
|
|
@ -25,8 +25,13 @@ import java.util.List;
|
|||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
import org.linphone.core.LinphoneCore;
|
||||
import org.linphone.core.LinphoneFriend;
|
||||
import org.linphone.core.OnlineStatus;
|
||||
import org.linphone.core.PresenceActivityType;
|
||||
import org.linphone.core.PresenceBasicStatus;
|
||||
import org.linphone.core.PresenceModel;
|
||||
import org.linphone.mediastream.Log;
|
||||
|
||||
import android.app.Dialog;
|
||||
import android.app.Fragment;
|
||||
|
|
@ -458,93 +463,65 @@ public class ContactsListFragment extends Fragment implements OnClickListener, O
|
|||
}
|
||||
|
||||
public View getView(final int position, View convertView, ViewGroup parent) {
|
||||
View view = null;
|
||||
LinphoneContact contact = (LinphoneContact) getItem(position);
|
||||
if (contact == null) return null;
|
||||
|
||||
if (convertView != null) {
|
||||
view = convertView;
|
||||
} else {
|
||||
view = mInflater.inflate(R.layout.contact_cell, parent, false);
|
||||
}
|
||||
View view = null;
|
||||
LinphoneContact contact = (LinphoneContact) getItem(position);
|
||||
if (contact == null) return null;
|
||||
|
||||
CheckBox delete = (CheckBox) view.findViewById(R.id.delete);
|
||||
|
||||
TextView name = (TextView) view.findViewById(R.id.name);
|
||||
name.setText(contact.getFullName());
|
||||
if (convertView != null) {
|
||||
view = convertView;
|
||||
} else {
|
||||
view = mInflater.inflate(R.layout.contact_cell, parent, false);
|
||||
}
|
||||
|
||||
LinearLayout separator = (LinearLayout) view.findViewById(R.id.separator);
|
||||
TextView separatorText = (TextView) view.findViewById(R.id.separatorText);
|
||||
if (getPositionForSection(getSectionForPosition(position)) != position) {
|
||||
separator.setVisibility(View.GONE);
|
||||
} else {
|
||||
separator.setVisibility(View.VISIBLE);
|
||||
separatorText.setText(String.valueOf(contact.getFullName().charAt(0)));
|
||||
}
|
||||
|
||||
ImageView icon = (ImageView) view.findViewById(R.id.contact_picture);
|
||||
if (contact.hasPhoto()) {
|
||||
LinphoneUtils.setImagePictureFromUri(getActivity(), icon, contact.getPhotoUri(), contact.getThumbnailUri());
|
||||
} else if (contact.getPhotoUri() != null) {
|
||||
icon.setImageURI(contact.getPhotoUri());
|
||||
} else {
|
||||
icon.setImageResource(R.drawable.avatar);
|
||||
}
|
||||
//CheckBox delete = (CheckBox) view.findViewById(R.id.delete);
|
||||
TextView name = (TextView) view.findViewById(R.id.name);
|
||||
name.setText(contact.getFullName());
|
||||
|
||||
LinearLayout separator = (LinearLayout) view.findViewById(R.id.separator);
|
||||
TextView separatorText = (TextView) view.findViewById(R.id.separatorText);
|
||||
if (getPositionForSection(getSectionForPosition(position)) != position) {
|
||||
separator.setVisibility(View.GONE);
|
||||
} else {
|
||||
separator.setVisibility(View.VISIBLE);
|
||||
separatorText.setText(String.valueOf(contact.getFullName().charAt(0)));
|
||||
}
|
||||
|
||||
ImageView icon = (ImageView) view.findViewById(R.id.contact_picture);
|
||||
if (contact.hasPhoto()) {
|
||||
LinphoneUtils.setImagePictureFromUri(getActivity(), icon, contact.getPhotoUri(), contact.getThumbnailUri());
|
||||
} else if (contact.getPhotoUri() != null) {
|
||||
icon.setImageURI(contact.getPhotoUri());
|
||||
} else {
|
||||
icon.setImageResource(R.drawable.avatar);
|
||||
}
|
||||
|
||||
if (contact != null) {
|
||||
ImageView friendStatus = (ImageView) view.findViewById(R.id.friendStatus);
|
||||
if (contact.isLinphoneFriend() && contact.getFriendPresenceModel() != null){
|
||||
PresenceModel presenceModel = contact.getFriendPresenceModel();
|
||||
PresenceBasicStatus basicStatus = presenceModel.getBasicStatus();
|
||||
String presenceStatus = "";
|
||||
if (basicStatus == PresenceBasicStatus.Open || basicStatus == PresenceBasicStatus.Open)
|
||||
presenceStatus = basicStatus.toString();
|
||||
Log.e("===>>> updateAvatarPresence status = " + presenceStatus + " - vs basicStatus = " + basicStatus);
|
||||
|
||||
if (basicStatus == PresenceBasicStatus.Closed) {
|
||||
friendStatus.setImageResource(R.drawable.presence_unregistered);
|
||||
} else if (presenceStatus == OnlineStatus.Online.toString()) {
|
||||
friendStatus.setImageResource(R.drawable.presence_online);
|
||||
} else {
|
||||
friendStatus.setImageResource(R.drawable.presence_offline);
|
||||
}
|
||||
} else{
|
||||
Log.e("===>>> updateAvatarPresence friend is null ");
|
||||
friendStatus.setImageResource(R.drawable.presence_unregistered);
|
||||
}
|
||||
}
|
||||
|
||||
if (isEditMode) {
|
||||
delete.setVisibility(View.VISIBLE);
|
||||
delete.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
|
||||
contactsList.setItemChecked(position, b);
|
||||
if(getNbItemsChecked() == getCount()){
|
||||
deselectAll.setVisibility(View.VISIBLE);
|
||||
selectAll.setVisibility(View.GONE);
|
||||
enabledDeleteButton(true);
|
||||
} else {
|
||||
if(getNbItemsChecked() == 0){
|
||||
deselectAll.setVisibility(View.GONE);
|
||||
selectAll.setVisibility(View.VISIBLE);
|
||||
enabledDeleteButton(false);
|
||||
} else {
|
||||
deselectAll.setVisibility(View.GONE);
|
||||
selectAll.setVisibility(View.VISIBLE);
|
||||
enabledDeleteButton(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
if (contactsList.isItemChecked(position)) {
|
||||
delete.setChecked(true);
|
||||
} else {
|
||||
delete.setChecked(false);
|
||||
}
|
||||
} else {
|
||||
delete.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
ImageView friendStatus = (ImageView) view.findViewById(R.id.friendStatus);
|
||||
LinphoneFriend[] friends = LinphoneManager.getLc().getFriendList();
|
||||
if (!ContactsManager.getInstance().isContactPresenceDisabled() && friends != null) {
|
||||
friendStatus.setVisibility(View.VISIBLE);
|
||||
PresenceActivityType presenceActivity = friends[0].getPresenceModel().getActivity().getType();
|
||||
if (presenceActivity == PresenceActivityType.Online) {
|
||||
friendStatus.setImageResource(R.drawable.led_connected);
|
||||
} else if (presenceActivity == PresenceActivityType.Busy) {
|
||||
friendStatus.setImageResource(R.drawable.led_error);
|
||||
} else if (presenceActivity == PresenceActivityType.Away) {
|
||||
friendStatus.setImageResource(R.drawable.led_inprogress);
|
||||
} else if (presenceActivity == PresenceActivityType.Offline) {
|
||||
friendStatus.setImageResource(R.drawable.led_disconnected);
|
||||
} else {
|
||||
friendStatus.setImageResource(R.drawable.call_quality_indicator_0);
|
||||
}
|
||||
}
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public Object[] getSections() {
|
||||
return sections;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@ import org.linphone.core.LinphoneCore.RegistrationState;
|
|||
import org.linphone.core.LinphoneCoreException;
|
||||
import org.linphone.core.LinphoneCoreFactory;
|
||||
import org.linphone.core.LinphoneCoreListenerBase;
|
||||
import org.linphone.core.LinphoneFriend;
|
||||
import org.linphone.core.LinphoneProxyConfig;
|
||||
import org.linphone.core.Reason;
|
||||
import org.linphone.mediastream.Log;
|
||||
|
|
@ -65,6 +66,7 @@ import android.net.Uri;
|
|||
import android.os.Bundle;
|
||||
import android.support.v4.app.ActivityCompat;
|
||||
import android.support.v4.widget.DrawerLayout;
|
||||
import android.transition.ChangeTransform;
|
||||
import android.view.Gravity;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.LayoutInflater;
|
||||
|
|
@ -274,6 +276,19 @@ public class LinphoneActivity extends Activity implements OnClickListener, Conta
|
|||
int missedCalls = LinphoneManager.getLc().getMissedCallsCount();
|
||||
displayMissedCalls(missedCalls);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notifyPresenceReceived(LinphoneCore lc, LinphoneFriend lf) {
|
||||
// if(currentFragment == FragmentsAvailable.HISTORY_DETAIL || currentFragment == FragmentsAvailable.HISTORY_LIST || currentFragment == FragmentsAvailable.CONTACTS_LIST
|
||||
// || currentFragment == FragmentsAvailable.CONTACT_DETAIL || currentFragment == FragmentsAvailable.CONTACT_EDITOR || currentFragment == FragmentsAvailable.CHAT_LIST
|
||||
// || currentFragment == FragmentsAvailable.CHAT){
|
||||
|
||||
if(currentFragment == FragmentsAvailable.CONTACTS_LIST){
|
||||
if (contactListFragment != null && contactListFragment.isVisible()) {
|
||||
((ContactsListFragment) contactListFragment).invalidate();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ import org.linphone.core.LinphoneCoreException;
|
|||
import org.linphone.core.LinphoneCoreFactory;
|
||||
import org.linphone.core.LinphoneFriend;
|
||||
import org.linphone.core.LinphoneFriend.SubscribePolicy;
|
||||
import org.linphone.core.PresenceModel;
|
||||
import org.linphone.mediastream.Log;
|
||||
|
||||
import android.content.ContentProviderOperation;
|
||||
|
|
@ -431,6 +432,11 @@ public class LinphoneContact implements Serializable, Comparable<LinphoneContact
|
|||
friend = f;
|
||||
}
|
||||
|
||||
public PresenceModel getFriendPresenceModel(){
|
||||
if(friend != null)return friend.getPresenceModel();
|
||||
else return null;
|
||||
}
|
||||
|
||||
public static LinphoneContact createContact() {
|
||||
if (ContactsManager.getInstance().hasContactsAccess()) {
|
||||
return createAndroidContact();
|
||||
|
|
|
|||
|
|
@ -842,6 +842,9 @@ public class LinphoneManager implements LinphoneCoreListener, LinphoneChatMessag
|
|||
}
|
||||
|
||||
public void notifyPresenceReceived(LinphoneCore lc, LinphoneFriend lf) {
|
||||
|
||||
// TODO:
|
||||
Log.e("===>> notifyPresenceReceived : "+lf.getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
Subproject commit 78aedfdf5cb02565ceb48e4acef202462c2f0dbf
|
||||
Subproject commit 4edc094bcfee08032b6d6fb38cfb00ecf66a9f49
|
||||
|
|
@ -1 +1 @@
|
|||
Subproject commit b3a628c7de0f6f74e09e60b134de6e3ebfbd3a54
|
||||
Subproject commit 29e865b5566890ae1ba3a50b0699337ef926d6b5
|
||||
|
|
@ -1 +1 @@
|
|||
Subproject commit da7030bb322f4cd74638e6710007b1470c1b602e
|
||||
Subproject commit 129a9f0cbb880361d1f10c08fd4c2bd188ec0565
|
||||
|
|
@ -1 +1 @@
|
|||
Subproject commit 1bff470db4829ed6c83712ee4a4b8cf973c6188a
|
||||
Subproject commit 4c486cf295bc4e8187c8315e95a687a030456ac3
|
||||
|
|
@ -1 +1 @@
|
|||
Subproject commit 6f48b4151cce800cb300a2c4c8dd8b32e7275c1b
|
||||
Subproject commit f0cd38ef228cf26bfdd0fd8bd037fd74fb1e1c5a
|
||||
Loading…
Add table
Reference in a new issue