From 7805f8a9b1130f849773cb4c978d82a4cb9cc440 Mon Sep 17 00:00:00 2001 From: XiangRongLin <41164160+XiangRongLin@users.noreply.github.com> Date: Sat, 14 Nov 2020 10:01:07 +0100 Subject: [PATCH] Add option to hide thumbnail on lock screen and inside notification --- .../java/org/schabi/newpipe/player/NotificationUtil.java | 6 +++++- .../java/org/schabi/newpipe/player/VideoPlayerImpl.java | 8 ++++++-- app/src/main/res/values/settings_keys.xml | 2 ++ app/src/main/res/values/strings.xml | 2 ++ app/src/main/res/xml/notification_settings.xml | 7 +++++++ 5 files changed, 22 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/player/NotificationUtil.java b/app/src/main/java/org/schabi/newpipe/player/NotificationUtil.java index 62f1d5dc2..510e4f882 100644 --- a/app/src/main/java/org/schabi/newpipe/player/NotificationUtil.java +++ b/app/src/main/java/org/schabi/newpipe/player/NotificationUtil.java @@ -146,7 +146,11 @@ public final class NotificationUtil { notificationBuilder.setContentText(player.getUploaderName()); notificationBuilder.setTicker(player.getVideoTitle()); updateActions(notificationBuilder, player); - setLargeIcon(notificationBuilder, player); + final boolean showThumbnail = player.sharedPreferences.getBoolean( + player.context.getString(R.string.show_thumbnail_key), true); + if (showThumbnail) { + setLargeIcon(notificationBuilder, player); + } } diff --git a/app/src/main/java/org/schabi/newpipe/player/VideoPlayerImpl.java b/app/src/main/java/org/schabi/newpipe/player/VideoPlayerImpl.java index fa016e158..3d626bb37 100644 --- a/app/src/main/java/org/schabi/newpipe/player/VideoPlayerImpl.java +++ b/app/src/main/java/org/schabi/newpipe/player/VideoPlayerImpl.java @@ -671,9 +671,13 @@ public class VideoPlayerImpl extends VideoPlayer super.onUpdateProgress(currentProgress, duration, bufferPercent); updateProgress(currentProgress, duration, bufferPercent); + final boolean showThumbnail = + sharedPreferences.getBoolean( + context.getString(R.string.show_thumbnail_key), + true); // setMetadata only updates the metadata when any of the metadata keys are null - mediaSessionManager.setMetadata(getVideoTitle(), getUploaderName(), getThumbnail(), - duration); + mediaSessionManager.setMetadata(getVideoTitle(), getUploaderName(), + showThumbnail ? getThumbnail() : null, duration); } @Override diff --git a/app/src/main/res/values/settings_keys.xml b/app/src/main/res/values/settings_keys.xml index 9c9fa4853..75c090e84 100644 --- a/app/src/main/res/values/settings_keys.xml +++ b/app/src/main/res/values/settings_keys.xml @@ -222,6 +222,8 @@ feed_update_threshold_key 300 + show_thumbnail_key + @string/feed_update_threshold_option_always_update diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 394a78d0c..60d2dc313 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -681,4 +681,6 @@ Created by %s By %s Playlist page + Show thumbnail + Show thumbnail on lock screen as background and inside notifications diff --git a/app/src/main/res/xml/notification_settings.xml b/app/src/main/res/xml/notification_settings.xml index 65d4af48a..5d937efa6 100644 --- a/app/src/main/res/xml/notification_settings.xml +++ b/app/src/main/res/xml/notification_settings.xml @@ -17,6 +17,13 @@ android:title="@string/notification_colorize_title" app:iconSpaceReserved="false" /> + +