2023-09-20 05:33:02 +02:00
|
|
|
package app.revanced.patches.youtube.layout.buttons.cast
|
2022-06-15 13:22:09 +02:00
|
|
|
|
2022-10-05 04:03:10 +02:00
|
|
|
import app.revanced.patcher.data.BytecodeContext
|
2023-06-07 03:46:13 +02:00
|
|
|
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
|
2022-10-05 04:03:10 +02:00
|
|
|
import app.revanced.patcher.patch.BytecodePatch
|
2023-08-27 21:40:49 +02:00
|
|
|
import app.revanced.patcher.patch.PatchException
|
2023-09-20 05:33:02 +02:00
|
|
|
import app.revanced.patcher.patch.annotation.CompatiblePackage
|
|
|
|
import app.revanced.patcher.patch.annotation.Patch
|
2022-11-28 20:13:34 +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.misc.integrations.IntegrationsPatch
|
|
|
|
import app.revanced.patches.youtube.misc.settings.SettingsPatch
|
2022-06-15 13:22:09 +02:00
|
|
|
|
2023-09-20 05:33:02 +02:00
|
|
|
@Patch(
|
|
|
|
name = "Hide cast button",
|
2024-01-01 16:30:04 +01:00
|
|
|
description = "Adds an option to hide the cast button in the video player.",
|
2023-09-20 05:33:02 +02:00
|
|
|
dependencies = [
|
|
|
|
IntegrationsPatch::class,
|
|
|
|
SettingsPatch::class
|
|
|
|
],
|
|
|
|
compatiblePackages = [
|
|
|
|
CompatiblePackage("com.google.android.youtube")
|
|
|
|
]
|
|
|
|
)
|
|
|
|
object HideCastButtonPatch : BytecodePatch() {
|
2023-08-27 21:40:49 +02:00
|
|
|
override fun execute(context: BytecodeContext) {
|
2022-08-22 01:59:43 +02:00
|
|
|
SettingsPatch.PreferenceScreen.LAYOUT.addPreferences(
|
|
|
|
SwitchPreference(
|
2022-12-06 23:47:25 +01:00
|
|
|
"revanced_hide_cast_button",
|
|
|
|
StringResource("revanced_hide_cast_button_title", "Hide cast button"),
|
|
|
|
StringResource("revanced_hide_cast_button_summary_on", "Cast button is hidden"),
|
|
|
|
StringResource("revanced_hide_cast_button_summary_off", "Cast button is shown")
|
2022-08-22 01:59:43 +02:00
|
|
|
)
|
|
|
|
)
|
|
|
|
|
2023-06-07 03:46:13 +02:00
|
|
|
val buttonClass = context.findClass("MediaRouteButton")
|
2023-08-27 21:40:49 +02:00
|
|
|
?: throw PatchException("MediaRouteButton class not found.")
|
2023-06-07 03:46:13 +02:00
|
|
|
|
|
|
|
buttonClass.mutableClass.methods.find { it.name == "setVisibility" }?.apply {
|
|
|
|
addInstructions(
|
|
|
|
0,
|
|
|
|
"""
|
|
|
|
invoke-static {p1}, Lapp/revanced/integrations/patches/HideCastButtonPatch;->getCastButtonOverrideV2(I)I
|
|
|
|
move-result p1
|
|
|
|
"""
|
|
|
|
)
|
2023-08-27 21:40:49 +02:00
|
|
|
} ?: throw PatchException("setVisibility method not found.")
|
2022-06-15 13:22:09 +02:00
|
|
|
}
|
|
|
|
}
|