SponsorBlock: "exclusion" to "whitelist"
Changed wording, and some other things I forgot do to earlier...
This commit is contained in:
parent
983078168c
commit
4f417b5b7c
7 changed files with 40 additions and 33 deletions
|
@ -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<String> channelExclusions = mPrefs.getStringSet(
|
||||
context.getString(R.string.sponsor_block_exclusion_list_key), null);
|
||||
final Set<String> 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
|
||||
|
|
|
@ -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<String> channelExclusions =
|
||||
final Set<String> 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:
|
||||
|
|
|
@ -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(""));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -3,5 +3,5 @@ package org.schabi.newpipe.util;
|
|||
public enum SponsorBlockMode {
|
||||
DISABLED,
|
||||
ENABLED,
|
||||
EXCLUDE
|
||||
IGNORE
|
||||
}
|
||||
|
|
|
@ -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_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_exclusion_list_key" translatable="false">sponsor_block_exclusion_list</string>
|
||||
<string name="sponsor_block_clear_exclusion_list_key" translatable="false">sponsor_block_clear_exclusion_list</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>
|
||||
|
||||
<!-- FileName Downloads -->
|
||||
<string name="settings_file_charset_key" translatable="false">file_rename_charset</string>
|
||||
|
|
|
@ -707,9 +707,11 @@
|
|||
<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_toggle_skipping">Toggle skipping sponsors</string>
|
||||
<string name="sponsor_block_clear_exclusion_list_title">Clear Exclusion List</string>
|
||||
<string name="sponsor_block_clear_exclusion_list_summary">Clear the list of uploaders excluded from SponsorBlock.</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>
|
||||
<string name="sponsor_block_enabled_toast">SponsorBlock enabled</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>
|
||||
|
|
|
@ -166,9 +166,9 @@
|
|||
|
||||
<Preference
|
||||
app:iconSpaceReserved="false"
|
||||
android:key="@string/sponsor_block_clear_exclusion_list_key"
|
||||
android:summary="@string/sponsor_block_clear_exclusion_list_summary"
|
||||
android:title="@string/sponsor_block_clear_exclusion_list_title"/>
|
||||
android:key="@string/sponsor_block_clear_whitelist_key"
|
||||
android:summary="@string/sponsor_block_clear_whitelist_summary"
|
||||
android:title="@string/sponsor_block_clear_whitelist_title"/>
|
||||
|
||||
</PreferenceCategory>
|
||||
</PreferenceScreen>
|
||||
|
|
Loading…
Reference in a new issue