diff --git a/app/src/main/java/org/schabi/newpipe/player/BasePlayer.java b/app/src/main/java/org/schabi/newpipe/player/BasePlayer.java index 2ebfc2b4f..902a969ce 100644 --- a/app/src/main/java/org/schabi/newpipe/player/BasePlayer.java +++ b/app/src/main/java/org/schabi/newpipe/player/BasePlayer.java @@ -706,7 +706,7 @@ public abstract class BasePlayer implements case ENABLED: sponsorBlockMode = SponsorBlockMode.DISABLED; break; - case EXCLUDE: + case IGNORE: // ignored } } @@ -1178,11 +1178,11 @@ public abstract class BasePlayer implements final boolean isSponsorBlockEnabled = mPrefs.getBoolean( context.getString(R.string.sponsor_block_enable_key), false); - final Set channelExclusions = mPrefs.getStringSet( - context.getString(R.string.sponsor_block_exclusion_list_key), null); + final Set uploaderWhitelist = mPrefs.getStringSet( + context.getString(R.string.sponsor_block_whitelist_key), null); - if (channelExclusions != null && channelExclusions.contains(info.getUploaderName())) { - sponsorBlockMode = SponsorBlockMode.EXCLUDE; + if (uploaderWhitelist != null && uploaderWhitelist.contains(info.getUploaderName())) { + sponsorBlockMode = SponsorBlockMode.IGNORE; } else { sponsorBlockMode = isSponsorBlockEnabled ? SponsorBlockMode.ENABLED diff --git a/app/src/main/java/org/schabi/newpipe/player/VideoPlayerImpl.java b/app/src/main/java/org/schabi/newpipe/player/VideoPlayerImpl.java index aada74021..91cbe9761 100644 --- a/app/src/main/java/org/schabi/newpipe/player/VideoPlayerImpl.java +++ b/app/src/main/java/org/schabi/newpipe/player/VideoPlayerImpl.java @@ -673,7 +673,7 @@ public class VideoPlayerImpl extends VideoPlayer Toast.makeText(context, R.string.sponsor_block_enabled_toast, Toast.LENGTH_SHORT) .show(); break; - case EXCLUDE: + case IGNORE: // ignored } } @@ -876,33 +876,35 @@ public class VideoPlayerImpl extends VideoPlayer return true; } - final Set channelExclusions = + final Set uploaderWhitelist = mPrefs.getStringSet( - context.getString(R.string.sponsor_block_exclusion_list_key), + context.getString(R.string.sponsor_block_whitelist_key), new HashSet<>()); final String toastText; - if (getSponsorBlockMode() == SponsorBlockMode.EXCLUDE) { - if (channelExclusions != null) { - channelExclusions.remove(currentMetadata.getMetadata().getUploaderName()); + if (getSponsorBlockMode() == SponsorBlockMode.IGNORE) { + if (uploaderWhitelist != null) { + uploaderWhitelist.remove(currentMetadata.getMetadata().getUploaderName()); } setSponsorBlockMode(SponsorBlockMode.ENABLED); - toastText = "Uploader removed from SponsorBlock exclusion list"; + toastText = context + .getString(R.string.sponsor_block_uploader_removed_from_whitelist_toast); } else { - if (channelExclusions != null) { - channelExclusions.add(currentMetadata.getMetadata().getUploaderName()); + if (uploaderWhitelist != null) { + uploaderWhitelist.add(currentMetadata.getMetadata().getUploaderName()); } - setSponsorBlockMode(SponsorBlockMode.EXCLUDE); - toastText = "Uploader excluded from SponsorBlock"; + setSponsorBlockMode(SponsorBlockMode.IGNORE); + toastText = context + .getString(R.string.sponsor_block_uploader_added_to_whitelist_toast); } mPrefs.edit() .putStringSet( - context.getString(R.string.sponsor_block_exclusion_list_key), - channelExclusions) + context.getString(R.string.sponsor_block_whitelist_key), + uploaderWhitelist) .apply(); setBlockSponsorsButton(blockSponsorsButton); @@ -1670,7 +1672,7 @@ public class VideoPlayerImpl extends VideoPlayer case ENABLED: resId = R.drawable.ic_sponsor_block_enable_white_24dp; break; - case EXCLUDE: + case IGNORE: resId = R.drawable.ic_sponsor_block_exclude_white_24dp; break; default: diff --git a/app/src/main/java/org/schabi/newpipe/settings/ContentSettingsFragment.java b/app/src/main/java/org/schabi/newpipe/settings/ContentSettingsFragment.java index 1ae3cb92d..475c8cc2e 100644 --- a/app/src/main/java/org/schabi/newpipe/settings/ContentSettingsFragment.java +++ b/app/src/main/java/org/schabi/newpipe/settings/ContentSettingsFragment.java @@ -171,16 +171,16 @@ public class ContentSettingsFragment extends BasePreferenceFragment { return true; }); - final Preference sponsorBlockClearExclusionListPreference = - findPreference(getString(R.string.sponsor_block_clear_exclusion_list_key)); - sponsorBlockClearExclusionListPreference.setOnPreferenceClickListener((Preference p) -> { + final Preference sponsorBlockClearWhitelistPreference = + findPreference(getString(R.string.sponsor_block_clear_whitelist_key)); + sponsorBlockClearWhitelistPreference.setOnPreferenceClickListener((Preference p) -> { getPreferenceManager() .getSharedPreferences() .edit() .putStringSet( - getString(R.string.sponsor_block_exclusion_list_key), new HashSet<>()) + getString(R.string.sponsor_block_whitelist_key), new HashSet<>()) .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(); return true; }); @@ -406,6 +406,9 @@ public class ContentSettingsFragment extends BasePreferenceFragment { findPreference(getString(R.string.sponsor_block_categories_key)) .onDependencyChanged(preference, newValue == null || newValue.equals("")); + findPreference(getString(R.string.sponsor_block_clear_whitelist_key)) + .onDependencyChanged(preference, + newValue == null || newValue.equals("")); } } diff --git a/app/src/main/java/org/schabi/newpipe/util/SponsorBlockMode.java b/app/src/main/java/org/schabi/newpipe/util/SponsorBlockMode.java index e9a75453c..b6f965816 100644 --- a/app/src/main/java/org/schabi/newpipe/util/SponsorBlockMode.java +++ b/app/src/main/java/org/schabi/newpipe/util/SponsorBlockMode.java @@ -3,5 +3,5 @@ package org.schabi.newpipe.util; public enum SponsorBlockMode { DISABLED, ENABLED, - EXCLUDE + IGNORE } diff --git a/app/src/main/res/values/settings_keys.xml b/app/src/main/res/values/settings_keys.xml index d77a18d2e..77b4864aa 100644 --- a/app/src/main/res/values/settings_keys.xml +++ b/app/src/main/res/values/settings_keys.xml @@ -258,8 +258,8 @@ sponsor_block_category_self_promo_color sponsor_block_category_music sponsor_block_category_music_color - sponsor_block_exclusion_list - sponsor_block_clear_exclusion_list + sponsor_block_whitelist + sponsor_block_clear_whitelist file_rename_charset diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 7d43117d6..ddff8be15 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -707,9 +707,11 @@ Skipped unpaid/self promo Skipped non-music Toggle skipping sponsors - Clear Exclusion List - Clear the list of uploaders excluded from SponsorBlock. + Clear Whitelist + Clear the list of uploaders SponsorBlock will ignore. SponsorBlock enabled SponsorBlock disabled - Exclusion list cleared + Whitelist cleared + Uploader added to whitelist + Uploader removed from whitelist diff --git a/app/src/main/res/xml/content_settings.xml b/app/src/main/res/xml/content_settings.xml index 453564be4..e233eb7ba 100644 --- a/app/src/main/res/xml/content_settings.xml +++ b/app/src/main/res/xml/content_settings.xml @@ -166,9 +166,9 @@ + android:key="@string/sponsor_block_clear_whitelist_key" + android:summary="@string/sponsor_block_clear_whitelist_summary" + android:title="@string/sponsor_block_clear_whitelist_title"/>