[Presence] Presence listener switched into LinphoneManager

This commit is contained in:
Brieuc Viel 2016-04-20 14:23:02 +02:00
parent 04530e1f64
commit 1b966bb236
10 changed files with 35 additions and 27 deletions

View file

@ -18,7 +18,7 @@
<!-- Push notification settings -->
<bool name="enable_push_id">true</bool>
<string name="push_sender_id">622464153529</string>
<string name="push_sender_id">1286</string>
<bool name="hide_camera_settings">false</bool>
<bool name="hide_wizard">false</bool>

View file

@ -367,7 +367,7 @@ public class ChatListFragment extends Fragment implements OnClickListener, OnIte
avatarWithPresenceImage.setFormatAvatarImage(AvatarWithPresenceImage.AVATAR_SMALL);
if(contact != null && contact.isLinphoneFriend()) {
avatarWithPresenceImage.setLinphoneContact(contact);
LinphoneActivity.instance().addPresenceUpdatedListener(avatarWithPresenceImage);
LinphoneManager.getInstance().addPresenceUpdatedListener(avatarWithPresenceImage);
}
//Obiane specification

View file

@ -121,7 +121,7 @@ public class ContactDetailsFragment extends Fragment implements OnClickListener
avatarWithPresenceImage.setFormatAvatarImage(AvatarWithPresenceImage.AVATAR_BIG);
if(contact != null && contact.isLinphoneFriend()) {
avatarWithPresenceImage.setLinphoneContact(contact);
LinphoneActivity.instance().addPresenceUpdatedListener(avatarWithPresenceImage);
LinphoneManager.getInstance().addPresenceUpdatedListener(avatarWithPresenceImage);
}
TextView contactName = (TextView) view.findViewById(R.id.contact_name);

View file

@ -444,14 +444,9 @@ public class ContactsListFragment extends Fragment implements OnClickListener, O
*/
AvatarWithPresenceImage avatarWithPresenceImage = (AvatarWithPresenceImage) view.findViewById(R.id.avatar_with_presence);
avatarWithPresenceImage.setFormatAvatarImage(AvatarWithPresenceImage.AVATAR_SMALL);
if(contact != null ) {
if(contact != null && contact.isLinphoneFriend()) {
avatarWithPresenceImage.setLinphoneContact(contact);
if (contact.isLinphoneFriend()) {
LinphoneActivity.instance().addPresenceUpdatedListener(avatarWithPresenceImage);
}
}else {
avatarWithPresenceImage.setLinphoneContact(contact);
LinphoneActivity.instance().addPresenceUpdatedListener(avatarWithPresenceImage);
LinphoneManager.getInstance().addPresenceUpdatedListener(avatarWithPresenceImage);
}
return view;
}

View file

