mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-05-29 05:10:20 +02:00
feat(music): add hide-radio-button
patch
This commit is contained in:
parent
2eff3d2f0a
commit
3c306ebcca
@ -0,0 +1,34 @@
|
||||
package app.revanced.patches.music.buttoncontainer.radio.patch
|
||||
|
||||
import app.revanced.patcher.annotation.Description
|
||||
import app.revanced.patcher.annotation.Name
|
||||
import app.revanced.patcher.data.BytecodeContext
|
||||
import app.revanced.patcher.patch.BytecodePatch
|
||||
import app.revanced.patcher.patch.annotations.DependsOn
|
||||
import app.revanced.patcher.patch.annotations.Patch
|
||||
import app.revanced.patches.music.utils.annotations.MusicCompatibility
|
||||
import app.revanced.patches.music.utils.buttoncontainerhook.patch.ButtonContainerHookPatch
|
||||
import app.revanced.patches.music.utils.settings.resource.patch.SettingsPatch
|
||||
import app.revanced.util.enum.CategoryType
|
||||
|
||||
@Patch
|
||||
@Name("Hide radio button")
|
||||
@Description("Hides start radio button.")
|
||||
@DependsOn(
|
||||
[
|
||||
ButtonContainerHookPatch::class,
|
||||
SettingsPatch::class
|
||||
]
|
||||
)
|
||||
@MusicCompatibility
|
||||
class HideRadioButtonPatch : BytecodePatch() {
|
||||
override fun execute(context: BytecodeContext) {
|
||||
|
||||
SettingsPatch.addMusicPreference(
|
||||
CategoryType.BUTTON_CONTAINER,
|
||||
"revanced_hide_button_container_radio",
|
||||
"false"
|
||||
)
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
package app.revanced.patches.music.utils.buttoncontainerhook.fingerprints
|
||||
|
||||
import app.revanced.patcher.extensions.or
|
||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||
import com.android.tools.smali.dexlib2.AccessFlags
|
||||
import com.android.tools.smali.dexlib2.Opcode
|
||||
|
||||
object ButtonContainerHookFingerprint : MethodFingerprint(
|
||||
returnType = "V",
|
||||
accessFlags = AccessFlags.PRIVATE or AccessFlags.FINAL,
|
||||
parameters = listOf("L"),
|
||||
opcodes = listOf(
|
||||
Opcode.IGET_OBJECT,
|
||||
Opcode.INVOKE_VIRTUAL,
|
||||
Opcode.IGET_OBJECT,
|
||||
Opcode.INVOKE_INTERFACE,
|
||||
Opcode.MOVE_RESULT_OBJECT,
|
||||
Opcode.INVOKE_INTERFACE,
|
||||
Opcode.MOVE_RESULT,
|
||||
Opcode.IF_EQZ
|
||||
)
|
||||
)
|
@ -0,0 +1,43 @@
|
||||
package app.revanced.patches.music.utils.buttoncontainerhook.patch
|
||||
|
||||
import app.revanced.extensions.exception
|
||||
import app.revanced.patcher.data.BytecodeContext
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
|
||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve
|
||||
import app.revanced.patcher.patch.BytecodePatch
|
||||
import app.revanced.patcher.patch.annotations.DependsOn
|
||||
import app.revanced.patches.music.utils.buttoncontainerhook.fingerprints.ButtonContainerHookFingerprint
|
||||
import app.revanced.patches.music.utils.fingerprints.ActionsContainerParentFingerprint
|
||||
import app.revanced.patches.music.utils.resourceid.patch.SharedResourceIdPatch
|
||||
import app.revanced.util.integrations.Constants.MUSIC_BUTTON_CONTAINER
|
||||
import com.android.tools.smali.dexlib2.iface.instruction.TwoRegisterInstruction
|
||||
|
||||
@DependsOn([SharedResourceIdPatch::class])
|
||||
class ButtonContainerHookPatch : BytecodePatch(
|
||||
listOf(ActionsContainerParentFingerprint)
|
||||
) {
|
||||
override fun execute(context: BytecodeContext) {
|
||||
|
||||
ActionsContainerParentFingerprint.result?.let { parentResult ->
|
||||
ButtonContainerHookFingerprint.also {
|
||||
it.resolve(
|
||||
context,
|
||||
parentResult.classDef
|
||||
)
|
||||
}.result?.let {
|
||||
it.mutableMethod.apply {
|
||||
val targetIndex = it.scanResult.patternScanResult!!.startIndex
|
||||
val targetRegister =
|
||||
getInstruction<TwoRegisterInstruction>(targetIndex).registerA
|
||||
|
||||
addInstruction(
|
||||
targetIndex + 1,
|
||||
"invoke-static {v$targetRegister}, $MUSIC_BUTTON_CONTAINER->hookButtonContainer(Landroid/view/ViewGroup;)V"
|
||||
)
|
||||
}
|
||||
} ?: throw ButtonContainerHookFingerprint.exception
|
||||
} ?: throw ActionsContainerParentFingerprint.exception
|
||||
|
||||
}
|
||||
}
|
@ -47,6 +47,8 @@
|
||||
<string name="revanced_external_downloader_package_name_title">External downloader package name</string>
|
||||
<string name="revanced_hide_button_container_label_summary">Hide labels in button container.</string>
|
||||
<string name="revanced_hide_button_container_label_title">Hide button container labels</string>
|
||||
<string name="revanced_hide_button_container_radio_summary">Hides start radio button.</string>
|
||||
<string name="revanced_hide_button_container_radio_title">Hide radio button</string>
|
||||
<string name="revanced_hide_button_shelf_summary">Hides the button shelf from homepage and explorer.</string>
|
||||
<string name="revanced_hide_button_shelf_title">Hide button shelf</string>
|
||||
<string name="revanced_hide_carousel_shelf_summary">Hides the carousel shelf from homepage and explorer.</string>
|
||||
|
Loading…
x
Reference in New Issue
Block a user