Incall notification (capturing video, active, paused)
This commit is contained in:
parent
13dbb00a77
commit
47f4ed9209
5 changed files with 85 additions and 12 deletions
|
@ -1,6 +1,10 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
|
||||
<string name="incall_notif_active">Audio call ongoing</string>
|
||||
<string name="incall_notif_paused">Paused call ongoing</string>
|
||||
<string name="incall_notif_video">Video capturing call ongoing</string>
|
||||
|
||||
<string name="not_ready_to_make_new_call">Not ready for a new call</string>
|
||||
<string name="bad_target_uri">Bad contact : %s</string>
|
||||
<string name="reset_sas_fmt">Reset validated %s</string>
|
||||
|
|
|
@ -423,11 +423,11 @@ public class LinphoneActivity extends TabActivity implements
|
|||
|
||||
// Do not call if video activity already launched as it would cause a pause() of the launched one
|
||||
// and a race condition with capture surfaceview leading to a crash
|
||||
public void startVideoActivity(LinphoneCall call, int delay) {
|
||||
public void startVideoActivity(final LinphoneCall call, int delay) {
|
||||
if (VideoCallActivity.launched || call == null) return;
|
||||
call.enableCamera(true);
|
||||
mHandler.postDelayed(new Runnable() {
|
||||
public void run() {
|
||||
LinphoneManager.getInstance().enableCamera(call, true);
|
||||
if (VideoCallActivity.launched) return;
|
||||
startActivityForResult(new Intent().setClass(
|
||||
LinphoneActivity.this,
|
||||
|
|
|
@ -360,15 +360,21 @@ public final class LinphoneManager implements LinphoneCoreListener {
|
|||
public boolean toggleEnableCamera() {
|
||||
if (mLc.isIncall()) {
|
||||
boolean enabled = !mLc.getCurrentCall().cameraEnabled();
|
||||
mLc.getCurrentCall().enableCamera(enabled);
|
||||
enableCamera(mLc.getCurrentCall(), enabled);
|
||||
return enabled;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public void enableCamera(LinphoneCall call, boolean enable) {
|
||||
if (call != null) {
|
||||
call.enableCamera(enable);
|
||||
LinphoneService.instance().refreshIncallIcon(mLc.getCurrentCall());
|
||||
}
|
||||
}
|
||||
|
||||
public void sendStaticImage(boolean send) {
|
||||
if (mLc.isIncall()) {
|
||||
mLc.getCurrentCall().enableCamera(!send);
|
||||
enableCamera(mLc.getCurrentCall(), !send);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -998,7 +1004,7 @@ public final class LinphoneManager implements LinphoneCoreListener {
|
|||
*/
|
||||
public boolean addVideo() {
|
||||
LinphoneCall call = mLc.getCurrentCall();
|
||||
if (call != null) call.enableCamera(true);
|
||||
enableCamera(call, true);
|
||||
return reinviteWithVideo();
|
||||
}
|
||||
|
||||
|
@ -1169,7 +1175,7 @@ public final class LinphoneManager implements LinphoneCoreListener {
|
|||
String message) {
|
||||
if (state==State.OutgoingInit || state==State.IncomingReceived) {
|
||||
boolean sendCamera = shareMyCamera() && mLc.getConferenceSize() == 0;
|
||||
call.enableCamera(sendCamera);
|
||||
enableCamera(call, sendCamera);
|
||||
}
|
||||
if (state == State.CallEnd && mLc.getCallsNb() == 0) {
|
||||
routeAudioToReceiver();
|
||||
|
|
|
@ -25,6 +25,7 @@ import java.lang.reflect.Method;
|
|||
import org.linphone.LinphoneManager.NewOutgoingCallUiListener;
|
||||
import org.linphone.LinphoneSimpleListener.LinphoneServiceListener;
|
||||
import org.linphone.core.LinphoneCall;
|
||||
import org.linphone.core.LinphoneCore;
|
||||
import org.linphone.core.LinphoneProxyConfig;
|
||||
import org.linphone.core.Log;
|
||||
import org.linphone.core.OnlineStatus;
|
||||
|
@ -88,10 +89,12 @@ public final class LinphoneService extends Service implements LinphoneServiceLis
|
|||
|
||||
|
||||
private final static int NOTIF_ID=1;
|
||||
private final static int INCALL_NOTIF_ID=2;
|
||||
|
||||
private Notification mNotif;
|
||||
private Notification mIncallNotif;
|
||||
private PendingIntent mNotifContentIntent;
|
||||
private String notificationTitle;
|
||||
private String mNotificationTitle;
|
||||
|
||||
|
||||
private static final int IC_LEVEL_ORANGE=0;
|
||||
|
@ -114,7 +117,7 @@ public final class LinphoneService extends Service implements LinphoneServiceLis
|
|||
PreferenceManager.setDefaultValues(this, R.xml.preferences, true);
|
||||
|
||||
|
||||
notificationTitle = getString(R.string.app_name);
|
||||
mNotificationTitle = getString(R.string.app_name);
|
||||
|
||||
// Dump some debugging information to the logs
|
||||
Log.i(START_LINPHONE_LOGS);
|
||||
|
@ -128,7 +131,7 @@ public final class LinphoneService extends Service implements LinphoneServiceLis
|
|||
|
||||
Intent notifIntent = new Intent(this, LinphoneActivity.class);
|
||||
mNotifContentIntent = PendingIntent.getActivity(this, 0, notifIntent, 0);
|
||||
mNotif.setLatestEventInfo(this, notificationTitle,"", mNotifContentIntent);
|
||||
mNotif.setLatestEventInfo(this, mNotificationTitle,"", mNotifContentIntent);
|
||||
|
||||
LinphoneManager.createAndStart(this, this);
|
||||
LinphoneManager.getLc().setPresenceInfo(0, null, OnlineStatus.Online);
|
||||
|
@ -164,6 +167,58 @@ public final class LinphoneService extends Service implements LinphoneServiceLis
|
|||
}
|
||||
}
|
||||
|
||||
private enum IncallIconState {INCALL, PAUSE, VIDEO, IDLE}
|
||||
private IncallIconState mCurrentIncallIconState = IncallIconState.IDLE;
|
||||
private synchronized void setIncallIcon(IncallIconState state) {
|
||||
if (state == mCurrentIncallIconState) return;
|
||||
mCurrentIncallIconState = state;
|
||||
if (mIncallNotif == null) mIncallNotif = new Notification();
|
||||
|
||||
int notificationTextId = 0;
|
||||
switch (state) {
|
||||
case IDLE:
|
||||
mNM.cancel(INCALL_NOTIF_ID);
|
||||
return;
|
||||
case INCALL:
|
||||
mIncallNotif.icon = R.drawable.conf_unhook;
|
||||
notificationTextId = R.string.incall_notif_active;
|
||||
break;
|
||||
case PAUSE:
|
||||
mIncallNotif.icon = R.drawable.conf_status_paused;
|
||||
notificationTextId = R.string.incall_notif_paused;
|
||||
break;
|
||||
case VIDEO:
|
||||
mIncallNotif.icon = R.drawable.conf_video;
|
||||
notificationTextId = R.string.incall_notif_video;
|
||||
break;
|
||||
default:
|
||||
throw new IllegalArgumentException("Unknown state " + state);
|
||||
}
|
||||
|
||||
mIncallNotif.iconLevel = 0;
|
||||
mIncallNotif.when=System.currentTimeMillis();
|
||||
mIncallNotif.flags &= Notification.FLAG_ONGOING_EVENT;
|
||||
mIncallNotif.setLatestEventInfo(this, mNotificationTitle, getString(notificationTextId), mNotifContentIntent);
|
||||
mNM.notify(INCALL_NOTIF_ID, mIncallNotif);
|
||||
}
|
||||
|
||||
public void refreshIncallIcon(LinphoneCall currentCall) {
|
||||
LinphoneCore lc = LinphoneManager.getLc();
|
||||
if (currentCall != null) {
|
||||
if (currentCall.getCurrentParamsCopy().getVideoEnabled() && currentCall.cameraEnabled()) {
|
||||
// checking first current params is mandatory
|
||||
setIncallIcon(IncallIconState.VIDEO);
|
||||
} else {
|
||||
setIncallIcon(IncallIconState.INCALL);
|
||||
}
|
||||
} else if (lc.getCallsNb() == 0) {
|
||||
setIncallIcon(IncallIconState.IDLE);
|
||||
} else if (lc.isInConference()) {
|
||||
setIncallIcon(IncallIconState.INCALL);
|
||||
} else {
|
||||
setIncallIcon(IncallIconState.PAUSE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static final Class<?>[] mSetFgSign = new Class[] {boolean.class};
|
||||
|
@ -274,7 +329,7 @@ public final class LinphoneService extends Service implements LinphoneServiceLis
|
|||
text = String.format(text, id);
|
||||
}
|
||||
|
||||
mNotif.setLatestEventInfo(this, notificationTitle, text, mNotifContentIntent);
|
||||
mNotif.setLatestEventInfo(this, mNotificationTitle, text, mNotifContentIntent);
|
||||
mNM.notify(NOTIF_ID, mNotif);
|
||||
}
|
||||
|
||||
|
@ -291,6 +346,7 @@ public final class LinphoneService extends Service implements LinphoneServiceLis
|
|||
super.onDestroy();
|
||||
// Make sure our notification is gone.
|
||||
stopForegroundCompat(NOTIF_ID);
|
||||
mNM.cancel(INCALL_NOTIF_ID);
|
||||
|
||||
LinphoneManager.getLcIfManagerNotDestroyedOrNull().setPresenceInfo(0, null, OnlineStatus.Offline);
|
||||
LinphoneManager.destroy();
|
||||
|
@ -358,6 +414,13 @@ public final class LinphoneService extends Service implements LinphoneServiceLis
|
|||
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
|
||||
}
|
||||
|
||||
if (state == State.StreamsRunning) {
|
||||
// Workaround bug current call seems to be updated after state changed to streams running
|
||||
refreshIncallIcon(call);
|
||||
} else {
|
||||
refreshIncallIcon(LinphoneManager.getLc().getCurrentCall());
|
||||
}
|
||||
|
||||
mHandler.post(new Runnable() {
|
||||
public void run() {
|
||||
if (guiListener() != null)
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 72a508632760bf20c2aeac7e253f7a481974f499
|
||||
Subproject commit bb2582f220ef902961efc42b3ca526d62605f600
|
Loading…
Reference in a new issue