This repository has been archived by the owner on Dec 8, 2024. It is now read-only.
forked from ReVanced/revanced-integrations
-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(YouTube/Player components): add
Sanitize video subtitle
setting
- Loading branch information
Showing
2 changed files
with
37 additions
and
0 deletions.
There are no files selected for viewing
36 changes: 36 additions & 0 deletions
36
...ain/java/app/revanced/integrations/youtube/patches/spans/SanitizeVideoSubtitleFilter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters