mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-05-29 13:20:19 +02:00
feat(youtube/custom-speed-overlay): change patch name hide-speed-overlay
→ custom-speed-overlay
This commit is contained in:
parent
4bcecb2a92
commit
0cf798a1aa
@ -0,0 +1,16 @@
|
||||
package app.revanced.patches.youtube.player.speedoverlay.fingerprints
|
||||
|
||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||
import com.android.tools.smali.dexlib2.Opcode
|
||||
|
||||
object SpeedOverlayHookFingerprint : MethodFingerprint(
|
||||
returnType = "V",
|
||||
opcodes = listOf(
|
||||
Opcode.CMPL_FLOAT,
|
||||
Opcode.IF_GEZ,
|
||||
Opcode.IGET_OBJECT,
|
||||
Opcode.INVOKE_VIRTUAL
|
||||
),
|
||||
strings = listOf("Failed to easy seek haptics vibrate."),
|
||||
customFingerprint = { methodDef, _ -> methodDef.name == "run" }
|
||||
)
|
@ -0,0 +1,13 @@
|
||||
package app.revanced.patches.youtube.player.speedoverlay.fingerprints
|
||||
|
||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||
import com.android.tools.smali.dexlib2.Opcode
|
||||
|
||||
object YouTubeTextViewFingerprint : MethodFingerprint(
|
||||
returnType = "V",
|
||||
opcodes = listOf(Opcode.INVOKE_SUPER),
|
||||
customFingerprint = { methodDef, _ ->
|
||||
methodDef.definingClass.endsWith("/YouTubeTextView;")
|
||||
&& methodDef.name == "setText"
|
||||
}
|
||||
)
|
@ -1,55 +0,0 @@
|
||||
package app.revanced.patches.youtube.player.speedoverlay.patch
|
||||
|
||||
import app.revanced.extensions.exception
|
||||
import app.revanced.patcher.annotation.Description
|
||||
import app.revanced.patcher.annotation.Name
|
||||
import app.revanced.patcher.data.BytecodeContext
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
|
||||
import app.revanced.patcher.patch.BytecodePatch
|
||||
import app.revanced.patcher.patch.annotations.DependsOn
|
||||
import app.revanced.patcher.patch.annotations.Patch
|
||||
import app.revanced.patches.youtube.player.speedoverlay.fingerprints.SpeedOverlayConfigFingerprint
|
||||
import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility
|
||||
import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch
|
||||
import app.revanced.util.integrations.Constants.PLAYER
|
||||
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
|
||||
|
||||
@Patch
|
||||
@Name("Hide speed overlay")
|
||||
@Description("Hide speed overlay in player.")
|
||||
@DependsOn([SettingsPatch::class])
|
||||
@YouTubeCompatibility
|
||||
class HideSpeedOverlayPatch : BytecodePatch(
|
||||
listOf(SpeedOverlayConfigFingerprint)
|
||||
) {
|
||||
override fun execute(context: BytecodeContext) {
|
||||
|
||||
SpeedOverlayConfigFingerprint.result?.let {
|
||||
it.mutableMethod.apply {
|
||||
val insertIndex = implementation!!.instructions.size - 1
|
||||
val targetRegister = getInstruction<OneRegisterInstruction>(insertIndex).registerA
|
||||
|
||||
addInstructions(
|
||||
insertIndex, """
|
||||
invoke-static {v$targetRegister}, $PLAYER->hideSpeedOverlay(Z)Z
|
||||
move-result v$targetRegister
|
||||
"""
|
||||
)
|
||||
}
|
||||
} ?: throw SpeedOverlayConfigFingerprint.exception
|
||||
|
||||
/**
|
||||
* Add settings
|
||||
*/
|
||||
SettingsPatch.addPreference(
|
||||
arrayOf(
|
||||
"PREFERENCE: PLAYER_SETTINGS",
|
||||
"SETTINGS: HIDE_SPEED_OVERLAY"
|
||||
)
|
||||
)
|
||||
|
||||
SettingsPatch.updatePatchStatus("hide-speed-overlay")
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,111 @@
|
||||
package app.revanced.patches.youtube.player.speedoverlay.patch
|
||||
|
||||
import app.revanced.extensions.exception
|
||||
import app.revanced.patcher.annotation.Description
|
||||
import app.revanced.patcher.annotation.Name
|
||||
import app.revanced.patcher.data.BytecodeContext
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.removeInstruction
|
||||
import app.revanced.patcher.patch.BytecodePatch
|
||||
import app.revanced.patcher.patch.annotations.DependsOn
|
||||
import app.revanced.patcher.patch.annotations.Patch
|
||||
import app.revanced.patches.youtube.player.speedoverlay.fingerprints.SpeedOverlayConfigFingerprint
|
||||
import app.revanced.patches.youtube.player.speedoverlay.fingerprints.SpeedOverlayHookFingerprint
|
||||
import app.revanced.patches.youtube.player.speedoverlay.fingerprints.YouTubeTextViewFingerprint
|
||||
import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility
|
||||
import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch
|
||||
import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch.Companion.SpeedOverlayText
|
||||
import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch
|
||||
import app.revanced.util.integrations.Constants.UTILS_PATH
|
||||
import com.android.tools.smali.dexlib2.Opcode
|
||||
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
|
||||
import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction
|
||||
import com.android.tools.smali.dexlib2.iface.instruction.formats.Instruction35c
|
||||
|
||||
@Patch
|
||||
@Name("Custom speed overlay")
|
||||
@Description("Customize 'Play at 2x speed' while holding down.")
|
||||
@DependsOn(
|
||||
[
|
||||
SettingsPatch::class,
|
||||
SharedResourceIdPatch::class
|
||||
]
|
||||
)
|
||||
@YouTubeCompatibility
|
||||
class SpeedOverlayPatch : BytecodePatch(
|
||||
listOf(
|
||||
SpeedOverlayConfigFingerprint,
|
||||
SpeedOverlayHookFingerprint,
|
||||
YouTubeTextViewFingerprint
|
||||
)
|
||||
) {
|
||||
override fun execute(context: BytecodeContext) {
|
||||
|
||||
SpeedOverlayConfigFingerprint.result?.let {
|
||||
it.mutableMethod.apply {
|
||||
val insertIndex = implementation!!.instructions.size - 1
|
||||
val targetRegister = getInstruction<OneRegisterInstruction>(insertIndex).registerA
|
||||
|
||||
addInstructions(
|
||||
insertIndex, """
|
||||
invoke-static {v$targetRegister}, $INTEGRATIONS_CLASS_DESCRIPTOR->disableSpeedOverlay(Z)Z
|
||||
move-result v$targetRegister
|
||||
"""
|
||||
)
|
||||
}
|
||||
} ?: throw SpeedOverlayConfigFingerprint.exception
|
||||
|
||||
SpeedOverlayHookFingerprint.result?.let {
|
||||
it.mutableMethod.apply {
|
||||
val insertIndex = implementation!!.instructions.indexOfFirst { instruction ->
|
||||
instruction.opcode == Opcode.CMPL_FLOAT
|
||||
} + 3
|
||||
val insertRegister = getInstruction<Instruction35c>(insertIndex).registerD
|
||||
|
||||
addInstructions(
|
||||
insertIndex, """
|
||||
invoke-static {v$insertRegister}, $INTEGRATIONS_CLASS_DESCRIPTOR->getSpeed(F)F
|
||||
move-result v$insertRegister
|
||||
"""
|
||||
)
|
||||
}
|
||||
} ?: throw SpeedOverlayHookFingerprint.exception
|
||||
|
||||
YouTubeTextViewFingerprint.result?.let {
|
||||
it.mutableMethod.apply {
|
||||
val targetIndex = it.scanResult.patternScanResult!!.startIndex
|
||||
val targetInstruction = getInstruction<Instruction35c>(targetIndex)
|
||||
val targetReference = getInstruction<ReferenceInstruction>(targetIndex).reference
|
||||
|
||||
addInstructions(
|
||||
targetIndex + 1, """
|
||||
const v0, $SpeedOverlayText
|
||||
invoke-static {v${targetInstruction.registerC}, v${targetInstruction.registerD}, v0}, $INTEGRATIONS_CLASS_DESCRIPTOR->getSpeedText(Landroid/widget/TextView;Ljava/lang/CharSequence;I)Ljava/lang/CharSequence;
|
||||
move-result-object v${targetInstruction.registerD}
|
||||
invoke-super {v${targetInstruction.registerC}, v${targetInstruction.registerD}, v${targetInstruction.registerE}}, $targetReference
|
||||
"""
|
||||
)
|
||||
removeInstruction(targetIndex)
|
||||
}
|
||||
} ?: throw YouTubeTextViewFingerprint.exception
|
||||
|
||||
/**
|
||||
* Add settings
|
||||
*/
|
||||
SettingsPatch.addPreference(
|
||||
arrayOf(
|
||||
"PREFERENCE: PLAYER_SETTINGS",
|
||||
"SETTINGS: CUSTOM_SPEED_OVERLAY"
|
||||
)
|
||||
)
|
||||
|
||||
SettingsPatch.updatePatchStatus("custom-speed-overlay")
|
||||
|
||||
}
|
||||
|
||||
private companion object {
|
||||
const val INTEGRATIONS_CLASS_DESCRIPTOR =
|
||||
"$UTILS_PATH/SpeedOverlayPatch;"
|
||||
}
|
||||
}
|
@ -73,6 +73,7 @@ class SharedResourceIdPatch : ResourcePatch {
|
||||
var ScrimOverlay: Long = -1
|
||||
var Scrubbing: Long = -1
|
||||
var SettingsBooleanTimeRangeDialog: Long = -1
|
||||
var SpeedOverlayText: Long = -1
|
||||
var SubtitleMenuSettingsFooterInfo: Long = -1
|
||||
var SuggestedAction: Long = -1
|
||||
var ToolBarPaddingHome: Long = -1
|
||||
@ -154,6 +155,7 @@ class SharedResourceIdPatch : ResourcePatch {
|
||||
ScrimOverlay = find(ID, "scrim_overlay")
|
||||
Scrubbing = find(DIMEN, "vertical_touch_offset_to_enter_fine_scrubbing")
|
||||
SettingsBooleanTimeRangeDialog = find(LAYOUT, "setting_boolean_time_range_dialog")
|
||||
SpeedOverlayText = find(ID, "speedmaster_edu_text")
|
||||
SubtitleMenuSettingsFooterInfo = find(STRING, "subtitle_menu_settings_footer_info")
|
||||
SuggestedAction = find(LAYOUT, "suggested_action")
|
||||
ToolBarPaddingHome = find(DIMEN, "toolbar_padding_home_action_up")
|
||||
|
@ -81,6 +81,8 @@
|
||||
<string name="revanced_disable_landscape_mode_summary_off">Landscape mode when entering fullscreen is enabled</string>
|
||||
<string name="revanced_disable_landscape_mode_summary_on">Landscape mode when entering fullscreen is disabled</string>
|
||||
<string name="revanced_disable_landscape_mode_title">Disable landscape mode</string>
|
||||
<string name="revanced_disable_speed_overlay_summary">"Disable 'Playing at 2x speed' while holding down"</string>
|
||||
<string name="revanced_disable_speed_overlay_title">Disable speed overlay</string>
|
||||
<string name="revanced_disable_quic_protocol_summary">"Disable CronetEngine's QUIC protocol"</string>
|
||||
<string name="revanced_disable_quic_protocol_title">Disable QUIC protocol</string>
|
||||
<string name="revanced_disable_startup_shorts_player_summary_off">Shorts player is enabled at app startup</string>
|
||||
@ -97,6 +99,9 @@
|
||||
<string name="revanced_enable_custom_seekbar_color_summary_off">Custom seekbar color is disabled</string>
|
||||
<string name="revanced_enable_custom_seekbar_color_summary_on">Custom seekbar color is enabled</string>
|
||||
<string name="revanced_enable_custom_seekbar_color_title">Enable custom seekbar color</string>
|
||||
<string name="revanced_edit_speed_overlay_value_summary">"Edit speed that changes while holding down
|
||||
Only available to some users who can use the speed overlay"</string>
|
||||
<string name="revanced_edit_speed_overlay_value_title">Edit custom speed overlay</string>
|
||||
<string name="revanced_enable_debug_logging_summary_off">Debug logs are disabled</string>
|
||||
<string name="revanced_enable_debug_logging_summary_on">Debug logs are enabled</string>
|
||||
<string name="revanced_enable_debug_logging_title">Enable debug logging</string>
|
||||
@ -503,9 +508,6 @@
|
||||
<string name="revanced_hide_snack_bar_summary_off">Snack bar is shown</string>
|
||||
<string name="revanced_hide_snack_bar_summary_on">Snack bar is hidden</string>
|
||||
<string name="revanced_hide_snack_bar_title">Hide snack bar</string>
|
||||
<string name="revanced_hide_speed_overlay_summary_off">Speed overlay are shown</string>
|
||||
<string name="revanced_hide_speed_overlay_summary_on">Speed overlay are hidden</string>
|
||||
<string name="revanced_hide_speed_overlay_title">Hide speed overlay</string>
|
||||
<string name="revanced_hide_subscriptions_button_summary_off">Subscriptions button is shown</string>
|
||||
<string name="revanced_hide_subscriptions_button_summary_on">Subscriptions button is hidden</string>
|
||||
<string name="revanced_hide_subscriptions_button_title">Hide subscriptions button</string>
|
||||
@ -628,6 +630,7 @@ Since these setting is quite outdated, it may not be valid"</string>
|
||||
<string name="revanced_shorts_player_title">Shorts player</string>
|
||||
<string name="revanced_show_fullscreen_title_summary">Known issue: Title disappears when clicked</string>
|
||||
<string name="revanced_show_fullscreen_title_title">Show fullscreen title</string>
|
||||
<string name="revanced_speed_overlay_text" formatted="false">Playing at %sx speed</string>
|
||||
<string name="revanced_spoof_app_version_summary">"Spoofing the client version to the old version
|
||||
|
||||
This will change the appearance of the app, but unknown side effects may occur
|
||||
|
@ -317,6 +317,7 @@
|
||||
<Preference android:title="hide-player-flyout-panel" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>
|
||||
|
||||
<Preference android:title=" " android:selectable="false" android:summary="@string/revanced_fullscreen" />
|
||||
<Preference android:title="custom-speed-overlay" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>
|
||||
<Preference android:title="disable-haptic-feedback" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>
|
||||
<Preference android:title="disable-landscape-mode" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>
|
||||
<Preference android:title="hide-autoplay-preview" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>
|
||||
@ -325,7 +326,6 @@
|
||||
<Preference android:title="hide-fullscreen-panels" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>
|
||||
<Preference android:title="hide-quick-actions" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>
|
||||
<Preference android:title="hide-seek-message" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>
|
||||
<Preference android:title="hide-speed-overlay" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>
|
||||
<Preference android:title="hide-suggested-video-overlay" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>
|
||||
|
||||
<Preference android:title=" " android:selectable="false" android:summary="@string/revanced_general" />
|
||||
@ -470,6 +470,10 @@
|
||||
<PreferenceScreen android:title="@string/revanced_player" android:key="player">
|
||||
<Preference android:title=" " android:selectable="false" android:summary="@string/revanced_player" />PREFERENCE: PLAYER_SETTINGS -->
|
||||
|
||||
<!-- SETTINGS: CUSTOM_SPEED_OVERLAY
|
||||
<SwitchPreference android:title="@string/revanced_disable_speed_overlay_title" android:key="revanced_disable_speed_overlay" android:defaultValue="false" android:summary="@string/revanced_disable_speed_overlay_summary" />
|
||||
<app.revanced.integrations.settingsmenu.ResettableEditTextPreference android:hint="2.0" android:title="@string/revanced_edit_speed_overlay_value_title" android:key="revanced_edit_speed_overlay_value" android:summary="@string/revanced_edit_speed_overlay_value_summary" android:inputType="text" />SETTINGS: CUSTOM_SPEED_OVERLAY -->
|
||||
|
||||
<!-- SETTINGS: HIDE_AUDIO_TRACK_BUTTON
|
||||
<SwitchPreference android:title="@string/revanced_hide_audio_track_button_title" android:key="revanced_hide_audio_track_button" android:defaultValue="true" android:summaryOn="@string/revanced_hide_audio_track_button_summary_on" android:summaryOff="@string/revanced_hide_audio_track_button_summary_off" />SETTINGS: HIDE_AUDIO_TRACK_BUTTON -->
|
||||
|
||||
@ -506,9 +510,6 @@
|
||||
<!-- SETTINGS: HIDE_SEEK_MESSAGE
|
||||
<SwitchPreference android:title="@string/revanced_hide_seek_message_title" android:key="revanced_hide_seek_message" android:defaultValue="false" android:summaryOn="@string/revanced_hide_seek_message_summary_on" android:summaryOff="@string/revanced_hide_seek_message_summary_off" />SETTINGS: HIDE_SEEK_MESSAGE -->
|
||||
|
||||
<!-- SETTINGS: HIDE_SPEED_OVERLAY
|
||||
<SwitchPreference android:title="@string/revanced_hide_speed_overlay_title" android:key="revanced_hide_speed_overlay" android:defaultValue="false" android:summaryOn="@string/revanced_hide_speed_overlay_summary_on" android:summaryOff="@string/revanced_hide_speed_overlay_summary_off" />SETTINGS: HIDE_SPEED_OVERLAY -->
|
||||
|
||||
<!-- SETTINGS: HIDE_SUGGESTED_ACTION
|
||||
<SwitchPreference android:title="@string/revanced_hide_suggested_actions_title" android:key="revanced_hide_suggested_actions" android:defaultValue="true" android:summaryOn="@string/revanced_hide_suggested_actions_summary_on" android:summaryOff="@string/revanced_hide_suggested_actions_summary_off" />SETTINGS: HIDE_SUGGESTED_ACTION -->
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user