From ebf63dd2941707fe77f1ae598575431a08bbf8ac Mon Sep 17 00:00:00 2001 From: Albert Vaca Date: Tue, 15 May 2018 01:10:39 +0200 Subject: [PATCH] Migrate to Oreo and drop support for APIs < 16 Summary: - Add a foreground notification to the background service - Add channel to notifications. - Remove unneeded permission - Remove legacy ciphers now that we don't support API<16 Reviewers: #kde_connect Subscribers: mtijink, nicolasfella, albertvaka, apol, kdeconnect, #kde_connect Tags: #kde_connect Differential Revision: https://phabricator.kde.org/D12881 --- res/values/strings.xml | 1 + .../kde/kdeconnect/Helpers/NotificationHelper.java | 13 ++++++++++--- .../Plugins/MprisPlugin/MprisMediaSession.java | 2 +- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/res/values/strings.xml b/res/values/strings.xml index 414bb94b..571f7379 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -246,5 +246,6 @@ Dark theme Other notifications Persistent indicator + Media control diff --git a/src/org/kde/kdeconnect/Helpers/NotificationHelper.java b/src/org/kde/kdeconnect/Helpers/NotificationHelper.java index 4572fa83..663c1eb6 100644 --- a/src/org/kde/kdeconnect/Helpers/NotificationHelper.java +++ b/src/org/kde/kdeconnect/Helpers/NotificationHelper.java @@ -12,6 +12,7 @@ public class NotificationHelper { public static class Channels { public final static String PERSISTENT = "persistent"; public final static String DEFAULT = "default"; + public final static String MEDIA_CONTROL = "media_control"; } public static void notifyCompat(NotificationManager notificationManager, int notificationId, Notification notification) { @@ -40,6 +41,12 @@ public class NotificationHelper { NotificationManager manager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); + manager.createNotificationChannel(new NotificationChannel( + Channels.PERSISTENT, + context.getString(R.string.notification_channel_persistent), + NotificationManager.IMPORTANCE_DEFAULT) + ); + manager.createNotificationChannel(new NotificationChannel( Channels.DEFAULT, context.getString(R.string.notification_channel_default), @@ -47,9 +54,9 @@ public class NotificationHelper { ); manager.createNotificationChannel(new NotificationChannel( - Channels.PERSISTENT, - context.getString(R.string.notification_channel_persistent), - NotificationManager.IMPORTANCE_DEFAULT) + Channels.MEDIA_CONTROL, + context.getString(R.string.notification_channel_media_control), + NotificationManager.IMPORTANCE_LOW) ); } diff --git a/src/org/kde/kdeconnect/Plugins/MprisPlugin/MprisMediaSession.java b/src/org/kde/kdeconnect/Plugins/MprisPlugin/MprisMediaSession.java index 5b8f5e73..d22ded72 100644 --- a/src/org/kde/kdeconnect/Plugins/MprisPlugin/MprisMediaSession.java +++ b/src/org/kde/kdeconnect/Plugins/MprisPlugin/MprisMediaSession.java @@ -308,7 +308,7 @@ public class MprisMediaSession implements SharedPreferences.OnSharedPreferenceCh final NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); - NotificationCompat.Builder notification = new NotificationCompat.Builder(context, NotificationHelper.Channels.DEFAULT); + NotificationCompat.Builder notification = new NotificationCompat.Builder(context, NotificationHelper.Channels.MEDIA_CONTROL); notification .setAutoCancel(false)