From b593fa302fdc6ee9837fa54014a2f68bb3206594 Mon Sep 17 00:00:00 2001 From: inotia00 <108592928+inotia00@users.noreply.github.com> Date: Sat, 23 Mar 2024 01:12:25 +0900 Subject: [PATCH] chore: lint code --- .../flyoutpanel/component/FlyoutPanelPatch.kt | 84 ++++++++----------- .../EndButtonsContainerFingerprint.kt | 10 +++ .../replace/ReplaceDismissQueuePatch.kt | 34 +------- .../shared/FlyoutPanelMenuItemPatch.kt | 83 ++++++++++++++++++ .../fingerprints/MenuItemFingerprint.kt | 2 +- .../music/flyoutpanel/utils/EnumUtils.kt | 28 ------- .../FlyoutButtonContainerPatch.kt | 52 ------------ .../FlyoutPanelLikeButtonFingerprint.kt | 14 ---- .../utils/resourceid/SharedResourceIdPatch.kt | 4 +- .../kotlin/app/revanced/util/BytecodeUtils.kt | 18 ++-- 10 files changed, 142 insertions(+), 187 deletions(-) create mode 100644 src/main/kotlin/app/revanced/patches/music/flyoutpanel/component/fingerprints/EndButtonsContainerFingerprint.kt create mode 100644 src/main/kotlin/app/revanced/patches/music/flyoutpanel/shared/FlyoutPanelMenuItemPatch.kt rename src/main/kotlin/app/revanced/patches/music/{utils => flyoutpanel/shared}/fingerprints/MenuItemFingerprint.kt (88%) delete mode 100644 src/main/kotlin/app/revanced/patches/music/flyoutpanel/utils/EnumUtils.kt delete mode 100644 src/main/kotlin/app/revanced/patches/music/utils/flyoutbutton/FlyoutButtonContainerPatch.kt delete mode 100644 src/main/kotlin/app/revanced/patches/music/utils/flyoutbutton/fingerprints/FlyoutPanelLikeButtonFingerprint.kt diff --git a/src/main/kotlin/app/revanced/patches/music/flyoutpanel/component/FlyoutPanelPatch.kt b/src/main/kotlin/app/revanced/patches/music/flyoutpanel/component/FlyoutPanelPatch.kt index ca062bb33..474cc7978 100644 --- a/src/main/kotlin/app/revanced/patches/music/flyoutpanel/component/FlyoutPanelPatch.kt +++ b/src/main/kotlin/app/revanced/patches/music/flyoutpanel/component/FlyoutPanelPatch.kt @@ -2,34 +2,34 @@ package app.revanced.patches.music.flyoutpanel.component import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.extensions.InstructionExtensions.addInstruction -import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels import app.revanced.patcher.extensions.InstructionExtensions.getInstruction import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.annotation.CompatiblePackage import app.revanced.patcher.patch.annotation.Patch -import app.revanced.patcher.util.smali.ExternalLabel +import app.revanced.patches.music.flyoutpanel.component.fingerprints.EndButtonsContainerFingerprint import app.revanced.patches.music.flyoutpanel.component.fingerprints.SleepTimerFingerprint -import app.revanced.patches.music.flyoutpanel.utils.EnumUtils.getEnumIndex -import app.revanced.patches.music.utils.fingerprints.MenuItemFingerprint -import app.revanced.patches.music.utils.flyoutbutton.FlyoutButtonContainerPatch +import app.revanced.patches.music.flyoutpanel.shared.FlyoutPanelMenuItemPatch import app.revanced.patches.music.utils.integrations.Constants.COMPONENTS_PATH import app.revanced.patches.music.utils.integrations.Constants.FLYOUT import app.revanced.patches.music.utils.litho.LithoFilterPatch +import app.revanced.patches.music.utils.resourceid.SharedResourceIdPatch +import app.revanced.patches.music.utils.resourceid.SharedResourceIdPatch.EndButtonsContainer import app.revanced.patches.music.utils.settings.CategoryType import app.revanced.patches.music.utils.settings.SettingsPatch import app.revanced.util.exception +import app.revanced.util.getTargetIndex +import app.revanced.util.getWideLiteralInstructionIndex import com.android.tools.smali.dexlib2.Opcode -import com.android.tools.smali.dexlib2.iface.instruction.Instruction import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction -import com.android.tools.smali.dexlib2.iface.instruction.TwoRegisterInstruction @Patch( name = "Hide flyout panel", description = "Adds options to hide flyout panel components.", dependencies = [ - FlyoutButtonContainerPatch::class, + FlyoutPanelMenuItemPatch::class, LithoFilterPatch::class, - SettingsPatch::class + SettingsPatch::class, + SharedResourceIdPatch::class ], compatiblePackages = [ CompatiblePackage( @@ -52,37 +52,29 @@ import com.android.tools.smali.dexlib2.iface.instruction.TwoRegisterInstruction @Suppress("unused") object FlyoutPanelPatch : BytecodePatch( setOf( - MenuItemFingerprint, + EndButtonsContainerFingerprint, SleepTimerFingerprint ) ) { override fun execute(context: BytecodeContext) { - MenuItemFingerprint.result?.let { + FlyoutPanelMenuItemPatch.hideComponents() + + EndButtonsContainerFingerprint.result?.let { it.mutableMethod.apply { - val freeIndex = implementation!!.instructions.indexOfFirst { instruction -> - instruction.opcode == Opcode.OR_INT_LIT16 - } - val freeRegister = getInstruction(freeIndex).registerA + val startIndex = getWideLiteralInstructionIndex(EndButtonsContainer) + val targetIndex = getTargetIndex(startIndex, Opcode.MOVE_RESULT_OBJECT) + val targetRegister = getInstruction(targetIndex).registerA - val enumIndex = getEnumIndex() - val enumRegister = getInstruction(enumIndex).registerA - - val jumpInstruction = - getInstruction(implementation!!.instructions.size - 1) - - addInstructionsWithLabels( - enumIndex + 1, """ - invoke-static {v$enumRegister}, $FLYOUT->hideFlyoutPanels(Ljava/lang/Enum;)Z - move-result v$freeRegister - if-nez v$freeRegister, :hide - """, ExternalLabel("hide", jumpInstruction) + addInstruction( + targetIndex + 1, + "invoke-static {v$targetRegister}, $FLYOUT->hideLikeDislikeContainer(Landroid/view/View;)V" ) } - } ?: throw MenuItemFingerprint.exception + } ?: throw EndButtonsContainerFingerprint.exception /** * Forces sleep timer menu to be enabled. - * This method may be deperated in the future. + * This method may be desperate in the future. */ SleepTimerFingerprint.result?.let { it.mutableMethod.apply { @@ -166,13 +158,11 @@ object FlyoutPanelPatch : BytecodePatch( "revanced_hide_flyout_panel_like_dislike", "false" ) - if (!SettingsPatch.upward0636) { - SettingsPatch.addMusicPreferenceWithoutSummary( - CategoryType.FLYOUT, - "revanced_hide_flyout_panel_play_next", - "false" - ) - } + SettingsPatch.addMusicPreferenceWithoutSummary( + CategoryType.FLYOUT, + "revanced_hide_flyout_panel_play_next", + "false" + ) SettingsPatch.addMusicPreferenceWithoutSummary( CategoryType.FLYOUT, "revanced_hide_flyout_panel_quality", @@ -203,18 +193,16 @@ object FlyoutPanelPatch : BytecodePatch( "revanced_hide_flyout_panel_save_to_library", "false" ) - if (!SettingsPatch.upward0636) { - SettingsPatch.addMusicPreferenceWithoutSummary( - CategoryType.FLYOUT, - "revanced_hide_flyout_panel_save_to_playlist", - "false" - ) - SettingsPatch.addMusicPreferenceWithoutSummary( - CategoryType.FLYOUT, - "revanced_hide_flyout_panel_share", - "false" - ) - } + SettingsPatch.addMusicPreferenceWithoutSummary( + CategoryType.FLYOUT, + "revanced_hide_flyout_panel_save_to_playlist", + "false" + ) + SettingsPatch.addMusicPreferenceWithoutSummary( + CategoryType.FLYOUT, + "revanced_hide_flyout_panel_share", + "false" + ) SettingsPatch.addMusicPreferenceWithoutSummary( CategoryType.FLYOUT, "revanced_hide_flyout_panel_shuffle_play", diff --git a/src/main/kotlin/app/revanced/patches/music/flyoutpanel/component/fingerprints/EndButtonsContainerFingerprint.kt b/src/main/kotlin/app/revanced/patches/music/flyoutpanel/component/fingerprints/EndButtonsContainerFingerprint.kt new file mode 100644 index 000000000..ab6a6e62d --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/music/flyoutpanel/component/fingerprints/EndButtonsContainerFingerprint.kt @@ -0,0 +1,10 @@ +package app.revanced.patches.music.flyoutpanel.component.fingerprints + +import app.revanced.patches.music.utils.resourceid.SharedResourceIdPatch.EndButtonsContainer +import app.revanced.util.fingerprint.LiteralValueFingerprint + +object EndButtonsContainerFingerprint : LiteralValueFingerprint( + returnType = "V", + literalSupplier = { EndButtonsContainer } +) + diff --git a/src/main/kotlin/app/revanced/patches/music/flyoutpanel/replace/ReplaceDismissQueuePatch.kt b/src/main/kotlin/app/revanced/patches/music/flyoutpanel/replace/ReplaceDismissQueuePatch.kt index fbdd0d6c0..60fd2ed68 100644 --- a/src/main/kotlin/app/revanced/patches/music/flyoutpanel/replace/ReplaceDismissQueuePatch.kt +++ b/src/main/kotlin/app/revanced/patches/music/flyoutpanel/replace/ReplaceDismissQueuePatch.kt @@ -1,24 +1,19 @@ package app.revanced.patches.music.flyoutpanel.replace 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.annotation.CompatiblePackage import app.revanced.patcher.patch.annotation.Patch -import app.revanced.patches.music.flyoutpanel.utils.EnumUtils.getEnumIndex -import app.revanced.patches.music.utils.fingerprints.MenuItemFingerprint -import app.revanced.patches.music.utils.integrations.Constants.FLYOUT +import app.revanced.patches.music.flyoutpanel.shared.FlyoutPanelMenuItemPatch import app.revanced.patches.music.utils.settings.CategoryType import app.revanced.patches.music.utils.settings.SettingsPatch import app.revanced.patches.music.video.information.VideoInformationPatch -import app.revanced.util.exception -import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction @Patch( name = "Replace dismiss queue", description = "Adds an option to replace \"Dismiss queue\" with \"Watch on YouTube\" in the flyout menu.", dependencies = [ + FlyoutPanelMenuItemPatch::class, SettingsPatch::class, VideoInformationPatch::class ], @@ -41,36 +36,15 @@ import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction ] ) @Suppress("unused") -object ReplaceDismissQueuePatch : BytecodePatch( - setOf(MenuItemFingerprint) -) { +object ReplaceDismissQueuePatch : BytecodePatch(emptySet()) { override fun execute(context: BytecodeContext) { - MenuItemFingerprint.result?.let { - it.mutableMethod.apply { - val enumIndex = getEnumIndex() - val enumRegister = getInstruction(enumIndex).registerA - - val textViewIndex = it.scanResult.patternScanResult!!.startIndex - val imageViewIndex = it.scanResult.patternScanResult!!.endIndex - - val textViewRegister = - getInstruction(textViewIndex).registerA - val imageViewRegister = - getInstruction(imageViewIndex).registerA - - addInstruction( - enumIndex + 1, - "invoke-static {v$enumRegister, v$textViewRegister, v$imageViewRegister}, $FLYOUT->replaceDismissQueue(Ljava/lang/Enum;Landroid/widget/TextView;Landroid/widget/ImageView;)V" - ) - } - } ?: throw MenuItemFingerprint.exception + FlyoutPanelMenuItemPatch.replaceComponents() SettingsPatch.addMusicPreference( CategoryType.FLYOUT, "revanced_replace_flyout_panel_dismiss_queue", "false" ) - SettingsPatch.addMusicPreference( CategoryType.FLYOUT, "revanced_replace_flyout_panel_dismiss_queue_continue_watch", diff --git a/src/main/kotlin/app/revanced/patches/music/flyoutpanel/shared/FlyoutPanelMenuItemPatch.kt b/src/main/kotlin/app/revanced/patches/music/flyoutpanel/shared/FlyoutPanelMenuItemPatch.kt new file mode 100644 index 000000000..2fa5b6b5d --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/music/flyoutpanel/shared/FlyoutPanelMenuItemPatch.kt @@ -0,0 +1,83 @@ +package app.revanced.patches.music.flyoutpanel.shared + +import app.revanced.patcher.data.BytecodeContext +import app.revanced.patcher.extensions.InstructionExtensions.addInstruction +import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels +import app.revanced.patcher.extensions.InstructionExtensions.getInstruction +import app.revanced.patcher.patch.BytecodePatch +import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod +import app.revanced.patcher.util.smali.ExternalLabel +import app.revanced.patches.music.flyoutpanel.shared.fingerprints.MenuItemFingerprint +import app.revanced.patches.music.utils.integrations.Constants.FLYOUT +import app.revanced.util.exception +import app.revanced.util.getTargetIndex +import app.revanced.util.indexOfFirstInstruction +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.TwoRegisterInstruction +import kotlin.properties.Delegates + +object FlyoutPanelMenuItemPatch : BytecodePatch( + setOf(MenuItemFingerprint) +) { + private lateinit var menuItemMethod: MutableMethod + private var freeRegister by Delegates.notNull() + private var textViewRegister by Delegates.notNull() + private var imageViewRegister by Delegates.notNull() + private var instructionAdded = false + + override fun execute(context: BytecodeContext) { + MenuItemFingerprint.result?.let { + it.mutableMethod.apply { + val freeIndex = getTargetIndex(Opcode.OR_INT_LIT16) + val textViewIndex = it.scanResult.patternScanResult!!.startIndex + val imageViewIndex = it.scanResult.patternScanResult!!.endIndex + + freeRegister = + getInstruction(freeIndex).registerA + textViewRegister = + getInstruction(textViewIndex).registerA + imageViewRegister = + getInstruction(imageViewIndex).registerA + + menuItemMethod = this + } + } ?: throw MenuItemFingerprint.exception + } + + private fun MutableMethod.getEnumIndex() = indexOfFirstInstruction { + opcode == Opcode.INVOKE_STATIC + && (this as? ReferenceInstruction)?.reference.toString().contains("(I)L") + } + 1 + + internal fun hideComponents() { + menuItemMethod.apply { + val enumIndex = getEnumIndex() + val enumRegister = getInstruction(enumIndex).registerA + + addInstructionsWithLabels( + enumIndex + 1, """ + invoke-static {v$enumRegister}, $FLYOUT->hideComponents(Ljava/lang/Enum;)Z + move-result v$freeRegister + if-nez v$freeRegister, :hide + """, ExternalLabel("hide", getInstruction(implementation!!.instructions.size - 1)) + ) + } + } + + internal fun replaceComponents() { + if (!instructionAdded) { + menuItemMethod.apply { + val enumIndex = getEnumIndex() + val enumRegister = getInstruction(enumIndex).registerA + + addInstruction( + enumIndex + 1, + "invoke-static {v$enumRegister, v$textViewRegister, v$imageViewRegister}, $FLYOUT->replaceComponents(Ljava/lang/Enum;Landroid/widget/TextView;Landroid/widget/ImageView;)V" + ) + } + instructionAdded = true + } + } +} diff --git a/src/main/kotlin/app/revanced/patches/music/utils/fingerprints/MenuItemFingerprint.kt b/src/main/kotlin/app/revanced/patches/music/flyoutpanel/shared/fingerprints/MenuItemFingerprint.kt similarity index 88% rename from src/main/kotlin/app/revanced/patches/music/utils/fingerprints/MenuItemFingerprint.kt rename to src/main/kotlin/app/revanced/patches/music/flyoutpanel/shared/fingerprints/MenuItemFingerprint.kt index 466fa205f..e8785541e 100644 --- a/src/main/kotlin/app/revanced/patches/music/utils/fingerprints/MenuItemFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/music/flyoutpanel/shared/fingerprints/MenuItemFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.music.utils.fingerprints +package app.revanced.patches.music.flyoutpanel.shared.fingerprints import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.MethodFingerprint diff --git a/src/main/kotlin/app/revanced/patches/music/flyoutpanel/utils/EnumUtils.kt b/src/main/kotlin/app/revanced/patches/music/flyoutpanel/utils/EnumUtils.kt deleted file mode 100644 index 662c93b3b..000000000 --- a/src/main/kotlin/app/revanced/patches/music/flyoutpanel/utils/EnumUtils.kt +++ /dev/null @@ -1,28 +0,0 @@ -package app.revanced.patches.music.flyoutpanel.utils - -import app.revanced.patcher.extensions.InstructionExtensions.getInstruction -import app.revanced.patcher.patch.PatchException -import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod -import com.android.tools.smali.dexlib2.Opcode -import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction - -internal object EnumUtils { - - fun MutableMethod.getEnumIndex(): Int { - var targetIndex = 0 - for ((index, instruction) in implementation!!.instructions.withIndex()) { - if (instruction.opcode != Opcode.INVOKE_STATIC) continue - - val targetParameter = getInstruction(index).reference - - if (!targetParameter.toString().contains("(I)")) continue - - targetIndex = index + 1 - break - } - if (targetIndex == 0) - throw PatchException("Target reference not found!") - - return targetIndex - } -} \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/music/utils/flyoutbutton/FlyoutButtonContainerPatch.kt b/src/main/kotlin/app/revanced/patches/music/utils/flyoutbutton/FlyoutButtonContainerPatch.kt deleted file mode 100644 index 9c4fdf79c..000000000 --- a/src/main/kotlin/app/revanced/patches/music/utils/flyoutbutton/FlyoutButtonContainerPatch.kt +++ /dev/null @@ -1,52 +0,0 @@ -package app.revanced.patches.music.utils.flyoutbutton - -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.annotation.Patch -import app.revanced.patches.music.utils.flyoutbutton.fingerprints.FlyoutPanelLikeButtonFingerprint -import app.revanced.patches.music.utils.integrations.Constants.FLYOUT -import app.revanced.patches.music.utils.resourceid.SharedResourceIdPatch -import app.revanced.patches.music.utils.resourceid.SharedResourceIdPatch.MusicMenuLikeButtons -import app.revanced.util.exception -import app.revanced.util.getWideLiteralInstructionIndex -import com.android.tools.smali.dexlib2.Opcode -import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction - -@Patch( - dependencies = [ - SharedResourceIdPatch::class - ] -) -object FlyoutButtonContainerPatch : BytecodePatch( - setOf(FlyoutPanelLikeButtonFingerprint) -) { - override fun execute(context: BytecodeContext) { - - FlyoutPanelLikeButtonFingerprint.result?.let { - it.mutableMethod.apply { - val targetIndex = getWideLiteralInstructionIndex(MusicMenuLikeButtons) - - var insertIndex = -1 - - for (index in targetIndex until targetIndex + 5) { - if (getInstruction(index).opcode != Opcode.MOVE_RESULT_OBJECT) continue - - val register = getInstruction(index).registerA - insertIndex = index - - addInstruction( - index + 1, - "invoke-static {v$register}, $FLYOUT->setFlyoutButtonContainer(Landroid/view/View;)V" - ) - break - } - if (insertIndex == -1) - throw PatchException("Couldn't find target Index") - } - } ?: throw FlyoutPanelLikeButtonFingerprint.exception - - } -} \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/music/utils/flyoutbutton/fingerprints/FlyoutPanelLikeButtonFingerprint.kt b/src/main/kotlin/app/revanced/patches/music/utils/flyoutbutton/fingerprints/FlyoutPanelLikeButtonFingerprint.kt deleted file mode 100644 index cb61008ad..000000000 --- a/src/main/kotlin/app/revanced/patches/music/utils/flyoutbutton/fingerprints/FlyoutPanelLikeButtonFingerprint.kt +++ /dev/null @@ -1,14 +0,0 @@ -package app.revanced.patches.music.utils.flyoutbutton.fingerprints - -import app.revanced.patcher.extensions.or -import app.revanced.patches.music.utils.resourceid.SharedResourceIdPatch.MusicMenuLikeButtons -import app.revanced.util.fingerprint.LiteralValueFingerprint -import com.android.tools.smali.dexlib2.AccessFlags - -object FlyoutPanelLikeButtonFingerprint : LiteralValueFingerprint( - returnType = "V", - accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL or AccessFlags.SYNTHETIC, - parameters = listOf("L", "Ljava/lang/Object;"), - literalSupplier = { MusicMenuLikeButtons } -) - diff --git a/src/main/kotlin/app/revanced/patches/music/utils/resourceid/SharedResourceIdPatch.kt b/src/main/kotlin/app/revanced/patches/music/utils/resourceid/SharedResourceIdPatch.kt index 20bf5465a..0e85f180e 100644 --- a/src/main/kotlin/app/revanced/patches/music/utils/resourceid/SharedResourceIdPatch.kt +++ b/src/main/kotlin/app/revanced/patches/music/utils/resourceid/SharedResourceIdPatch.kt @@ -22,6 +22,7 @@ object SharedResourceIdPatch : ResourcePatch() { var ColorGrey: Long = -1 var DesignBottomSheetDialog: Long = -1 var DialogSolid: Long = -1 + var EndButtonsContainer: Long = -1 var FloatingLayout: Long = -1 var HistoryMenuItem: Long = -1 var InlineTimeBarAdBreakMarkerColor: Long = -1 @@ -30,7 +31,6 @@ object SharedResourceIdPatch : ResourcePatch() { var MenuEntry: Long = -1 var MiniPlayerMdxPlaying: Long = -1 var MiniPlayerPlayPauseReplayButton: Long = -1 - var MusicMenuLikeButtons: Long = -1 var MusicNotifierShelf: Long = -1 var MusicTasteBuilderShelf: Long = -1 var NamesInactiveAccountThumbnailSize: Long = -1 @@ -59,6 +59,7 @@ object SharedResourceIdPatch : ResourcePatch() { ColorGrey = find(COLOR, "ytm_color_grey_12") DesignBottomSheetDialog = find(LAYOUT, "design_bottom_sheet_dialog") DialogSolid = find(STYLE, "Theme.YouTubeMusic.Dialog.Solid") + EndButtonsContainer = find(ID, "end_buttons_container") FloatingLayout = find(ID, "floating_layout") HistoryMenuItem = find(ID, "history_menu_item") InlineTimeBarAdBreakMarkerColor = find(COLOR, "inline_time_bar_ad_break_marker_color") @@ -67,7 +68,6 @@ object SharedResourceIdPatch : ResourcePatch() { MenuEntry = find(LAYOUT, "menu_entry") MiniPlayerMdxPlaying = find(STRING, "mini_player_mdx_playing") MiniPlayerPlayPauseReplayButton = find(ID, "mini_player_play_pause_replay_button") - MusicMenuLikeButtons = find(LAYOUT, "music_menu_like_buttons") MusicNotifierShelf = find(LAYOUT, "music_notifier_shelf") MusicTasteBuilderShelf = find(LAYOUT, "music_tastebuilder_shelf") NamesInactiveAccountThumbnailSize = find(DIMEN, "names_inactive_account_thumbnail_size") diff --git a/src/main/kotlin/app/revanced/util/BytecodeUtils.kt b/src/main/kotlin/app/revanced/util/BytecodeUtils.kt index 08ba5045d..ae0165d68 100644 --- a/src/main/kotlin/app/revanced/util/BytecodeUtils.kt +++ b/src/main/kotlin/app/revanced/util/BytecodeUtils.kt @@ -91,19 +91,13 @@ fun Method.getWideLiteralInstructionIndex(literal: Long) = implementation?.let { } } ?: -1 -fun Method.getEmptyStringInstructionIndex() = implementation?.let { - it.instructions.indexOfFirst { instruction -> - instruction.opcode == Opcode.CONST_STRING - && (instruction as? BuilderInstruction21c)?.reference.toString().isEmpty() - } -} ?: -1 +fun MutableMethod.getEmptyStringInstructionIndex() += getStringInstructionIndex("") -fun Method.getStringInstructionIndex(value: String) = implementation?.let { - it.instructions.indexOfFirst { instruction -> - instruction.opcode == Opcode.CONST_STRING - && (instruction as? BuilderInstruction21c)?.reference.toString() == value - } -} ?: -1 +fun MutableMethod.getStringInstructionIndex(value: String) = indexOfFirstInstruction { + opcode == Opcode.CONST_STRING + && (this as? BuilderInstruction21c)?.reference.toString() == value +} /** * Check if the method contains a literal with the given value.