refactor: Use map instead of list to lookup resource ids

This commit is contained in:
inotia00 2025-03-28 19:09:31 +09:00
parent f3abc04812
commit 8169ccacc2
5 changed files with 212 additions and 767 deletions

View File

@ -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.LAYOUT
import app.revanced.patches.shared.mapping.ResourceType.STRING import app.revanced.patches.shared.mapping.ResourceType.STRING
import app.revanced.patches.shared.mapping.ResourceType.STYLE 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.resourceMappingPatch
import app.revanced.patches.shared.mapping.resourceMappings
var accountSwitcherAccessibility = -1L var accountSwitcherAccessibility = -1L
private set private set
@ -126,217 +125,58 @@ internal val sharedResourceIdPatch = resourcePatch(
dependsOn(resourceMappingPatch) dependsOn(resourceMappingPatch)
execute { execute {
accountSwitcherAccessibility = resourceMappings[ accountSwitcherAccessibility = getResourceId(STRING, "account_switcher_accessibility_label")
STRING, actionBarLogo = getResourceId(DRAWABLE, "action_bar_logo")
"account_switcher_accessibility_label", actionBarLogoRingo2 = getResourceId(DRAWABLE, "action_bar_logo_ringo2")
] bottomSheetRecyclerView = getResourceId(LAYOUT, "bottom_sheet_recycler_view")
actionBarLogo = resourceMappings[ buttonContainer = getResourceId(ID, "button_container")
DRAWABLE, buttonIconPaddingMedium = getResourceId(DIMEN, "button_icon_padding_medium")
"action_bar_logo", chipCloud = getResourceId(LAYOUT, "chip_cloud")
] colorGrey = getResourceId(COLOR, "ytm_color_grey_12")
actionBarLogoRingo2 = resourceMappings[ darkBackground = getResourceId(ID, "dark_background")
DRAWABLE, designBottomSheetDialog = getResourceId(LAYOUT, "design_bottom_sheet_dialog")
"action_bar_logo_ringo2", elementsContainer = getResourceId(ID, "elements_container")
] endButtonsContainer = getResourceId(ID, "end_buttons_container")
bottomSheetRecyclerView = resourceMappings[ floatingLayout = getResourceId(ID, "floating_layout")
LAYOUT, historyMenuItem = getResourceId(ID, "history_menu_item")
"bottom_sheet_recycler_view" inlineTimeBarAdBreakMarkerColor = getResourceId(COLOR, "inline_time_bar_ad_break_marker_color")
] inlineTimeBarProgressColor = getResourceId(COLOR, "inline_time_bar_progress_color")
buttonContainer = resourceMappings[ interstitialsContainer = getResourceId(ID, "interstitials_container")
ID, isTablet = getResourceId(BOOL, "is_tablet")
"button_container" likeDislikeContainer = getResourceId(ID, "like_dislike_container")
] mainActivityLaunchAnimation = getResourceId(LAYOUT, "main_activity_launch_animation")
buttonIconPaddingMedium = resourceMappings[ menuEntry = getResourceId(LAYOUT, "menu_entry")
DIMEN, miniPlayerDefaultText = getResourceId(STRING, "mini_player_default_text")
"button_icon_padding_medium" miniPlayerMdxPlaying = getResourceId(STRING, "mini_player_mdx_playing")
] miniPlayerPlayPauseReplayButton = getResourceId(ID, "mini_player_play_pause_replay_button")
chipCloud = resourceMappings[ miniPlayerViewPager = getResourceId(ID, "mini_player_view_pager")
LAYOUT, modernDialogBackground = getResourceId(DRAWABLE, "modern_dialog_background")
"chip_cloud" musicNotifierShelf = getResourceId(LAYOUT, "music_notifier_shelf")
] musicTasteBuilderShelf = getResourceId(LAYOUT, "music_tastebuilder_shelf")
colorGrey = resourceMappings[ namesInactiveAccountThumbnailSize = getResourceId(DIMEN, "names_inactive_account_thumbnail_size")
COLOR, offlineSettingsMenuItem = getResourceId(ID, "offline_settings_menu_item")
"ytm_color_grey_12" playerOverlayChip = getResourceId(ID, "player_overlay_chip")
] playerViewPager = getResourceId(ID, "player_view_pager")
darkBackground = resourceMappings[ privacyTosFooter = getResourceId(ID, "privacy_tos_footer")
ID, qualityAuto = getResourceId(STRING, "quality_auto")
"dark_background" remixGenericButtonSize = getResourceId(DIMEN, "remix_generic_button_size")
] searchButton = getResourceId(LAYOUT, "search_button")
designBottomSheetDialog = resourceMappings[ slidingDialogAnimation = getResourceId(STYLE, "SlidingDialogAnimation")
LAYOUT, tapBloomView = getResourceId(ID, "tap_bloom_view")
"design_bottom_sheet_dialog" text1 = getResourceId(ID, "text1")
] toolTipContentView = getResourceId(LAYOUT, "tooltip_content_view")
elementsContainer = resourceMappings[ topEnd = getResourceId(ID, "TOP_END")
ID, topStart = getResourceId(ID, "TOP_START")
"elements_container" topBarMenuItemImageView = getResourceId(ID, "top_bar_menu_item_image_view")
] tosFooter = getResourceId(ID, "tos_footer")
endButtonsContainer = resourceMappings[ touchOutside = getResourceId(ID, "touch_outside")
ID, trimSilenceSwitch = getResourceId(ID, "trim_silence_switch")
"end_buttons_container" varispeedUnavailableTitle = getResourceId(STRING, "varispeed_unavailable_title")
] ytFillSamples = getResourceId(DRAWABLE, "yt_fill_samples_vd_theme_24")
floatingLayout = resourceMappings[ ytFillYouTubeMusic = getResourceId(DRAWABLE, "yt_fill_youtube_music_vd_theme_24")
ID, ytOutlineSamples = getResourceId(DRAWABLE, "yt_outline_samples_vd_theme_24")
"floating_layout" ytOutlineYouTubeMusic = getResourceId(DRAWABLE, "yt_outline_youtube_music_vd_theme_24")
] ytmLogo = getResourceId(DRAWABLE, "ytm_logo")
historyMenuItem = resourceMappings[ ytmLogoRingo2 = getResourceId(DRAWABLE, "ytm_logo_ringo2")
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",
]
} }
} }

