Add option to not colorize notification

This commit is contained in:
Xiang Rong Lin 2020-11-01 18:13:41 +01:00 committed by Stypox
parent e97d0b9a69
commit 974f8f692c
No known key found for this signature in database
GPG key ID: 4BDF1B40A49FDD23
5 changed files with 24 additions and 1 deletions

View file

@ -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));

View file

@ -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)
}
}
}
}

View file

@ -132,6 +132,8 @@
<string name="notification_slot_compact_1_key" translatable="false">notification_slot_compact_1_key</string>
<string name="notification_slot_compact_2_key" translatable="false">notification_slot_compact_2_key</string>
<string name="notification_colorize_key" translatable="false">notification_colorize_key</string>
<string name="video_mp4_key" translatable="false">video_mp4</string>
<string name="video_webm_key" translatable="false">video_webm</string>
<string name="video_3gp_key" translatable="false">video_3gp</string>

View file

@ -72,6 +72,8 @@
<string name="notification_action_shuffle">Shuffle</string>
<string name="notification_action_buffering">Buffering</string>
<string name="notification_action_nothing">Nothing</string>
<string name="notification_colorize_title">Colorize notification</string>
<string name="notification_colorize_summary">Have Android customize the notification\'s color according to the main color in the thumbnail (note that this is not available on all devices)</string>
<string name="play_audio">Audio</string>
<string name="default_audio_format_title">Default audio format</string>
<string name="default_video_format_title">Default video format</string>

View file

@ -10,6 +10,13 @@
android:title="@string/notification_scale_to_square_image_title"
app:iconSpaceReserved="false" />
<SwitchPreferenceCompat
android:defaultValue="true"
android:key="@string/notification_colorize_key"
android:summary="@string/notification_colorize_summary"
android:title="@string/notification_colorize_title"
app:iconSpaceReserved="false" />
<PreferenceCategory
android:layout="@layout/settings_category_header_layout"
app:iconSpaceReserved="false">