Using new callback for presence notification
This commit is contained in:
parent
a484b55fe2
commit
a3558f70be
3 changed files with 44 additions and 11 deletions
|
@ -1012,9 +1012,7 @@ public class LinphoneManager implements CoreListener, SensorEventListener, Accou
|
||||||
private Vibrator mVibrator;
|
private Vibrator mVibrator;
|
||||||
|
|
||||||
public void onNewSubscriptionRequested(Core lc, Friend lf, String url) {}
|
public void onNewSubscriptionRequested(Core lc, Friend lf, String url) {}
|
||||||
public void onNotifyPresenceReceived(Core lc, Friend lf) {
|
public void onNotifyPresenceReceived(Core lc, Friend lf) {}
|
||||||
ContactsManager.getInstance().refreshSipContact(lf);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEcCalibrationAudioInit(Core lc) {
|
public void onEcCalibrationAudioInit(Core lc) {
|
||||||
|
@ -1659,12 +1657,12 @@ public class LinphoneManager implements CoreListener, SensorEventListener, Accou
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFriendListCreated(Core lc, FriendList list) {
|
public void onFriendListCreated(Core lc, FriendList list) {
|
||||||
// TODO Auto-generated method stub
|
list.setListener(ContactsManager.getInstance());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFriendListRemoved(Core lc, FriendList list) {
|
public void onFriendListRemoved(Core lc, FriendList list) {
|
||||||
// TODO Auto-generated method stub
|
list.setListener(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -45,6 +45,7 @@ import org.linphone.core.Core;
|
||||||
import org.linphone.core.Factory;
|
import org.linphone.core.Factory;
|
||||||
import org.linphone.core.Friend;
|
import org.linphone.core.Friend;
|
||||||
import org.linphone.core.FriendList;
|
import org.linphone.core.FriendList;
|
||||||
|
import org.linphone.core.FriendListListener;
|
||||||
import org.linphone.core.MagicSearch;
|
import org.linphone.core.MagicSearch;
|
||||||
import org.linphone.core.ProxyConfig;
|
import org.linphone.core.ProxyConfig;
|
||||||
import org.linphone.mediastream.Log;
|
import org.linphone.mediastream.Log;
|
||||||
|
@ -59,7 +60,7 @@ import java.util.Locale;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
public class ContactsManager extends ContentObserver {
|
public class ContactsManager extends ContentObserver implements FriendListListener {
|
||||||
private static ContactsManager instance;
|
private static ContactsManager instance;
|
||||||
|
|
||||||
private List<LinphoneContact> contacts, sipContacts;
|
private List<LinphoneContact> contacts, sipContacts;
|
||||||
|
@ -93,6 +94,12 @@ public class ContactsManager extends ContentObserver {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void destroy() {
|
public void destroy() {
|
||||||
|
Core lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
|
||||||
|
if (lc != null) {
|
||||||
|
for (FriendList list : lc.getFriendsLists()) {
|
||||||
|
list.setListener(null);
|
||||||
|
}
|
||||||
|
}
|
||||||
defaultAvatar.recycle();
|
defaultAvatar.recycle();
|
||||||
instance = null;
|
instance = null;
|
||||||
}
|
}
|
||||||
|
@ -293,10 +300,6 @@ public class ContactsManager extends ContentObserver {
|
||||||
LinphoneContact contact = (LinphoneContact)lf.getUserData();
|
LinphoneContact contact = (LinphoneContact)lf.getUserData();
|
||||||
if (contact != null && !sipContacts.contains(contact)) {
|
if (contact != null && !sipContacts.contains(contact)) {
|
||||||
sipContacts.add(contact);
|
sipContacts.add(contact);
|
||||||
Collections.sort(sipContacts);
|
|
||||||
for (ContactsUpdatedListener listener : contactsUpdatedListeners) {
|
|
||||||
listener.onContactsUpdated();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -590,4 +593,36 @@ public class ContactsManager extends ContentObserver {
|
||||||
Cursor c = getContentResolver().query(ContactsContract.Data.CONTENT_URI, projection, select, new String[]{ ContactsContract.CommonDataKinds.Organization.CONTENT_ITEM_TYPE }, null);
|
Cursor c = getContentResolver().query(ContactsContract.Data.CONTENT_URI, projection, select, new String[]{ ContactsContract.CommonDataKinds.Organization.CONTENT_ITEM_TYPE }, null);
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onContactCreated(FriendList list, Friend lf) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onContactDeleted(FriendList list, Friend lf) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onContactUpdated(FriendList list, Friend newFriend, Friend oldFriend) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSyncStatusChanged(FriendList list, FriendList.SyncStatus status, String msg) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPresenceReceived(FriendList list, Friend[] friends) {
|
||||||
|
for (Friend lf : friends) {
|
||||||
|
ContactsManager.getInstance().refreshSipContact(lf);
|
||||||
|
}
|
||||||
|
|
||||||
|
Collections.sort(sipContacts);
|
||||||
|
for (ContactsUpdatedListener listener : contactsUpdatedListeners) {
|
||||||
|
listener.onContactsUpdated();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit d5006fc6ea570cfd5efac51d86e2bd442ac1d055
|
Subproject commit bf8735e40194cc04e1fae2f1d555cca361719137
|
Loading…
Reference in a new issue