SponsorBlock: "exclusion" to "whitelist"

Changed wording, and some other things I forgot do to earlier...
This commit is contained in:
polymorphicshade 2020-08-24 11:28:53 -06:00
parent 983078168c
commit 4f417b5b7c
7 changed files with 40 additions and 33 deletions

View file

@ -706,7 +706,7 @@ public abstract class BasePlayer implements
case ENABLED: case ENABLED:
sponsorBlockMode = SponsorBlockMode.DISABLED; sponsorBlockMode = SponsorBlockMode.DISABLED;
break; break;
case EXCLUDE: case IGNORE:
// ignored // ignored
} }
} }
@ -1178,11 +1178,11 @@ public abstract class BasePlayer implements
final boolean isSponsorBlockEnabled = mPrefs.getBoolean( final boolean isSponsorBlockEnabled = mPrefs.getBoolean(
context.getString(R.string.sponsor_block_enable_key), false); context.getString(R.string.sponsor_block_enable_key), false);
final Set<String> channelExclusions = mPrefs.getStringSet( final Set<String> uploaderWhitelist = mPrefs.getStringSet(
context.getString(R.string.sponsor_block_exclusion_list_key), null); context.getString(R.string.sponsor_block_whitelist_key), null);
if (channelExclusions != null && channelExclusions.contains(info.getUploaderName())) { if (uploaderWhitelist != null && uploaderWhitelist.contains(info.getUploaderName())) {
sponsorBlockMode = SponsorBlockMode.EXCLUDE; sponsorBlockMode = SponsorBlockMode.IGNORE;
} else { } else {
sponsorBlockMode = isSponsorBlockEnabled sponsorBlockMode = isSponsorBlockEnabled
? SponsorBlockMode.ENABLED ? SponsorBlockMode.ENABLED

View file

@ -673,7 +673,7 @@ public class VideoPlayerImpl extends VideoPlayer
Toast.makeText(context, R.string.sponsor_block_enabled_toast, Toast.LENGTH_SHORT) Toast.makeText(context, R.string.sponsor_block_enabled_toast, Toast.LENGTH_SHORT)
.show(); .show();
break; break;
case EXCLUDE: case IGNORE:
// ignored // ignored
} }
} }
@ -876,33 +876,35 @@ public class VideoPlayerImpl extends VideoPlayer
return true; return true;
} }
final Set<String> channelExclusions = final Set<String> uploaderWhitelist =
mPrefs.getStringSet( mPrefs.getStringSet(
context.getString(R.string.sponsor_block_exclusion_list_key), context.getString(R.string.sponsor_block_whitelist_key),
new HashSet<>()); new HashSet<>());
final String toastText; final String toastText;
if (getSponsorBlockMode() == SponsorBlockMode.EXCLUDE) { if (getSponsorBlockMode() == SponsorBlockMode.IGNORE) {
if (channelExclusions != null) { if (uploaderWhitelist != null) {
channelExclusions.remove(currentMetadata.getMetadata().getUploaderName()); uploaderWhitelist.remove(currentMetadata.getMetadata().getUploaderName());
} }
setSponsorBlockMode(SponsorBlockMode.ENABLED); setSponsorBlockMode(SponsorBlockMode.ENABLED);
toastText = "Uploader removed from SponsorBlock exclusion list"; toastText = context
.getString(R.string.sponsor_block_uploader_removed_from_whitelist_toast);
} else { } else {
if (channelExclusions != null) { if (uploaderWhitelist != null) {
channelExclusions.add(currentMetadata.getMetadata().getUploaderName()); uploaderWhitelist.add(currentMetadata.getMetadata().getUploaderName());
} }
setSponsorBlockMode(SponsorBlockMode.EXCLUDE); setSponsorBlockMode(SponsorBlockMode.IGNORE);
toastText = "Uploader excluded from SponsorBlock"; toastText = context
.getString(R.string.sponsor_block_uploader_added_to_whitelist_toast);
} }
mPrefs.edit() mPrefs.edit()
.putStringSet( .putStringSet(
context.getString(R.string.sponsor_block_exclusion_list_key), context.getString(R.string.sponsor_block_whitelist_key),
channelExclusions) uploaderWhitelist)
.apply(); .apply();
setBlockSponsorsButton(blockSponsorsButton); setBlockSponsorsButton(blockSponsorsButton);
@ -1670,7 +1672,7 @@ public class VideoPlayerImpl extends VideoPlayer
case ENABLED: case ENABLED:
resId = R.drawable.ic_sponsor_block_enable_white_24dp; resId = R.drawable.ic_sponsor_block_enable_white_24dp;
break; break;
case EXCLUDE: case IGNORE:
resId = R.drawable.ic_sponsor_block_exclude_white_24dp; resId = R.drawable.ic_sponsor_block_exclude_white_24dp;
break; break;
default: default:

View file

