mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-05-29 05:10:20 +02:00
feat(music): add hide-account-menu
patch
This commit is contained in:
parent
63a7d6fbec
commit
81ceb4e598
@ -0,0 +1,10 @@
|
||||
package app.revanced.patches.music.account.component.fingerprints
|
||||
|
||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||
import app.revanced.patches.music.utils.resourceid.patch.SharedResourceIdPatch.Companion.MenuEntry
|
||||
import app.revanced.util.bytecode.isWideLiteralExists
|
||||
|
||||
object MenuEntryFingerprint : MethodFingerprint(
|
||||
returnType = "V",
|
||||
customFingerprint = { methodDef, _ -> methodDef.isWideLiteralExists(MenuEntry) }
|
||||
)
|
@ -0,0 +1,81 @@
|
||||
package app.revanced.patches.music.account.component.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.patch.BytecodePatch
|
||||
import app.revanced.patcher.patch.PatchException
|
||||
import app.revanced.patcher.patch.annotations.DependsOn
|
||||
import app.revanced.patcher.patch.annotations.Patch
|
||||
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
|
||||
import app.revanced.patches.music.account.component.fingerprints.MenuEntryFingerprint
|
||||
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.iface.instruction.FiveRegisterInstruction
|
||||
import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction
|
||||
import com.android.tools.smali.dexlib2.iface.reference.MethodReference
|
||||
|
||||
@Patch
|
||||
@Name("Hide account menu")
|
||||
@Description("Hide account menu elements.")
|
||||
@DependsOn(
|
||||
[
|
||||
SettingsPatch::class,
|
||||
SharedResourceIdPatch::class
|
||||
]
|
||||
)
|
||||
@MusicCompatibility
|
||||
class MenuComponentPatch : BytecodePatch(
|
||||
listOf(MenuEntryFingerprint)
|
||||
) {
|
||||
override fun execute(context: BytecodeContext) {
|
||||
|
||||
MenuEntryFingerprint.result?.let {
|
||||
it.mutableMethod.apply {
|
||||
val textIndex = targetIndex("setText")
|
||||
val viewIndex = targetIndex("addView")
|
||||
|
||||
val textRegister = getInstruction<FiveRegisterInstruction>(textIndex).registerD
|
||||
val viewRegister = getInstruction<FiveRegisterInstruction>(viewIndex).registerD
|
||||
|
||||
addInstruction(
|
||||
textIndex + 1,
|
||||
"invoke-static {v$textRegister, v$viewRegister}, $MUSIC_ACCOUNT->hideAccountMenu(Ljava/lang/CharSequence;Landroid/view/View;)V"
|
||||
)
|
||||
}
|
||||
} ?: throw MenuEntryFingerprint.exception
|
||||
|
||||
SettingsPatch.addMusicPreference(
|
||||
CategoryType.ACCOUNT,
|
||||
"revanced_hide_account_menu",
|
||||
"false"
|
||||
)
|
||||
SettingsPatch.addMusicPreferenceWithIntent(
|
||||
CategoryType.ACCOUNT,
|
||||
"revanced_hide_account_menu_filter_strings",
|
||||
"revanced_hide_account_menu"
|
||||
)
|
||||
SettingsPatch.addMusicPreference(
|
||||
CategoryType.ACCOUNT,
|
||||
"revanced_hide_account_menu_empty_component",
|
||||
"false",
|
||||
"revanced_hide_account_menu"
|
||||
)
|
||||
}
|
||||
|
||||
private companion object {
|
||||
fun MutableMethod.targetIndex(descriptor: String): Int {
|
||||
return implementation?.let {
|
||||
it.instructions.indexOfFirst { instruction ->
|
||||
((instruction as? ReferenceInstruction)?.reference as? MethodReference)?.name == descriptor
|
||||
}
|
||||
} ?: throw PatchException("No Method Implementation found!")
|
||||
}
|
||||
}
|
||||
}
|
@ -25,6 +25,7 @@ class SharedResourceIdPatch : ResourcePatch {
|
||||
var DisabledIconAlpha: Long = -1
|
||||
var InlineTimeBarAdBreakMarkerColor: Long = -1
|
||||
var IsTablet: Long = -1
|
||||
var MenuEntry: Long = -1
|
||||
var MusicMenuLikeButtons: Long = -1
|
||||
var NamesInactiveAccountThumbnailSize: Long = -1
|
||||
var PrivacyTosFooter: Long = -1
|
||||
@ -50,6 +51,7 @@ class SharedResourceIdPatch : ResourcePatch {
|
||||
DisabledIconAlpha = find(DIMEN, "disabled_icon_alpha")
|
||||
InlineTimeBarAdBreakMarkerColor = find(COLOR, "inline_time_bar_ad_break_marker_color")
|
||||
IsTablet = find(BOOL, "is_tablet")
|
||||
MenuEntry = find(LAYOUT, "menu_entry")
|
||||
MusicMenuLikeButtons = find(LAYOUT, "music_menu_like_buttons")
|
||||
NamesInactiveAccountThumbnailSize = find(DIMEN, "names_inactive_account_thumbnail_size")
|
||||
PrivacyTosFooter = find(ID, "privacy_tos_footer")
|
||||
|
@ -63,6 +63,10 @@
|
||||
<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_flyout_panel_watch_on_youtube">Watch on YouTube</string>
|
||||
<string name="revanced_hide_account_menu_empty_component_summary">Hides empty components in the account menu</string>
|
||||
<string name="revanced_hide_account_menu_empty_component_title">Hide empty component</string>
|
||||
<string name="revanced_hide_account_menu_summary">Hide account menu elements.</string>
|
||||
<string name="revanced_hide_account_menu_title">Hide account menu</string>
|
||||
<string name="revanced_hide_action_bar_label_summary">Hide labels in action bar.</string>
|
||||
<string name="revanced_hide_action_bar_label_title">Hide action bar labels</string>
|
||||
<string name="revanced_hide_action_bar_radio_summary">Hides start radio button.</string>
|
||||
|
@ -3,6 +3,9 @@
|
||||
<!-- Translation Exception -->
|
||||
<string name="revanced_extended_settings_title">ReVanced Extended</string>
|
||||
|
||||
<string name="revanced_hide_account_menu_filter_strings_summary">@string/revanced_custom_filter_strings_summary</string>
|
||||
<string name="revanced_hide_account_menu_filter_strings_title">@string/revanced_custom_filter_strings_title</string>
|
||||
|
||||
<string name="revanced_ryd_attribution_title">ReturnYouTubeDislike.com</string>
|
||||
<string name="revanced_ryd_enabled_title">@string/revanced_ryd_settings_title</string>
|
||||
<string name="revanced_ryd_settings_title">Return YouTube Dislike</string>
|
||||
|
Loading…
x
Reference in New Issue
Block a user