Implement Preview/Recap Category

Implements part of #99 and #111
Uses the default SponsorBlock color for the category
This commit is contained in:
Muonis 2022-02-27 20:42:08 +01:00
parent 34f00e4e32
commit 06422d74f7
8 changed files with 57 additions and 0 deletions

View file

@ -322,6 +322,10 @@ public class LocalPlayer implements EventListener {
toastText = context
.getString(R.string.sponsor_block_skip_non_music_toast);
break;
case "preview":
toastText = context
.getString(R.string.sponsor_block_skip_preview_toast);
break;
}
Toast.makeText(context, toastText, Toast.LENGTH_SHORT).show();

View file

@ -1823,6 +1823,10 @@ public final class Player implements
toastText = context
.getString(R.string.sponsor_block_skip_non_music_toast);
break;
case "preview":
toastText = context
.getString(R.string.sponsor_block_skip_preview_toast);
break;
}
Toast.makeText(context, toastText, Toast.LENGTH_SHORT).show();

View file

@ -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_preview_color_key,
R.color.preview_segment);
editor.apply();
Toast.makeText(p.getContext(), R.string.sponsor_block_reset_colors_toast,

View file

@ -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 includePreviewCategory = prefs.getBoolean(context
.getString(R.string.sponsor_block_category_preview_key), false);
final ArrayList<String> categoryParamList = new ArrayList<>();
@ -92,6 +94,9 @@ public final class SponsorBlockUtils {
if (includeMusicCategory) {
categoryParamList.add("music_offtopic");
}
if (includePreviewCategory) {
categoryParamList.add("preview");
}
if (categoryParamList.size() == 0) {
return null;
@ -268,6 +273,16 @@ public final class SponsorBlockUtils {
: Color.parseColor(colorStr);
}
break;
case "preview":
key = context.getString(R.string.sponsor_block_category_preview_key);
if (prefs.getBoolean(key, false)) {
key = context.getString(R.string.sponsor_block_category_preview_color_key);
colorStr = prefs.getString(key, null);
return colorStr == null
? context.getResources().getColor(R.color.preview_segment)
: Color.parseColor(colorStr);
}
break;
}
return null;

View file

@ -87,4 +87,5 @@
<color name="interaction_segment">#cc00ff</color>
<color name="self_promo_segment">#ffff00</color>
<color name="non_music_segment">#ff9900</color>
<color name="preview_segment">#008fd6</color>
</resources>

View file

@ -411,6 +411,8 @@
<string name="sponsor_block_category_self_promo_color_key" translatable="false">sponsor_block_category_self_promo_color</string>
<string name="sponsor_block_category_non_music_key" translatable="false">sponsor_block_category_music</string>
<string name="sponsor_block_category_non_music_color_key" translatable="false">sponsor_block_category_music_color</string>
<string name="sponsor_block_category_preview_key" translatable="false">sponsor_block_category_preview</string>
<string name="sponsor_block_category_preview_color_key" translatable="false">sponsor_block_category_preview_color</string>
<string name="sponsor_block_whitelist_key" translatable="false">sponsor_block_whitelist</string>
<string name="sponsor_block_clear_whitelist_key" translatable="false">sponsor_block_clear_whitelist</string>

View file

@ -160,6 +160,8 @@
<string name="settings_category_sponsor_block_category_self_promo_summary">Similar to "sponsor" except for unpaid or self promotion. This includes sections about merchandise, donations, or information about who they collaborated with.</string>
<string name="settings_category_sponsor_block_category_non_music_title">Music: Non-Music Section</string>
<string name="settings_category_sponsor_block_category_non_music_summary">Only for use in music videos. This includes introductions or outros in music videos.</string>
<string name="settings_category_sponsor_block_category_preview_title">Preview/Recap</string>
<string name="settings_category_sponsor_block_category_preview_summary">Quick recap of previous episodes, or a preview of what\'s coming up later in the current video. Meant for edited together clips, not for spoken summaries.</string>
<string name="background_player_playing_toast">Playing in background</string>
<string name="popup_playing_toast">Playing in popup mode</string>
<string name="content">Content</string>
@ -759,6 +761,7 @@
<string name="sponsor_block_skip_interaction_toast">Skipped interaction reminder</string>
<string name="sponsor_block_skip_self_promo_toast">Skipped unpaid/self promo</string>
<string name="sponsor_block_skip_non_music_toast">Skipped non-music</string>
<string name="sponsor_block_skip_preview_toast">Skipped preview/recap</string>
<string name="sponsor_block_toggle_skipping">Toggle skipping sponsors</string>
<string name="sponsor_block_clear_whitelist_title">Clear Whitelist</string>
<string name="sponsor_block_clear_whitelist_summary">Clear the list of uploaders SponsorBlock will ignore.</string>

View file

@ -148,6 +148,30 @@
</PreferenceCategory>
<PreferenceCategory
android:layout="@layout/settings_category_header_layout"
android:title="@string/settings_category_sponsor_block_category_preview_title">
<Preference
app:iconSpaceReserved="false"
android:summary="@string/settings_category_sponsor_block_category_preview_summary"
android:selectable="false"/>
<SwitchPreference
app:iconSpaceReserved="false"
android:defaultValue="false"
android:key="@string/sponsor_block_category_preview_key"
android:title="@string/settings_category_sponsor_block_category_enable_title"/>
<org.schabi.newpipe.settings.custom.EditColorPreference
app:iconSpaceReserved="false"
android:dependency="@string/sponsor_block_category_preview_key"
android:defaultValue="@color/preview_segment"
android:key="@string/sponsor_block_category_preview_color_key"
android:title="@string/settings_category_sponsor_block_category_color"/>
</PreferenceCategory>
<PreferenceCategory
android:layout="@layout/settings_category_header_layout">