Skip to content
This repository has been archived by the owner on Dec 8, 2024. It is now read-only.

Commit

Permalink
feat(YouTube/Player components): add Sanitize video subtitle setting
Browse files Browse the repository at this point in the history
  • Loading branch information
inotia00 committed Oct 20, 2024
1 parent 952be89 commit ee4f543
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package app.revanced.integrations.youtube.patches.spans;

import android.text.SpannableString;

import app.revanced.integrations.shared.patches.spans.Filter;
import app.revanced.integrations.shared.patches.spans.SpanType;
import app.revanced.integrations.shared.patches.spans.StringFilterGroup;
import app.revanced.integrations.youtube.settings.Settings;

@SuppressWarnings({"unused", "ConstantValue", "FieldCanBeLocal"})
public final class SanitizeVideoSubtitleFilter extends Filter {

public SanitizeVideoSubtitleFilter() {
addCallbacks(
new StringFilterGroup(
Settings.SANITIZE_VIDEO_SUBTITLE,
"|video_subtitle.eml|"
)
);
}

@Override
public boolean skip(String conversionContext, SpannableString spannableString, Object span,
int start, int end, int flags, boolean isWord, SpanType spanType, StringFilterGroup matchedGroup) {
if (isWord) {
if (spanType == SpanType.IMAGE) {
hideImageSpan(spannableString, start, end, flags);
return super.skip(conversionContext, spannableString, span, start, end, flags, isWord, spanType, matchedGroup);
} else if (spanType == SpanType.CUSTOM_CHARACTER_STYLE) {
hideSpan(spannableString, start, end, flags);
return super.skip(conversionContext, spannableString, span, start, end, flags, isWord, spanType, matchedGroup);
}
}
return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@ public class Settings extends BaseSettings {
public static final BooleanSetting HIDE_SUGGESTED_VIDEO_END_SCREEN = new BooleanSetting("revanced_hide_suggested_video_end_screen", TRUE, true);
public static final BooleanSetting SKIP_AUTOPLAY_COUNTDOWN = new BooleanSetting("revanced_skip_autoplay_countdown", FALSE, true, parent(HIDE_SUGGESTED_VIDEO_END_SCREEN));
public static final BooleanSetting HIDE_ZOOM_OVERLAY = new BooleanSetting("revanced_hide_zoom_overlay", FALSE, true);
public static final BooleanSetting SANITIZE_VIDEO_SUBTITLE = new BooleanSetting("revanced_sanitize_video_subtitle", FALSE);


// PreferenceScreen: Player - Action buttons
Expand Down

0 comments on commit ee4f543

Please sign in to comment.