2023-09-20 05:33:02 +02:00
|
|
|
package app.revanced.patches.youtube.misc.zoomhaptics
|
2022-11-20 14:24:41 +01:00
|
|
|
|
|
|
|
import app.revanced.patcher.data.BytecodeContext
|
2023-06-07 03:46:13 +02:00
|
|
|
import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels
|
|
|
|
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
|
2022-11-20 14:24:41 +01:00
|
|
|
import app.revanced.patcher.patch.BytecodePatch
|
2023-09-20 05:33:02 +02:00
|
|
|
import app.revanced.patcher.patch.annotation.CompatiblePackage
|
|
|
|
import app.revanced.patcher.patch.annotation.Patch
|
2022-11-20 14:24:41 +01:00
|
|
|
import app.revanced.patcher.util.smali.ExternalLabel
|
2024-01-27 02:34:01 +01:00
|
|
|
import app.revanced.patches.all.misc.resources.AddResourcesPatch
|
|
|
|
import app.revanced.patches.shared.misc.settings.preference.SwitchPreference
|
2023-09-20 05:33:02 +02:00
|
|
|
import app.revanced.patches.youtube.misc.settings.SettingsPatch
|
2022-11-20 14:24:41 +01:00
|
|
|
import app.revanced.patches.youtube.misc.zoomhaptics.fingerprints.ZoomHapticsFingerprint
|
|
|
|
|
2023-09-20 05:33:02 +02:00
|
|
|
@Patch(
|
|
|
|
name = "Disable zoom haptics",
|
2024-01-01 16:30:04 +01:00
|
|
|
description = "Adds an option to disable haptics when zooming.",
|
2024-01-27 02:34:01 +01:00
|
|
|
dependencies = [SettingsPatch::class, AddResourcesPatch::class],
|
2023-09-20 05:33:02 +02:00
|
|
|
compatiblePackages = [CompatiblePackage("com.google.android.youtube")]
|
|
|
|
)
|
|
|
|
@Suppress("unused")
|
|
|
|
object ZoomHapticsPatch : BytecodePatch(
|
|
|
|
setOf(ZoomHapticsFingerprint)
|
2022-11-20 14:24:41 +01:00
|
|
|
) {
|
2023-08-27 21:40:49 +02:00
|
|
|
override fun execute(context: BytecodeContext) {
|
2024-01-27 02:34:01 +01:00
|
|
|
AddResourcesPatch(this::class)
|
|
|
|
|
2024-03-02 08:27:05 +01:00
|
|
|
SettingsPatch.PreferenceScreen.MISC.addPreferences(
|
|
|
|
SwitchPreference("revanced_disable_zoom_haptics")
|
|
|
|
)
|
2022-11-20 14:24:41 +01:00
|
|
|
|
|
|
|
val zoomHapticsFingerprintMethod = ZoomHapticsFingerprint.result!!.mutableMethod
|
|
|
|
|
2023-06-07 03:46:13 +02:00
|
|
|
zoomHapticsFingerprintMethod.addInstructionsWithLabels(
|
|
|
|
0,
|
|
|
|
"""
|
2024-01-01 16:33:07 +01:00
|
|
|
invoke-static { }, Lapp/revanced/integrations/youtube/patches/ZoomHapticsPatch;->shouldVibrate()Z
|
2022-11-20 14:24:41 +01:00
|
|
|
move-result v0
|
|
|
|
if-nez v0, :vibrate
|
|
|
|
return-void
|
2023-06-07 03:46:13 +02:00
|
|
|
""",
|
|
|
|
ExternalLabel("vibrate", zoomHapticsFingerprintMethod.getInstruction(0))
|
2022-11-20 14:24:41 +01:00
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|