@ -171,16 +171,16 @@ public class ContentSettingsFragment extends BasePreferenceFragment {
return true; return true;
}); });
final Preference sponsorBlockClearExclusionListPreference = final Preference sponsorBlockClearWhitelistPreference =
findPreference(getString(R.string.sponsor_block_clear_exclusion_list_key)); findPreference(getString(R.string.sponsor_block_clear_whitelist_key));
sponsorBlockClearExclusionListPreference.setOnPreferenceClickListener((Preference p) -> { sponsorBlockClearWhitelistPreference.setOnPreferenceClickListener((Preference p) -> {
getPreferenceManager() getPreferenceManager()
.getSharedPreferences() .getSharedPreferences()
.edit() .edit()
.putStringSet( .putStringSet(
getString(R.string.sponsor_block_exclusion_list_key), new HashSet<>()) getString(R.string.sponsor_block_whitelist_key), new HashSet<>())
.apply(); .apply();
Toast.makeText(getContext(), R.string.sponsor_block_exclusion_list_cleared_toast, Toast.makeText(getContext(), R.string.sponsor_block_whitelist_cleared_toast,
Toast.LENGTH_SHORT).show(); Toast.LENGTH_SHORT).show();
return true; return true;
}); });
@ -406,6 +406,9 @@ public class ContentSettingsFragment extends BasePreferenceFragment {
findPreference(getString(R.string.sponsor_block_categories_key)) findPreference(getString(R.string.sponsor_block_categories_key))
.onDependencyChanged(preference, .onDependencyChanged(preference,
newValue == null || newValue.equals("")); newValue == null || newValue.equals(""));
findPreference(getString(R.string.sponsor_block_clear_whitelist_key))
.onDependencyChanged(preference,
newValue == null || newValue.equals(""));
} }
} }

View file

@ -3,5 +3,5 @@ package org.schabi.newpipe.util;
public enum SponsorBlockMode { public enum SponsorBlockMode {
DISABLED, DISABLED,
ENABLED, ENABLED,
EXCLUDE IGNORE
} }

View file

@ -258,8 +258,8 @@
<string name="sponsor_block_category_self_promo_color_key" translatable="false">sponsor_block_category_self_promo_color</string> <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_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_non_music_color_key" translatable="false">sponsor_block_category_music_color</string>
<string name="sponsor_block_exclusion_list_key" translatable="false">sponsor_block_exclusion_list</string> <string name="sponsor_block_whitelist_key" translatable="false">sponsor_block_whitelist</string>
<string name="sponsor_block_clear_exclusion_list_key" translatable="false">sponsor_block_clear_exclusion_list</string> <string name="sponsor_block_clear_whitelist_key" translatable="false">sponsor_block_clear_whitelist</string>
<!-- FileName Downloads --> <!-- FileName Downloads -->
<string name="settings_file_charset_key" translatable="false">file_rename_charset</string> <string name="settings_file_charset_key" translatable="false">file_rename_charset</string>

View file

@ -707,9 +707,11 @@
<string name="sponsor_block_skip_self_promo_message">Skipped unpaid/self promo</string> <string name="sponsor_block_skip_self_promo_message">Skipped unpaid/self promo</string>
<string name="sponsor_block_skip_non_music_message">Skipped non-music</string> <string name="sponsor_block_skip_non_music_message">Skipped non-music</string>
<string name="sponsor_block_toggle_skipping">Toggle skipping sponsors</string> <string name="sponsor_block_toggle_skipping">Toggle skipping sponsors</string>
<string name="sponsor_block_clear_exclusion_list_title">Clear Exclusion List</string> <string name="sponsor_block_clear_whitelist_title">Clear Whitelist</string>
<string name="sponsor_block_clear_exclusion_list_summary">Clear the list of uploaders excluded from SponsorBlock.</string> <string name="sponsor_block_clear_whitelist_summary">Clear the list of uploaders SponsorBlock will ignore.</string>
<string name="sponsor_block_enabled_toast">SponsorBlock enabled</string> <string name="sponsor_block_enabled_toast">SponsorBlock enabled</string>
<string name="sponsor_block_disabled_toast">SponsorBlock disabled</string> <string name="sponsor_block_disabled_toast">SponsorBlock disabled</string>
<string name="sponsor_block_exclusion_list_cleared_toast">Exclusion list cleared</string> <string name="sponsor_block_whitelist_cleared_toast">Whitelist cleared</string>
<string name="sponsor_block_uploader_added_to_whitelist_toast">Uploader added to whitelist</string>
<string name="sponsor_block_uploader_removed_from_whitelist_toast">Uploader removed from whitelist</string>
</resources> </resources>

View file

@ -166,9 +166,9 @@
<Preference <Preference
app:iconSpaceReserved="false" app:iconSpaceReserved="false"
android:key="@string/sponsor_block_clear_exclusion_list_key" android:key="@string/sponsor_block_clear_whitelist_key"
android:summary="@string/sponsor_block_clear_exclusion_list_summary" android:summary="@string/sponsor_block_clear_whitelist_summary"
android:title="@string/sponsor_block_clear_exclusion_list_title"/> android:title="@string/sponsor_block_clear_whitelist_title"/>
</PreferenceCategory> </PreferenceCategory>
</PreferenceScreen> </PreferenceScreen>