use of cx.ring.model.SipCall in project ring-client-android by savoirfairelinux.
the class CallService method incomingCall.
void incomingCall(String accountId, String callId, String from) {
Log.d(TAG, "incoming call: " + accountId + ", " + callId + ", " + from);
SipCall call = addCall(accountId, callId, from, SipCall.Direction.INCOMING);
setChanged();
ServiceEvent event = new ServiceEvent(ServiceEvent.EventType.INCOMING_CALL);
event.addEventInput(ServiceEvent.EventInput.CALL, call);
notifyObservers(event);
}
use of cx.ring.model.SipCall in project ring-client-android by savoirfairelinux.
the class NotificationServiceImpl method showCallNotification.
@Override
public void showCallNotification(Conference conference) {
if (conference == null || conference.getParticipants().isEmpty() || !(conference.isOnGoing() || conference.isRinging())) {
return;
}
SipCall call = conference.getParticipants().get(0);
CallContact contact = call.getContact();
final int notificationId = call.getCallId().hashCode();
notificationManager.cancel(notificationId);
PendingIntent gotoIntent = PendingIntent.getService(mContext, random.nextInt(), new Intent(DRingService.ACTION_CALL_VIEW).setClass(mContext, DRingService.class).putExtra(KEY_CALL_ID, call.getCallId()), 0);
NotificationCompat.Builder messageNotificationBuilder = new NotificationCompat.Builder(mContext, NOTIF_CHANNEL_CALL);
if (conference.isOnGoing()) {
messageNotificationBuilder.setContentTitle(mContext.getString(R.string.notif_current_call_title, contact.getRingUsername())).setContentText(mContext.getText(R.string.notif_current_call)).setContentIntent(gotoIntent).addAction(R.drawable.ic_call_end_white, mContext.getText(R.string.action_call_hangup), PendingIntent.getService(mContext, random.nextInt(), new Intent(DRingService.ACTION_CALL_END).setClass(mContext, DRingService.class).putExtra(KEY_CALL_ID, call.getCallId()), PendingIntent.FLAG_ONE_SHOT));
} else if (conference.isRinging()) {
if (conference.isIncoming()) {
Bundle extras = new Bundle();
messageNotificationBuilder.setContentTitle(mContext.getString(R.string.notif_incoming_call_title, contact.getRingUsername())).setPriority(NotificationCompat.PRIORITY_MAX).setContentText(mContext.getText(R.string.notif_incoming_call)).setContentIntent(gotoIntent).setFullScreenIntent(gotoIntent, true).addAction(R.drawable.ic_call_end_white, mContext.getText(R.string.action_call_decline), PendingIntent.getService(mContext, random.nextInt(), new Intent(DRingService.ACTION_CALL_REFUSE).setClass(mContext, DRingService.class).putExtra(KEY_CALL_ID, call.getCallId()), PendingIntent.FLAG_ONE_SHOT)).addAction(R.drawable.ic_action_accept, mContext.getText(R.string.action_call_accept), PendingIntent.getService(mContext, random.nextInt(), new Intent(DRingService.ACTION_CALL_ACCEPT).setClass(mContext, DRingService.class).putExtra(KEY_CALL_ID, call.getCallId()), PendingIntent.FLAG_ONE_SHOT)).addExtras(extras);
} else {
messageNotificationBuilder.setContentTitle(mContext.getString(R.string.notif_outgoing_call_title, contact.getRingUsername())).setContentText(mContext.getText(R.string.notif_outgoing_call)).setContentIntent(gotoIntent).addAction(R.drawable.ic_call_end_white, mContext.getText(R.string.action_call_hangup), PendingIntent.getService(mContext, random.nextInt(), new Intent(DRingService.ACTION_CALL_END).setClass(mContext, DRingService.class).putExtra(KEY_CALL_ID, call.getCallId()), PendingIntent.FLAG_ONE_SHOT));
}
}
messageNotificationBuilder.setOngoing(true).setCategory(NotificationCompat.CATEGORY_CALL).setSmallIcon(R.drawable.ic_ring_logo_white);
setContactPicture(contact, messageNotificationBuilder);
messageNotificationBuilder.setColor(ResourcesCompat.getColor(mContext.getResources(), R.color.color_primary_dark, null));
notificationManager.notify(notificationId, messageNotificationBuilder.build());
mNotificationBuilders.put(notificationId, messageNotificationBuilder);
}
use of cx.ring.model.SipCall in project ring-client-android by savoirfairelinux.
the class CallService method placeCall.
public SipCall placeCall(final String account, final String number, final boolean audioOnly) {
return FutureUtils.executeDaemonThreadCallable(mExecutor, mDeviceRuntimeService.provideDaemonThreadId(), true, () -> {
Log.i(TAG, "placeCall() thread running... " + number + " audioOnly: " + audioOnly);
HashMap<String, String> volatileDetails = new HashMap<>();
volatileDetails.put(SipCall.KEY_AUDIO_ONLY, String.valueOf(audioOnly));
String callId = Ringservice.placeCall(account, number, StringMap.toSwig(volatileDetails));
if (callId == null || callId.isEmpty())
return null;
if (audioOnly) {
Ringservice.muteLocalMedia(callId, "MEDIA_TYPE_VIDEO", true);
}
CallContact contact = mContactService.findContactByNumber(number);
SipCall call = addCall(account, callId, number, SipCall.Direction.OUTGOING);
call.muteVideo(audioOnly);
call.setContact(contact);
return call;
});
}
use of cx.ring.model.SipCall in project ring-client-android by savoirfairelinux.
the class CallService method callStateChanged.
void callStateChanged(String callId, String newState, int detailCode) {
Log.d(TAG, "call state changed: " + callId + ", " + newState + ", " + detailCode);
try {
SipCall call = parseCallState(callId, newState);
if (call != null) {
setChanged();
ServiceEvent event = new ServiceEvent(ServiceEvent.EventType.CALL_STATE_CHANGED);
event.addEventInput(ServiceEvent.EventInput.CALL, call);
notifyObservers(event);
if (call.getCallState() == SipCall.State.OVER) {
currentCalls.remove(call.getCallId());
}
}
} catch (Exception e) {
Log.w(TAG, "Exception during state change: ", e);
}
}
use of cx.ring.model.SipCall in project ring-client-android by savoirfairelinux.
the class CallService method addCall.
private SipCall addCall(String accountId, String callId, String from, int direction) {
SipCall call = currentCalls.get(callId);
if (call == null) {
call = new SipCall(callId, accountId, new Uri(from), direction);
currentCalls.put(callId, call);
} else {
Log.w(TAG, "Call already existed ! " + callId + " " + from);
}
return call;
}
Aggregations