View File

@ -2,9 +2,8 @@ package app.revanced.patches.reddit.utils.resourceid
import app.revanced.patcher.patch.resourcePatch import app.revanced.patcher.patch.resourcePatch
import app.revanced.patches.shared.mapping.ResourceType.STRING 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.resourceMappingPatch
import app.revanced.patches.shared.mapping.resourceMappings
var screenShotShareBanner = -1L var screenShotShareBanner = -1L
private set private set
@ -15,9 +14,6 @@ internal val sharedResourceIdPatch = resourcePatch(
dependsOn(resourceMappingPatch) dependsOn(resourceMappingPatch)
execute { execute {
screenShotShareBanner = resourceMappings[ screenShotShareBanner = getResourceId(STRING, "screenshot_share_banner_title")
STRING,
"screenshot_share_banner_title",
]
} }
} }

View File

@ -1,72 +1,52 @@
package app.revanced.patches.shared.mapping package app.revanced.patches.shared.mapping
import app.revanced.patcher.patch.PatchException
import app.revanced.patcher.patch.resourcePatch import app.revanced.patcher.patch.resourcePatch
import org.w3c.dom.Element 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. data class ResourceElement(val type: String, val name: String, val id: Long)
lateinit var resourceMappings: List<ResourceElement>
private set private lateinit var resourceMappings: MutableMap<String, ResourceElement>
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( val resourceMappingPatch = resourcePatch(
description = "resourceMappingPatch" description = "resourceMappingPatch"
) { ) {
val threadCount = Runtime.getRuntime().availableProcessors()
val threadPoolExecutor = Executors.newFixedThreadPool(threadCount)
val resourceMappings = Collections.synchronizedList(mutableListOf<ResourceElement>())
execute { execute {
// Save the file in memory to concurrently read from it. document("res/values/public.xml").use { document ->
val resourceXmlFile = get("res/values/public.xml").readBytes()
for (threadIndex in 0 until threadCount) {
threadPoolExecutor.execute thread@{
document(resourceXmlFile.inputStream()).use { document ->
val resources = document.documentElement.childNodes val resources = document.documentElement.childNodes
val resourcesLength = resources.length val resourcesLength = resources.length
val jobSize = resourcesLength / threadCount resourceMappings = HashMap<String, ResourceElement>(2 * resourcesLength)
val batchStart = jobSize * threadIndex for (i in 0 until resourcesLength) {
val batchEnd = jobSize * (threadIndex + 1) val node = resources.item(i) as? Element ?: continue
element@ for (i in batchStart until batchEnd) { if (node.nodeName != "public") continue
// Prevent out of bounds.
if (i >= resourcesLength) return@thread
val node = resources.item(i)
if (node !is Element) continue
val nameAttribute = node.getAttribute("name") val nameAttribute = node.getAttribute("name")
if (nameAttribute.startsWith("APKTOOL")) continue
val typeAttribute = node.getAttribute("type") val typeAttribute = node.getAttribute("type")
if (node.nodeName != "public" || nameAttribute.startsWith("APKTOOL")) continue
val id = node.getAttribute("id").substring(2).toLong(16) 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<ResourceElement>.get(type: String, name: String) = resourceMappings.firstOrNull {
it.type == type && it.name == name
}?.id ?: -1L
operator fun List<ResourceElement>.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) { enum class ResourceType(val value: String) {
ATTR("attr"), ATTR("attr"),
BOOL("bool"), BOOL("bool"),

View File

@ -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.STRING
import app.revanced.patches.shared.mapping.ResourceType.STYLE import app.revanced.patches.shared.mapping.ResourceType.STYLE
import app.revanced.patches.shared.mapping.ResourceType.XML 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.resourceMappingPatch
import app.revanced.patches.shared.mapping.resourceMappings
var accountSwitcherAccessibility = -1L var accountSwitcherAccessibility = -1L
private set private set
@ -268,497 +267,128 @@ internal val sharedResourceIdPatch = resourcePatch(
dependsOn(resourceMappingPatch) dependsOn(resourceMappingPatch)
execute { execute {
accountSwitcherAccessibility = resourceMappings[ accountSwitcherAccessibility = getResourceId(STRING, "account_switcher_accessibility_label")
STRING, actionBarRingo = getResourceId(LAYOUT, "action_bar_ringo")
"account_switcher_accessibility_label" actionBarRingoBackground = getResourceId(LAYOUT, "action_bar_ringo_background")
] adAttribution = getResourceId(ID, "ad_attribution")
actionBarRingo = resourceMappings[ appearance = getResourceId(STRING, "app_theme_appearance_dark")
LAYOUT, appRelatedEndScreenResults = getResourceId(LAYOUT, "app_related_endscreen_results")
"action_bar_ringo" autoNavPreviewStub = getResourceId(ID, "autonav_preview_stub")
] autoNavScrollCancelPadding = getResourceId(DIMEN, "autonav_scroll_cancel_padding")
actionBarRingoBackground = resourceMappings[ autoNavToggle = getResourceId(ID, "autonav_toggle")
LAYOUT, backgroundCategory = getResourceId(STRING, "pref_background_and_offline_category")
"action_bar_ringo_background" badgeLabel = getResourceId(ID, "badge_label")
] bar = getResourceId(LAYOUT, "bar")
adAttribution = resourceMappings[ barContainerHeight = getResourceId(DIMEN, "bar_container_height")
ID, bottomBarContainer = getResourceId(ID, "bottom_bar_container")
"ad_attribution" bottomSheetFooterText = getResourceId(ID, "bottom_sheet_footer_text")
] bottomSheetRecyclerView = getResourceId(LAYOUT, "bottom_sheet_recycler_view")
appearance = resourceMappings[ bottomUiContainerStub = getResourceId(ID, "bottom_ui_container_stub")
STRING, captionToggleContainer = getResourceId(ID, "caption_toggle_container")
"app_theme_appearance_dark" castMediaRouteButton = getResourceId(LAYOUT, "castmediaroutebutton")
] cfFullscreenButton = getResourceId(ID, "cf_fullscreen_button")
appRelatedEndScreenResults = resourceMappings[ channelListSubMenu = getResourceId(LAYOUT, "channel_list_sub_menu")
LAYOUT, compactLink = getResourceId(LAYOUT, "compact_link")
"app_related_endscreen_results" compactListItem = getResourceId(LAYOUT, "compact_list_item")
] componentLongClickListener = getResourceId(ID, "component_long_click_listener")
autoNavPreviewStub = resourceMappings[ contentPill = getResourceId(LAYOUT, "content_pill")
ID, controlsLayoutStub = getResourceId(ID, "controls_layout_stub")
"autonav_preview_stub" darkBackground = getResourceId(ID, "dark_background")
] darkSplashAnimation = getResourceId(ID, "dark_splash_animation")
autoNavScrollCancelPadding = resourceMappings[ designBottomSheet = getResourceId(ID, "design_bottom_sheet")
DIMEN, donationCompanion = getResourceId(LAYOUT, "donation_companion")
"autonav_scroll_cancel_padding" drawerContentView = getResourceId(ID, "drawer_content_view")
] drawerResults = getResourceId(ID, "drawer_results")
autoNavToggle = resourceMappings[ easySeekEduContainer = getResourceId(ID, "easy_seek_edu_container")
ID, editSettingsAction = getResourceId(STRING, "edit_settings_action")
"autonav_toggle" endScreenElementLayoutCircle = getResourceId(LAYOUT, "endscreen_element_layout_circle")
] endScreenElementLayoutIcon = getResourceId(LAYOUT, "endscreen_element_layout_icon")
backgroundCategory = resourceMappings[ endScreenElementLayoutVideo = getResourceId(LAYOUT, "endscreen_element_layout_video")
STRING, emojiPickerIcon = getResourceId(ID, "emoji_picker_icon")
"pref_background_and_offline_category" expandButtonDown = getResourceId(LAYOUT, "expand_button_down")
] fab = getResourceId(ID, "fab")
badgeLabel = resourceMappings[ fadeDurationFast = getResourceId(INTEGER, "fade_duration_fast")
ID, filterBarHeight = getResourceId(DIMEN, "filter_bar_height")
"badge_label" floatyBarTopMargin = getResourceId(DIMEN, "floaty_bar_button_top_margin")
] fullScreenButton = getResourceId(ID, "fullscreen_button")
bar = resourceMappings[ fullScreenEngagementAdContainer = getResourceId(ID, "fullscreen_engagement_ad_container")
LAYOUT, fullScreenEngagementOverlay = getResourceId(LAYOUT, "fullscreen_engagement_overlay")
"bar" fullScreenEngagementPanel = getResourceId(ID, "fullscreen_engagement_panel_holder")
] horizontalCardList = getResourceId(LAYOUT, "horizontal_card_list")
barContainerHeight = resourceMappings[ imageOnlyTab = getResourceId(LAYOUT, "image_only_tab")
DIMEN, inlineTimeBarColorizedBarPlayedColorDark = getResourceId(COLOR, "inline_time_bar_colorized_bar_played_color_dark")
"bar_container_height" inlineTimeBarLiveSeekAbleRange = getResourceId(COLOR, "inline_time_bar_live_seekable_range")
] inlineTimeBarPlayedNotHighlightedColor = getResourceId(COLOR, "inline_time_bar_played_not_highlighted_color")
bottomBarContainer = resourceMappings[ insetOverlayViewLayout = getResourceId(ID, "inset_overlay_view_layout")
ID, interstitialsContainer = getResourceId(ID, "interstitials_container")
"bottom_bar_container" insetElementsWrapper = getResourceId(LAYOUT, "inset_elements_wrapper")
] menuItemView = getResourceId(ID, "menu_item_view")
bottomSheetFooterText = resourceMappings[ metaPanel = getResourceId(ID, "metapanel")
ID, miniplayerMaxSize = getResourceId(DIMEN, "miniplayer_max_size")
"bottom_sheet_footer_text" modernMiniPlayerClose = getResourceId(ID, "modern_miniplayer_close")
] modernMiniPlayerExpand = getResourceId(ID, "modern_miniplayer_expand")
bottomSheetRecyclerView = resourceMappings[ modernMiniPlayerForwardButton = getResourceId(ID, "modern_miniplayer_forward_button")
LAYOUT, modernMiniPlayerOverlayActionButton = getResourceId(ID, "modern_miniplayer_overlay_action_button")
"bottom_sheet_recycler_view" modernMiniPlayerRewindButton = getResourceId(ID, "modern_miniplayer_rewind_button")
] musicAppDeeplinkButtonView = getResourceId(ID, "music_app_deeplink_button_view")
bottomUiContainerStub = resourceMappings[ notificationBigPictureIconWidth = getResourceId(DIMEN, "notification_big_picture_icon_width")
ID, offlineActionsVideoDeletedUndoSnackbarText = getResourceId(STRING, "offline_actions_video_deleted_undo_snackbar_text")
"bottom_ui_container_stub" playerCollapseButton = getResourceId(ID, "player_collapse_button")
] playerControlPreviousButtonTouchArea = getResourceId(ID, "player_control_previous_button_touch_area")
captionToggleContainer = resourceMappings[ playerControlNextButtonTouchArea = getResourceId(ID, "player_control_next_button_touch_area")
ID, playerVideoTitleView = getResourceId(ID, "player_video_title_view")
"caption_toggle_container" posterArtWidthDefault = getResourceId(DIMEN, "poster_art_width_default")
] qualityAuto = getResourceId(STRING, "quality_auto")
castMediaRouteButton = resourceMappings[ quickActionsElementContainer = getResourceId(ID, "quick_actions_element_container")
LAYOUT, reelDynRemix = getResourceId(ID, "reel_dyn_remix")
"castmediaroutebutton" reelDynShare = getResourceId(ID, "reel_dyn_share")
] reelFeedbackLike = getResourceId(ID, "reel_feedback_like")
cfFullscreenButton = resourceMappings[ reelFeedbackPause = getResourceId(ID, "reel_feedback_pause")
ID, reelFeedbackPlay = getResourceId(ID, "reel_feedback_play")
"cf_fullscreen_button" reelForcedMuteButton = getResourceId(ID, "reel_player_forced_mute_button")
] reelPlayerFooter = getResourceId(LAYOUT, "reel_player_dyn_footer_vert_stories3")
channelListSubMenu = resourceMappings[ reelPlayerRightPivotV2Size = getResourceId(DIMEN, "reel_player_right_pivot_v2_size")
LAYOUT, reelRightDislikeIcon = getResourceId(DRAWABLE, "reel_right_dislike_icon")
"channel_list_sub_menu" reelRightLikeIcon = getResourceId(DRAWABLE, "reel_right_like_icon")
] reelTimeBarPlayedColor = getResourceId(COLOR, "reel_time_bar_played_color")
compactLink = resourceMappings[ reelVodTimeStampsContainer = getResourceId(ID, "reel_vod_timestamps_container")
LAYOUT, reelWatchPlayer = getResourceId(ID, "reel_watch_player")
"compact_link" relatedChipCloudMargin = getResourceId(LAYOUT, "related_chip_cloud_reduced_margins")
] rightComment = getResourceId(DRAWABLE, "ic_right_comment_32c")
compactListItem = resourceMappings[ scrimOverlay = getResourceId(ID, "scrim_overlay")
LAYOUT, seekEasyHorizontalTouchOffsetToStartScrubbing = getResourceId(DIMEN, "seek_easy_horizontal_touch_offset_to_start_scrubbing")
"compact_list_item" seekUndoEduOverlayStub = getResourceId(ID, "seek_undo_edu_overlay_stub")
] settingsFragment = getResourceId(XML, "settings_fragment")
componentLongClickListener = resourceMappings[ settingsFragmentCairo = getResourceId(XML, "settings_fragment_cairo")
ID, slidingDialogAnimation = getResourceId(STYLE, "SlidingDialogAnimation")
"component_long_click_listener" subtitleMenuSettingsFooterInfo = getResourceId(STRING, "subtitle_menu_settings_footer_info")
] suggestedAction = getResourceId(LAYOUT, "suggested_action")
contentPill = resourceMappings[ tapBloomView = getResourceId(ID, "tap_bloom_view")
LAYOUT, titleAnchor = getResourceId(ID, "title_anchor")
"content_pill" toolbarContainerId = getResourceId(ID, "toolbar_container")
] toolTipContentView = getResourceId(LAYOUT, "tooltip_content_view")
controlsLayoutStub = resourceMappings[ totalTime = getResourceId(STRING, "total_time")
ID, touchArea = getResourceId(ID, "touch_area")
"controls_layout_stub" videoQualityBottomSheet = getResourceId(LAYOUT, "video_quality_bottom_sheet_list_fragment_title")
] varispeedUnavailableTitle = getResourceId(STRING, "varispeed_unavailable_title")
darkBackground = resourceMappings[ verticalTouchOffsetToEnterFineScrubbing = getResourceId(DIMEN, "vertical_touch_offset_to_enter_fine_scrubbing")
ID, verticalTouchOffsetToStartFineScrubbing = getResourceId(DIMEN, "vertical_touch_offset_to_start_fine_scrubbing")
"dark_background" videoQualityUnavailableAnnouncement = getResourceId(STRING, "video_quality_unavailable_announcement")
] videoZoomSnapIndicator = getResourceId(ID, "video_zoom_snap_indicator")
darkSplashAnimation = resourceMappings[ voiceSearch = getResourceId(ID, "voice_search")
ID, youTubeControlsOverlaySubtitleButton = getResourceId(LAYOUT, "youtube_controls_overlay_subtitle_button")
"dark_splash_animation" youTubeLogo = getResourceId(ID, "youtube_logo")
] ytCallToAction = getResourceId(ATTR, "ytCallToAction")
designBottomSheet = resourceMappings[ ytFillBell = getResourceId(DRAWABLE, "yt_fill_bell_black_24")
ID, ytOutlineLibrary = getResourceId(DRAWABLE, "yt_outline_library_black_24")
"design_bottom_sheet" ytOutlineMoonZ = getResourceId(DRAWABLE, "yt_outline_moon_z_vd_theme_24")
] ytOutlinePictureInPictureWhite = getResourceId(DRAWABLE, "yt_outline_picture_in_picture_white_24")
donationCompanion = resourceMappings[ ytOutlineVideoCamera = getResourceId(DRAWABLE, "yt_outline_video_camera_black_24")
LAYOUT, ytOutlineXWhite = getResourceId(DRAWABLE, "yt_outline_x_white_24")
"donation_companion" ytPremiumWordMarkHeader = getResourceId(ATTR, "ytPremiumWordmarkHeader")
] ytTextSecondary = getResourceId(ATTR, "ytTextSecondary")
drawerContentView = resourceMappings[ ytStaticBrandRed = getResourceId(ATTR, "ytStaticBrandRed")
ID, ytWordMarkHeader = getResourceId(ATTR, "ytWordmarkHeader")
"drawer_content_view" ytYoutubeMagenta = getResourceId(COLOR, "yt_youtube_magenta")
]
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",
]
} }
} }

View File

@ -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.MutableField.Companion.toMutable
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod.Companion.toMutable 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.resourceMappingPatch
import app.revanced.patches.shared.mapping.resourceMappings
import app.revanced.util.Utils.printWarn import app.revanced.util.Utils.printWarn
import com.android.tools.smali.dexlib2.AccessFlags import com.android.tools.smali.dexlib2.AccessFlags
import com.android.tools.smali.dexlib2.Opcode import com.android.tools.smali.dexlib2.Opcode
@ -134,7 +133,7 @@ internal fun MutableMethod.addInstructionsAtControlFlowLabel(
* @see [indexOfFirstResourceIdOrThrow], [indexOfFirstLiteralInstructionReversed] * @see [indexOfFirstResourceIdOrThrow], [indexOfFirstLiteralInstructionReversed]
*/ */
fun Method.indexOfFirstResourceId(resourceName: String): Int { fun Method.indexOfFirstResourceId(resourceName: String): Int {
val resourceId = resourceMappings["id", resourceName] val resourceId = getResourceId("id", resourceName)
if (resourceId == -1L) { if (resourceId == -1L) {
printWarn("Could not find resource type: id name: $name") printWarn("Could not find resource type: id name: $name")
return -1 return -1