2023-09-20 05:33:02 +02:00
|
|
|
package app.revanced.patches.youtube.layout.buttons.player.hide
|
2023-02-03 04:39:40 +01:00
|
|
|
|
2023-08-27 21:40:49 +02:00
|
|
|
import app.revanced.extensions.exception
|
2023-02-03 04:39:40 +01:00
|
|
|
import app.revanced.patcher.data.BytecodeContext
|
2023-06-07 03:46:13 +02:00
|
|
|
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
|
|
|
|
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
|
2023-02-03 04:39:40 +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
|
2023-02-03 04:39:40 +01:00
|
|
|
import app.revanced.patches.shared.settings.preference.impl.StringResource
|
|
|
|
import app.revanced.patches.shared.settings.preference.impl.SwitchPreference
|
2023-09-20 05:33:02 +02:00
|
|
|
import app.revanced.patches.youtube.layout.buttons.player.hide.HidePlayerButtonsPatch.ParameterOffsets.HAS_NEXT
|
|
|
|
import app.revanced.patches.youtube.layout.buttons.player.hide.HidePlayerButtonsPatch.ParameterOffsets.HAS_PREVIOUS
|
2023-02-19 23:54:29 +01:00
|
|
|
import app.revanced.patches.youtube.layout.buttons.player.hide.fingerprints.PlayerControlsVisibilityModelFingerprint
|
2023-09-20 05:33:02 +02:00
|
|
|
import app.revanced.patches.youtube.misc.integrations.IntegrationsPatch
|
|
|
|
import app.revanced.patches.youtube.misc.settings.SettingsPatch
|
2023-08-27 21:40:49 +02:00
|
|
|
import com.android.tools.smali.dexlib2.iface.instruction.formats.Instruction3rc
|
2023-02-03 04:39:40 +01:00
|
|
|
|
2023-09-20 05:33:02 +02:00
|
|
|
@Patch(
|
|
|
|
name = "Hide player buttons",
|
|
|
|
description = "Adds the option to hide video player previous and next buttons.",
|
|
|
|
dependencies = [
|
|
|
|
IntegrationsPatch::class,
|
|
|
|
SettingsPatch::class
|
|
|
|
],
|
|
|
|
compatiblePackages = [
|
|
|
|
CompatiblePackage(
|
|
|
|
"com.google.android.youtube",
|
|
|
|
[
|
|
|
|
"18.16.37",
|
|
|
|
"18.19.35",
|
|
|
|
"18.20.39",
|
|
|
|
"18.23.35",
|
|
|
|
"18.29.38",
|
2023-09-28 01:28:25 +02:00
|
|
|
"18.32.39",
|
|
|
|
"18.37.36"
|
2023-09-20 05:33:02 +02:00
|
|
|
]
|
|
|
|
)
|
|
|
|
]
|
|
|
|
)
|
|
|
|
@Suppress("unused")
|
|
|
|
object HidePlayerButtonsPatch : BytecodePatch(
|
|
|
|
setOf(PlayerControlsVisibilityModelFingerprint)
|
2023-02-03 04:39:40 +01:00
|
|
|
) {
|
2023-08-27 21:40:49 +02:00
|
|
|
override fun execute(context: BytecodeContext) {
|
2023-02-03 04:39:40 +01:00
|
|
|
SettingsPatch.PreferenceScreen.LAYOUT.addPreferences(
|
|
|
|
SwitchPreference(
|
|
|
|
"revanced_hide_player_buttons",
|
|
|
|
StringResource(
|
|
|
|
"revanced_hide_player_buttons_title",
|
|
|
|
"Hide previous & next video buttons"
|
|
|
|
),
|
|
|
|
StringResource(
|
|
|
|
"revanced_hide_player_buttons_summary_on",
|
2023-02-22 06:06:53 +01:00
|
|
|
"Buttons are hidden"
|
2023-02-03 04:39:40 +01:00
|
|
|
),
|
|
|
|
StringResource(
|
|
|
|
"revanced_hide_player_buttons_summary_off",
|
2023-02-22 06:06:53 +01:00
|
|
|
"Buttons are shown"
|
2023-02-03 04:39:40 +01:00
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
PlayerControlsVisibilityModelFingerprint.result?.apply {
|
|
|
|
val callIndex = scanResult.patternScanResult!!.endIndex
|
2023-06-07 03:46:13 +02:00
|
|
|
val callInstruction = mutableMethod.getInstruction<Instruction3rc>(callIndex)
|
2023-02-03 04:39:40 +01:00
|
|
|
|
|
|
|
// overriding this parameter register hides the previous and next buttons
|
2023-09-20 05:33:02 +02:00
|
|
|
val hasNextParameterRegister = callInstruction.startRegister + HAS_NEXT
|
|
|
|
val hasPreviousParameterRegister = callInstruction.startRegister + HAS_PREVIOUS
|
2023-02-03 04:39:40 +01:00
|
|
|
|
|
|
|
mutableMethod.addInstructions(
|
|
|
|
callIndex,
|
|
|
|
"""
|
2023-05-25 19:34:38 +02:00
|
|
|
invoke-static { v$hasNextParameterRegister }, Lapp/revanced/integrations/patches/HidePlayerButtonsPatch;->previousOrNextButtonIsVisible(Z)Z
|
2023-02-03 04:39:40 +01:00
|
|
|
move-result v$hasNextParameterRegister
|
2023-05-25 19:34:38 +02:00
|
|
|
|
|
|
|
invoke-static { v$hasPreviousParameterRegister }, Lapp/revanced/integrations/patches/HidePlayerButtonsPatch;->previousOrNextButtonIsVisible(Z)Z
|
|
|
|
move-result v$hasPreviousParameterRegister
|
2023-02-03 04:39:40 +01:00
|
|
|
"""
|
|
|
|
)
|
2023-08-27 21:40:49 +02:00
|
|
|
} ?: throw PlayerControlsVisibilityModelFingerprint.exception
|
2023-02-03 04:39:40 +01:00
|
|
|
}
|
2023-09-20 05:33:02 +02:00
|
|
|
|
|
|
|
private object ParameterOffsets {
|
|
|
|
const val HAS_NEXT = 5
|
|
|
|
const val HAS_PREVIOUS = 6
|
|
|
|
}
|
2023-02-03 04:39:40 +01:00
|
|
|
}
|