mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-05-09 02:54:37 +02:00
feat(music) add hide-sample-button
patch
This commit is contained in:
parent
4eec203126
commit
1c305e8da1
@ -0,0 +1,21 @@
|
||||
package app.revanced.patches.music.navigation.sample.fingerprints
|
||||
|
||||
import app.revanced.patcher.extensions.or
|
||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||
import app.revanced.util.bytecode.isNarrowLiteralExists
|
||||
import com.android.tools.smali.dexlib2.AccessFlags
|
||||
import com.android.tools.smali.dexlib2.Opcode
|
||||
|
||||
object PivotBarConstructorFingerprint : MethodFingerprint(
|
||||
returnType = "V",
|
||||
accessFlags = AccessFlags.PUBLIC or AccessFlags.CONSTRUCTOR,
|
||||
opcodes = listOf(
|
||||
Opcode.IPUT_OBJECT,
|
||||
Opcode.RETURN_VOID
|
||||
),
|
||||
customFingerprint = { methodDef, _ ->
|
||||
methodDef.name == "<init>" && methodDef.isNarrowLiteralExists(
|
||||
117501096
|
||||
)
|
||||
}
|
||||
)
|
@ -0,0 +1,66 @@
|
||||
package app.revanced.patches.music.navigation.sample.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.addInstruction
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction
|
||||
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.navigation.sample.fingerprints.PivotBarConstructorFingerprint
|
||||
import app.revanced.patches.music.navigation.upgrade.patch.UpgradeButtonPatch
|
||||
import app.revanced.patches.music.utils.annotations.MusicCompatibility
|
||||
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_NAVIGATION
|
||||
import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction
|
||||
import com.android.tools.smali.dexlib2.iface.instruction.TwoRegisterInstruction
|
||||
|
||||
@Patch
|
||||
@Name("Hide sample buttons")
|
||||
@Description("Adds options to hide sample buttons.")
|
||||
@DependsOn(
|
||||
[
|
||||
SettingsPatch::class,
|
||||
SharedResourceIdPatch::class,
|
||||
UpgradeButtonPatch::class
|
||||
]
|
||||
)
|
||||
@MusicCompatibility
|
||||
class SampleButtonPatch : BytecodePatch(
|
||||
listOf(PivotBarConstructorFingerprint)
|
||||
) {
|
||||
override fun execute(context: BytecodeContext) {
|
||||
|
||||
PivotBarConstructorFingerprint.result?.let {
|
||||
it.mutableMethod.apply {
|
||||
val targetIndex = it.scanResult.patternScanResult!!.startIndex
|
||||
val targetRegisterA = getInstruction<TwoRegisterInstruction>(targetIndex).registerA
|
||||
val targetRegisterB = getInstruction<TwoRegisterInstruction>(targetIndex).registerB
|
||||
|
||||
val replaceReference =
|
||||
getInstruction<ReferenceInstruction>(targetIndex).reference.toString()
|
||||
|
||||
replaceInstruction(
|
||||
targetIndex,
|
||||
"invoke-static {v$targetRegisterA}, $MUSIC_NAVIGATION->hideSampleButton(Ljava/util/List;)V"
|
||||
)
|
||||
addInstruction(
|
||||
targetIndex + 1,
|
||||
"iput-object v$targetRegisterA, v$targetRegisterB, $replaceReference"
|
||||
)
|
||||
}
|
||||
} ?: throw PivotBarConstructorFingerprint.exception
|
||||
|
||||
SettingsPatch.addMusicPreference(
|
||||
CategoryType.NAVIGATION,
|
||||
"revanced_hide_sample_button",
|
||||
"false"
|
||||
)
|
||||
|
||||
}
|
||||
}
|
@ -61,6 +61,8 @@
|
||||
<string name="revanced_hide_new_playlist_button_title">Hide new playlist button</string>
|
||||
<string name="revanced_hide_playlist_card_summary">Hides the playlist card from homepage.</string>
|
||||
<string name="revanced_hide_playlist_card_title">Hide playlist card</string>
|
||||
<string name="revanced_hide_sample_button_summary">Hides the sample button in navigation bar.</string>
|
||||
<string name="revanced_hide_sample_button_title">Hide sample button</string>
|
||||
<string name="revanced_hook_share_button_summary">Replace share button with external download button.</string>
|
||||
<string name="revanced_hook_share_button_title">Hook share button (Experimental Flags)</string>
|
||||
<string name="revanced_reboot_message">Refresh and restart</string>
|
||||
|
Loading…
x
Reference in New Issue
Block a user