mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-05-22 19:09:12 +02:00
feat(music): add hide-handle
patch
This commit is contained in:
parent
b82205482d
commit
5dab82ffff
@ -0,0 +1,11 @@
|
|||||||
|
package app.revanced.patches.music.account.handle.fingerprints
|
||||||
|
|
||||||
|
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||||
|
import app.revanced.patches.music.utils.resourceid.patch.SharedResourceIdPatch.Companion.AccountSwitcherAccessibility
|
||||||
|
import app.revanced.util.bytecode.isWideLiteralExists
|
||||||
|
|
||||||
|
object AccountSwitcherAccessibilityLabelFingerprint : MethodFingerprint(
|
||||||
|
returnType = "V",
|
||||||
|
parameters = listOf("L", "Ljava/lang/Object;"),
|
||||||
|
customFingerprint = { methodDef, _ -> methodDef.isWideLiteralExists(AccountSwitcherAccessibility) }
|
||||||
|
)
|
@ -0,0 +1,29 @@
|
|||||||
|
package app.revanced.patches.music.account.handle.fingerprints
|
||||||
|
|
||||||
|
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||||
|
import app.revanced.patches.music.utils.resourceid.patch.SharedResourceIdPatch.Companion.NamesInactiveAccountThumbnailSize
|
||||||
|
import app.revanced.util.bytecode.isWideLiteralExists
|
||||||
|
import com.android.tools.smali.dexlib2.Opcode
|
||||||
|
|
||||||
|
object NamesInactiveAccountThumbnailSizeFingerprint : MethodFingerprint(
|
||||||
|
returnType = "V",
|
||||||
|
parameters = listOf("L", "Ljava/lang/Object;"),
|
||||||
|
opcodes = listOf(
|
||||||
|
Opcode.IF_NEZ,
|
||||||
|
Opcode.IGET_OBJECT,
|
||||||
|
Opcode.INVOKE_VIRTUAL,
|
||||||
|
Opcode.IGET_OBJECT,
|
||||||
|
Opcode.INVOKE_VIRTUAL,
|
||||||
|
Opcode.GOTO,
|
||||||
|
Opcode.IGET_OBJECT,
|
||||||
|
Opcode.INVOKE_VIRTUAL,
|
||||||
|
Opcode.INVOKE_VIRTUAL,
|
||||||
|
Opcode.MOVE_RESULT_OBJECT,
|
||||||
|
Opcode.IF_EQZ
|
||||||
|
),
|
||||||
|
customFingerprint = { methodDef, _ ->
|
||||||
|
methodDef.isWideLiteralExists(
|
||||||
|
NamesInactiveAccountThumbnailSize
|
||||||
|
)
|
||||||
|
}
|
||||||
|
)
|
@ -0,0 +1,95 @@
|
|||||||
|
package app.revanced.patches.music.account.handle.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.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.account.handle.fingerprints.AccountSwitcherAccessibilityLabelFingerprint
|
||||||
|
import app.revanced.patches.music.account.handle.fingerprints.NamesInactiveAccountThumbnailSizeFingerprint
|
||||||
|
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_ACCOUNT
|
||||||
|
import com.android.tools.smali.dexlib2.Opcode
|
||||||
|
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
|
||||||
|
import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction
|
||||||
|
import com.android.tools.smali.dexlib2.iface.instruction.formats.Instruction35c
|
||||||
|
import com.android.tools.smali.dexlib2.iface.reference.MethodReference
|
||||||
|
|
||||||
|
@Patch
|
||||||
|
@Name("Hide handle")
|
||||||
|
@Description("Hides the handle in the account switcher.")
|
||||||
|
@DependsOn(
|
||||||
|
[
|
||||||
|
SettingsPatch::class,
|
||||||
|
SharedResourceIdPatch::class
|
||||||
|
]
|
||||||
|
)
|
||||||
|
@MusicCompatibility
|
||||||
|
class HideHandlePatch : BytecodePatch(
|
||||||
|
listOf(
|
||||||
|
AccountSwitcherAccessibilityLabelFingerprint,
|
||||||
|
NamesInactiveAccountThumbnailSizeFingerprint
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
override fun execute(context: BytecodeContext) {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Hide handle in account menu
|
||||||
|
*/
|
||||||
|
AccountSwitcherAccessibilityLabelFingerprint.result?.let {
|
||||||
|
it.mutableMethod.apply {
|
||||||
|
val textColorIndex = implementation!!.instructions.indexOfFirst { instruction ->
|
||||||
|
((instruction as? ReferenceInstruction)?.reference as? MethodReference)?.name == "setTextColor"
|
||||||
|
}
|
||||||
|
|
||||||
|
for (index in textColorIndex until textColorIndex + 5) {
|
||||||
|
if (getInstruction(index).opcode != Opcode.INVOKE_VIRTUAL) continue
|
||||||
|
|
||||||
|
if ((getInstruction<ReferenceInstruction>(index).reference as MethodReference).name == "setVisibility") {
|
||||||
|
|
||||||
|
val textViewInstruction = getInstruction<Instruction35c>(index)
|
||||||
|
|
||||||
|
replaceInstruction(
|
||||||
|
index,
|
||||||
|
"invoke-static {v${textViewInstruction.registerC}, v${textViewInstruction.registerD}}, $MUSIC_ACCOUNT->hideHandle(Landroid/widget/TextView;I)V"
|
||||||
|
)
|
||||||
|
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} ?: throw AccountSwitcherAccessibilityLabelFingerprint.exception
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Hide handle in account switcher
|
||||||
|
*/
|
||||||
|
NamesInactiveAccountThumbnailSizeFingerprint.result?.let {
|
||||||
|
it.mutableMethod.apply {
|
||||||
|
val targetIndex = it.scanResult.patternScanResult!!.startIndex
|
||||||
|
val targetRegister = getInstruction<OneRegisterInstruction>(targetIndex).registerA
|
||||||
|
|
||||||
|
addInstructions(
|
||||||
|
targetIndex, """
|
||||||
|
invoke-static {v$targetRegister}, $MUSIC_ACCOUNT->hideHandle(Z)Z
|
||||||
|
move-result v$targetRegister
|
||||||
|
"""
|
||||||
|
)
|
||||||
|
}
|
||||||
|
} ?: throw NamesInactiveAccountThumbnailSizeFingerprint.exception
|
||||||
|
|
||||||
|
SettingsPatch.addMusicPreference(
|
||||||
|
CategoryType.ACCOUNT,
|
||||||
|
"revanced_hide_handle",
|
||||||
|
"true"
|
||||||
|
)
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -16,6 +16,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 AccountSwitcherAccessibility: Long = -1
|
||||||
var ActionsContainer: Long = -1
|
var ActionsContainer: Long = -1
|
||||||
var ButtonIconPaddingMedium: Long = -1
|
var ButtonIconPaddingMedium: Long = -1
|
||||||
var ChipCloud: Long = -1
|
var ChipCloud: Long = -1
|
||||||
@ -25,6 +26,7 @@ class SharedResourceIdPatch : ResourcePatch {
|
|||||||
var InlineTimeBarAdBreakMarkerColor: Long = -1
|
var InlineTimeBarAdBreakMarkerColor: Long = -1
|
||||||
var IsTablet: Long = -1
|
var IsTablet: Long = -1
|
||||||
var MusicMenuLikeButtons: Long = -1
|
var MusicMenuLikeButtons: Long = -1
|
||||||
|
var NamesInactiveAccountThumbnailSize: Long = -1
|
||||||
var PrivacyTosFooter: Long = -1
|
var PrivacyTosFooter: Long = -1
|
||||||
var QualityTitle: Long = -1
|
var QualityTitle: Long = -1
|
||||||
var Text1: Long = -1
|
var Text1: Long = -1
|
||||||
@ -38,6 +40,7 @@ class SharedResourceIdPatch : ResourcePatch {
|
|||||||
.find { it.type == resourceType.value && it.name == resourceName }?.id
|
.find { it.type == resourceType.value && it.name == resourceName }?.id
|
||||||
?: -1
|
?: -1
|
||||||
|
|
||||||
|
AccountSwitcherAccessibility = find(STRING, "account_switcher_accessibility_label")
|
||||||
ActionsContainer = find(ID, "actions_container")
|
ActionsContainer = find(ID, "actions_container")
|
||||||
ButtonIconPaddingMedium = find(DIMEN, "button_icon_padding_medium")
|
ButtonIconPaddingMedium = find(DIMEN, "button_icon_padding_medium")
|
||||||
ChipCloud = find(LAYOUT, "chip_cloud")
|
ChipCloud = find(LAYOUT, "chip_cloud")
|
||||||
@ -47,6 +50,7 @@ class SharedResourceIdPatch : ResourcePatch {
|
|||||||
InlineTimeBarAdBreakMarkerColor = find(COLOR, "inline_time_bar_ad_break_marker_color")
|
InlineTimeBarAdBreakMarkerColor = find(COLOR, "inline_time_bar_ad_break_marker_color")
|
||||||
IsTablet = find(BOOL, "is_tablet")
|
IsTablet = find(BOOL, "is_tablet")
|
||||||
MusicMenuLikeButtons = find(LAYOUT, "music_menu_like_buttons")
|
MusicMenuLikeButtons = find(LAYOUT, "music_menu_like_buttons")
|
||||||
|
NamesInactiveAccountThumbnailSize = find(DIMEN, "names_inactive_account_thumbnail_size")
|
||||||
PrivacyTosFooter = find(ID, "privacy_tos_footer")
|
PrivacyTosFooter = find(ID, "privacy_tos_footer")
|
||||||
QualityTitle = find(STRING, "quality_title")
|
QualityTitle = find(STRING, "quality_title")
|
||||||
Text1 = find(ID, "text1")
|
Text1 = find(ID, "text1")
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package app.revanced.util.enum
|
package app.revanced.util.enum
|
||||||
|
|
||||||
internal enum class CategoryType(val value: String, var added: Boolean) {
|
internal enum class CategoryType(val value: String, var added: Boolean) {
|
||||||
|
ACCOUNT("account", false),
|
||||||
ACTION_BAR("action_bar", false),
|
ACTION_BAR("action_bar", false),
|
||||||
ADS("ads", false),
|
ADS("ads", false),
|
||||||
FLYOUT("flyout", false),
|
FLYOUT("flyout", false),
|
||||||
|
@ -21,6 +21,7 @@ internal object Constants {
|
|||||||
const val MUSIC_INTEGRATIONS_PATH = "Lapp/revanced/music"
|
const val MUSIC_INTEGRATIONS_PATH = "Lapp/revanced/music"
|
||||||
private const val MUSIC_PATCHES_PATH = "$MUSIC_INTEGRATIONS_PATH/patches"
|
private const val MUSIC_PATCHES_PATH = "$MUSIC_INTEGRATIONS_PATH/patches"
|
||||||
|
|
||||||
|
const val MUSIC_ACCOUNT = "$MUSIC_PATCHES_PATH/account/AccountPatch;"
|
||||||
const val MUSIC_ACTIONBAR = "$MUSIC_PATCHES_PATH/actionbar/ActionBarPatch;"
|
const val MUSIC_ACTIONBAR = "$MUSIC_PATCHES_PATH/actionbar/ActionBarPatch;"
|
||||||
const val MUSIC_ADS_PATH = "$MUSIC_PATCHES_PATH/ads"
|
const val MUSIC_ADS_PATH = "$MUSIC_PATCHES_PATH/ads"
|
||||||
const val MUSIC_FLYOUT = "$MUSIC_PATCHES_PATH/flyout/FlyoutPatch;"
|
const val MUSIC_FLYOUT = "$MUSIC_PATCHES_PATH/flyout/FlyoutPatch;"
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<resources>
|
<resources>
|
||||||
|
<string name="revanced_category_account">Account</string>
|
||||||
<string name="revanced_category_action_bar">Action Bar</string>
|
<string name="revanced_category_action_bar">Action Bar</string>
|
||||||
<string name="revanced_category_ads">Ads</string>
|
<string name="revanced_category_ads">Ads</string>
|
||||||
<string name="revanced_category_flyout">Flyout</string>
|
<string name="revanced_category_flyout">Flyout</string>
|
||||||
@ -94,6 +95,8 @@
|
|||||||
<string name="revanced_hide_flyout_panel_share_title">Hide share menu</string>
|
<string name="revanced_hide_flyout_panel_share_title">Hide share menu</string>
|
||||||
<string name="revanced_hide_flyout_panel_start_radio_title">Hide start radio menu</string>
|
<string name="revanced_hide_flyout_panel_start_radio_title">Hide start radio menu</string>
|
||||||
<string name="revanced_hide_flyout_panel_view_song_credit_title">Hide view song credit menu</string>
|
<string name="revanced_hide_flyout_panel_view_song_credit_title">Hide view song credit menu</string>
|
||||||
|
<string name="revanced_hide_handle_summary">Hides the handle in the account switcher.</string>
|
||||||
|
<string name="revanced_hide_handle_title">Hide handle</string>
|
||||||
<string name="revanced_hide_home_button_summary">Hides the home button.</string>
|
<string name="revanced_hide_home_button_summary">Hides the home button.</string>
|
||||||
<string name="revanced_hide_home_button_title">Hide home button</string>
|
<string name="revanced_hide_home_button_title">Hide home button</string>
|
||||||
<string name="revanced_hide_library_button_summary">Hides the library button.</string>
|
<string name="revanced_hide_library_button_summary">Hides the library button.</string>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user