feat(YouTube): Add Disable haptic feedback
patch (#5033)
This commit is contained in:
@ -0,0 +1,74 @@
|
||||
package app.revanced.patches.youtube.misc.hapticfeedback
|
||||
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
|
||||
import app.revanced.patcher.patch.bytecodePatch
|
||||
import app.revanced.patcher.util.smali.ExternalLabel
|
||||
import app.revanced.patches.all.misc.resources.addResources
|
||||
import app.revanced.patches.all.misc.resources.addResourcesPatch
|
||||
import app.revanced.patches.shared.misc.settings.preference.PreferenceScreenPreference
|
||||
import app.revanced.patches.shared.misc.settings.preference.SwitchPreference
|
||||
import app.revanced.patches.youtube.misc.settings.PreferenceScreen
|
||||
import app.revanced.patches.youtube.misc.settings.settingsPatch
|
||||
|
||||
private const val EXTENSION_CLASS_DESCRIPTOR =
|
||||
"Lapp/revanced/extension/youtube/patches/DisableHapticFeedbackPatch;"
|
||||
|
||||
@Suppress("unused")
|
||||
val disableHapticFeedbackPatch = bytecodePatch(
|
||||
name = "Disable haptic feedback",
|
||||
description = "Adds an option to disable haptic feedback in the player for various actions.",
|
||||
) {
|
||||
dependsOn(
|
||||
settingsPatch,
|
||||
addResourcesPatch,
|
||||
)
|
||||
|
||||
compatibleWith(
|
||||
"com.google.android.youtube"(
|
||||
"19.16.39",
|
||||
"19.25.37",
|
||||
"19.34.42",
|
||||
"19.43.41",
|
||||
"19.47.53",
|
||||
"20.07.39",
|
||||
"20.12.46",
|
||||
)
|
||||
)
|
||||
|
||||
execute {
|
||||
addResources("youtube", "misc.hapticfeedback.disableHapticFeedbackPatch")
|
||||
|
||||
PreferenceScreen.PLAYER.addPreferences(
|
||||
PreferenceScreenPreference(
|
||||
"revanced_disable_haptic_feedback",
|
||||
preferences = setOf(
|
||||
SwitchPreference("revanced_disable_haptic_feedback_chapters"),
|
||||
SwitchPreference("revanced_disable_haptic_feedback_precise_seeking"),
|
||||
SwitchPreference("revanced_disable_haptic_feedback_seek_undo"),
|
||||
SwitchPreference("revanced_disable_haptic_feedback_zoom"),
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
arrayOf(
|
||||
markerHapticsFingerprint to "disableChapterVibrate",
|
||||
scrubbingHapticsFingerprint to "disablePreciseSeekingVibrate",
|
||||
seekUndoHapticsFingerprint to "disableSeekUndoVibrate",
|
||||
zoomHapticsFingerprint to "disableZoomVibrate"
|
||||
).forEach { (fingerprint, methodName) ->
|
||||
fingerprint.method.apply {
|
||||
addInstructionsWithLabels(
|
||||
0,
|
||||
"""
|
||||
invoke-static {}, $EXTENSION_CLASS_DESCRIPTOR->$methodName()Z
|
||||
move-result v0
|
||||
if-eqz v0, :vibrate
|
||||
return-void
|
||||
""",
|
||||
ExternalLabel("vibrate", getInstruction(0))
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
package app.revanced.patches.youtube.misc.hapticfeedback
|
||||
|
||||
import app.revanced.patcher.fingerprint
|
||||
|
||||
internal val markerHapticsFingerprint = fingerprint {
|
||||
returns("V")
|
||||
strings("Failed to execute markers haptics vibrate.")
|
||||
}
|
||||
|
||||
internal val scrubbingHapticsFingerprint = fingerprint {
|
||||
returns("V")
|
||||
strings("Failed to haptics vibrate for fine scrubbing.")
|
||||
}
|
||||
|
||||
internal val seekUndoHapticsFingerprint = fingerprint {
|
||||
returns("V")
|
||||
strings("Failed to execute seek undo haptics vibrate.")
|
||||
}
|
||||
|
||||
internal val zoomHapticsFingerprint = fingerprint {
|
||||
returns("V")
|
||||
strings("Failed to haptics vibrate for video zoom")
|
||||
}
|
@ -1,7 +0,0 @@
|
||||
package app.revanced.patches.youtube.misc.zoomhaptics
|
||||
|
||||
import app.revanced.patcher.fingerprint
|
||||
|
||||
internal val zoomHapticsFingerprint = fingerprint {
|
||||
strings("Failed to haptics vibrate for video zoom")
|
||||
}
|
@ -1,54 +1,11 @@
|
||||
package app.revanced.patches.youtube.misc.zoomhaptics
|
||||
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
|
||||
import app.revanced.patcher.patch.bytecodePatch
|
||||
import app.revanced.patcher.util.smali.ExternalLabel
|
||||
import app.revanced.patches.all.misc.resources.addResources
|
||||
import app.revanced.patches.all.misc.resources.addResourcesPatch
|
||||
import app.revanced.patches.shared.misc.settings.preference.SwitchPreference
|
||||
import app.revanced.patches.youtube.misc.settings.PreferenceScreen
|
||||
import app.revanced.patches.youtube.misc.settings.settingsPatch
|
||||
import app.revanced.patches.youtube.misc.hapticfeedback.disableHapticFeedbackPatch
|
||||
|
||||
@Deprecated("Superseded by disableHapticFeedbackPatch", ReplaceWith("disableHapticFeedbackPatch"))
|
||||
val zoomHapticsPatch = bytecodePatch(
|
||||
name = "Disable zoom haptics",
|
||||
description = "Adds an option to disable haptics when zooming.",
|
||||
) {
|
||||
dependsOn(
|
||||
settingsPatch,
|
||||
addResourcesPatch,
|
||||
)
|
||||
|
||||
compatibleWith(
|
||||
"com.google.android.youtube"(
|
||||
"19.16.39",
|
||||
"19.25.37",
|
||||
"19.34.42",
|
||||
"19.43.41",
|
||||
"19.47.53",
|
||||
"20.07.39",
|
||||
"20.12.46",
|
||||
)
|
||||
)
|
||||
|
||||
execute {
|
||||
addResources("youtube", "misc.zoomhaptics.zoomHapticsPatch")
|
||||
|
||||
PreferenceScreen.MISC.addPreferences(
|
||||
SwitchPreference("revanced_disable_zoom_haptics"),
|
||||
)
|
||||
|
||||
zoomHapticsFingerprint.method.apply {
|
||||
addInstructionsWithLabels(
|
||||
0,
|
||||
"""
|
||||
invoke-static { }, Lapp/revanced/extension/youtube/patches/ZoomHapticsPatch;->shouldVibrate()Z
|
||||
move-result v0
|
||||
if-nez v0, :vibrate
|
||||
return-void
|
||||
""",
|
||||
ExternalLabel("vibrate", getInstruction(0)),
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
dependsOn(disableHapticFeedbackPatch)
|
||||
}
|
Reference in New Issue
Block a user