Mercurial > 510Connectbot
changeset 488:869070df0e80 stable-1.9.4-1
new notification channel needs android 8
author | Carl Byington <carl@five-ten-sg.com> |
---|---|
date | Wed, 14 Oct 2020 11:27:14 -0700 |
parents | 3afdeb535e9f |
children | b257517e9bef |
files | app/build.gradle app/src/main/java/com/five_ten_sg/connectbot/service/ConnectionNotifier.java |
diffstat | 2 files changed, 18 insertions(+), 15 deletions(-) [+] |
line wrap: on
line diff
--- a/app/build.gradle Wed Oct 14 11:11:09 2020 -0700 +++ b/app/build.gradle Wed Oct 14 11:27:14 2020 -0700 @@ -60,7 +60,7 @@ defaultConfig { applicationId = "com.five_ten_sg.connectbot" - minSdkVersion = 21 + minSdkVersion = 26 targetSdkVersion = 28 ndk { moduleName = "com_google_ase_Exec"
--- a/app/src/main/java/com/five_ten_sg/connectbot/service/ConnectionNotifier.java Wed Oct 14 11:11:09 2020 -0700 +++ b/app/src/main/java/com/five_ten_sg/connectbot/service/ConnectionNotifier.java Wed Oct 14 11:27:14 2020 -0700 @@ -40,6 +40,7 @@ public class ConnectionNotifier { private static final int ONLINE_NOTIFICATION = 1; private static final int ACTIVITY_NOTIFICATION = 2; + private NotificationChannel chan = null; protected NotificationManager getNotificationManager(Context context) { return (NotificationManager)context.getSystemService(Context.NOTIFICATION_SERVICE); @@ -61,13 +62,14 @@ 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); + if (chan == null) { + 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)) @@ -90,13 +92,14 @@ 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); + if (chan == null) { + 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))