feat(shared-resource-id) If the target resource ID is not found, empty index is returned instead of generating patch exception

This commit is contained in:
inotia00 2023-09-05 12:32:29 +09:00
parent 1b5eb0561f
commit 6686088fc8
3 changed files with 3 additions and 6 deletions

View File

@ -1,7 +1,6 @@
package app.revanced.patches.music.utils.resourceid.patch
import app.revanced.patcher.data.ResourceContext
import app.revanced.patcher.patch.PatchException
import app.revanced.patcher.patch.ResourcePatch
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patches.shared.patch.mapping.ResourceMappingPatch
@ -37,7 +36,7 @@ class SharedResourceIdPatch : ResourcePatch {
fun find(resourceType: ResourceType, resourceName: String) = ResourceMappingPatch
.resourceMappings
.find { it.type == resourceType.value && it.name == resourceName }?.id
?: throw PatchException("Failed to find resource id : $resourceName")
?: -1
ActionsContainer = find(ID, "actions_container")
ButtonIconPaddingMedium = find(DIMEN, "button_icon_padding_medium")

View File

@ -1,7 +1,6 @@
package app.revanced.patches.reddit.utils.resourceid.patch
import app.revanced.patcher.data.ResourceContext
import app.revanced.patcher.patch.PatchException
import app.revanced.patcher.patch.ResourcePatch
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patches.shared.patch.mapping.ResourceMappingPatch
@ -19,7 +18,7 @@ class SharedResourceIdPatch : ResourcePatch {
fun find(resourceType: ResourceType, resourceName: String) = ResourceMappingPatch
.resourceMappings
.find { it.type == resourceType.value && it.name == resourceName }?.id
?: throw PatchException("Failed to find resource id : $resourceName")
?: -1
ScreenShotShareBanner = find(STRING, "screenshot_share_banner_title")

View File

@ -1,7 +1,6 @@
package app.revanced.patches.youtube.utils.resourceid.patch
import app.revanced.patcher.data.ResourceContext
import app.revanced.patcher.patch.PatchException
import app.revanced.patcher.patch.ResourcePatch
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patches.shared.patch.mapping.ResourceMappingPatch
@ -89,7 +88,7 @@ class SharedResourceIdPatch : ResourcePatch {
fun find(resourceType: ResourceType, resourceName: String) = ResourceMappingPatch
.resourceMappings
.find { it.type == resourceType.value && it.name == resourceName }?.id
?: throw PatchException("Failed to find resource id : $resourceName")
?: -1
AccountSwitcherAccessibility = find(STRING, "account_switcher_accessibility_label")
AccessibilityCaptionsButtonName = find(STRING, "accessibility_captions_button_name")