From 974f8f692c13ad123b87f45a1673bc0030d34864 Mon Sep 17 00:00:00 2001 From: Xiang Rong Lin <41164160+XiangRongLin@users.noreply.github.com> Date: Sun, 1 Nov 2020 18:13:41 +0100 Subject: [PATCH] Add option to not colorize notification --- .../java/org/schabi/newpipe/player/NotificationUtil.java | 5 ++++- .../newpipe/settings/NotificationSettingsFragment.kt | 9 +++++++++ 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, 24 insertions(+), 1 deletion(-) 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 10fff5298..62f1d5dc2 100644 --- a/app/src/main/java/org/schabi/newpipe/player/NotificationUtil.java +++ b/app/src/main/java/org/schabi/newpipe/player/NotificationUtil.java @@ -120,7 +120,10 @@ public final class NotificationUtil { .setCategory(NotificationCompat.CATEGORY_TRANSPORT) .setShowWhen(false) .setSmallIcon(R.drawable.ic_newpipe_triangle_white) - .setColor(ContextCompat.getColor(player.context, R.color.gray)) + .setColor(ContextCompat.getColor(player.context, R.color.dark_background_color)) + .setColorized(player.sharedPreferences.getBoolean( + player.context.getString(R.string.notification_colorize_key), + true)) .setDeleteIntent(PendingIntent.getBroadcast(player.context, NOTIFICATION_ID, new Intent(ACTION_CLOSE), FLAG_UPDATE_CURRENT)); diff --git a/app/src/main/java/org/schabi/newpipe/settings/NotificationSettingsFragment.kt b/app/src/main/java/org/schabi/newpipe/settings/NotificationSettingsFragment.kt index 860968626..c68b699d3 100644 --- a/app/src/main/java/org/schabi/newpipe/settings/NotificationSettingsFragment.kt +++ b/app/src/main/java/org/schabi/newpipe/settings/NotificationSettingsFragment.kt @@ -1,10 +1,19 @@ package org.schabi.newpipe.settings +import android.os.Build import android.os.Bundle +import androidx.preference.Preference import org.schabi.newpipe.R class NotificationSettingsFragment : BasePreferenceFragment() { override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) { addPreferencesFromResource(R.xml.notification_settings) + + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { + val colorizePref: Preference? = findPreference(getString(R.string.notification_colorize_key)) + colorizePref?.let { + preferenceScreen.removePreference(it) + } + } } } \ No newline at end of file diff --git a/app/src/main/res/values/settings_keys.xml b/app/src/main/res/values/settings_keys.xml index ba40ab931..c73d7d9de 100644 --- a/app/src/main/res/values/settings_keys.xml +++ b/app/src/main/res/values/settings_keys.xml @@ -132,6 +132,8 @@ notification_slot_compact_1_key notification_slot_compact_2_key + notification_colorize_key + video_mp4 video_webm video_3gp diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index a2ab0d78e..e0aefc935 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -72,6 +72,8 @@ Shuffle Buffering Nothing + Colorize notification + Have Android customize the notification\'s color according to the main color in the thumbnail (note that this is not available on all devices) Audio Default audio format Default video format diff --git a/app/src/main/res/xml/notification_settings.xml b/app/src/main/res/xml/notification_settings.xml index d9e45a41b..65d4af48a 100644 --- a/app/src/main/res/xml/notification_settings.xml +++ b/app/src/main/res/xml/notification_settings.xml @@ -10,6 +10,13 @@ android:title="@string/notification_scale_to_square_image_title" app:iconSpaceReserved="false" /> + +