@ -105,7 +105,7 @@ public class HistoryDetailFragment extends Fragment implements OnClickListener {
LinphoneContact contact = ContactsManager.getInstance().findContactFromAddress(lAddress);
if (contact != null && contact.isLinphoneFriend() ) {
avatarWithPresenceImage.setLinphoneContact(contact);
LinphoneActivity.instance().addPresenceUpdatedListener(avatarWithPresenceImage);
LinphoneManager.getInstance().addPresenceUpdatedListener(avatarWithPresenceImage);
}
} catch(LinphoneCoreException e) {
e.printStackTrace();

View file

@ -452,7 +452,7 @@ public class HistoryListFragment extends Fragment implements OnClickListener, On
holder.avatarWithPresenceImage.setFormatAvatarImage(AvatarWithPresenceImage.AVATAR_SMALL);
if(c != null && c.isLinphoneFriend() ) {
holder.avatarWithPresenceImage.setLinphoneContact(c);
LinphoneActivity.instance().addPresenceUpdatedListener(holder.avatarWithPresenceImage);
LinphoneManager.getInstance().addPresenceUpdatedListener(holder.avatarWithPresenceImage);
}
if (isEditMode) {

View file

@ -284,12 +284,12 @@ public class LinphoneActivity extends Activity implements OnClickListener, Conta
@Override
public void notifyPresenceReceived(LinphoneCore lc, LinphoneFriend lf) {
Log.e("===>> LinphoneActivity : notifyPresenceReceived 1 : "+lf.getName().toString());
for(AvatarWithPresenceImage listener : listeners){
/* for(AvatarWithPresenceImage listener : listeners){
Log.e("===>> LinphoneActivity : notifyPresenceReceived 2 : "+lf.getName().toString());
if(listener.isThisFriend(lf)){
listener.updatePresenceIcon(lc, lf);
}
}
}*/
}
};
@ -321,6 +321,7 @@ public class LinphoneActivity extends Activity implements OnClickListener, Conta
mAlwaysChangingPhoneAngle = rotation;
updateAnimationsState();
LinphoneManager.getInstance().enableProxyPublish(true);
}
public void resetListener(){
@ -421,10 +422,10 @@ public class LinphoneActivity extends Activity implements OnClickListener, Conta
}
public void addPresenceUpdatedListener(AvatarWithPresenceImage aWPI){
listeners.add(aWPI);
}
/* public void addPresenceUpdatedListener(AvatarWithPresenceImage aWPI){
listeners.add(aWPI);
}
*/
private boolean isTablet() {
return getResources().getBoolean(R.bool.isTablet);
}
@ -1292,6 +1293,8 @@ public class LinphoneActivity extends Activity implements OnClickListener, Conta
@Override
protected void onPause() {
Log.e("LinphoneActivity - onPause");
//LinphoneManager.getInstance().enableProxyPublish(false);
getIntent().putExtra("PreviousActivity", 0);
super.onPause();

View file

@ -377,7 +377,6 @@ public class LinphoneContact implements Serializable, Comparable<LinphoneContact
PresenceModel model = LinphoneCoreFactory.instance().createPresenceModel(PresenceActivityType.TV, null);
friend.setPresenceModel(model);
}
Log.e("===>>> LinphoneContact : isAndroidContact & isLinphoneFriend : ");
fullName = friend.getName();
thumbnailUri = null;
photoUri = null;
@ -387,7 +386,6 @@ public class LinphoneContact implements Serializable, Comparable<LinphoneContact
hasSipAddress = true;
}
} else if (isAndroidContact()) {
Log.e("===>>> LinphoneContact : isAndroidContact : "+getFriendPresenceModel().toString());
String id = getAndroidId();
getContactNames(id);
setThumbnailUri(getContactPictureUri(id));

View file

@ -78,6 +78,7 @@ import org.linphone.mediastream.Version;
import org.linphone.mediastream.video.capture.hwconf.AndroidCameraConfiguration;
import org.linphone.mediastream.video.capture.hwconf.AndroidCameraConfiguration.AndroidCamera;
import org.linphone.mediastream.video.capture.hwconf.Hacks;
import org.linphone.ui.AvatarWithPresenceImage;
import android.annotation.SuppressLint;
import android.annotation.TargetApi;
@ -203,7 +204,7 @@ public class LinphoneManager implements LinphoneCoreListener, LinphoneChatMessag
private final String mErrorToneFile;
private final String mUserCertificatePath;
private ByteArrayInputStream mUploadingImageStream;
private ArrayList<AvatarWithPresenceImage> listeners;
private Timer mTimer;
private BroadcastReceiver mKeepAliveReceiver = new KeepAliveReceiver();
@ -242,7 +243,7 @@ public class LinphoneManager implements LinphoneCoreListener, LinphoneChatMessag
TelephonyManager tm = (TelephonyManager) c.getSystemService(Context.TELEPHONY_SERVICE);
boolean gsmIdle = tm.getCallState() == TelephonyManager.CALL_STATE_IDLE;
setGsmIdle(gsmIdle);
instance.listeners = new ArrayList<AvatarWithPresenceImage>();
instance.enableProxyPublish(true);
return instance;
}
@ -350,11 +351,15 @@ public class LinphoneManager implements LinphoneCoreListener, LinphoneChatMessag
return false;
}
private void enableProxyPublish( boolean enabled) {
public void enableProxyPublish( boolean enabled) {
changeStatusToOffline();
Log.e("==>> enableProxyPublish : "+enabled);
LinphoneCore lc = getLcIfManagerNotDestroyedOrNull();
if(lc != null ) {
LinphoneProxyConfig[] proxyList = lc.getProxyConfigList();
Log.e("==>> enableProxyPublish : LC not null : "+proxyList.length);
for (LinphoneProxyConfig proxyConfig : proxyList) {
Log.e("==>> enableProxyPublish : proxyList");
proxyConfig.edit();
proxyConfig.enablePublish(enabled);
proxyConfig.done();
@ -803,7 +808,6 @@ public class LinphoneManager implements LinphoneCoreListener, LinphoneChatMessag
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
private void doDestroy() {
enableProxyPublish(false);
if (LinphoneService.isReady()) // indeed, no need to crash
ChatStorage.getInstance().close();
@ -866,9 +870,17 @@ public class LinphoneManager implements LinphoneCoreListener, LinphoneChatMessag
}
public void notifyPresenceReceived(LinphoneCore lc, LinphoneFriend lf) {
Log.e("===>> LinphoneManager - notifyPresenceReceived : "+lf.getName());
for(AvatarWithPresenceImage listener : listeners){
if(listener.isThisFriend(lf)){
Log.e("===>> LinphoneManager : notifyPresenceReceived 2 : "+lf.getName().toString());
listener.updatePresenceIcon(lc, lf);
}
}
}
// TODO:
Log.e("===>> LinphoneMAnager - notifyPresenceReceived : "+lf.getName());
public void addPresenceUpdatedListener(AvatarWithPresenceImage aWPI){
listeners.add(aWPI);
}
@Override

@ -1 +1 @@
Subproject commit 16e21507be68b24d8beb95775fe639a903efcefe
Subproject commit 465559dd662d8e1c2a05dea873154c1d2dbdd241