show 'incoming video cal' notification
This commit is contained in:
parent
d4788fc1f4
commit
5a20faaf0f
|
@ -41,6 +41,7 @@ import java.util.Iterator;
|
|||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
@ -63,6 +64,7 @@ import eu.siacs.conversations.utils.GeoHelper;
|
|||
import eu.siacs.conversations.utils.UIHelper;
|
||||
import eu.siacs.conversations.xmpp.XmppConnection;
|
||||
import eu.siacs.conversations.xmpp.jingle.AbstractJingleConnection;
|
||||
import eu.siacs.conversations.xmpp.jingle.Media;
|
||||
|
||||
public class NotificationService {
|
||||
|
||||
|
@ -334,7 +336,7 @@ public class NotificationService {
|
|||
}
|
||||
}
|
||||
|
||||
public void showIncomingCallNotification(AbstractJingleConnection.Id id) {
|
||||
public void showIncomingCallNotification(final AbstractJingleConnection.Id id, final Set<Media> media) {
|
||||
final Intent fullScreenIntent = new Intent(mXmppConnectionService, RtpSessionActivity.class);
|
||||
fullScreenIntent.putExtra(RtpSessionActivity.EXTRA_ACCOUNT, id.account.getJid().asBareJid().toEscapedString());
|
||||
fullScreenIntent.putExtra(RtpSessionActivity.EXTRA_WITH, id.with.toEscapedString());
|
||||
|
@ -342,8 +344,13 @@ public class NotificationService {
|
|||
fullScreenIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
fullScreenIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
final NotificationCompat.Builder builder = new NotificationCompat.Builder(mXmppConnectionService, "incoming_calls");
|
||||
builder.setSmallIcon(R.drawable.ic_call_white_24dp);
|
||||
builder.setContentTitle(mXmppConnectionService.getString(R.string.rtp_state_incoming_call));
|
||||
if (media.contains(Media.VIDEO)) {
|
||||
builder.setSmallIcon(R.drawable.ic_videocam_white_24dp);
|
||||
builder.setContentTitle(mXmppConnectionService.getString(R.string.rtp_state_incoming_video_call));
|
||||
} else {
|
||||
builder.setSmallIcon(R.drawable.ic_call_white_24dp);
|
||||
builder.setContentTitle(mXmppConnectionService.getString(R.string.rtp_state_incoming_call));
|
||||
}
|
||||
builder.setContentText(id.account.getRoster().getContact(id.with).getDisplayName());
|
||||
builder.setVisibility(NotificationCompat.VISIBILITY_PUBLIC);
|
||||
builder.setPriority(NotificationCompat.PRIORITY_HIGH);
|
||||
|
|
|
@ -333,7 +333,11 @@ public class RtpSessionActivity extends XmppActivity implements XmppConnectionSe
|
|||
private void updateStateDisplay(final RtpEndUserState state) {
|
||||
switch (state) {
|
||||
case INCOMING_CALL:
|
||||
setTitle(R.string.rtp_state_incoming_call);
|
||||
if (getMedia().contains(Media.VIDEO)) {
|
||||
setTitle(R.string.rtp_state_incoming_video_call);
|
||||
} else {
|
||||
setTitle(R.string.rtp_state_incoming_call);
|
||||
}
|
||||
break;
|
||||
case CONNECTING:
|
||||
setTitle(R.string.rtp_state_connecting);
|
||||
|
@ -369,6 +373,10 @@ public class RtpSessionActivity extends XmppActivity implements XmppConnectionSe
|
|||
}
|
||||
}
|
||||
|
||||
private Set<Media> getMedia() {
|
||||
return requireRtpConnection().getMedia();
|
||||
}
|
||||
|
||||
@SuppressLint("RestrictedApi")
|
||||
private void updateButtonConfiguration(final RtpEndUserState state) {
|
||||
if (state == RtpEndUserState.INCOMING_CALL) {
|
||||
|
|
|
@ -278,7 +278,7 @@ public class JingleRtpConnection extends AbstractJingleConnection implements Web
|
|||
"proposed media must be set when processing pre-approved session-initiate"
|
||||
);
|
||||
if (!this.proposedMedia.equals(contentMap.getMedia())) {
|
||||
sendSessionTerminate(Reason.SECURITY_ERROR,String.format(
|
||||
sendSessionTerminate(Reason.SECURITY_ERROR, String.format(
|
||||
"Your session proposal (Jingle Message Initiation) included media %s but your session-initiate was %s",
|
||||
this.proposedMedia,
|
||||
contentMap.getMedia()
|
||||
|
@ -500,7 +500,7 @@ public class JingleRtpConnection extends AbstractJingleConnection implements Web
|
|||
final boolean originatedFromMyself = from.asBareJid().equals(id.account.getJid().asBareJid());
|
||||
if (originatedFromMyself) {
|
||||
Log.d(Config.LOGTAG, id.account.getJid().asBareJid() + ": saw proposal from mysql. ignoring");
|
||||
} else if (transition(State.PROPOSED)) {
|
||||
} else if (isInState(State.NULL)) {
|
||||
final Collection<RtpDescription> descriptions = Collections2.transform(
|
||||
Collections2.filter(propose.getDescriptions(), d -> d instanceof RtpDescription),
|
||||
input -> (RtpDescription) input
|
||||
|
@ -509,6 +509,7 @@ public class JingleRtpConnection extends AbstractJingleConnection implements Web
|
|||
Preconditions.checkState(!media.contains(Media.UNKNOWN), "RTP descriptions contain unknown media");
|
||||
Log.d(Config.LOGTAG, id.account.getJid().asBareJid() + ": received session proposal from " + from + " for " + media);
|
||||
this.proposedMedia = Sets.newHashSet(media);
|
||||
transitionOrThrow(State.PROPOSED);
|
||||
if (serverMsgId != null) {
|
||||
this.message.setServerMsgId(serverMsgId);
|
||||
}
|
||||
|
@ -521,7 +522,7 @@ public class JingleRtpConnection extends AbstractJingleConnection implements Web
|
|||
|
||||
private void startRinging() {
|
||||
Log.d(Config.LOGTAG, id.account.getJid().asBareJid() + ": received call from " + id.with + ". start ringing");
|
||||
xmppConnectionService.getNotificationService().showIncomingCallNotification(id);
|
||||
xmppConnectionService.getNotificationService().showIncomingCallNotification(id, getMedia());
|
||||
}
|
||||
|
||||
private void receiveProceed(final Jid from, final String serverMsgId, final long timestamp) {
|
||||
|
@ -623,7 +624,7 @@ public class JingleRtpConnection extends AbstractJingleConnection implements Web
|
|||
writeLogMessage(target);
|
||||
final JinglePacket jinglePacket = new JinglePacket(JinglePacket.Action.SESSION_TERMINATE, id.sessionId);
|
||||
jinglePacket.setReason(reason, text);
|
||||
Log.d(Config.LOGTAG,jinglePacket.toString());
|
||||
Log.d(Config.LOGTAG, jinglePacket.toString());
|
||||
send(jinglePacket);
|
||||
jingleConnectionManager.finishConnection(this);
|
||||
}
|
||||
|
@ -744,6 +745,16 @@ public class JingleRtpConnection extends AbstractJingleConnection implements Web
|
|||
throw new IllegalStateException(String.format("%s has no equivalent EndUserState", this.state));
|
||||
}
|
||||
|
||||
public Set<Media> getMedia() {
|
||||
if (isInState(State.NULL)) {
|
||||
throw new IllegalStateException("RTP connection has not been initialized yet");
|
||||
}
|
||||
if (isInState(State.PROPOSED, State.PROCEED)) {
|
||||
return Preconditions.checkNotNull(this.proposedMedia, "RTP connection has not been initialized properly");
|
||||
}
|
||||
return Preconditions.checkNotNull(initiatorRtpContentMap.getMedia());
|
||||
}
|
||||
|
||||
|
||||
public synchronized void acceptCall() {
|
||||
switch (this.state) {
|
||||
|
|
|
@ -889,6 +889,7 @@
|
|||
<string name="please_enable_an_account">Please enable an account</string>
|
||||
<string name="make_call">Make call</string>
|
||||
<string name="rtp_state_incoming_call">Incoming call</string>
|
||||
<string name="rtp_state_incoming_video_call">Incoming video call</string>
|
||||
<string name="rtp_state_connecting">Connecting</string>
|
||||
<string name="rtp_state_connected">Connected</string>
|
||||
<string name="rtp_state_accepting_call">Accepting call</string>
|
||||
|
|
Loading…
Reference in a new issue