mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-05-14 13:27:17 +02:00
feat(music): add hide-button-container-labels
patch
This commit is contained in:
parent
f0dfbd27ee
commit
2eff3d2f0a
@ -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,
|
||||||
|
)
|
||||||
|
)
|
@ -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"
|
||||||
|
)
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -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) }
|
||||||
|
)
|
||||||
|
|
@ -17,6 +17,7 @@ import app.revanced.util.enum.ResourceType.STYLE
|
|||||||
@DependsOn([ResourceMappingPatch::class])
|
@DependsOn([ResourceMappingPatch::class])
|
||||||
class SharedResourceIdPatch : ResourcePatch {
|
class SharedResourceIdPatch : ResourcePatch {
|
||||||
internal companion object {
|
internal companion object {
|
||||||
|
var ActionsContainer: Long = -1
|
||||||
var ChipCloud: Long = -1
|
var ChipCloud: Long = -1
|
||||||
var ColorGrey: Long = -1
|
var ColorGrey: Long = -1
|
||||||
var DialogSolid: Long = -1
|
var DialogSolid: Long = -1
|
||||||
@ -36,6 +37,7 @@ class SharedResourceIdPatch : ResourcePatch {
|
|||||||
.find { it.type == resourceType.value && it.name == resourceName }?.id
|
.find { it.type == resourceType.value && it.name == resourceName }?.id
|
||||||
?: throw PatchException("Failed to find resource id : $resourceName")
|
?: throw PatchException("Failed to find resource id : $resourceName")
|
||||||
|
|
||||||
|
ActionsContainer = find(ID, "actions_container")
|
||||||
ChipCloud = find(LAYOUT, "chip_cloud")
|
ChipCloud = find(LAYOUT, "chip_cloud")
|
||||||
ColorGrey = find(COLOR, "ytm_color_grey_12")
|
ColorGrey = find(COLOR, "ytm_color_grey_12")
|
||||||
DialogSolid = find(STYLE, "Theme.YouTubeMusic.Dialog.Solid")
|
DialogSolid = find(STYLE, "Theme.YouTubeMusic.Dialog.Solid")
|
||||||
|
@ -45,6 +45,8 @@
|
|||||||
<string name="revanced_external_downloader_not_installed_warning" formatted="false">%s is not installed. Please install it.</string>
|
<string name="revanced_external_downloader_not_installed_warning" formatted="false">%s is not installed. Please install it.</string>
|
||||||
<string name="revanced_external_downloader_package_name_summary">Package name of your installed external downloader app, such as NewPipe or Seal</string>
|
<string name="revanced_external_downloader_package_name_summary">Package name of your installed external downloader app, such as NewPipe or Seal</string>
|
||||||
<string name="revanced_external_downloader_package_name_title">External downloader package name</string>
|
<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_shelf_summary">Hides the button shelf from homepage and explorer.</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_button_shelf_title">Hide button shelf</string>
|
||||||
<string name="revanced_hide_carousel_shelf_summary">Hides the carousel shelf from homepage and explorer.</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