diff --git a/src/main/kotlin/app/revanced/patches/shared/patch/litho/ComponentParserPatch.kt b/src/main/kotlin/app/revanced/patches/shared/patch/litho/ComponentParserPatch.kt index 853d1e44f..6cb37b2f8 100644 --- a/src/main/kotlin/app/revanced/patches/shared/patch/litho/ComponentParserPatch.kt +++ b/src/main/kotlin/app/revanced/patches/shared/patch/litho/ComponentParserPatch.kt @@ -23,6 +23,42 @@ object ComponentParserPatch : BytecodePatch( IdentifierFingerprint ) ) { + internal lateinit var emptyComponentLabel: String + private lateinit var insertMethod: MutableMethod + + private var emptyComponentIndex by Delegates.notNull() + private var insertIndex by Delegates.notNull() + + private var identifierRegister by Delegates.notNull() + private var objectRegister by Delegates.notNull() + private var stringBuilderRegister by Delegates.notNull() + + internal fun generalHook(descriptor: String) { + insertMethod.apply { + addInstructionsWithLabels( + insertIndex, + """ + invoke-static {v$stringBuilderRegister, v$identifierRegister, v$objectRegister}, $descriptor(Ljava/lang/StringBuilder;Ljava/lang/String;Ljava/lang/Object;)Z + move-result v$stringBuilderRegister + if-nez v$stringBuilderRegister, :filter + """, ExternalLabel("filter", getInstruction(emptyComponentIndex)) + ) + } + } + + internal fun pathBuilderHook(descriptor: String) { + insertMethod.apply { + addInstructionsWithLabels( + insertIndex, + """ + invoke-static {v$stringBuilderRegister}, $descriptor(Ljava/lang/StringBuilder;)Z + move-result v$stringBuilderRegister + if-nez v$stringBuilderRegister, :filter + """, ExternalLabel("filter", getInstruction(emptyComponentIndex)) + ) + } + } + override fun execute(context: BytecodeContext) { /** @@ -75,40 +111,4 @@ object ComponentParserPatch : BytecodePatch( } } - - lateinit var emptyComponentLabel: String - lateinit var insertMethod: MutableMethod - - var emptyComponentIndex by Delegates.notNull() - var insertIndex by Delegates.notNull() - - var identifierRegister by Delegates.notNull() - var objectRegister by Delegates.notNull() - var stringBuilderRegister by Delegates.notNull() - - fun generalHook(descriptor: String) { - insertMethod.apply { - addInstructionsWithLabels( - insertIndex, - """ - invoke-static {v$stringBuilderRegister, v$identifierRegister, v$objectRegister}, $descriptor(Ljava/lang/StringBuilder;Ljava/lang/String;Ljava/lang/Object;)Z - move-result v$stringBuilderRegister - if-nez v$stringBuilderRegister, :filter - """, ExternalLabel("filter", getInstruction(emptyComponentIndex)) - ) - } - } - - fun pathBuilderHook(descriptor: String) { - insertMethod.apply { - addInstructionsWithLabels( - insertIndex, - """ - invoke-static {v$stringBuilderRegister}, $descriptor(Ljava/lang/StringBuilder;)Z - move-result v$stringBuilderRegister - if-nez v$stringBuilderRegister, :filter - """, ExternalLabel("filter", getInstruction(emptyComponentIndex)) - ) - } - } } \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/utils/settings/SettingsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/settings/SettingsPatch.kt index 58a45f6ce..890362a69 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/utils/settings/SettingsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/settings/SettingsPatch.kt @@ -3,8 +3,10 @@ package app.revanced.patches.youtube.utils.settings import app.revanced.patcher.data.ResourceContext import app.revanced.patcher.patch.annotation.CompatiblePackage import app.revanced.patcher.patch.annotation.Patch +import app.revanced.patches.shared.patch.mapping.ResourceMappingPatch import app.revanced.patches.shared.patch.settings.AbstractSettingsResourcePatch import app.revanced.patches.youtube.utils.integrations.IntegrationsPatch +import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch import app.revanced.util.resources.IconHelper.YOUTUBE_LAUNCHER_ICON_ARRAY import app.revanced.util.resources.IconHelper.copyFiles import app.revanced.util.resources.IconHelper.makeDirectoryAndCopyFiles @@ -24,6 +26,8 @@ import java.util.concurrent.TimeUnit description = "Applies mandatory patches to implement ReVanced Extended settings into the application.", dependencies = [ IntegrationsPatch::class, + ResourceMappingPatch::class, + SharedResourceIdPatch::class, SettingsBytecodePatch::class ], compatiblePackages = [