diff --git a/patches/src/main/kotlin/app/revanced/patches/music/utils/resourceid/SharedResourceIdPatch.kt b/patches/src/main/kotlin/app/revanced/patches/music/utils/resourceid/SharedResourceIdPatch.kt index fd21eb157..86224d8af 100644 --- a/patches/src/main/kotlin/app/revanced/patches/music/utils/resourceid/SharedResourceIdPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/music/utils/resourceid/SharedResourceIdPatch.kt @@ -9,9 +9,8 @@ import app.revanced.patches.shared.mapping.ResourceType.ID import app.revanced.patches.shared.mapping.ResourceType.LAYOUT import app.revanced.patches.shared.mapping.ResourceType.STRING import app.revanced.patches.shared.mapping.ResourceType.STYLE -import app.revanced.patches.shared.mapping.get +import app.revanced.patches.shared.mapping.getResourceId import app.revanced.patches.shared.mapping.resourceMappingPatch -import app.revanced.patches.shared.mapping.resourceMappings var accountSwitcherAccessibility = -1L private set @@ -126,217 +125,58 @@ internal val sharedResourceIdPatch = resourcePatch( dependsOn(resourceMappingPatch) execute { - accountSwitcherAccessibility = resourceMappings[ - STRING, - "account_switcher_accessibility_label", - ] - actionBarLogo = resourceMappings[ - DRAWABLE, - "action_bar_logo", - ] - actionBarLogoRingo2 = resourceMappings[ - DRAWABLE, - "action_bar_logo_ringo2", - ] - bottomSheetRecyclerView = resourceMappings[ - LAYOUT, - "bottom_sheet_recycler_view" - ] - buttonContainer = resourceMappings[ - ID, - "button_container" - ] - buttonIconPaddingMedium = resourceMappings[ - DIMEN, - "button_icon_padding_medium" - ] - chipCloud = resourceMappings[ - LAYOUT, - "chip_cloud" - ] - colorGrey = resourceMappings[ - COLOR, - "ytm_color_grey_12" - ] - darkBackground = resourceMappings[ - ID, - "dark_background" - ] - designBottomSheetDialog = resourceMappings[ - LAYOUT, - "design_bottom_sheet_dialog" - ] - elementsContainer = resourceMappings[ - ID, - "elements_container" - ] - endButtonsContainer = resourceMappings[ - ID, - "end_buttons_container" - ] - floatingLayout = resourceMappings[ - ID, - "floating_layout" - ] - historyMenuItem = resourceMappings[ - ID, - "history_menu_item" - ] - inlineTimeBarAdBreakMarkerColor = resourceMappings[ - COLOR, - "inline_time_bar_ad_break_marker_color" - ] - inlineTimeBarProgressColor = resourceMappings[ - COLOR, - "inline_time_bar_progress_color" - ] - interstitialsContainer = resourceMappings[ - ID, - "interstitials_container" - ] - isTablet = resourceMappings[ - BOOL, - "is_tablet" - ] - likeDislikeContainer = resourceMappings[ - ID, - "like_dislike_container" - ] - mainActivityLaunchAnimation = resourceMappings[ - LAYOUT, - "main_activity_launch_animation" - ] - menuEntry = resourceMappings[ - LAYOUT, - "menu_entry" - ] - miniPlayerDefaultText = resourceMappings[ - STRING, - "mini_player_default_text" - ] - miniPlayerMdxPlaying = resourceMappings[ - STRING, - "mini_player_mdx_playing" - ] - miniPlayerPlayPauseReplayButton = resourceMappings[ - ID, - "mini_player_play_pause_replay_button" - ] - miniPlayerViewPager = resourceMappings[ - ID, - "mini_player_view_pager" - ] - modernDialogBackground = resourceMappings[ - DRAWABLE, - "modern_dialog_background" - ] - musicNotifierShelf = resourceMappings[ - LAYOUT, - "music_notifier_shelf" - ] - musicTasteBuilderShelf = resourceMappings[ - LAYOUT, - "music_tastebuilder_shelf" - ] - namesInactiveAccountThumbnailSize = resourceMappings[ - DIMEN, - "names_inactive_account_thumbnail_size" - ] - offlineSettingsMenuItem = resourceMappings[ - ID, - "offline_settings_menu_item" - ] - playerOverlayChip = resourceMappings[ - ID, - "player_overlay_chip" - ] - playerViewPager = resourceMappings[ - ID, - "player_view_pager" - ] - privacyTosFooter = resourceMappings[ - ID, - "privacy_tos_footer" - ] - qualityAuto = resourceMappings[ - STRING, - "quality_auto" - ] - remixGenericButtonSize = resourceMappings[ - DIMEN, - "remix_generic_button_size" - ] - searchButton = resourceMappings[ - LAYOUT, - "search_button" - ] - slidingDialogAnimation = resourceMappings[ - STYLE, - "SlidingDialogAnimation" - ] - tapBloomView = resourceMappings[ - ID, - "tap_bloom_view" - ] - text1 = resourceMappings[ - ID, - "text1" - ] - toolTipContentView = resourceMappings[ - LAYOUT, - "tooltip_content_view" - ] - topEnd = resourceMappings[ - ID, - "TOP_END" - ] - topStart = resourceMappings[ - ID, - "TOP_START" - ] - topBarMenuItemImageView = resourceMappings[ - ID, - "top_bar_menu_item_image_view" - ] - tosFooter = resourceMappings[ - ID, - "tos_footer" - ] - touchOutside = resourceMappings[ - ID, - "touch_outside" - ] - trimSilenceSwitch = resourceMappings[ - ID, - "trim_silence_switch" - ] - varispeedUnavailableTitle = resourceMappings[ - STRING, - "varispeed_unavailable_title" - ] - ytFillSamples = resourceMappings[ - DRAWABLE, - "yt_fill_samples_vd_theme_24", - ] - ytFillYouTubeMusic = resourceMappings[ - DRAWABLE, - "yt_fill_youtube_music_vd_theme_24", - ] - ytOutlineSamples = resourceMappings[ - DRAWABLE, - "yt_outline_samples_vd_theme_24", - ] - ytOutlineYouTubeMusic = resourceMappings[ - DRAWABLE, - "yt_outline_youtube_music_vd_theme_24", - ] - ytmLogo = resourceMappings[ - DRAWABLE, - "ytm_logo", - ] - ytmLogoRingo2 = resourceMappings[ - DRAWABLE, - "ytm_logo_ringo2", - ] + accountSwitcherAccessibility = getResourceId(STRING, "account_switcher_accessibility_label") + actionBarLogo = getResourceId(DRAWABLE, "action_bar_logo") + actionBarLogoRingo2 = getResourceId(DRAWABLE, "action_bar_logo_ringo2") + bottomSheetRecyclerView = getResourceId(LAYOUT, "bottom_sheet_recycler_view") + buttonContainer = getResourceId(ID, "button_container") + buttonIconPaddingMedium = getResourceId(DIMEN, "button_icon_padding_medium") + chipCloud = getResourceId(LAYOUT, "chip_cloud") + colorGrey = getResourceId(COLOR, "ytm_color_grey_12") + darkBackground = getResourceId(ID, "dark_background") + designBottomSheetDialog = getResourceId(LAYOUT, "design_bottom_sheet_dialog") + elementsContainer = getResourceId(ID, "elements_container") + endButtonsContainer = getResourceId(ID, "end_buttons_container") + floatingLayout = getResourceId(ID, "floating_layout") + historyMenuItem = getResourceId(ID, "history_menu_item") + inlineTimeBarAdBreakMarkerColor = getResourceId(COLOR, "inline_time_bar_ad_break_marker_color") + inlineTimeBarProgressColor = getResourceId(COLOR, "inline_time_bar_progress_color") + interstitialsContainer = getResourceId(ID, "interstitials_container") + isTablet = getResourceId(BOOL, "is_tablet") + likeDislikeContainer = getResourceId(ID, "like_dislike_container") + mainActivityLaunchAnimation = getResourceId(LAYOUT, "main_activity_launch_animation") + menuEntry = getResourceId(LAYOUT, "menu_entry") + miniPlayerDefaultText = getResourceId(STRING, "mini_player_default_text") + miniPlayerMdxPlaying = getResourceId(STRING, "mini_player_mdx_playing") + miniPlayerPlayPauseReplayButton = getResourceId(ID, "mini_player_play_pause_replay_button") + miniPlayerViewPager = getResourceId(ID, "mini_player_view_pager") + modernDialogBackground = getResourceId(DRAWABLE, "modern_dialog_background") + musicNotifierShelf = getResourceId(LAYOUT, "music_notifier_shelf") + musicTasteBuilderShelf = getResourceId(LAYOUT, "music_tastebuilder_shelf") + namesInactiveAccountThumbnailSize = getResourceId(DIMEN, "names_inactive_account_thumbnail_size") + offlineSettingsMenuItem = getResourceId(ID, "offline_settings_menu_item") + playerOverlayChip = getResourceId(ID, "player_overlay_chip") + playerViewPager = getResourceId(ID, "player_view_pager") + privacyTosFooter = getResourceId(ID, "privacy_tos_footer") + qualityAuto = getResourceId(STRING, "quality_auto") + remixGenericButtonSize = getResourceId(DIMEN, "remix_generic_button_size") + searchButton = getResourceId(LAYOUT, "search_button") + slidingDialogAnimation = getResourceId(STYLE, "SlidingDialogAnimation") + tapBloomView = getResourceId(ID, "tap_bloom_view") + text1 = getResourceId(ID, "text1") + toolTipContentView = getResourceId(LAYOUT, "tooltip_content_view") + topEnd = getResourceId(ID, "TOP_END") + topStart = getResourceId(ID, "TOP_START") + topBarMenuItemImageView = getResourceId(ID, "top_bar_menu_item_image_view") + tosFooter = getResourceId(ID, "tos_footer") + touchOutside = getResourceId(ID, "touch_outside") + trimSilenceSwitch = getResourceId(ID, "trim_silence_switch") + varispeedUnavailableTitle = getResourceId(STRING, "varispeed_unavailable_title") + ytFillSamples = getResourceId(DRAWABLE, "yt_fill_samples_vd_theme_24") + ytFillYouTubeMusic = getResourceId(DRAWABLE, "yt_fill_youtube_music_vd_theme_24") + ytOutlineSamples = getResourceId(DRAWABLE, "yt_outline_samples_vd_theme_24") + ytOutlineYouTubeMusic = getResourceId(DRAWABLE, "yt_outline_youtube_music_vd_theme_24") + ytmLogo = getResourceId(DRAWABLE, "ytm_logo") + ytmLogoRingo2 = getResourceId(DRAWABLE, "ytm_logo_ringo2") } } \ No newline at end of file diff --git a/patches/src/main/kotlin/app/revanced/patches/reddit/utils/resourceid/SharedResourceIdPatch.kt b/patches/src/main/kotlin/app/revanced/patches/reddit/utils/resourceid/SharedResourceIdPatch.kt index 8fcffa95d..4f8faec53 100644 --- a/patches/src/main/kotlin/app/revanced/patches/reddit/utils/resourceid/SharedResourceIdPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/reddit/utils/resourceid/SharedResourceIdPatch.kt @@ -2,9 +2,8 @@ package app.revanced.patches.reddit.utils.resourceid import app.revanced.patcher.patch.resourcePatch import app.revanced.patches.shared.mapping.ResourceType.STRING -import app.revanced.patches.shared.mapping.get +import app.revanced.patches.shared.mapping.getResourceId import app.revanced.patches.shared.mapping.resourceMappingPatch -import app.revanced.patches.shared.mapping.resourceMappings var screenShotShareBanner = -1L private set @@ -15,9 +14,6 @@ internal val sharedResourceIdPatch = resourcePatch( dependsOn(resourceMappingPatch) execute { - screenShotShareBanner = resourceMappings[ - STRING, - "screenshot_share_banner_title", - ] + screenShotShareBanner = getResourceId(STRING, "screenshot_share_banner_title") } } \ No newline at end of file diff --git a/patches/src/main/kotlin/app/revanced/patches/shared/mapping/ResourceMappingPatch.kt b/patches/src/main/kotlin/app/revanced/patches/shared/mapping/ResourceMappingPatch.kt index f48e8f201..4e881a0e8 100644 --- a/patches/src/main/kotlin/app/revanced/patches/shared/mapping/ResourceMappingPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/shared/mapping/ResourceMappingPatch.kt @@ -1,72 +1,52 @@ package app.revanced.patches.shared.mapping +import app.revanced.patcher.patch.PatchException import app.revanced.patcher.patch.resourcePatch import org.w3c.dom.Element -import java.util.Collections -import java.util.concurrent.Executors -import java.util.concurrent.TimeUnit -// TODO: Probably renaming the patch/this is a good idea. -lateinit var resourceMappings: List - private set +data class ResourceElement(val type: String, val name: String, val id: Long) + +private lateinit var resourceMappings: MutableMap + +private fun setResourceId(type: String, name: String, id: Long) { + resourceMappings[type + name] = ResourceElement(type, name, id) +} + +fun getResourceId(resourceType: ResourceType, name: String) = + getResourceId(resourceType.value, name) + +/** + * @return A resource id of the given resource type and name. + * @throws PatchException if the resource is not found. + */ +fun getResourceId(type: String, name: String) = resourceMappings[type + name]?.id + ?: -1L val resourceMappingPatch = resourcePatch( description = "resourceMappingPatch" ) { - val threadCount = Runtime.getRuntime().availableProcessors() - val threadPoolExecutor = Executors.newFixedThreadPool(threadCount) - - val resourceMappings = Collections.synchronizedList(mutableListOf()) - execute { - // Save the file in memory to concurrently read from it. - val resourceXmlFile = get("res/values/public.xml").readBytes() + document("res/values/public.xml").use { document -> + val resources = document.documentElement.childNodes + val resourcesLength = resources.length + resourceMappings = HashMap(2 * resourcesLength) - for (threadIndex in 0 until threadCount) { - threadPoolExecutor.execute thread@{ - document(resourceXmlFile.inputStream()).use { document -> + for (i in 0 until resourcesLength) { + val node = resources.item(i) as? Element ?: continue + if (node.nodeName != "public") continue - val resources = document.documentElement.childNodes - val resourcesLength = resources.length - val jobSize = resourcesLength / threadCount + val nameAttribute = node.getAttribute("name") + if (nameAttribute.startsWith("APKTOOL")) continue - val batchStart = jobSize * threadIndex - val batchEnd = jobSize * (threadIndex + 1) - element@ for (i in batchStart until batchEnd) { - // Prevent out of bounds. - if (i >= resourcesLength) return@thread + val typeAttribute = node.getAttribute("type") + val id = node.getAttribute("id").substring(2).toLong(16) - val node = resources.item(i) - if (node !is Element) continue - - val nameAttribute = node.getAttribute("name") - val typeAttribute = node.getAttribute("type") - - if (node.nodeName != "public" || nameAttribute.startsWith("APKTOOL")) continue - - val id = node.getAttribute("id").substring(2).toLong(16) - - resourceMappings.add(ResourceElement(typeAttribute, nameAttribute, id)) - } - } + setResourceId(typeAttribute, nameAttribute, id) } } - - threadPoolExecutor.also { it.shutdown() }.awaitTermination(Long.MAX_VALUE, TimeUnit.SECONDS) - - app.revanced.patches.shared.mapping.resourceMappings = resourceMappings } } -operator fun List.get(type: String, name: String) = resourceMappings.firstOrNull { - it.type == type && it.name == name -}?.id ?: -1L - -operator fun List.get(resourceType: ResourceType, name: String) = - get(resourceType.value, name) - -data class ResourceElement(val type: String, val name: String, val id: Long) - enum class ResourceType(val value: String) { ATTR("attr"), BOOL("bool"), diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/utils/resourceid/SharedResourceIdPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/utils/resourceid/SharedResourceIdPatch.kt index 56194df98..08816a3d8 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/utils/resourceid/SharedResourceIdPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/utils/resourceid/SharedResourceIdPatch.kt @@ -11,9 +11,8 @@ import app.revanced.patches.shared.mapping.ResourceType.LAYOUT import app.revanced.patches.shared.mapping.ResourceType.STRING import app.revanced.patches.shared.mapping.ResourceType.STYLE import app.revanced.patches.shared.mapping.ResourceType.XML -import app.revanced.patches.shared.mapping.get +import app.revanced.patches.shared.mapping.getResourceId import app.revanced.patches.shared.mapping.resourceMappingPatch -import app.revanced.patches.shared.mapping.resourceMappings var accountSwitcherAccessibility = -1L private set @@ -268,497 +267,128 @@ internal val sharedResourceIdPatch = resourcePatch( dependsOn(resourceMappingPatch) execute { - accountSwitcherAccessibility = resourceMappings[ - STRING, - "account_switcher_accessibility_label" - ] - actionBarRingo = resourceMappings[ - LAYOUT, - "action_bar_ringo" - ] - actionBarRingoBackground = resourceMappings[ - LAYOUT, - "action_bar_ringo_background" - ] - adAttribution = resourceMappings[ - ID, - "ad_attribution" - ] - appearance = resourceMappings[ - STRING, - "app_theme_appearance_dark" - ] - appRelatedEndScreenResults = resourceMappings[ - LAYOUT, - "app_related_endscreen_results" - ] - autoNavPreviewStub = resourceMappings[ - ID, - "autonav_preview_stub" - ] - autoNavScrollCancelPadding = resourceMappings[ - DIMEN, - "autonav_scroll_cancel_padding" - ] - autoNavToggle = resourceMappings[ - ID, - "autonav_toggle" - ] - backgroundCategory = resourceMappings[ - STRING, - "pref_background_and_offline_category" - ] - badgeLabel = resourceMappings[ - ID, - "badge_label" - ] - bar = resourceMappings[ - LAYOUT, - "bar" - ] - barContainerHeight = resourceMappings[ - DIMEN, - "bar_container_height" - ] - bottomBarContainer = resourceMappings[ - ID, - "bottom_bar_container" - ] - bottomSheetFooterText = resourceMappings[ - ID, - "bottom_sheet_footer_text" - ] - bottomSheetRecyclerView = resourceMappings[ - LAYOUT, - "bottom_sheet_recycler_view" - ] - bottomUiContainerStub = resourceMappings[ - ID, - "bottom_ui_container_stub" - ] - captionToggleContainer = resourceMappings[ - ID, - "caption_toggle_container" - ] - castMediaRouteButton = resourceMappings[ - LAYOUT, - "castmediaroutebutton" - ] - cfFullscreenButton = resourceMappings[ - ID, - "cf_fullscreen_button" - ] - channelListSubMenu = resourceMappings[ - LAYOUT, - "channel_list_sub_menu" - ] - compactLink = resourceMappings[ - LAYOUT, - "compact_link" - ] - compactListItem = resourceMappings[ - LAYOUT, - "compact_list_item" - ] - componentLongClickListener = resourceMappings[ - ID, - "component_long_click_listener" - ] - contentPill = resourceMappings[ - LAYOUT, - "content_pill" - ] - controlsLayoutStub = resourceMappings[ - ID, - "controls_layout_stub" - ] - darkBackground = resourceMappings[ - ID, - "dark_background" - ] - darkSplashAnimation = resourceMappings[ - ID, - "dark_splash_animation" - ] - designBottomSheet = resourceMappings[ - ID, - "design_bottom_sheet" - ] - donationCompanion = resourceMappings[ - LAYOUT, - "donation_companion" - ] - drawerContentView = resourceMappings[ - ID, - "drawer_content_view" - ] - drawerResults = resourceMappings[ - ID, - "drawer_results" - ] - easySeekEduContainer = resourceMappings[ - ID, - "easy_seek_edu_container" - ] - editSettingsAction = resourceMappings[ - STRING, - "edit_settings_action" - ] - endScreenElementLayoutCircle = resourceMappings[ - LAYOUT, - "endscreen_element_layout_circle" - ] - endScreenElementLayoutIcon = resourceMappings[ - LAYOUT, - "endscreen_element_layout_icon" - ] - endScreenElementLayoutVideo = resourceMappings[ - LAYOUT, - "endscreen_element_layout_video" - ] - emojiPickerIcon = resourceMappings[ - ID, - "emoji_picker_icon" - ] - expandButtonDown = resourceMappings[ - LAYOUT, - "expand_button_down" - ] - fab = resourceMappings[ - ID, - "fab" - ] - fadeDurationFast = resourceMappings[ - INTEGER, - "fade_duration_fast" - ] - filterBarHeight = resourceMappings[ - DIMEN, - "filter_bar_height" - ] - floatyBarTopMargin = resourceMappings[ - DIMEN, - "floaty_bar_button_top_margin" - ] - fullScreenButton = resourceMappings[ - ID, - "fullscreen_button" - ] - fullScreenEngagementAdContainer = resourceMappings[ - ID, - "fullscreen_engagement_ad_container" - ] - fullScreenEngagementOverlay = resourceMappings[ - LAYOUT, - "fullscreen_engagement_overlay" - ] - fullScreenEngagementPanel = resourceMappings[ - ID, - "fullscreen_engagement_panel_holder" - ] - horizontalCardList = resourceMappings[ - LAYOUT, - "horizontal_card_list" - ] - imageOnlyTab = resourceMappings[ - LAYOUT, - "image_only_tab" - ] - inlineTimeBarColorizedBarPlayedColorDark = resourceMappings[ - COLOR, - "inline_time_bar_colorized_bar_played_color_dark" - ] - inlineTimeBarLiveSeekAbleRange = resourceMappings[ - COLOR, - "inline_time_bar_live_seekable_range" - ] - inlineTimeBarPlayedNotHighlightedColor = resourceMappings[ - COLOR, - "inline_time_bar_played_not_highlighted_color" - ] - insetOverlayViewLayout = resourceMappings[ - ID, - "inset_overlay_view_layout" - ] - interstitialsContainer = resourceMappings[ - ID, - "interstitials_container" - ] - insetElementsWrapper = resourceMappings[ - LAYOUT, - "inset_elements_wrapper" - ] - menuItemView = resourceMappings[ - ID, - "menu_item_view" - ] - metaPanel = resourceMappings[ - ID, - "metapanel" - ] - miniplayerMaxSize = resourceMappings[ - DIMEN, - "miniplayer_max_size", - ] - modernMiniPlayerClose = resourceMappings[ - ID, - "modern_miniplayer_close" - ] - modernMiniPlayerExpand = resourceMappings[ - ID, - "modern_miniplayer_expand" - ] - modernMiniPlayerForwardButton = resourceMappings[ - ID, - "modern_miniplayer_forward_button" - ] - modernMiniPlayerOverlayActionButton = resourceMappings[ - ID, - "modern_miniplayer_overlay_action_button" - ] - modernMiniPlayerRewindButton = resourceMappings[ - ID, - "modern_miniplayer_rewind_button" - ] - musicAppDeeplinkButtonView = resourceMappings[ - ID, - "music_app_deeplink_button_view" - ] - notificationBigPictureIconWidth = resourceMappings[ - DIMEN, - "notification_big_picture_icon_width" - ] - offlineActionsVideoDeletedUndoSnackbarText = resourceMappings[ - STRING, - "offline_actions_video_deleted_undo_snackbar_text" - ] - playerCollapseButton = resourceMappings[ - ID, - "player_collapse_button" - ] - playerControlPreviousButtonTouchArea = resourceMappings[ - ID, - "player_control_previous_button_touch_area" - ] - playerControlNextButtonTouchArea = resourceMappings[ - ID, - "player_control_next_button_touch_area" - ] - playerVideoTitleView = resourceMappings[ - ID, - "player_video_title_view" - ] - posterArtWidthDefault = resourceMappings[ - DIMEN, - "poster_art_width_default" - ] - qualityAuto = resourceMappings[ - STRING, - "quality_auto" - ] - quickActionsElementContainer = resourceMappings[ - ID, - "quick_actions_element_container" - ] - reelDynRemix = resourceMappings[ - ID, - "reel_dyn_remix" - ] - reelDynShare = resourceMappings[ - ID, - "reel_dyn_share" - ] - reelFeedbackLike = resourceMappings[ - ID, - "reel_feedback_like" - ] - reelFeedbackPause = resourceMappings[ - ID, - "reel_feedback_pause" - ] - reelFeedbackPlay = resourceMappings[ - ID, - "reel_feedback_play" - ] - reelForcedMuteButton = resourceMappings[ - ID, - "reel_player_forced_mute_button" - ] - reelPlayerFooter = resourceMappings[ - LAYOUT, - "reel_player_dyn_footer_vert_stories3" - ] - reelPlayerRightPivotV2Size = resourceMappings[ - DIMEN, - "reel_player_right_pivot_v2_size" - ] - reelRightDislikeIcon = resourceMappings[ - DRAWABLE, - "reel_right_dislike_icon" - ] - reelRightLikeIcon = resourceMappings[ - DRAWABLE, - "reel_right_like_icon" - ] - reelTimeBarPlayedColor = resourceMappings[ - COLOR, - "reel_time_bar_played_color" - ] - reelVodTimeStampsContainer = resourceMappings[ - ID, - "reel_vod_timestamps_container" - ] - reelWatchPlayer = resourceMappings[ - ID, - "reel_watch_player" - ] - relatedChipCloudMargin = resourceMappings[ - LAYOUT, - "related_chip_cloud_reduced_margins" - ] - rightComment = resourceMappings[ - DRAWABLE, - "ic_right_comment_32c" - ] - scrimOverlay = resourceMappings[ - ID, - "scrim_overlay" - ] - seekEasyHorizontalTouchOffsetToStartScrubbing = resourceMappings[ - DIMEN, - "seek_easy_horizontal_touch_offset_to_start_scrubbing" - ] - seekUndoEduOverlayStub = resourceMappings[ - ID, - "seek_undo_edu_overlay_stub" - ] - settingsFragment = resourceMappings[ - XML, - "settings_fragment" - ] - settingsFragmentCairo = resourceMappings[ - XML, - "settings_fragment_cairo" - ] - slidingDialogAnimation = resourceMappings[ - STYLE, - "SlidingDialogAnimation" - ] - subtitleMenuSettingsFooterInfo = resourceMappings[ - STRING, - "subtitle_menu_settings_footer_info" - ] - suggestedAction = resourceMappings[ - LAYOUT, - "suggested_action" - ] - tapBloomView = resourceMappings[ - ID, - "tap_bloom_view" - ] - titleAnchor = resourceMappings[ - ID, - "title_anchor" - ] - toolbarContainerId = resourceMappings[ - ID, - "toolbar_container" - ] - toolTipContentView = resourceMappings[ - LAYOUT, - "tooltip_content_view" - ] - totalTime = resourceMappings[ - STRING, - "total_time" - ] - touchArea = resourceMappings[ - ID, - "touch_area" - ] - videoQualityBottomSheet = resourceMappings[ - LAYOUT, - "video_quality_bottom_sheet_list_fragment_title" - ] - varispeedUnavailableTitle = resourceMappings[ - STRING, - "varispeed_unavailable_title" - ] - verticalTouchOffsetToEnterFineScrubbing = resourceMappings[ - DIMEN, - "vertical_touch_offset_to_enter_fine_scrubbing" - ] - verticalTouchOffsetToStartFineScrubbing = resourceMappings[ - DIMEN, - "vertical_touch_offset_to_start_fine_scrubbing" - ] - videoQualityUnavailableAnnouncement = resourceMappings[ - STRING, - "video_quality_unavailable_announcement" - ] - videoZoomSnapIndicator = resourceMappings[ - ID, - "video_zoom_snap_indicator" - ] - voiceSearch = resourceMappings[ - ID, - "voice_search" - ] - youTubeControlsOverlaySubtitleButton = resourceMappings[ - LAYOUT, - "youtube_controls_overlay_subtitle_button" - ] - youTubeLogo = resourceMappings[ - ID, - "youtube_logo" - ] - ytCallToAction = resourceMappings[ - ATTR, - "ytCallToAction" - ] - ytFillBell = resourceMappings[ - DRAWABLE, - "yt_fill_bell_black_24" - ] - ytOutlineLibrary = resourceMappings[ - DRAWABLE, - "yt_outline_library_black_24" - ] - ytOutlineMoonZ = resourceMappings[ - DRAWABLE, - "yt_outline_moon_z_vd_theme_24" - ] - ytOutlinePictureInPictureWhite = resourceMappings[ - DRAWABLE, - "yt_outline_picture_in_picture_white_24" - ] - ytOutlineVideoCamera = resourceMappings[ - DRAWABLE, - "yt_outline_video_camera_black_24" - ] - ytOutlineXWhite = resourceMappings[ - DRAWABLE, - "yt_outline_x_white_24" - ] - ytPremiumWordMarkHeader = resourceMappings[ - ATTR, - "ytPremiumWordmarkHeader" - ] - ytTextSecondary = resourceMappings[ - ATTR, - "ytTextSecondary", - ] - ytStaticBrandRed = resourceMappings[ - ATTR, - "ytStaticBrandRed", - ] - ytWordMarkHeader = resourceMappings[ - ATTR, - "ytWordmarkHeader" - ] - ytYoutubeMagenta = resourceMappings[ - COLOR, - "yt_youtube_magenta", - ] + accountSwitcherAccessibility = getResourceId(STRING, "account_switcher_accessibility_label") + actionBarRingo = getResourceId(LAYOUT, "action_bar_ringo") + actionBarRingoBackground = getResourceId(LAYOUT, "action_bar_ringo_background") + adAttribution = getResourceId(ID, "ad_attribution") + appearance = getResourceId(STRING, "app_theme_appearance_dark") + appRelatedEndScreenResults = getResourceId(LAYOUT, "app_related_endscreen_results") + autoNavPreviewStub = getResourceId(ID, "autonav_preview_stub") + autoNavScrollCancelPadding = getResourceId(DIMEN, "autonav_scroll_cancel_padding") + autoNavToggle = getResourceId(ID, "autonav_toggle") + backgroundCategory = getResourceId(STRING, "pref_background_and_offline_category") + badgeLabel = getResourceId(ID, "badge_label") + bar = getResourceId(LAYOUT, "bar") + barContainerHeight = getResourceId(DIMEN, "bar_container_height") + bottomBarContainer = getResourceId(ID, "bottom_bar_container") + bottomSheetFooterText = getResourceId(ID, "bottom_sheet_footer_text") + bottomSheetRecyclerView = getResourceId(LAYOUT, "bottom_sheet_recycler_view") + bottomUiContainerStub = getResourceId(ID, "bottom_ui_container_stub") + captionToggleContainer = getResourceId(ID, "caption_toggle_container") + castMediaRouteButton = getResourceId(LAYOUT, "castmediaroutebutton") + cfFullscreenButton = getResourceId(ID, "cf_fullscreen_button") + channelListSubMenu = getResourceId(LAYOUT, "channel_list_sub_menu") + compactLink = getResourceId(LAYOUT, "compact_link") + compactListItem = getResourceId(LAYOUT, "compact_list_item") + componentLongClickListener = getResourceId(ID, "component_long_click_listener") + contentPill = getResourceId(LAYOUT, "content_pill") + controlsLayoutStub = getResourceId(ID, "controls_layout_stub") + darkBackground = getResourceId(ID, "dark_background") + darkSplashAnimation = getResourceId(ID, "dark_splash_animation") + designBottomSheet = getResourceId(ID, "design_bottom_sheet") + donationCompanion = getResourceId(LAYOUT, "donation_companion") + drawerContentView = getResourceId(ID, "drawer_content_view") + drawerResults = getResourceId(ID, "drawer_results") + easySeekEduContainer = getResourceId(ID, "easy_seek_edu_container") + editSettingsAction = getResourceId(STRING, "edit_settings_action") + endScreenElementLayoutCircle = getResourceId(LAYOUT, "endscreen_element_layout_circle") + endScreenElementLayoutIcon = getResourceId(LAYOUT, "endscreen_element_layout_icon") + endScreenElementLayoutVideo = getResourceId(LAYOUT, "endscreen_element_layout_video") + emojiPickerIcon = getResourceId(ID, "emoji_picker_icon") + expandButtonDown = getResourceId(LAYOUT, "expand_button_down") + fab = getResourceId(ID, "fab") + fadeDurationFast = getResourceId(INTEGER, "fade_duration_fast") + filterBarHeight = getResourceId(DIMEN, "filter_bar_height") + floatyBarTopMargin = getResourceId(DIMEN, "floaty_bar_button_top_margin") + fullScreenButton = getResourceId(ID, "fullscreen_button") + fullScreenEngagementAdContainer = getResourceId(ID, "fullscreen_engagement_ad_container") + fullScreenEngagementOverlay = getResourceId(LAYOUT, "fullscreen_engagement_overlay") + fullScreenEngagementPanel = getResourceId(ID, "fullscreen_engagement_panel_holder") + horizontalCardList = getResourceId(LAYOUT, "horizontal_card_list") + imageOnlyTab = getResourceId(LAYOUT, "image_only_tab") + inlineTimeBarColorizedBarPlayedColorDark = getResourceId(COLOR, "inline_time_bar_colorized_bar_played_color_dark") + inlineTimeBarLiveSeekAbleRange = getResourceId(COLOR, "inline_time_bar_live_seekable_range") + inlineTimeBarPlayedNotHighlightedColor = getResourceId(COLOR, "inline_time_bar_played_not_highlighted_color") + insetOverlayViewLayout = getResourceId(ID, "inset_overlay_view_layout") + interstitialsContainer = getResourceId(ID, "interstitials_container") + insetElementsWrapper = getResourceId(LAYOUT, "inset_elements_wrapper") + menuItemView = getResourceId(ID, "menu_item_view") + metaPanel = getResourceId(ID, "metapanel") + miniplayerMaxSize = getResourceId(DIMEN, "miniplayer_max_size") + modernMiniPlayerClose = getResourceId(ID, "modern_miniplayer_close") + modernMiniPlayerExpand = getResourceId(ID, "modern_miniplayer_expand") + modernMiniPlayerForwardButton = getResourceId(ID, "modern_miniplayer_forward_button") + modernMiniPlayerOverlayActionButton = getResourceId(ID, "modern_miniplayer_overlay_action_button") + modernMiniPlayerRewindButton = getResourceId(ID, "modern_miniplayer_rewind_button") + musicAppDeeplinkButtonView = getResourceId(ID, "music_app_deeplink_button_view") + notificationBigPictureIconWidth = getResourceId(DIMEN, "notification_big_picture_icon_width") + offlineActionsVideoDeletedUndoSnackbarText = getResourceId(STRING, "offline_actions_video_deleted_undo_snackbar_text") + playerCollapseButton = getResourceId(ID, "player_collapse_button") + playerControlPreviousButtonTouchArea = getResourceId(ID, "player_control_previous_button_touch_area") + playerControlNextButtonTouchArea = getResourceId(ID, "player_control_next_button_touch_area") + playerVideoTitleView = getResourceId(ID, "player_video_title_view") + posterArtWidthDefault = getResourceId(DIMEN, "poster_art_width_default") + qualityAuto = getResourceId(STRING, "quality_auto") + quickActionsElementContainer = getResourceId(ID, "quick_actions_element_container") + reelDynRemix = getResourceId(ID, "reel_dyn_remix") + reelDynShare = getResourceId(ID, "reel_dyn_share") + reelFeedbackLike = getResourceId(ID, "reel_feedback_like") + reelFeedbackPause = getResourceId(ID, "reel_feedback_pause") + reelFeedbackPlay = getResourceId(ID, "reel_feedback_play") + reelForcedMuteButton = getResourceId(ID, "reel_player_forced_mute_button") + reelPlayerFooter = getResourceId(LAYOUT, "reel_player_dyn_footer_vert_stories3") + reelPlayerRightPivotV2Size = getResourceId(DIMEN, "reel_player_right_pivot_v2_size") + reelRightDislikeIcon = getResourceId(DRAWABLE, "reel_right_dislike_icon") + reelRightLikeIcon = getResourceId(DRAWABLE, "reel_right_like_icon") + reelTimeBarPlayedColor = getResourceId(COLOR, "reel_time_bar_played_color") + reelVodTimeStampsContainer = getResourceId(ID, "reel_vod_timestamps_container") + reelWatchPlayer = getResourceId(ID, "reel_watch_player") + relatedChipCloudMargin = getResourceId(LAYOUT, "related_chip_cloud_reduced_margins") + rightComment = getResourceId(DRAWABLE, "ic_right_comment_32c") + scrimOverlay = getResourceId(ID, "scrim_overlay") + seekEasyHorizontalTouchOffsetToStartScrubbing = getResourceId(DIMEN, "seek_easy_horizontal_touch_offset_to_start_scrubbing") + seekUndoEduOverlayStub = getResourceId(ID, "seek_undo_edu_overlay_stub") + settingsFragment = getResourceId(XML, "settings_fragment") + settingsFragmentCairo = getResourceId(XML, "settings_fragment_cairo") + slidingDialogAnimation = getResourceId(STYLE, "SlidingDialogAnimation") + subtitleMenuSettingsFooterInfo = getResourceId(STRING, "subtitle_menu_settings_footer_info") + suggestedAction = getResourceId(LAYOUT, "suggested_action") + tapBloomView = getResourceId(ID, "tap_bloom_view") + titleAnchor = getResourceId(ID, "title_anchor") + toolbarContainerId = getResourceId(ID, "toolbar_container") + toolTipContentView = getResourceId(LAYOUT, "tooltip_content_view") + totalTime = getResourceId(STRING, "total_time") + touchArea = getResourceId(ID, "touch_area") + videoQualityBottomSheet = getResourceId(LAYOUT, "video_quality_bottom_sheet_list_fragment_title") + varispeedUnavailableTitle = getResourceId(STRING, "varispeed_unavailable_title") + verticalTouchOffsetToEnterFineScrubbing = getResourceId(DIMEN, "vertical_touch_offset_to_enter_fine_scrubbing") + verticalTouchOffsetToStartFineScrubbing = getResourceId(DIMEN, "vertical_touch_offset_to_start_fine_scrubbing") + videoQualityUnavailableAnnouncement = getResourceId(STRING, "video_quality_unavailable_announcement") + videoZoomSnapIndicator = getResourceId(ID, "video_zoom_snap_indicator") + voiceSearch = getResourceId(ID, "voice_search") + youTubeControlsOverlaySubtitleButton = getResourceId(LAYOUT, "youtube_controls_overlay_subtitle_button") + youTubeLogo = getResourceId(ID, "youtube_logo") + ytCallToAction = getResourceId(ATTR, "ytCallToAction") + ytFillBell = getResourceId(DRAWABLE, "yt_fill_bell_black_24") + ytOutlineLibrary = getResourceId(DRAWABLE, "yt_outline_library_black_24") + ytOutlineMoonZ = getResourceId(DRAWABLE, "yt_outline_moon_z_vd_theme_24") + ytOutlinePictureInPictureWhite = getResourceId(DRAWABLE, "yt_outline_picture_in_picture_white_24") + ytOutlineVideoCamera = getResourceId(DRAWABLE, "yt_outline_video_camera_black_24") + ytOutlineXWhite = getResourceId(DRAWABLE, "yt_outline_x_white_24") + ytPremiumWordMarkHeader = getResourceId(ATTR, "ytPremiumWordmarkHeader") + ytTextSecondary = getResourceId(ATTR, "ytTextSecondary") + ytStaticBrandRed = getResourceId(ATTR, "ytStaticBrandRed") + ytWordMarkHeader = getResourceId(ATTR, "ytWordmarkHeader") + ytYoutubeMagenta = getResourceId(COLOR, "yt_youtube_magenta") } } \ No newline at end of file diff --git a/patches/src/main/kotlin/app/revanced/util/BytecodeUtils.kt b/patches/src/main/kotlin/app/revanced/util/BytecodeUtils.kt index 18edf0a80..1e5910f03 100644 --- a/patches/src/main/kotlin/app/revanced/util/BytecodeUtils.kt +++ b/patches/src/main/kotlin/app/revanced/util/BytecodeUtils.kt @@ -17,9 +17,8 @@ import app.revanced.patcher.util.proxy.mutableTypes.MutableClass import app.revanced.patcher.util.proxy.mutableTypes.MutableField.Companion.toMutable import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod.Companion.toMutable -import app.revanced.patches.shared.mapping.get +import app.revanced.patches.shared.mapping.getResourceId import app.revanced.patches.shared.mapping.resourceMappingPatch -import app.revanced.patches.shared.mapping.resourceMappings import app.revanced.util.Utils.printWarn import com.android.tools.smali.dexlib2.AccessFlags import com.android.tools.smali.dexlib2.Opcode @@ -134,7 +133,7 @@ internal fun MutableMethod.addInstructionsAtControlFlowLabel( * @see [indexOfFirstResourceIdOrThrow], [indexOfFirstLiteralInstructionReversed] */ fun Method.indexOfFirstResourceId(resourceName: String): Int { - val resourceId = resourceMappings["id", resourceName] + val resourceId = getResourceId("id", resourceName) if (resourceId == -1L) { printWarn("Could not find resource type: id name: $name") return -1