Use service notifications channel for call notifications so they don't show up and ring

This commit is contained in:
Sylvain Berfini 2017-11-30 15:06:27 +01:00
parent a6332bab67
commit dc580ea9f1

View file

@ -39,7 +39,7 @@ public class ApiTwentySixPlus {
public static void CreateChannel(Context context) { public static void CreateChannel(Context context) {
NotificationManager notificationManager = NotificationManager notificationManager =
(NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
// Create service notification channel // Create service/call notification channel
String id = context.getString(R.string.notification_service_channel_id); String id = context.getString(R.string.notification_service_channel_id);
CharSequence name = context.getString(R.string.content_title_notification_service); CharSequence name = context.getString(R.string.content_title_notification_service);
String description = context.getString(R.string.content_title_notification_service); String description = context.getString(R.string.content_title_notification_service);
@ -47,8 +47,9 @@ public class ApiTwentySixPlus {
NotificationChannel mChannel = new NotificationChannel(id, name, importance); NotificationChannel mChannel = new NotificationChannel(id, name, importance);
mChannel.setDescription(description); mChannel.setDescription(description);
mChannel.enableVibration(false); mChannel.enableVibration(false);
mChannel.enableLights(false);
notificationManager.createNotificationChannel(mChannel); notificationManager.createNotificationChannel(mChannel);
// Create message/call notification channel // Create message notification channel
id = context.getString(R.string.notification_channel_id); id = context.getString(R.string.notification_channel_id);
name = context.getString(R.string.content_title_notification); name = context.getString(R.string.content_title_notification);
description = context.getString(R.string.content_title_notification); description = context.getString(R.string.content_title_notification);
@ -71,8 +72,6 @@ public class ApiTwentySixPlus {
title = context.getString(R.string.unread_messages).replace("%i", String.valueOf(msgCount)); title = context.getString(R.string.unread_messages).replace("%i", String.valueOf(msgCount));
} }
NotificationManager notificationManager =
(NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
Notification notif = null; Notification notif = null;
notif = new Notification.Builder(context, context.getString(R.string.notification_channel_id)) notif = new Notification.Builder(context, context.getString(R.string.notification_channel_id))
.setContentTitle(title) .setContentTitle(title)
@ -96,7 +95,7 @@ public class ApiTwentySixPlus {
String title, String msg, int iconID, Bitmap contactIcon, String title, String msg, int iconID, Bitmap contactIcon,
String contactName, PendingIntent intent) { String contactName, PendingIntent intent) {
Notification notif = new Notification.Builder(context, context.getString(R.string.notification_channel_id)) Notification notif = new Notification.Builder(context, context.getString(R.string.notification_service_channel_id))
.setContentTitle(contactName) .setContentTitle(contactName)
.setContentText(msg) .setContentText(msg)
.setSmallIcon(iconID) .setSmallIcon(iconID)