mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-05-01 07:04:30 +02:00
refactor(shared-resource-id): move resource type to enum
This commit is contained in:
parent
9b3adf928c
commit
0079846a12
@ -9,6 +9,8 @@ import app.revanced.patcher.patch.ResourcePatch
|
||||
import app.revanced.patcher.patch.annotations.DependsOn
|
||||
import app.revanced.patches.shared.annotation.YouTubeMusicCompatibility
|
||||
import app.revanced.patches.shared.patch.mapping.ResourceMappingPatch
|
||||
import app.revanced.util.enum.ResourceType
|
||||
import app.revanced.util.enum.ResourceType.*
|
||||
|
||||
@Name("music-resource-id")
|
||||
@DependsOn([ResourceMappingPatch::class])
|
||||
@ -25,15 +27,15 @@ class SharedResourceIdPatch : ResourcePatch {
|
||||
|
||||
override fun execute(context: ResourceContext): PatchResult {
|
||||
|
||||
fun findSharedResourceId(type: String, name: String) = ResourceMappingPatch
|
||||
fun find(type: ResourceType, name: String) = ResourceMappingPatch
|
||||
.resourceMappings
|
||||
.single { it.type == type && it.name == name }.id
|
||||
.single { it.type == type.value && it.name == name }.id
|
||||
|
||||
colorGreyLabelId = findSharedResourceId("color", "ytm_color_grey_12")
|
||||
dialogSolidLabelId = findSharedResourceId("style", "Theme.YouTubeMusic.Dialog.Solid")
|
||||
disabledIconLabelId = findSharedResourceId("dimen", "disabled_icon_alpha")
|
||||
floatingActionButtonLabelId = findSharedResourceId("id", "floating_action_button")
|
||||
isTabletLabelId = findSharedResourceId("bool", "is_tablet")
|
||||
colorGreyLabelId = find(COLOR, "ytm_color_grey_12")
|
||||
dialogSolidLabelId = find(STYLE, "Theme.YouTubeMusic.Dialog.Solid")
|
||||
disabledIconLabelId = find(DIMEN, "disabled_icon_alpha")
|
||||
floatingActionButtonLabelId = find(ID, "floating_action_button")
|
||||
isTabletLabelId = find(BOOL, "is_tablet")
|
||||
|
||||
return PatchResultSuccess()
|
||||
}
|
||||
|
@ -9,6 +9,8 @@ import app.revanced.patcher.patch.ResourcePatch
|
||||
import app.revanced.patcher.patch.annotations.DependsOn
|
||||
import app.revanced.patches.shared.annotation.YouTubeCompatibility
|
||||
import app.revanced.patches.shared.patch.mapping.ResourceMappingPatch
|
||||
import app.revanced.util.enum.ResourceType
|
||||
import app.revanced.util.enum.ResourceType.*
|
||||
|
||||
@Name("shared-resource-id")
|
||||
@DependsOn([ResourceMappingPatch::class])
|
||||
@ -47,37 +49,37 @@ class SharedResourceIdPatch : ResourcePatch {
|
||||
|
||||
override fun execute(context: ResourceContext): PatchResult {
|
||||
|
||||
fun findSharedResourceId(type: String, name: String) = ResourceMappingPatch
|
||||
fun find(type: ResourceType, name: String) = ResourceMappingPatch
|
||||
.resourceMappings
|
||||
.single { it.type == type && it.name == name }.id
|
||||
.single { it.type == type.value && it.name == name }.id
|
||||
|
||||
accessibilityProgressTimeLabelId = findSharedResourceId("string", "accessibility_player_progress_time")
|
||||
accountSwitcherAccessibilityLabelId = findSharedResourceId("string", "account_switcher_accessibility_label")
|
||||
appearanceStringId = findSharedResourceId("string", "app_theme_appearance_dark")
|
||||
backgroundCategoryLabelId = findSharedResourceId("string", "pref_background_and_offline_category")
|
||||
barContainerHeightLabelId = findSharedResourceId("dimen", "bar_container_height")
|
||||
bottomUiContainerResourceId = findSharedResourceId("id", "bottom_ui_container_stub")
|
||||
channelListSubMenuLabelId = findSharedResourceId("layout", "channel_list_sub_menu")
|
||||
chapterRepeatOnResourceId = findSharedResourceId("string", "chapter_repeat_on")
|
||||
compactLinkLabelId = findSharedResourceId("layout", "compact_link")
|
||||
controlsLayoutStubResourceId = findSharedResourceId("id", "controls_layout_stub")
|
||||
donationCompanionResourceId = findSharedResourceId("layout", "donation_companion")
|
||||
emptyColorLabelId = findSharedResourceId("color", "inline_time_bar_colorized_bar_empty_color_dark")
|
||||
fabLabelId = findSharedResourceId("id", "fab")
|
||||
filterBarHeightLabelId = findSharedResourceId("dimen", "filter_bar_height")
|
||||
floatyBarQueueLabelId = findSharedResourceId("string", "floaty_bar_queue_status")
|
||||
imageOnlyTabId = findSharedResourceId("layout", "image_only_tab")
|
||||
imageWithTextTabId = findSharedResourceId("layout", "image_with_text_tab")
|
||||
layoutCircle = findSharedResourceId("layout", "endscreen_element_layout_circle")
|
||||
layoutIcon = findSharedResourceId("layout", "endscreen_element_layout_icon")
|
||||
layoutVideo = findSharedResourceId("layout", "endscreen_element_layout_video")
|
||||
liveChatButtonId = findSharedResourceId("id", "live_chat_overlay_button")
|
||||
reelPlayerFooterLabelId = findSharedResourceId("layout", "reel_player_dyn_footer_vert_stories3")
|
||||
relatedChipCloudMarginLabelId = findSharedResourceId("layout", "related_chip_cloud_reduced_margins")
|
||||
scrubbingLabelId = findSharedResourceId("dimen", "vertical_touch_offset_to_enter_fine_scrubbing")
|
||||
timeStampsContainerLabelId = findSharedResourceId("id", "timestamps_container")
|
||||
tooltipLabelId = findSharedResourceId("layout", "tooltip_content_view")
|
||||
videoQualityFragmentLabelId = findSharedResourceId("layout", "video_quality_bottom_sheet_list_fragment_title")
|
||||
accessibilityProgressTimeLabelId = find(STRING, "accessibility_player_progress_time")
|
||||
accountSwitcherAccessibilityLabelId = find(STRING, "account_switcher_accessibility_label")
|
||||
appearanceStringId = find(STRING, "app_theme_appearance_dark")
|
||||
backgroundCategoryLabelId = find(STRING, "pref_background_and_offline_category")
|
||||
barContainerHeightLabelId = find(DIMEN, "bar_container_height")
|
||||
bottomUiContainerResourceId = find(ID, "bottom_ui_container_stub")
|
||||
channelListSubMenuLabelId = find(LAYOUT, "channel_list_sub_menu")
|
||||
chapterRepeatOnResourceId = find(STRING, "chapter_repeat_on")
|
||||
compactLinkLabelId = find(LAYOUT, "compact_link")
|
||||
controlsLayoutStubResourceId = find(ID, "controls_layout_stub")
|
||||
donationCompanionResourceId = find(LAYOUT, "donation_companion")
|
||||
emptyColorLabelId = find(COLOR, "inline_time_bar_colorized_bar_empty_color_dark")
|
||||
fabLabelId = find(ID, "fab")
|
||||
filterBarHeightLabelId = find(DIMEN, "filter_bar_height")
|
||||
floatyBarQueueLabelId = find(STRING, "floaty_bar_queue_status")
|
||||
imageOnlyTabId = find(LAYOUT, "image_only_tab")
|
||||
imageWithTextTabId = find(LAYOUT, "image_with_text_tab")
|
||||
layoutCircle = find(LAYOUT, "endscreen_element_layout_circle")
|
||||
layoutIcon = find(LAYOUT, "endscreen_element_layout_icon")
|
||||
layoutVideo = find(LAYOUT, "endscreen_element_layout_video")
|
||||
liveChatButtonId = find(ID, "live_chat_overlay_button")
|
||||
reelPlayerFooterLabelId = find(LAYOUT, "reel_player_dyn_footer_vert_stories3")
|
||||
relatedChipCloudMarginLabelId = find(LAYOUT, "related_chip_cloud_reduced_margins")
|
||||
scrubbingLabelId = find(DIMEN, "vertical_touch_offset_to_enter_fine_scrubbing")
|
||||
timeStampsContainerLabelId = find(ID, "timestamps_container")
|
||||
tooltipLabelId = find(LAYOUT, "tooltip_content_view")
|
||||
videoQualityFragmentLabelId = find(LAYOUT, "video_quality_bottom_sheet_list_fragment_title")
|
||||
|
||||
return PatchResultSuccess()
|
||||
}
|
||||
|
12
src/main/kotlin/app/revanced/util/enum/ResourceType.kt
Normal file
12
src/main/kotlin/app/revanced/util/enum/ResourceType.kt
Normal file
@ -0,0 +1,12 @@
|
||||
package app.revanced.util.enum
|
||||
|
||||
internal enum class ResourceType(val value: String) {
|
||||
BOOL("bool"),
|
||||
COLOR("color"),
|
||||
DIMEN("dimen"),
|
||||
DRAWABLE("drawable"),
|
||||
ID("id"),
|
||||
LAYOUT("layout"),
|
||||
STRING("string"),
|
||||
STYLE("style")
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user