use of androidx.core.app.NotificationCompat.Builder in project Conversations by siacs.
the class NotificationService method getOngoingCallNotification.
public Notification getOngoingCallNotification(final XmppConnectionService.OngoingCall ongoingCall) {
final AbstractJingleConnection.Id id = ongoingCall.id;
final NotificationCompat.Builder builder = new NotificationCompat.Builder(mXmppConnectionService, "ongoing_calls");
if (ongoingCall.media.contains(Media.VIDEO)) {
builder.setSmallIcon(R.drawable.ic_videocam_white_24dp);
if (ongoingCall.reconnecting) {
builder.setContentTitle(mXmppConnectionService.getString(R.string.reconnecting_video_call));
} else {
builder.setContentTitle(mXmppConnectionService.getString(R.string.ongoing_video_call));
}
} else {
builder.setSmallIcon(R.drawable.ic_call_white_24dp);
if (ongoingCall.reconnecting) {
builder.setContentTitle(mXmppConnectionService.getString(R.string.reconnecting_call));
} else {
builder.setContentTitle(mXmppConnectionService.getString(R.string.ongoing_call));
}
}
builder.setContentText(id.account.getRoster().getContact(id.with).getDisplayName());
builder.setVisibility(NotificationCompat.VISIBILITY_PUBLIC);
builder.setPriority(NotificationCompat.PRIORITY_HIGH);
builder.setCategory(NotificationCompat.CATEGORY_CALL);
builder.setContentIntent(createPendingRtpSession(id, Intent.ACTION_VIEW, 101));
builder.setOngoing(true);
builder.addAction(new NotificationCompat.Action.Builder(R.drawable.ic_call_end_white_48dp, mXmppConnectionService.getString(R.string.hang_up), createCallAction(id.sessionId, XmppConnectionService.ACTION_END_CALL, 104)).build());
return builder.build();
}
use of androidx.core.app.NotificationCompat.Builder in project Conversations by siacs.
the class NotificationService method updateNotification.
private void updateNotification(final boolean notify, final List<String> conversations, final boolean summaryOnly) {
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(mXmppConnectionService);
final boolean quiteHours = isQuietHours();
// if this check is changed to > 0 catchup messages will create one notification per conversation
final boolean notifyOnlyOneChild = notify && conversations != null && conversations.size() == 1;
if (notifications.size() == 0) {
cancel(NOTIFICATION_ID);
} else {
if (notify) {
this.markLastNotification();
}
final Builder mBuilder;
if (notifications.size() == 1 && Build.VERSION.SDK_INT < Build.VERSION_CODES.N) {
mBuilder = buildSingleConversations(notifications.values().iterator().next(), notify, quiteHours);
modifyForSoundVibrationAndLight(mBuilder, notify, quiteHours, preferences);
notify(NOTIFICATION_ID, mBuilder.build());
} else {
mBuilder = buildMultipleConversation(notify, quiteHours);
if (notifyOnlyOneChild) {
mBuilder.setGroupAlertBehavior(NotificationCompat.GROUP_ALERT_CHILDREN);
}
modifyForSoundVibrationAndLight(mBuilder, notify, quiteHours, preferences);
if (!summaryOnly) {
for (Map.Entry<String, ArrayList<Message>> entry : notifications.entrySet()) {
String uuid = entry.getKey();
final boolean notifyThis = notifyOnlyOneChild ? conversations.contains(uuid) : notify;
Builder singleBuilder = buildSingleConversations(entry.getValue(), notifyThis, quiteHours);
if (!notifyOnlyOneChild) {
singleBuilder.setGroupAlertBehavior(NotificationCompat.GROUP_ALERT_SUMMARY);
}
modifyForSoundVibrationAndLight(singleBuilder, notifyThis, quiteHours, preferences);
singleBuilder.setGroup(CONVERSATIONS_GROUP);
setNotificationColor(singleBuilder);
notify(entry.getKey(), NOTIFICATION_ID, singleBuilder.build());
}
}
notify(NOTIFICATION_ID, mBuilder.build());
}
}
}
Aggregations