diff --git a/src/main/kotlin/app/revanced/patches/youtube/swipe/swipebrightnessinhdr/bytecode/fingerprints/HDRVideoFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/swipe/swipebrightnessinhdr/bytecode/fingerprints/HDRVideoFingerprint.kt new file mode 100644 index 000000000..c58deadc9 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/youtube/swipe/swipebrightnessinhdr/bytecode/fingerprints/HDRVideoFingerprint.kt @@ -0,0 +1,8 @@ +package app.revanced.patches.youtube.swipe.swipebrightnessinhdr.bytecode.fingerprints + +import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint + +object HDRVideoFingerprint : MethodFingerprint( + returnType = "V", + strings = listOf("mediaViewambientBrightnessSensor") +) diff --git a/src/main/kotlin/app/revanced/patches/youtube/swipe/swipebrightnessinhdr/bytecode/patch/SwipeGestureBrightnessInHDRPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/swipe/swipebrightnessinhdr/bytecode/patch/SwipeGestureBrightnessInHDRPatch.kt new file mode 100644 index 000000000..b3dabbb7e --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/youtube/swipe/swipebrightnessinhdr/bytecode/patch/SwipeGestureBrightnessInHDRPatch.kt @@ -0,0 +1,40 @@ +package app.revanced.patches.youtube.swipe.swipebrightnessinhdr.bytecode.patch + +import app.revanced.patcher.annotation.Name +import app.revanced.patcher.annotation.Version +import app.revanced.patcher.data.BytecodeContext +import app.revanced.patcher.extensions.addInstructions +import app.revanced.patcher.extensions.instruction +import app.revanced.patcher.patch.BytecodePatch +import app.revanced.patcher.patch.PatchResult +import app.revanced.patcher.patch.PatchResultSuccess +import app.revanced.patcher.util.smali.ExternalLabel +import app.revanced.patches.youtube.swipe.swipebrightnessinhdr.bytecode.fingerprints.HDRVideoFingerprint +import app.revanced.shared.annotation.YouTubeCompatibility +import app.revanced.shared.extensions.toErrorResult +import app.revanced.shared.util.integrations.Constants.SWIPE_PATH + +@Name("enable-swipe-gesture-brightness-in-hdr-patch") +@YouTubeCompatibility +@Version("0.0.1") +class SwipeGestureBrightnessInHDRPatch : BytecodePatch( + listOf( + HDRVideoFingerprint + ) +) { + override fun execute(context: BytecodeContext): PatchResult { + + HDRVideoFingerprint.result?.mutableMethod?.let { + it.addInstructions( + 0, """ + invoke-static {}, $SWIPE_PATH/EnableSwipeGestureBrightnessInHDRPatch;->enableSwipeGestureBrightnessInHDR()Z + move-result v0 + if-eqz v0, :default + return-void + """, listOf(ExternalLabel("default", it.instruction(0))) + ) + } ?: return HDRVideoFingerprint.toErrorResult() + + return PatchResultSuccess() + } +} \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/shared/util/integrations/Constants.kt b/src/main/kotlin/app/revanced/shared/util/integrations/Constants.kt index f3f9dae89..3066f66ab 100644 --- a/src/main/kotlin/app/revanced/shared/util/integrations/Constants.kt +++ b/src/main/kotlin/app/revanced/shared/util/integrations/Constants.kt @@ -5,7 +5,8 @@ internal object Constants { const val PATCHES_PATH = "$INTEGRATIONS_PATH/patches" const val ADS_PATH = "$PATCHES_PATH/ads" - const val BUTTON_PATH = "$PATCHES_PATH/button" + + const val SWIPE_PATH = "$PATCHES_PATH/swipe" const val GENERAL_LAYOUT = "$PATCHES_PATH/layout/GeneralLayoutPatch;" const val PLAYER_LAYOUT = "$PATCHES_PATH/layout/PlayerLayoutPatch;" @@ -13,9 +14,12 @@ internal object Constants { const val FLYOUTPANEL_LAYOUT = "$PATCHES_PATH/layout/FlyoutPanelLayoutPatch;" const val SEEKBAR_LAYOUT = "$PATCHES_PATH/layout/SeekbarLayoutPatch;" - const val EXTENDED_PATH = "$PATCHES_PATH/extended" const val MISC_PATH = "$PATCHES_PATH/misc" + + const val BUTTON_PATH = "$PATCHES_PATH/button" const val VIDEO_PATH = "$PATCHES_PATH/video" + const val EXTENDED_PATH = "$PATCHES_PATH/extended" + const val UTILS_PATH = "$PATCHES_PATH/utils" const val MUSIC_SETTINGS_PATH = "$INTEGRATIONS_PATH/settings/MusicSettings;" diff --git a/src/main/resources/youtube/settings/host/values/strings.xml b/src/main/resources/youtube/settings/host/values/strings.xml index f1278396b..de90149c0 100644 --- a/src/main/resources/youtube/settings/host/values/strings.xml +++ b/src/main/resources/youtube/settings/host/values/strings.xml @@ -246,6 +246,9 @@ Is it ready to submit?" Brightness swipe is disabled Brightness swipe is enabled Enable brightness gesture + When playing HDR videos, brightness values specified by YouTube are applied + When playing HDR video, swipe gesture brightness values are applied + Enable swipe gesture brightness values in HDR video Press-to-swipe haptic feedback is disabled Press-to-swipe haptic feedback is enabled Enable press-to-swipe haptic feedback diff --git a/src/main/resources/youtube/settings/xml/revanced_prefs.xml b/src/main/resources/youtube/settings/xml/revanced_prefs.xml index 5781da79c..a4b9c6b5d 100644 --- a/src/main/resources/youtube/settings/xml/revanced_prefs.xml +++ b/src/main/resources/youtube/settings/xml/revanced_prefs.xml @@ -70,7 +70,9 @@ - SETTINGS: SWIPE_CONTROLS --> + + + SETTINGS: SWIPE_CONTROLS -->