Improvements regarding call notifications and activities
This commit is contained in:
parent
5f09435bbb
commit
8ca7f395d8
3 changed files with 41 additions and 5 deletions
|
@ -431,16 +431,22 @@ public final class LinphoneService extends Service {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onIncomingReceived() {
|
private void onIncomingReceived() {
|
||||||
// wakeup linphone
|
|
||||||
|
|
||||||
PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
|
PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
|
||||||
Intent intent = new Intent().setClass(this, mIncomingReceivedActivity);
|
Intent intent = new Intent().setClass(this, mIncomingReceivedActivity);
|
||||||
|
|
||||||
if (!pm.isInteractive()) {
|
if (!pm.isInteractive()) {
|
||||||
// This is to workaround an infinite loop of pause/start in LinphoneActivity issue
|
// This is to workaround an infinite loop of pause/start in LinphoneActivity issue
|
||||||
// if incoming call is being stopped by caller while screen if off and locked
|
// if incoming call is being stopped by caller while screen if off and locked
|
||||||
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
|
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
|
||||||
}
|
}
|
||||||
startActivity(intent);
|
|
||||||
|
if (LinphoneActivity.isInstanciated()) {
|
||||||
|
LinphoneActivity.instance().startActivity(intent);
|
||||||
|
} else {
|
||||||
|
// This flag is required to start an Activity from a Service context
|
||||||
|
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
|
startActivity(intent);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*Believe me or not, but knowing the application visibility state on Android is a nightmare.
|
/*Believe me or not, but knowing the application visibility state on Android is a nightmare.
|
||||||
|
|
|
@ -34,6 +34,9 @@ import org.linphone.LinphoneActivity;
|
||||||
import org.linphone.LinphoneManager;
|
import org.linphone.LinphoneManager;
|
||||||
import org.linphone.LinphoneService;
|
import org.linphone.LinphoneService;
|
||||||
import org.linphone.R;
|
import org.linphone.R;
|
||||||
|
import org.linphone.call.CallActivity;
|
||||||
|
import org.linphone.call.CallIncomingActivity;
|
||||||
|
import org.linphone.call.CallOutgoingActivity;
|
||||||
import org.linphone.compatibility.Compatibility;
|
import org.linphone.compatibility.Compatibility;
|
||||||
import org.linphone.contacts.ContactsManager;
|
import org.linphone.contacts.ContactsManager;
|
||||||
import org.linphone.contacts.LinphoneContact;
|
import org.linphone.contacts.LinphoneContact;
|
||||||
|
@ -296,8 +299,21 @@ public class NotificationsManager {
|
||||||
|
|
||||||
public void displayCallNotification(Call call) {
|
public void displayCallNotification(Call call) {
|
||||||
if (call == null) return;
|
if (call == null) return;
|
||||||
Intent callNotifIntent =
|
|
||||||
new Intent(mContext, LinphoneService.instance().getIncomingReceivedActivity());
|
Intent callNotifIntent;
|
||||||
|
if (call.getState() == Call.State.IncomingReceived
|
||||||
|
|| call.getState() == Call.State.IncomingEarlyMedia) {
|
||||||
|
callNotifIntent = new Intent(mContext, CallIncomingActivity.class);
|
||||||
|
} else if (call.getState() == Call.State.OutgoingInit
|
||||||
|
|| call.getState() == Call.State.OutgoingProgress
|
||||||
|
|| call.getState() == Call.State.OutgoingRinging
|
||||||
|
|| call.getState() == Call.State.OutgoingEarlyMedia) {
|
||||||
|
callNotifIntent = new Intent(mContext, CallOutgoingActivity.class);
|
||||||
|
} else {
|
||||||
|
callNotifIntent = new Intent(mContext, CallActivity.class);
|
||||||
|
}
|
||||||
|
callNotifIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
|
|
||||||
PendingIntent pendingIntent =
|
PendingIntent pendingIntent =
|
||||||
PendingIntent.getActivity(
|
PendingIntent.getActivity(
|
||||||
mContext, 0, callNotifIntent, PendingIntent.FLAG_UPDATE_CURRENT);
|
mContext, 0, callNotifIntent, PendingIntent.FLAG_UPDATE_CURRENT);
|
||||||
|
@ -330,6 +346,18 @@ public class NotificationsManager {
|
||||||
iconId = R.drawable.topbar_call_notification;
|
iconId = R.drawable.topbar_call_notification;
|
||||||
notificationTextId = R.string.incall_notif_paused;
|
notificationTextId = R.string.incall_notif_paused;
|
||||||
break;
|
break;
|
||||||
|
case IncomingEarlyMedia:
|
||||||
|
case IncomingReceived:
|
||||||
|
iconId = R.drawable.topbar_call_notification;
|
||||||
|
notificationTextId = R.string.incall_notif_incoming;
|
||||||
|
break;
|
||||||
|
case OutgoingEarlyMedia:
|
||||||
|
case OutgoingInit:
|
||||||
|
case OutgoingProgress:
|
||||||
|
case OutgoingRinging:
|
||||||
|
iconId = R.drawable.topbar_call_notification;
|
||||||
|
notificationTextId = R.string.incall_notif_outgoing;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
if (call.getCurrentParams().videoEnabled()) {
|
if (call.getCurrentParams().videoEnabled()) {
|
||||||
iconId = R.drawable.topbar_videocall_notification;
|
iconId = R.drawable.topbar_videocall_notification;
|
||||||
|
|
|
@ -307,6 +307,8 @@
|
||||||
<string name="incall_notif_active">Audio call ongoing</string>
|
<string name="incall_notif_active">Audio call ongoing</string>
|
||||||
<string name="incall_notif_paused">Paused call ongoing</string>
|
<string name="incall_notif_paused">Paused call ongoing</string>
|
||||||
<string name="incall_notif_video">Video capturing call ongoing</string>
|
<string name="incall_notif_video">Video capturing call ongoing</string>
|
||||||
|
<string name="incall_notif_incoming">Call incoming</string>
|
||||||
|
<string name="incall_notif_outgoing">Call outgoing</string>
|
||||||
<string name="notification_started">started</string>
|
<string name="notification_started">started</string>
|
||||||
<string name="unread_messages">%i unread messages</string>
|
<string name="unread_messages">%i unread messages</string>
|
||||||
<string name="missed_calls_notif_title">Missed call</string>
|
<string name="missed_calls_notif_title">Missed call</string>
|
||||||
|
|
Loading…
Reference in a new issue