mirror of
https://github.com/revanced/revanced-patches.git
synced 2025-04-29 22:24:27 +02:00
fix(YouTube - Disable auto captions): Correctly hide captions with YT 20.12
This commit is contained in:
parent
409f98cf65
commit
5ecbe823ed
@ -1,20 +1,23 @@
|
|||||||
package app.revanced.extension.youtube.patches;
|
package app.revanced.extension.youtube.patches;
|
||||||
|
|
||||||
import app.revanced.extension.youtube.settings.Settings;
|
import app.revanced.extension.youtube.settings.Settings;
|
||||||
import app.revanced.extension.youtube.shared.ShortsPlayerState;
|
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
public class DisableAutoCaptionsPatch {
|
public class DisableAutoCaptionsPatch {
|
||||||
|
|
||||||
|
private static volatile boolean captionsButtonStatus;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used by injected code. Do not delete.
|
* Injection point.
|
||||||
*/
|
*/
|
||||||
public static boolean captionsButtonDisabled;
|
public static boolean disableAutoCaptions() {
|
||||||
|
return Settings.DISABLE_AUTO_CAPTIONS.get() && !captionsButtonStatus;
|
||||||
public static boolean autoCaptionsEnabled() {
|
|
||||||
return Settings.AUTO_CAPTIONS.get()
|
|
||||||
// Do not use auto captions for Shorts.
|
|
||||||
&& ShortsPlayerState.isOpen();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Injection point.
|
||||||
|
*/
|
||||||
|
public static void setCaptionsButtonStatus(boolean status) {
|
||||||
|
captionsButtonStatus = status;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -124,6 +124,7 @@ public class Settings extends BaseSettings {
|
|||||||
// Player
|
// Player
|
||||||
public static final BooleanSetting COPY_VIDEO_URL = new BooleanSetting("revanced_copy_video_url", FALSE);
|
public static final BooleanSetting COPY_VIDEO_URL = new BooleanSetting("revanced_copy_video_url", FALSE);
|
||||||
public static final BooleanSetting COPY_VIDEO_URL_TIMESTAMP = new BooleanSetting("revanced_copy_video_url_timestamp", TRUE);
|
public static final BooleanSetting COPY_VIDEO_URL_TIMESTAMP = new BooleanSetting("revanced_copy_video_url_timestamp", TRUE);
|
||||||
|
public static final BooleanSetting DISABLE_AUTO_CAPTIONS = new BooleanSetting("revanced_disable_auto_captions", FALSE, true);
|
||||||
public static final BooleanSetting DISABLE_FULLSCREEN_AMBIENT_MODE = new BooleanSetting("revanced_disable_fullscreen_ambient_mode", TRUE, true);
|
public static final BooleanSetting DISABLE_FULLSCREEN_AMBIENT_MODE = new BooleanSetting("revanced_disable_fullscreen_ambient_mode", TRUE, true);
|
||||||
public static final BooleanSetting DISABLE_ROLLING_NUMBER_ANIMATIONS = new BooleanSetting("revanced_disable_rolling_number_animations", FALSE);
|
public static final BooleanSetting DISABLE_ROLLING_NUMBER_ANIMATIONS = new BooleanSetting("revanced_disable_rolling_number_animations", FALSE);
|
||||||
public static final EnumSetting<FullscreenMode> EXIT_FULLSCREEN = new EnumSetting<>("revanced_exit_fullscreen", FullscreenMode.DISABLED);
|
public static final EnumSetting<FullscreenMode> EXIT_FULLSCREEN = new EnumSetting<>("revanced_exit_fullscreen", FullscreenMode.DISABLED);
|
||||||
@ -294,7 +295,6 @@ public class Settings extends BaseSettings {
|
|||||||
// Misc
|
// Misc
|
||||||
public static final BooleanSetting ANNOUNCEMENTS = new BooleanSetting("revanced_announcements", TRUE);
|
public static final BooleanSetting ANNOUNCEMENTS = new BooleanSetting("revanced_announcements", TRUE);
|
||||||
public static final IntegerSetting ANNOUNCEMENT_LAST_ID = new IntegerSetting("revanced_announcement_last_id", -1, false, false);
|
public static final IntegerSetting ANNOUNCEMENT_LAST_ID = new IntegerSetting("revanced_announcement_last_id", -1, false, false);
|
||||||
public static final BooleanSetting AUTO_CAPTIONS = new BooleanSetting("revanced_auto_captions", FALSE);
|
|
||||||
public static final BooleanSetting AUTO_REPEAT = new BooleanSetting("revanced_auto_repeat", FALSE);
|
public static final BooleanSetting AUTO_REPEAT = new BooleanSetting("revanced_auto_repeat", FALSE);
|
||||||
public static final BooleanSetting BYPASS_URL_REDIRECTS = new BooleanSetting("revanced_bypass_url_redirects", TRUE);
|
public static final BooleanSetting BYPASS_URL_REDIRECTS = new BooleanSetting("revanced_bypass_url_redirects", TRUE);
|
||||||
public static final BooleanSetting CHECK_WATCH_HISTORY_DOMAIN_NAME = new BooleanSetting("revanced_check_watch_history_domain_name", TRUE, false, false);
|
public static final BooleanSetting CHECK_WATCH_HISTORY_DOMAIN_NAME = new BooleanSetting("revanced_check_watch_history_domain_name", TRUE, false, false);
|
||||||
@ -403,6 +403,7 @@ public class Settings extends BaseSettings {
|
|||||||
private static final StringSetting DEPRECATED_SEEKBAR_CUSTOM_COLOR_PRIMARY = new StringSetting("revanced_seekbar_custom_color_value", "#FF0033");
|
private static final StringSetting DEPRECATED_SEEKBAR_CUSTOM_COLOR_PRIMARY = new StringSetting("revanced_seekbar_custom_color_value", "#FF0033");
|
||||||
private static final BooleanSetting DEPRECATED_DISABLE_SUGGESTED_VIDEO_END_SCREEN = new BooleanSetting("revanced_disable_suggested_video_end_screen", FALSE);
|
private static final BooleanSetting DEPRECATED_DISABLE_SUGGESTED_VIDEO_END_SCREEN = new BooleanSetting("revanced_disable_suggested_video_end_screen", FALSE);
|
||||||
private static final BooleanSetting DEPRECATED_RESTORE_OLD_VIDEO_QUALITY_MENU = new BooleanSetting("revanced_restore_old_video_quality_menu", TRUE);
|
private static final BooleanSetting DEPRECATED_RESTORE_OLD_VIDEO_QUALITY_MENU = new BooleanSetting("revanced_restore_old_video_quality_menu", TRUE);
|
||||||
|
private static final BooleanSetting DEPRECATED_AUTO_CAPTIONS = new BooleanSetting("revanced_auto_captions", FALSE);
|
||||||
|
|
||||||
static {
|
static {
|
||||||
// region Migration
|
// region Migration
|
||||||
@ -456,6 +457,11 @@ public class Settings extends BaseSettings {
|
|||||||
SPOOF_APP_VERSION_TARGET.resetToDefault();
|
SPOOF_APP_VERSION_TARGET.resetToDefault();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!DEPRECATED_AUTO_CAPTIONS.isSetToDefault()) {
|
||||||
|
DISABLE_AUTO_CAPTIONS.save(true);
|
||||||
|
DEPRECATED_AUTO_CAPTIONS.resetToDefault();
|
||||||
|
}
|
||||||
|
|
||||||
// endregion
|
// endregion
|
||||||
|
|
||||||
// region SB import/export callbacks
|
// region SB import/export callbacks
|
||||||
|
@ -8,7 +8,9 @@ import app.revanced.patches.shared.misc.settings.preference.SwitchPreference
|
|||||||
import app.revanced.patches.youtube.misc.extension.sharedExtensionPatch
|
import app.revanced.patches.youtube.misc.extension.sharedExtensionPatch
|
||||||
import app.revanced.patches.youtube.misc.settings.PreferenceScreen
|
import app.revanced.patches.youtube.misc.settings.PreferenceScreen
|
||||||
import app.revanced.patches.youtube.misc.settings.settingsPatch
|
import app.revanced.patches.youtube.misc.settings.settingsPatch
|
||||||
import app.revanced.patches.youtube.shared.subtitleButtonControllerFingerprint
|
|
||||||
|
private const val EXTENSION_CLASS_DESCRIPTOR =
|
||||||
|
"Lapp/revanced/extension/youtube/patches/DisableAutoCaptionsPatch;"
|
||||||
|
|
||||||
val autoCaptionsPatch = bytecodePatch(
|
val autoCaptionsPatch = bytecodePatch(
|
||||||
name = "Disable auto captions",
|
name = "Disable auto captions",
|
||||||
@ -36,35 +38,33 @@ val autoCaptionsPatch = bytecodePatch(
|
|||||||
addResources("youtube", "layout.autocaptions.autoCaptionsPatch")
|
addResources("youtube", "layout.autocaptions.autoCaptionsPatch")
|
||||||
|
|
||||||
PreferenceScreen.PLAYER.addPreferences(
|
PreferenceScreen.PLAYER.addPreferences(
|
||||||
SwitchPreference("revanced_auto_captions"),
|
SwitchPreference("revanced_disable_auto_captions"),
|
||||||
|
)
|
||||||
|
|
||||||
|
subtitleTrackFingerprint.method.addInstructions(
|
||||||
|
0,
|
||||||
|
"""
|
||||||
|
invoke-static {}, $EXTENSION_CLASS_DESCRIPTOR->disableAutoCaptions()Z
|
||||||
|
move-result v0
|
||||||
|
if-eqz v0, :auto_captions_enabled
|
||||||
|
const/4 v0, 0x1
|
||||||
|
return v0
|
||||||
|
:auto_captions_enabled
|
||||||
|
nop
|
||||||
|
"""
|
||||||
)
|
)
|
||||||
|
|
||||||
mapOf(
|
mapOf(
|
||||||
startVideoInformerFingerprint to 0,
|
startVideoInformerFingerprint to 0,
|
||||||
subtitleButtonControllerFingerprint to 1,
|
storyboardRendererDecoderRecommendedLevelFingerprint to 1
|
||||||
).forEach { (fingerprint, enabled) ->
|
).forEach { (fingerprint, enabled) ->
|
||||||
fingerprint.method.addInstructions(
|
fingerprint.method.addInstructions(
|
||||||
0,
|
0,
|
||||||
"""
|
"""
|
||||||
const/4 v0, 0x$enabled
|
const/4 v0, 0x$enabled
|
||||||
sput-boolean v0, Lapp/revanced/extension/youtube/patches/DisableAutoCaptionsPatch;->captionsButtonDisabled:Z
|
invoke-static { v0 }, $EXTENSION_CLASS_DESCRIPTOR->setCaptionsButtonStatus(Z)V
|
||||||
""",
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
subtitleTrackFingerprint.method.addInstructions(
|
|
||||||
0,
|
|
||||||
"""
|
"""
|
||||||
invoke-static {}, Lapp/revanced/extension/youtube/patches/DisableAutoCaptionsPatch;->autoCaptionsEnabled()Z
|
|
||||||
move-result v0
|
|
||||||
if-eqz v0, :auto_captions_enabled
|
|
||||||
sget-boolean v0, Lapp/revanced/extension/youtube/patches/DisableAutoCaptionsPatch;->captionsButtonDisabled:Z
|
|
||||||
if-nez v0, :auto_captions_enabled
|
|
||||||
const/4 v0, 0x1
|
|
||||||
return v0
|
|
||||||
:auto_captions_enabled
|
|
||||||
nop
|
|
||||||
""",
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
@ -14,6 +14,13 @@ internal val startVideoInformerFingerprint = fingerprint {
|
|||||||
strings("pc")
|
strings("pc")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal val storyboardRendererDecoderRecommendedLevelFingerprint = fingerprint {
|
||||||
|
returns("V")
|
||||||
|
accessFlags(AccessFlags.PUBLIC, AccessFlags.FINAL)
|
||||||
|
parameters("L")
|
||||||
|
strings("#-1#")
|
||||||
|
}
|
||||||
|
|
||||||
internal val subtitleTrackFingerprint = fingerprint {
|
internal val subtitleTrackFingerprint = fingerprint {
|
||||||
accessFlags(AccessFlags.PUBLIC, AccessFlags.FINAL)
|
accessFlags(AccessFlags.PUBLIC, AccessFlags.FINAL)
|
||||||
returns("Z")
|
returns("Z")
|
||||||
@ -28,6 +35,6 @@ internal val subtitleTrackFingerprint = fingerprint {
|
|||||||
)
|
)
|
||||||
strings("DISABLE_CAPTIONS_OPTION")
|
strings("DISABLE_CAPTIONS_OPTION")
|
||||||
custom { _, classDef ->
|
custom { _, classDef ->
|
||||||
classDef.endsWith("SubtitleTrack;")
|
classDef.endsWith("/SubtitleTrack;")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -540,9 +540,9 @@ Adjust volume by swiping vertically on the right side of the screen"</string>
|
|||||||
<string name="revanced_swipe_change_video_summary_off">Swiping in fullscreen mode will not change to the next/previous video</string>
|
<string name="revanced_swipe_change_video_summary_off">Swiping in fullscreen mode will not change to the next/previous video</string>
|
||||||
</patch>
|
</patch>
|
||||||
<patch id="layout.autocaptions.autoCaptionsPatch">
|
<patch id="layout.autocaptions.autoCaptionsPatch">
|
||||||
<string name="revanced_auto_captions_title">Disable auto captions</string>
|
<string name="revanced_disable_auto_captions_title">Disable auto captions</string>
|
||||||
<string name="revanced_auto_captions_summary_on">Auto captions are disabled</string>
|
<string name="revanced_disable_auto_captions_summary_on">Auto captions are disabled</string>
|
||||||
<string name="revanced_auto_captions_summary_off">Auto captions are enabled</string>
|
<string name="revanced_disable_auto_captions_summary_off">Auto captions are enabled</string>
|
||||||
</patch>
|
</patch>
|
||||||
<patch id="layout.buttons.action.hideButtonsPatch">
|
<patch id="layout.buttons.action.hideButtonsPatch">
|
||||||
<string name="revanced_hide_buttons_screen_title">Action buttons</string>
|
<string name="revanced_hide_buttons_screen_title">Action buttons</string>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user