[Android] Notifications channel for recommendations

Geoffrey Métais git at videolan.org
Fri Oct 13 15:47:52 CEST 2017


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Fri Oct 13 11:36:01 2017 +0200| [2108fa1bbd0a2278fb2fd89d44e469fd576c5ce0] | committer: Geoffrey Métais

Notifications channel for recommendations

> https://code.videolan.org/videolan/vlc-android/commit/2108fa1bbd0a2278fb2fd89d44e469fd576c5ce0
---

 vlc-android/res/values/strings.xml                    |  2 ++
 .../videolan/vlc/gui/helpers/NotificationHelper.java  | 19 +++++++++++++++----
 2 files changed, 17 insertions(+), 4 deletions(-)

diff --git a/vlc-android/res/values/strings.xml b/vlc-android/res/values/strings.xml
index e3311c99d..62f8764f6 100644
--- a/vlc-android/res/values/strings.xml
+++ b/vlc-android/res/values/strings.xml
@@ -565,4 +565,6 @@
     <string name="unsaved_set_deleted_message">Unsaved equalizer-set deleted.</string>
     <string name="equalizer_new_preset_name">New</string>
     <string name="settings_ml_block_scan">Medialibray is scanning your devices right now</string>
+    <string name="recommendations">Recommendations</string>
+    <string name="recommendations_desc">Recommendations cards on launcher</string>
 </resources>
diff --git a/vlc-android/src/org/videolan/vlc/gui/helpers/NotificationHelper.java b/vlc-android/src/org/videolan/vlc/gui/helpers/NotificationHelper.java
index 8f706ba62..efbc8cbee 100644
--- a/vlc-android/src/org/videolan/vlc/gui/helpers/NotificationHelper.java
+++ b/vlc-android/src/org/videolan/vlc/gui/helpers/NotificationHelper.java
@@ -26,6 +26,7 @@ import android.app.NotificationManager;
 import android.app.PendingIntent;
 import android.content.Context;
 import android.content.Intent;
+import android.content.res.Resources;
 import android.graphics.Bitmap;
 import android.media.session.MediaSession;
 import android.os.Build;
@@ -172,19 +173,29 @@ public class NotificationHelper {
     @RequiresApi(api = Build.VERSION_CODES.O)
     public static void createNotificationChannels() {
         final NotificationManager notificationManager = (NotificationManager) VLCApplication.getAppContext().getSystemService(Context.NOTIFICATION_SERVICE);
+        final Resources res = VLCApplication.getAppResources();
         // Playback channel
-        CharSequence name = VLCApplication.getAppResources().getString(R.string.playback);
-        String description = VLCApplication.getAppResources().getString(R.string.playback_controls);
+        CharSequence name = res.getString(R.string.playback);
+        String description = res.getString(R.string.playback_controls);
         NotificationChannel channel = new NotificationChannel("vlc_playback", name, NotificationManager.IMPORTANCE_LOW);
         channel.setDescription(description);
         channel.setLockscreenVisibility(Notification.VISIBILITY_PUBLIC);
         notificationManager.createNotificationChannel(channel);
         // Scan channel
-        name = VLCApplication.getAppResources().getString(R.string.medialibrary_scan);
-        description = VLCApplication.getAppResources().getString(R.string.Medialibrary_progress);
+        name = res.getString(R.string.medialibrary_scan);
+        description = res.getString(R.string.Medialibrary_progress);
         channel = new NotificationChannel("vlc_medialibrary", name, NotificationManager.IMPORTANCE_LOW);
         channel.setDescription(description);
         channel.setLockscreenVisibility(Notification.VISIBILITY_PUBLIC);
         notificationManager.createNotificationChannel(channel);
+        // Recommendations channel
+        if (AndroidDevices.isAndroidTv) {
+            name = res.getString(R.string.recommendations);
+            description = res.getString(R.string.recommendations_desc);
+            channel = new NotificationChannel("vlc_recommendations", name, NotificationManager.IMPORTANCE_LOW);
+            channel.setDescription(description);
+            channel.setLockscreenVisibility(Notification.VISIBILITY_PUBLIC);
+            notificationManager.createNotificationChannel(channel);
+        }
     }
 }



More information about the Android mailing list