mirror of
https://github.com/ReVanced/revanced-patches.git
synced 2024-11-10 01:01:56 +01:00
feat: hide-cast-button
patch
This commit is contained in:
parent
22bdd23cac
commit
2cd531eb5a
5 changed files with 64 additions and 16 deletions
|
@ -0,0 +1,13 @@
|
|||
package app.revanced.patches.youtube.layout.castbutton.annotations
|
||||
|
||||
import app.revanced.patcher.annotation.Compatibility
|
||||
import app.revanced.patcher.annotation.Package
|
||||
|
||||
@Compatibility(
|
||||
[Package(
|
||||
"com.google.android.youtube", arrayOf()
|
||||
)]
|
||||
)
|
||||
@Target(AnnotationTarget.CLASS)
|
||||
@Retention(AnnotationRetention.RUNTIME)
|
||||
internal annotation class CastButtonCompatibility
|
|
@ -0,0 +1,44 @@
|
|||
package app.revanced.patches.youtube.layout.castbutton.patch
|
||||
|
||||
import app.revanced.patcher.annotation.Description
|
||||
import app.revanced.patcher.annotation.Name
|
||||
import app.revanced.patcher.annotation.Version
|
||||
import app.revanced.patcher.data.implementation.BytecodeData
|
||||
import app.revanced.patcher.data.implementation.proxy
|
||||
import app.revanced.patcher.extensions.addInstructions
|
||||
import app.revanced.patcher.patch.annotations.Dependencies
|
||||
import app.revanced.patcher.patch.annotations.Patch
|
||||
import app.revanced.patcher.patch.implementation.BytecodePatch
|
||||
import app.revanced.patcher.patch.implementation.misc.PatchResult
|
||||
import app.revanced.patcher.patch.implementation.misc.PatchResultSuccess
|
||||
import app.revanced.patcher.util.smali.toInstructions
|
||||
import app.revanced.patches.youtube.layout.castbutton.annotations.CastButtonCompatibility
|
||||
import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch
|
||||
|
||||
@Patch
|
||||
@Dependencies(dependencies = [IntegrationsPatch::class])
|
||||
@Name("hide-cast-button")
|
||||
@Description("Patch to hide the cast button.")
|
||||
@CastButtonCompatibility
|
||||
@Version("0.0.1")
|
||||
class HideCastButtonPatch : BytecodePatch(listOf()) {
|
||||
override fun execute(data: BytecodeData): PatchResult {
|
||||
data.classes.forEach { classDef ->
|
||||
classDef.methods.forEach { method ->
|
||||
if (classDef.type.endsWith("MediaRouteButton;") && method.name == "setVisibility") {
|
||||
val implementation =
|
||||
data.proxy(classDef).resolve().methods.first { it.name == "setVisibility" }.implementation!!
|
||||
|
||||
implementation.addInstructions(
|
||||
0, """
|
||||
invoke-static {p1}, Lfi/razerman/youtube/XGlobals;->getCastButtonOverrideV2(I)I
|
||||
move-result p1
|
||||
""".trimIndent().toInstructions("I", 2, false)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return PatchResultSuccess()
|
||||
}
|
||||
}
|
|
@ -18,7 +18,7 @@ import org.jf.dexlib2.iface.instruction.formats.Instruction11x
|
|||
|
||||
@Patch
|
||||
@Dependencies(dependencies = [IntegrationsPatch::class])
|
||||
@Name("shorts-button")
|
||||
@Name("disable-shorts-button")
|
||||
@Description("Hide the shorts button.")
|
||||
@ShortsButtonCompatibility
|
||||
@Version("0.0.1")
|
||||
|
|
|
@ -15,6 +15,7 @@ import app.revanced.patcher.patch.implementation.misc.PatchResultSuccess
|
|||
import app.revanced.patcher.util.proxy.mutableTypes.MutableClass
|
||||
import app.revanced.patcher.util.smali.toInstruction
|
||||
import app.revanced.patcher.util.smali.toInstructions
|
||||
import app.revanced.patches.youtube.layout.castbutton.patch.HideCastButtonPatch
|
||||
import app.revanced.patches.youtube.misc.microg.annotations.MicroGPatchCompatibility
|
||||
import app.revanced.patches.youtube.misc.microg.patch.resource.MicroGResourcePatch
|
||||
import app.revanced.patches.youtube.misc.microg.patch.resource.enum.StringReplaceMode
|
||||
|
@ -24,13 +25,14 @@ import app.revanced.patches.youtube.misc.microg.signatures.*
|
|||
import org.jf.dexlib2.Opcode
|
||||
import org.jf.dexlib2.builder.MutableMethodImplementation
|
||||
import org.jf.dexlib2.builder.instruction.BuilderInstruction21c
|
||||
import org.jf.dexlib2.builder.instruction.BuilderInstruction21s
|
||||
import org.jf.dexlib2.iface.instruction.formats.Instruction21c
|
||||
import org.jf.dexlib2.iface.reference.StringReference
|
||||
import org.jf.dexlib2.immutable.reference.ImmutableStringReference
|
||||
|
||||
@Patch(include = false)
|
||||
@Dependencies(dependencies = [MicroGResourcePatch::class])
|
||||
@Dependencies(
|
||||
dependencies = [MicroGResourcePatch::class, HideCastButtonPatch::class]
|
||||
)
|
||||
@Name("microg-support")
|
||||
@Description("Patch to allow YouTube ReVanced to run without root and under a different package name.")
|
||||
@MicroGPatchCompatibility
|
||||
|
@ -56,17 +58,6 @@ class MicroGBytecodePatch : BytecodePatch(
|
|||
|
||||
var proxiedImplementation: MutableMethodImplementation? = null
|
||||
|
||||
// disable cast button since it is unsupported by microg and causes battery issues
|
||||
// the code is here instead of the fixCastIssues method because we do not need a signature this way
|
||||
if (classDef.type.endsWith("MediaRouteButton;") && method.name == "setVisibility") {
|
||||
proxiedClass = data.proxy(classDef).resolve()
|
||||
proxiedImplementation = proxiedClass!!.methods.first { it.name == "setVisibility" }.implementation
|
||||
|
||||
proxiedImplementation!!.replaceInstruction(
|
||||
0, BuilderInstruction21s(Opcode.CONST_16, 1, 8) // 8 == HIDDEN
|
||||
)
|
||||
}
|
||||
|
||||
implementation.instructions.forEachIndexed { i, instruction ->
|
||||
if (instruction.opcode != Opcode.CONST_STRING) return@forEachIndexed
|
||||
|
||||
|
|
|
@ -3,5 +3,5 @@ package app.revanced.patches.youtube.misc.microg.shared
|
|||
object Constants {
|
||||
internal const val BASE_MICROG_PACKAGE_NAME = "com.mgoogle"
|
||||
internal const val REVANCED_PACKAGE_NAME = "app.revanced.android.youtube"
|
||||
internal const val REVANCED_APP_NAME = "YouTube ReVanced"
|
||||
}
|
||||
internal const val REVANCED_APP_NAME = "ReVanced"
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue