From 3339910d7f4aea662dbac8ca6a996adf51e618c0 Mon Sep 17 00:00:00 2001 From: MDP43140 <68391650+MDP43140@users.noreply.github.com> Date: Sat, 16 Apr 2022 10:23:47 +0700 Subject: [PATCH] Add Filler category Implement Tangential jokes/filler SponsorBlock category. --- .../schabi/newpipe/player/LocalPlayer.java | 4 ++++ .../org/schabi/newpipe/player/Player.java | 4 ++++ ...ponsorBlockCategoriesSettingsFragment.java | 4 ++++ .../newpipe/util/SponsorBlockUtils.java | 15 ++++++++++++ app/src/main/res/values/colors.xml | 1 + app/src/main/res/values/settings_keys.xml | 2 ++ app/src/main/res/values/strings.xml | 3 +++ .../xml/sponsor_block_category_settings.xml | 24 +++++++++++++++++++ 8 files changed, 57 insertions(+) diff --git a/app/src/main/java/org/schabi/newpipe/player/LocalPlayer.java b/app/src/main/java/org/schabi/newpipe/player/LocalPlayer.java index d8208e44f..eb27556ad 100644 --- a/app/src/main/java/org/schabi/newpipe/player/LocalPlayer.java +++ b/app/src/main/java/org/schabi/newpipe/player/LocalPlayer.java @@ -322,6 +322,10 @@ public class LocalPlayer implements EventListener { toastText = context .getString(R.string.sponsor_block_skip_non_music_toast); break; + case "filler": + toastText = context + .getString(R.string.sponsor_block_skip_filler_toast); + break; } Toast.makeText(context, toastText, Toast.LENGTH_SHORT).show(); diff --git a/app/src/main/java/org/schabi/newpipe/player/Player.java b/app/src/main/java/org/schabi/newpipe/player/Player.java index 8fcb80df1..fd7390157 100644 --- a/app/src/main/java/org/schabi/newpipe/player/Player.java +++ b/app/src/main/java/org/schabi/newpipe/player/Player.java @@ -1823,6 +1823,10 @@ public final class Player implements toastText = context .getString(R.string.sponsor_block_skip_non_music_toast); break; + case "filler": + toastText = context + .getString(R.string.sponsor_block_skip_filler_toast); + break; } Toast.makeText(context, toastText, Toast.LENGTH_SHORT).show(); diff --git a/app/src/main/java/org/schabi/newpipe/settings/SponsorBlockCategoriesSettingsFragment.java b/app/src/main/java/org/schabi/newpipe/settings/SponsorBlockCategoriesSettingsFragment.java index d261c2899..0372ad2ff 100644 --- a/app/src/main/java/org/schabi/newpipe/settings/SponsorBlockCategoriesSettingsFragment.java +++ b/app/src/main/java/org/schabi/newpipe/settings/SponsorBlockCategoriesSettingsFragment.java @@ -58,6 +58,10 @@ public class SponsorBlockCategoriesSettingsFragment extends BasePreferenceFragme R.string.sponsor_block_category_non_music_color_key, R.color.non_music_segment); + setColorPreference(editor, + R.string.sponsor_block_category_filler_color_key, + R.color.filler_segment); + editor.apply(); Toast.makeText(p.getContext(), R.string.sponsor_block_reset_colors_toast, diff --git a/app/src/main/java/org/schabi/newpipe/util/SponsorBlockUtils.java b/app/src/main/java/org/schabi/newpipe/util/SponsorBlockUtils.java index cf9e715d0..f6e39166c 100644 --- a/app/src/main/java/org/schabi/newpipe/util/SponsorBlockUtils.java +++ b/app/src/main/java/org/schabi/newpipe/util/SponsorBlockUtils.java @@ -71,6 +71,8 @@ public final class SponsorBlockUtils { .getString(R.string.sponsor_block_category_self_promo_key), false); final boolean includeMusicCategory = prefs.getBoolean(context .getString(R.string.sponsor_block_category_non_music_key), false); + final boolean includeFillerCategory = prefs.getBoolean(context + .getString(R.string.sponsor_block_category_filler_key), false); final ArrayList categoryParamList = new ArrayList<>(); @@ -92,6 +94,9 @@ public final class SponsorBlockUtils { if (includeMusicCategory) { categoryParamList.add("music_offtopic"); } + if (includeFillerCategory) { + categoryParamList.add("filler"); + } if (categoryParamList.size() == 0) { return null; @@ -268,6 +273,16 @@ public final class SponsorBlockUtils { : Color.parseColor(colorStr); } break; + case "filler": + key = context.getString(R.string.sponsor_block_category_filler_key); + if (prefs.getBoolean(key, false)) { + key = context.getString(R.string.sponsor_block_category_filler_color_key); + colorStr = prefs.getString(key, null); + return colorStr == null + ? context.getResources().getColor(R.color.filler_segment) + : Color.parseColor(colorStr); + } + break; } return null; diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index e1d5bb011..36baec567 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -87,4 +87,5 @@ #cc00ff #ffff00 #ff9900 + #7300ff diff --git a/app/src/main/res/values/settings_keys.xml b/app/src/main/res/values/settings_keys.xml index 979b6c5d7..b3e1f9864 100644 --- a/app/src/main/res/values/settings_keys.xml +++ b/app/src/main/res/values/settings_keys.xml @@ -411,6 +411,8 @@ sponsor_block_category_self_promo_color sponsor_block_category_music sponsor_block_category_music_color + sponsor_block_category_filler + sponsor_block_category_filler_color sponsor_block_whitelist sponsor_block_clear_whitelist diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 8a8b79e24..4b795a59e 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -160,6 +160,8 @@ Similar to "sponsor" except for unpaid or self promotion. This includes sections about merchandise, donations, or information about who they collaborated with. Music: Non-Music Section Only for use in music videos. This includes introductions or outros in music videos. + Filler Tangent/Jokes + This is for tangential scenes added only for filler or humor that are not required to understand the main content of the video. Playing in background Playing in popup mode Content @@ -759,6 +761,7 @@ Skipped interaction reminder Skipped unpaid/self promo Skipped non-music + Skipped filler Toggle skipping sponsors Clear Whitelist Clear the list of uploaders SponsorBlock will ignore. diff --git a/app/src/main/res/xml/sponsor_block_category_settings.xml b/app/src/main/res/xml/sponsor_block_category_settings.xml index e066a1a50..78c1d6259 100644 --- a/app/src/main/res/xml/sponsor_block_category_settings.xml +++ b/app/src/main/res/xml/sponsor_block_category_settings.xml @@ -148,6 +148,30 @@ + + + + + + + + + +