# HG changeset patch # User Carl Byington # Date 1602699069 25200 # Node ID 3afdeb535e9f70989b51a6f5314f376ed2c1e8fc # Parent 6751ed7635f680b7249e5f40b7fc62b0a20e077a notification needs a notification channel diff -r 6751ed7635f6 -r 3afdeb535e9f app/src/main/java/com/five_ten_sg/connectbot/service/ConnectionNotifier.java --- a/app/src/main/java/com/five_ten_sg/connectbot/service/ConnectionNotifier.java Wed Oct 14 09:07:21 2020 -0700 +++ b/app/src/main/java/com/five_ten_sg/connectbot/service/ConnectionNotifier.java Wed Oct 14 11:11:09 2020 -0700 @@ -22,6 +22,7 @@ import com.five_ten_sg.connectbot.bean.HostBean; import com.five_ten_sg.connectbot.util.HostDatabase; import android.app.Notification; +import android.app.NotificationChannel; import android.app.NotificationManager; import android.app.PendingIntent; import android.app.Service; @@ -57,6 +58,17 @@ Resources res = context.getResources(); Intent notificationIntent = new Intent(context, ConsoleActivity.class); PendingIntent contentIntent = PendingIntent.getActivity(context, 0, notificationIntent, 0); + + String channelID = "com.five_ten_sg.connectbot.service"; + String channelName = "background"; + NotificationChannel chan = new NotificationChannel(channelID, channelName, NotificationManager.IMPORTANCE_NONE); + chan.setLightColor(R.color.colorAccent); + chan.setLockscreenVisibility(Notification.VISIBILITY_PRIVATE); + + NotificationManager manager = getNotificationManager(context); + assert manager != null; + manager.createNotificationChannel(chan); + Notification notification = new Notification.Builder(context) .setContentTitle(res.getString(R.string.app_name)) .setContentText(res.getString(R.string.notification_text, host.getNickname())) @@ -64,6 +76,7 @@ .setWhen(System.currentTimeMillis()) .setSmallIcon(R.drawable.notification_icon) .setLargeIcon(BitmapFactory.decodeResource(res, R.drawable.notification_icon)) + .setChannelId(channelID) .setLights(rgb, 300, 1000) .build(); notification.flags |= Notification.FLAG_AUTO_CANCEL; @@ -74,6 +87,17 @@ Resources res = context.getResources(); Intent notificationIntent = new Intent(context, ConsoleActivity.class); PendingIntent contentIntent = PendingIntent.getActivity(context, ONLINE_NOTIFICATION, notificationIntent, 0); + + String channelID = "com.five_ten_sg.connectbot.service"; + String channelName = "background"; + NotificationChannel chan = new NotificationChannel(channelID, channelName, NotificationManager.IMPORTANCE_NONE); + chan.setLightColor(R.color.colorAccent); + chan.setLockscreenVisibility(Notification.VISIBILITY_PRIVATE); + + NotificationManager manager = getNotificationManager(context); + assert manager != null; + manager.createNotificationChannel(chan); + Notification notification = new Notification.Builder(context) .setContentTitle(res.getString(R.string.app_name)) .setContentText(res.getString(R.string.app_is_running)) @@ -82,6 +106,7 @@ .setOngoing(true) .setSmallIcon(R.drawable.notification_icon) .setLargeIcon(BitmapFactory.decodeResource(res, R.drawable.notification_icon)) + .setChannelId(channelID) .build(); notification.flags |= Notification.FLAG_NO_CLEAR; return notification; diff -r 6751ed7635f6 -r 3afdeb535e9f app/src/main/res/values/colors.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/app/src/main/res/values/colors.xml Wed Oct 14 11:11:09 2020 -0700 @@ -0,0 +1,6 @@ + + + #008577 + #00574B + #D81B60 +