feat(YouTube): add Enable bottom player gestures patch

This commit is contained in:
inotia00
2023-12-17 21:23:14 +09:00
parent 75d62ccaf9
commit d701a9acb6
5 changed files with 97 additions and 0 deletions

View File

@ -0,0 +1,79 @@
package app.revanced.patches.youtube.buttomplayer.gestures
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.annotation.CompatiblePackage
import app.revanced.patcher.patch.annotation.Patch
import app.revanced.patches.youtube.buttomplayer.gestures.fingerprints.BottomPlayerGesturesFingerprint
import app.revanced.patches.youtube.utils.integrations.Constants.BOTTOM_PLAYER
import app.revanced.patches.youtube.utils.settings.SettingsPatch
import app.revanced.util.exception
import app.revanced.util.getWideLiteralInstructionIndex
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
@Patch(
name = "Enable bottom player gestures",
description = "Switching to fullscreen by swiping the bottom area of the player.",
dependencies = [SettingsPatch::class],
compatiblePackages = [
CompatiblePackage(
"com.google.android.youtube",
[
"18.25.40",
"18.27.36",
"18.29.38",
"18.30.37",
"18.31.40",
"18.32.39",
"18.33.40",
"18.34.38",
"18.35.36",
"18.36.39",
"18.37.36",
"18.38.44",
"18.39.41",
"18.40.34",
"18.41.39",
"18.42.41",
"18.43.45",
"18.44.41",
"18.45.43"
]
)
]
)
@Suppress("unused")
object BottomPlayerGesturesPatch : BytecodePatch(
setOf(BottomPlayerGesturesFingerprint)
) {
override fun execute(context: BytecodeContext) {
BottomPlayerGesturesFingerprint.result?.let {
it.mutableMethod.apply {
val targetIndex = getWideLiteralInstructionIndex(45372793) + 3
val targetRegister = getInstruction<OneRegisterInstruction>(targetIndex).registerA
addInstructions(
targetIndex + 1, """
invoke-static {}, $BOTTOM_PLAYER->enableBottomPlayerGestures()Z
move-result v$targetRegister
"""
)
}
} ?: throw BottomPlayerGesturesFingerprint.exception
/**
* Add settings
*/
SettingsPatch.addPreference(
arrayOf(
"PREFERENCE: BOTTOM_PLAYER_SETTINGS",
"SETTINGS: ENABLE_BOTTOM_PLAYER_GESTURES"
)
)
SettingsPatch.updatePatchStatus("Enable bottom player gestures")
}
}

View File

@ -0,0 +1,8 @@
package app.revanced.patches.youtube.buttomplayer.gestures.fingerprints
import app.revanced.util.fingerprint.LiteralValueFingerprint
object BottomPlayerGesturesFingerprint : LiteralValueFingerprint(
returnType = "V",
literalSupplier = { 45372793 }
)

View File

@ -7,6 +7,7 @@ object Constants {
const val ADS_PATH = "$PATCHES_PATH/ads"
const val ALTERNATIVE_THUMBNAILS_PATH = "$PATCHES_PATH/alternativethumbnails"
const val BOTTOM_PLAYER_PATH = "$PATCHES_PATH/bottomplayer"
const val COMPONENTS_PATH = "$PATCHES_PATH/components"
const val FLYOUT_PANEL_PATH = "$PATCHES_PATH/flyoutpanel"
const val FULLSCREEN_PATH = "$PATCHES_PATH/fullscreen"
@ -22,6 +23,7 @@ object Constants {
const val VIDEO_PATH = "$PATCHES_PATH/video"
const val ALTERNATIVE_THUMBNAILS = "$ALTERNATIVE_THUMBNAILS_PATH/AlternativeThumbnailsPatch;"
const val BOTTOM_PLAYER = "$BOTTOM_PLAYER_PATH/BottomPlayerPatch;"
const val FLYOUT_PANEL = "$FLYOUT_PANEL_PATH/FlyoutPanelPatch;"
const val FULLSCREEN = "$FULLSCREEN_PATH/FullscreenPatch;"
const val GENERAL = "$GENERAL_PATH/GeneralPatch;"