forked from inotia00/revanced-patches
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(music): add
hide-button-container-labels
patch
- Loading branch information
Showing
5 changed files
with
103 additions
and
0 deletions.
There are no files selected for viewing
20 changes: 20 additions & 0 deletions
20
...anced/patches/music/buttoncontainer/label/fingerprints/ButtonContainerLabelFingerprint.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package app.revanced.patches.music.buttoncontainer.label.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 ButtonContainerLabelFingerprint : MethodFingerprint( | ||
returnType = "V", | ||
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL, | ||
parameters = listOf("L", "L"), | ||
opcodes = listOf( | ||
Opcode.INVOKE_INTERFACE, | ||
Opcode.MOVE_RESULT_OBJECT, | ||
Opcode.CHECK_CAST, | ||
Opcode.INVOKE_VIRTUAL, | ||
Opcode.MOVE_RESULT, | ||
Opcode.IF_EQZ, | ||
) | ||
) |
65 changes: 65 additions & 0 deletions
65
...otlin/app/revanced/patches/music/buttoncontainer/label/patch/ButtonContainerLabelPatch.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
package app.revanced.patches.music.buttoncontainer.label.patch | ||
|
||
import app.revanced.extensions.exception | ||
import app.revanced.patcher.annotation.Description | ||
import app.revanced.patcher.annotation.Name | ||
import app.revanced.patcher.data.BytecodeContext | ||
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions | ||
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.patcher.patch.annotations.Patch | ||
import app.revanced.patches.music.buttoncontainer.label.fingerprints.ButtonContainerLabelFingerprint | ||
import app.revanced.patches.music.utils.annotations.MusicCompatibility | ||
import app.revanced.patches.music.utils.fingerprints.ActionsContainerParentFingerprint | ||
import app.revanced.patches.music.utils.resourceid.patch.SharedResourceIdPatch | ||
import app.revanced.patches.music.utils.settings.resource.patch.SettingsPatch | ||
import app.revanced.util.enum.CategoryType | ||
import app.revanced.util.integrations.Constants.MUSIC_BUTTON_CONTAINER | ||
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction | ||
|
||
@Patch | ||
@Name("Hide button container labels") | ||
@Description("Hide labels in button container.") | ||
@DependsOn( | ||
[ | ||
SettingsPatch::class, | ||
SharedResourceIdPatch::class | ||
] | ||
) | ||
@MusicCompatibility | ||
class ButtonContainerLabelPatch : BytecodePatch( | ||
listOf(ActionsContainerParentFingerprint) | ||
) { | ||
override fun execute(context: BytecodeContext) { | ||
ActionsContainerParentFingerprint.result?.let { parentResult -> | ||
ButtonContainerLabelFingerprint.also { | ||
it.resolve( | ||
context, | ||
parentResult.classDef | ||
) | ||
}.result?.let { | ||
it.mutableMethod.apply { | ||
val targetIndex = it.scanResult.patternScanResult!!.endIndex | ||
val targetRegister = | ||
getInstruction<OneRegisterInstruction>(targetIndex).registerA | ||
|
||
addInstructions( | ||
targetIndex, """ | ||
invoke-static {v$targetRegister}, $MUSIC_BUTTON_CONTAINER->hideButtonContainerLabel(Z)Z | ||
move-result v$targetRegister | ||
""" | ||
) | ||
} | ||
} ?: throw ButtonContainerLabelFingerprint.exception | ||
} ?: throw ActionsContainerParentFingerprint.exception | ||
|
||
SettingsPatch.addMusicPreference( | ||
CategoryType.BUTTON_CONTAINER, | ||
"revanced_hide_button_container_label", | ||
"false" | ||
) | ||
|
||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
...kotlin/app/revanced/patches/music/utils/fingerprints/ActionsContainerParentFingerprint.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package app.revanced.patches.music.utils.fingerprints | ||
|
||
import app.revanced.patcher.extensions.or | ||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint | ||
import app.revanced.patches.music.utils.resourceid.patch.SharedResourceIdPatch.Companion.ActionsContainer | ||
import app.revanced.util.bytecode.isWideLiteralExists | ||
import com.android.tools.smali.dexlib2.AccessFlags | ||
|
||
object ActionsContainerParentFingerprint : MethodFingerprint( | ||
returnType = "V", | ||
accessFlags = AccessFlags.PUBLIC or AccessFlags.CONSTRUCTOR, | ||
customFingerprint = { methodDef, _ -> methodDef.isWideLiteralExists(ActionsContainer) } | ||
) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters