From 491f292182a419cb5399de768560ae4daa7c86cb Mon Sep 17 00:00:00 2001 From: oSumAtrIX Date: Thu, 18 May 2023 02:59:02 +0200 Subject: [PATCH] feat(youtube): support version `18.19.35` --- .../annotation/HideAdsCompatibility.kt | 2 +- .../annotations/VideoAdsCompatibility.kt | 2 +- .../annotation/CopyVideoUrlCompatibility.kt | 2 +- .../annotation/DownloadsCompatibility.kt | 2 +- .../annotation/SeekbarTappingCompatibility.kt | 2 +- ...essibilityPlayerProgressTimeFingerprint.kt | 23 +++ .../fingerprints/SeekbarTappingFingerprint.kt | 46 +++--- .../SeekbarTappingParentFingerprint.kt | 44 ------ .../patch/EnableSeekbarTappingPatch.kt | 144 ++++++++---------- .../EnableSeekbarTappingResourcePatch.kt | 38 +++++ .../annotation/SwipeControlsCompatibility.kt | 2 +- .../annotations/AutoCaptionsCompatibility.kt | 2 +- .../annotations/HideButtonsCompatibility.kt | 2 +- .../AutoplayButtonCompatibility.kt | 2 +- .../HideCaptionsButtonCompatibility.kt | 2 +- .../NavigationButtonsCompatibility.kt | 2 +- .../PlayerButtonBackgroundCompatibility.kt | 2 +- .../HidePlayerButtonsCompatibility.kt | 2 +- .../annotations/AlbumCardsCompatibility.kt | 2 +- .../HideArtistCardCompatibility.kt | 2 +- .../annotations/BreakingNewsCompatibility.kt | 2 +- .../annotations/HideCommentsCompatibility.kt | 2 +- .../CrowdfundingBoxCompatibility.kt | 2 +- .../HideEndscreenCardsCompatibility.kt | 2 +- .../filterbar/annotations/HideFilterBar.kt | 2 +- ...deFloatingMicrophoneButtonCompatibility.kt | 2 +- .../HideGetPremiumCompatibility.kt | 2 +- .../annotations/HideInfocardsCompatibility.kt | 2 +- .../HideLoadMoreButtonCompatibility.kt | 2 +- .../HideEmailAddressCompatibility.kt | 2 +- .../annotations/HideSeekbarCompatibility.kt | 2 +- .../HideShortsComponentsCompatibility.kt | 2 +- .../time/annotations/HideTimeCompatibility.kt | 2 +- .../annotations/WatchInVRCompatibility.kt | 2 +- .../annotations/HideWatermarkCompatibility.kt | 2 +- .../FullscreenPanelsCompatibility.kt | 2 +- .../PlayerPopupPanelsCompatibility.kt | 2 +- .../ReturnYouTubeDislikeCompatibility.kt | 2 +- ...TextComponentAtomicReferenceFingerprint.kt | 3 +- .../patch/ReturnYouTubeDislikePatch.kt | 4 +- .../annotations/WideSearchbarCompatibility.kt | 2 +- .../annotations/SponsorBlockCompatibility.kt | 2 +- .../patch/SponsorBlockBytecodePatch.kt | 44 ++---- .../patch/SponsorBlockResourcePatch.kt | 2 - .../SpoofAppVersionCompatibility.kt | 2 +- .../StartupShortsResetCompatibility.kt | 2 +- .../TabletMiniPlayerCompatibility.kt | 2 +- .../bytecode/patch/ThemeBytecodePatch.kt | 11 +- .../theme/resource/ThemeResourcePatch.kt | 74 +++++++-- .../annotations/AutoRepeatCompatibility.kt | 2 +- .../FixBackToExitGestureCompatibility.kt | 2 +- .../annotations/ClientSpoofCompatibility.kt | 4 +- .../UserAgentHeaderBuilderFingerprint.kt | 2 +- .../fix/playback}/patch/ClientSpoofPatch.kt | 7 +- .../annotations/IntegrationsCompatibility.kt | 2 +- .../OpenLinksExternallyCompatibility.kt | 2 +- .../annotation/LithoFilterCompatibility.kt | 2 +- .../annotations/MicroGPatchCompatibility.kt | 2 +- .../patch/bytecode/MicroGBytecodePatch.kt | 2 - .../MinimizedPlaybackCompatibility.kt | 2 +- .../annotation/PlayerControlsCompatibility.kt | 2 +- .../PlayerOverlaysHookCompatibility.kt | 2 +- .../annotation/PlayerTypeHookCompatibility.kt | 2 +- .../CustomVideoBufferCompatibility.kt | 2 +- .../annotations/HDRBrightnessCompatibility.kt | 2 +- .../VideoInformationCompatibility.kt | 2 +- .../OldQualityLayoutCompatibility.kt | 2 +- .../QualityMenuViewInflateFingerprint.kt | 25 +-- .../patch/OldQualityLayoutPatch.kt | 26 +--- .../patch/OldQualityLayoutResourcePatch.kt | 36 +++++ .../RememberVideoQualityCompatibility.kt | 2 +- .../video/speed/VideoSpeedCompatibility.kt | 2 +- .../annotation/VideoIdCompatibility.kt | 2 +- .../theme/values-night-v31/styles.xml | 8 - 74 files changed, 349 insertions(+), 304 deletions(-) create mode 100644 src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/fingerprints/AccessibilityPlayerProgressTimeFingerprint.kt delete mode 100644 src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/fingerprints/SeekbarTappingParentFingerprint.kt create mode 100644 src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/patch/EnableSeekbarTappingResourcePatch.kt rename src/main/kotlin/app/revanced/patches/{shared/misc/fix/spoof => youtube/misc/fix/playback}/annotations/ClientSpoofCompatibility.kt (73%) rename src/main/kotlin/app/revanced/patches/{shared/misc/fix/spoof => youtube/misc/fix/playback}/fingerprints/UserAgentHeaderBuilderFingerprint.kt (82%) rename src/main/kotlin/app/revanced/patches/{shared/misc/fix/spoof => youtube/misc/fix/playback}/patch/ClientSpoofPatch.kt (83%) create mode 100644 src/main/kotlin/app/revanced/patches/youtube/video/oldqualitylayout/patch/OldQualityLayoutResourcePatch.kt delete mode 100644 src/main/resources/theme/values-night-v31/styles.xml diff --git a/src/main/kotlin/app/revanced/patches/youtube/ad/general/annotation/HideAdsCompatibility.kt b/src/main/kotlin/app/revanced/patches/youtube/ad/general/annotation/HideAdsCompatibility.kt index 16b5cb3c6b..798560a764 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/ad/general/annotation/HideAdsCompatibility.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/ad/general/annotation/HideAdsCompatibility.kt @@ -3,7 +3,7 @@ package app.revanced.patches.youtube.ad.general.annotation import app.revanced.patcher.annotation.Compatibility import app.revanced.patcher.annotation.Package -@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37"))]) +@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35"))]) @Target(AnnotationTarget.CLASS) internal annotation class HideAdsCompatibility diff --git a/src/main/kotlin/app/revanced/patches/youtube/ad/video/annotations/VideoAdsCompatibility.kt b/src/main/kotlin/app/revanced/patches/youtube/ad/video/annotations/VideoAdsCompatibility.kt index e8e558f2fb..6713227a12 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/ad/video/annotations/VideoAdsCompatibility.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/ad/video/annotations/VideoAdsCompatibility.kt @@ -3,7 +3,7 @@ package app.revanced.patches.youtube.ad.video.annotations import app.revanced.patcher.annotation.Compatibility import app.revanced.patcher.annotation.Package -@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37"))]) +@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35"))]) @Target(AnnotationTarget.CLASS) internal annotation class VideoAdsCompatibility diff --git a/src/main/kotlin/app/revanced/patches/youtube/interaction/copyvideourl/annotation/CopyVideoUrlCompatibility.kt b/src/main/kotlin/app/revanced/patches/youtube/interaction/copyvideourl/annotation/CopyVideoUrlCompatibility.kt index 937aa19c7a..fc46729a45 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/interaction/copyvideourl/annotation/CopyVideoUrlCompatibility.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/interaction/copyvideourl/annotation/CopyVideoUrlCompatibility.kt @@ -3,6 +3,6 @@ package app.revanced.patches.youtube.interaction.copyvideourl.annotation import app.revanced.patcher.annotation.Compatibility import app.revanced.patcher.annotation.Package -@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37"))]) +@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35"))]) @Target(AnnotationTarget.CLASS) internal annotation class CopyVideoUrlCompatibility \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/interaction/downloads/annotation/DownloadsCompatibility.kt b/src/main/kotlin/app/revanced/patches/youtube/interaction/downloads/annotation/DownloadsCompatibility.kt index 6ea47d04ca..5e8525309b 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/interaction/downloads/annotation/DownloadsCompatibility.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/interaction/downloads/annotation/DownloadsCompatibility.kt @@ -3,7 +3,7 @@ package app.revanced.patches.youtube.interaction.downloads.annotation import app.revanced.patcher.annotation.Compatibility import app.revanced.patcher.annotation.Package -@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37"))]) +@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35"))]) @Target(AnnotationTarget.CLASS) internal annotation class DownloadsCompatibility diff --git a/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/annotation/SeekbarTappingCompatibility.kt b/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/annotation/SeekbarTappingCompatibility.kt index d7c18e8d91..56a7b6893a 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/annotation/SeekbarTappingCompatibility.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/annotation/SeekbarTappingCompatibility.kt @@ -3,7 +3,7 @@ package app.revanced.patches.youtube.interaction.seekbar.annotation import app.revanced.patcher.annotation.Compatibility import app.revanced.patcher.annotation.Package -@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37"))]) +@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35"))]) @Target(AnnotationTarget.CLASS) internal annotation class SeekbarTappingCompatibility diff --git a/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/fingerprints/AccessibilityPlayerProgressTimeFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/fingerprints/AccessibilityPlayerProgressTimeFingerprint.kt new file mode 100644 index 0000000000..2976fb7a6a --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/fingerprints/AccessibilityPlayerProgressTimeFingerprint.kt @@ -0,0 +1,23 @@ +package app.revanced.patches.youtube.interaction.seekbar.fingerprints + +import app.revanced.patcher.extensions.or +import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint +import app.revanced.patches.youtube.interaction.seekbar.patch.EnableSeekbarTappingResourcePatch +import org.jf.dexlib2.AccessFlags +import org.jf.dexlib2.Opcode +import org.jf.dexlib2.iface.instruction.WideLiteralInstruction + + +object AccessibilityPlayerProgressTimeFingerprint : MethodFingerprint( + returnType = "L", + access = AccessFlags.PUBLIC or AccessFlags.FINAL, + customFingerprint = { methodDef, _ -> + methodDef.implementation?.instructions?.any { instruction -> + if (instruction.opcode != Opcode.CONST) return@any false + + val wideLiteral = (instruction as WideLiteralInstruction).wideLiteral + + EnableSeekbarTappingResourcePatch.accessibilityPlayerProgressTime == wideLiteral + } ?: false + } +) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/fingerprints/SeekbarTappingFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/fingerprints/SeekbarTappingFingerprint.kt index 94d6b2cefa..4a947813f5 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/fingerprints/SeekbarTappingFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/fingerprints/SeekbarTappingFingerprint.kt @@ -1,34 +1,34 @@ package app.revanced.patches.youtube.interaction.seekbar.fingerprints import app.revanced.patcher.extensions.or -import app.revanced.patcher.fingerprint.method.annotation.FuzzyPatternScanMethod import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import org.jf.dexlib2.AccessFlags import org.jf.dexlib2.Opcode +import org.jf.dexlib2.iface.instruction.NarrowLiteralInstruction -@FuzzyPatternScanMethod(2) // FIXME: Test this threshold and find the best value. object SeekbarTappingFingerprint : MethodFingerprint( - "Z", AccessFlags.PUBLIC or AccessFlags.FINAL, listOf("L"), listOf( - Opcode.INVOKE_VIRTUAL, - Opcode.MOVE_RESULT_WIDE, - Opcode.IGET, - Opcode.IGET_OBJECT, - Opcode.IGET, - Opcode.DIV_INT_2ADDR, - Opcode.ADD_INT, - Opcode.SUB_INT_2ADDR, - Opcode.INT_TO_FLOAT, - Opcode.CMPG_FLOAT, - Opcode.IF_GTZ, - Opcode.INT_TO_FLOAT, - Opcode.CMPG_FLOAT, - Opcode.IF_GTZ, - Opcode.CONST_4, - Opcode.INVOKE_INTERFACE, - Opcode.NEW_INSTANCE, - Opcode.INVOKE_DIRECT, + returnType = "Z", + access = AccessFlags.PUBLIC or AccessFlags.FINAL, + parameters = listOf("L"), + opcodes = listOf( Opcode.IPUT_OBJECT, - Opcode.INVOKE_VIRTUAL - ) + Opcode.INVOKE_VIRTUAL, + // Insert seekbar tapping instructions here. + Opcode.RETURN, + Opcode.INVOKE_VIRTUAL, + ), + customFingerprint = custom@{ methodDef, _ -> + if (methodDef.name != "onTouchEvent") return@custom false + + methodDef.implementation!!.instructions.any { instruction -> + if (instruction.opcode != Opcode.CONST) return@any false + + val literal = (instruction as NarrowLiteralInstruction).narrowLiteral + + // onTouchEvent method contains a CONST instruction + // with this literal making it unique with the rest of the properties of this fingerprint. + literal == Integer.MAX_VALUE + } + } ) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/fingerprints/SeekbarTappingParentFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/fingerprints/SeekbarTappingParentFingerprint.kt deleted file mode 100644 index 20f83effb9..0000000000 --- a/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/fingerprints/SeekbarTappingParentFingerprint.kt +++ /dev/null @@ -1,44 +0,0 @@ -package app.revanced.patches.youtube.interaction.seekbar.fingerprints - -import app.revanced.patcher.extensions.or -import app.revanced.patcher.fingerprint.method.annotation.FuzzyPatternScanMethod -import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint -import org.jf.dexlib2.AccessFlags -import org.jf.dexlib2.Opcode - - -@FuzzyPatternScanMethod(2) // FIXME: Test this threshold and find the best value. -object SeekbarTappingParentFingerprint : MethodFingerprint( - "L", AccessFlags.PUBLIC or AccessFlags.FINAL, listOf(), listOf( - Opcode.INVOKE_VIRTUAL, - Opcode.MOVE_RESULT_OBJECT, - Opcode.INVOKE_VIRTUAL, - Opcode.MOVE_RESULT_OBJECT, - Opcode.CONST_4, - Opcode.NEW_ARRAY, - Opcode.INVOKE_VIRTUAL, - Opcode.MOVE_RESULT_OBJECT, - Opcode.INVOKE_VIRTUAL, - Opcode.MOVE_RESULT_WIDE, - Opcode.INVOKE_STATIC, - Opcode.MOVE_RESULT_OBJECT, - Opcode.INVOKE_STATIC, - Opcode.MOVE_RESULT_OBJECT, - Opcode.CONST_4, - Opcode.APUT_OBJECT, - Opcode.INVOKE_VIRTUAL, - Opcode.MOVE_RESULT_OBJECT, - Opcode.INVOKE_VIRTUAL, - Opcode.MOVE_RESULT_WIDE, - Opcode.INVOKE_STATIC, - Opcode.MOVE_RESULT_OBJECT, - Opcode.INVOKE_STATIC, - Opcode.MOVE_RESULT_OBJECT, - Opcode.CONST_4, - Opcode.APUT_OBJECT, - Opcode.CONST, - Opcode.INVOKE_VIRTUAL, - Opcode.MOVE_RESULT_OBJECT, - Opcode.RETURN_OBJECT - ) -) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/patch/EnableSeekbarTappingPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/patch/EnableSeekbarTappingPatch.kt index 6e930ce5e0..b9d0dc0979 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/patch/EnableSeekbarTappingPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/patch/EnableSeekbarTappingPatch.kt @@ -1,109 +1,95 @@ package app.revanced.patches.youtube.interaction.seekbar.patch +import app.revanced.extensions.toErrorResult import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.extensions.addInstructions +import app.revanced.patcher.extensions.instruction import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult -import app.revanced.patcher.patch.PatchResultError import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch +import app.revanced.patcher.util.smali.ExternalLabel import app.revanced.patches.youtube.interaction.seekbar.annotation.SeekbarTappingCompatibility +import app.revanced.patches.youtube.interaction.seekbar.fingerprints.AccessibilityPlayerProgressTimeFingerprint import app.revanced.patches.youtube.interaction.seekbar.fingerprints.SeekbarTappingFingerprint -import app.revanced.patches.youtube.interaction.seekbar.fingerprints.SeekbarTappingParentFingerprint import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch -import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch -import app.revanced.patches.shared.settings.preference.impl.StringResource -import app.revanced.patches.shared.settings.preference.impl.SwitchPreference import org.jf.dexlib2.Opcode -import org.jf.dexlib2.builder.instruction.BuilderInstruction21t import org.jf.dexlib2.iface.Method -import org.jf.dexlib2.iface.instruction.formats.Instruction11n +import org.jf.dexlib2.iface.instruction.NarrowLiteralInstruction import org.jf.dexlib2.iface.instruction.formats.Instruction35c @Patch -@DependsOn([IntegrationsPatch::class, SettingsPatch::class]) +@DependsOn([IntegrationsPatch::class, EnableSeekbarTappingResourcePatch::class]) @Name("seekbar-tapping") @Description("Enables tap-to-seek on the seekbar of the video player.") @SeekbarTappingCompatibility @Version("0.0.1") class EnableSeekbarTappingPatch : BytecodePatch( - listOf( - SeekbarTappingParentFingerprint, SeekbarTappingFingerprint - ) + listOf(AccessibilityPlayerProgressTimeFingerprint, SeekbarTappingFingerprint) ) { override fun execute(context: BytecodeContext): PatchResult { - SettingsPatch.PreferenceScreen.INTERACTIONS.addPreferences( - SwitchPreference( - "revanced_tap_seeking", - StringResource("revanced_tap_seeking_title", "Enable seekbar tapping"), - StringResource("revanced_tap_seeking_summary_on", "Seekbar tapping is enabled"), - StringResource("revanced_tap_seeking_summary_off", "Seekbar tapping is disabled") - ) - ) + // Find the required methods to tap the seekbar. + val seekbarTappingMethods = + AccessibilityPlayerProgressTimeFingerprint.result?.classDef?.methods?.let { methods -> + buildMap { + // find the methods which tap the seekbar + methods.forEach { method -> + if (method.implementation == null) return@forEach + + val instructions = method.implementation!!.instructions + + // The method has more than 7 instructions. + if (instructions.count() < 7) return@forEach + + // The 7th instruction has the opcode CONST_4. + val instruction = instructions.elementAt(6) + if (instruction.opcode != Opcode.CONST_4) return@forEach + + // the literal for this instruction has to be either 1 or 2. + val literal = (instruction as NarrowLiteralInstruction).narrowLiteral + + // Based on the literal, determine which method is which. + if (literal == 1) this["P"] = method + if (literal == 2) this["O"] = method + } + } + } + + seekbarTappingMethods ?: return AccessibilityPlayerProgressTimeFingerprint.toErrorResult() + + SeekbarTappingFingerprint.result?.let { + val insertIndex = it.scanResult.patternScanResult!!.endIndex - 1 + + it.mutableMethod.apply { + val thisInstanceRegister = instruction(insertIndex - 1).registerC + + val freeRegister = 0 + val xAxisRegister = 2 + + val pMethod = seekbarTappingMethods["P"]!! + val oMethod = seekbarTappingMethods["O"]!! + + fun Method.toInvokeInstructionString() = + "invoke-virtual { v$thisInstanceRegister, v$xAxisRegister }, $definingClass->$name(I)V" + + addInstructions( + insertIndex, + """ + invoke-static { }, Lapp/revanced/integrations/patches/SeekbarTappingPatch;->seekbarTappingEnabled()Z + move-result v$freeRegister + if-eqz v$freeRegister, :disabled + ${oMethod.toInvokeInstructionString()} + ${pMethod.toInvokeInstructionString()} + """, + listOf(ExternalLabel("disabled", instruction(insertIndex))) + ) + } + } ?: return SeekbarTappingFingerprint.toErrorResult() - var result = SeekbarTappingParentFingerprint.result!! - - val tapSeekMethods = mutableMapOf() - - // find the methods which tap the seekbar - for (it in result.classDef.methods) { - if (it.implementation == null) continue - - val instructions = it.implementation!!.instructions - // here we make sure we actually find the method because it has more than 7 instructions - if (instructions.count() < 7) continue - - // we know that the 7th instruction has the opcode CONST_4 - val instruction = instructions.elementAt(6) - if (instruction.opcode != Opcode.CONST_4) continue - - // the literal for this instruction has to be either 1 or 2 - val literal = (instruction as Instruction11n).narrowLiteral - - // method founds - if (literal == 1) tapSeekMethods["P"] = it - if (literal == 2) tapSeekMethods["O"] = it - } - - // replace map because we don't need the upper one anymore - result = SeekbarTappingFingerprint.result!! - - val implementation = result.mutableMethod.implementation!! - - // if tap-seeking is enabled, do not invoke the two methods below - val pMethod = tapSeekMethods["P"]!! - val oMethod = tapSeekMethods["O"]!! - - val insertIndex = result.scanResult.patternScanResult!!.endIndex + 1 - - // get the required register - val instruction = implementation.instructions[insertIndex - 1] - if (instruction.opcode != Opcode.INVOKE_VIRTUAL) return PatchResultError("Could not find the correct register") - val register = (instruction as Instruction35c).registerC - - val elseLabel = implementation.newLabelForIndex(insertIndex) - // the instructions are written in reverse order. - result.mutableMethod.addInstructions( - insertIndex, """ - invoke-virtual { v$register, v2 }, ${oMethod.definingClass}->${oMethod.name}(I)V - invoke-virtual { v$register, v2 }, ${pMethod.definingClass}->${pMethod.name}(I)V - """ - ) - - // if tap-seeking is disabled, do not invoke the two methods above by jumping to the else label - implementation.addInstruction( - insertIndex, BuilderInstruction21t(Opcode.IF_EQZ, 0, elseLabel) - ) - result.mutableMethod.addInstructions( - insertIndex, """ - invoke-static { }, Lapp/revanced/integrations/patches/SeekbarTappingPatch;->isTapSeekingEnabled()Z - move-result v0 - """ - ) return PatchResultSuccess() } -} +} \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/patch/EnableSeekbarTappingResourcePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/patch/EnableSeekbarTappingResourcePatch.kt new file mode 100644 index 0000000000..d2281ad275 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/patch/EnableSeekbarTappingResourcePatch.kt @@ -0,0 +1,38 @@ +package app.revanced.patches.youtube.interaction.seekbar.patch + +import app.revanced.patcher.annotation.Version +import app.revanced.patcher.data.ResourceContext +import app.revanced.patcher.patch.PatchResult +import app.revanced.patcher.patch.PatchResultError +import app.revanced.patcher.patch.PatchResultSuccess +import app.revanced.patcher.patch.ResourcePatch +import app.revanced.patcher.patch.annotations.DependsOn +import app.revanced.patches.shared.mapping.misc.patch.ResourceMappingPatch +import app.revanced.patches.shared.settings.preference.impl.StringResource +import app.revanced.patches.shared.settings.preference.impl.SwitchPreference +import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch + +@DependsOn([SettingsPatch::class, ResourceMappingPatch::class]) +@Version("0.0.1") +class EnableSeekbarTappingResourcePatch : ResourcePatch { + override fun execute(context: ResourceContext): PatchResult { + SettingsPatch.PreferenceScreen.INTERACTIONS.addPreferences( + SwitchPreference( + "revanced_seekbar_tapping", + StringResource("revanced_seekbar_tapping_title", "Enable seekbar tapping"), + StringResource("revanced_seekbar_tapping_summary_on", "Seekbar tapping is enabled"), + StringResource("revanced_seekbar_tapping_summary_off", "Seekbar tapping is disabled") + ) + ) + + accessibilityPlayerProgressTime = ResourceMappingPatch.resourceMappings.find { + it.name == "accessibility_player_progress_time" + }?.id ?: return PatchResultError("Failed to find required resource") + + return PatchResultSuccess() + } + + internal companion object { + var accessibilityPlayerProgressTime = -1L + } +} \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/interaction/swipecontrols/annotation/SwipeControlsCompatibility.kt b/src/main/kotlin/app/revanced/patches/youtube/interaction/swipecontrols/annotation/SwipeControlsCompatibility.kt index 2a7a4795a2..feaa5effcf 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/interaction/swipecontrols/annotation/SwipeControlsCompatibility.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/interaction/swipecontrols/annotation/SwipeControlsCompatibility.kt @@ -3,6 +3,6 @@ package app.revanced.patches.youtube.interaction.swipecontrols.annotation import app.revanced.patcher.annotation.Compatibility import app.revanced.patcher.annotation.Package -@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37"))]) +@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35"))]) @Target(AnnotationTarget.CLASS) internal annotation class SwipeControlsCompatibility diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/autocaptions/annotations/AutoCaptionsCompatibility.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/autocaptions/annotations/AutoCaptionsCompatibility.kt index f28f15834d..c03a3e7f9c 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/autocaptions/annotations/AutoCaptionsCompatibility.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/autocaptions/annotations/AutoCaptionsCompatibility.kt @@ -3,6 +3,6 @@ package app.revanced.patches.youtube.layout.autocaptions.annotations import app.revanced.patcher.annotation.Compatibility import app.revanced.patcher.annotation.Package -@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37"))]) +@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35"))]) @Target(AnnotationTarget.CLASS) internal annotation class AutoCaptionsCompatibility diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/action/annotations/HideButtonsCompatibility.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/action/annotations/HideButtonsCompatibility.kt index 7739a8267b..1127253581 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/action/annotations/HideButtonsCompatibility.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/action/annotations/HideButtonsCompatibility.kt @@ -3,6 +3,6 @@ package app.revanced.patches.youtube.layout.buttons.action.annotations import app.revanced.patcher.annotation.Compatibility import app.revanced.patcher.annotation.Package -@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37"))]) +@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35"))]) @Target(AnnotationTarget.CLASS) internal annotation class HideButtonsCompatibility diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/autoplay/annotations/AutoplayButtonCompatibility.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/autoplay/annotations/AutoplayButtonCompatibility.kt index 92e2c8f9d2..278fb0c2fd 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/autoplay/annotations/AutoplayButtonCompatibility.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/autoplay/annotations/AutoplayButtonCompatibility.kt @@ -3,6 +3,6 @@ package app.revanced.patches.youtube.layout.buttons.autoplay.annotations import app.revanced.patcher.annotation.Compatibility import app.revanced.patcher.annotation.Package -@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37"))]) +@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35"))]) @Target(AnnotationTarget.CLASS) internal annotation class AutoplayButtonCompatibility diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/captions/annotations/HideCaptionsButtonCompatibility.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/captions/annotations/HideCaptionsButtonCompatibility.kt index 9c28654181..849d2e18e1 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/captions/annotations/HideCaptionsButtonCompatibility.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/captions/annotations/HideCaptionsButtonCompatibility.kt @@ -3,6 +3,6 @@ package app.revanced.patches.youtube.layout.buttons.captions.annotations import app.revanced.patcher.annotation.Compatibility import app.revanced.patcher.annotation.Package -@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37"))]) +@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35"))]) @Target(AnnotationTarget.CLASS) internal annotation class HideCaptionsButtonCompatibility diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/navigation/annotations/NavigationButtonsCompatibility.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/navigation/annotations/NavigationButtonsCompatibility.kt index c4671a348c..e298888c11 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/navigation/annotations/NavigationButtonsCompatibility.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/navigation/annotations/NavigationButtonsCompatibility.kt @@ -3,6 +3,6 @@ package app.revanced.patches.youtube.layout.buttons.navigation.annotations import app.revanced.patcher.annotation.Compatibility import app.revanced.patcher.annotation.Package -@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37"))]) +@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35"))]) @Target(AnnotationTarget.CLASS) internal annotation class NavigationButtonsCompatibility \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/player/background/annotations/PlayerButtonBackgroundCompatibility.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/player/background/annotations/PlayerButtonBackgroundCompatibility.kt index 8030864b57..a939d9b7e3 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/player/background/annotations/PlayerButtonBackgroundCompatibility.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/player/background/annotations/PlayerButtonBackgroundCompatibility.kt @@ -2,6 +2,6 @@ package app.revanced.patches.youtube.layout.buttons.player.background.annotation import app.revanced.patcher.annotation.Compatibility import app.revanced.patcher.annotation.Package -@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37"))]) +@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35"))]) @Target(AnnotationTarget.CLASS) internal annotation class PlayerButtonBackgroundCompatibility diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/player/hide/annotations/HidePlayerButtonsCompatibility.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/player/hide/annotations/HidePlayerButtonsCompatibility.kt index 5d4e9f3e50..1f20ff2fbe 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/player/hide/annotations/HidePlayerButtonsCompatibility.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/player/hide/annotations/HidePlayerButtonsCompatibility.kt @@ -3,6 +3,6 @@ package app.revanced.patches.youtube.layout.buttons.player.hide.annotations import app.revanced.patcher.annotation.Compatibility import app.revanced.patcher.annotation.Package -@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37"))]) +@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35"))]) @Target(AnnotationTarget.CLASS) internal annotation class HidePlayerButtonsCompatibility \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/albumcards/annotations/AlbumCardsCompatibility.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/albumcards/annotations/AlbumCardsCompatibility.kt index 909dc12fe6..1523ca1c2f 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/albumcards/annotations/AlbumCardsCompatibility.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/albumcards/annotations/AlbumCardsCompatibility.kt @@ -3,6 +3,6 @@ package app.revanced.patches.youtube.layout.hide.albumcards.annotations import app.revanced.patcher.annotation.Compatibility import app.revanced.patcher.annotation.Package -@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37"))]) +@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35"))]) @Target(AnnotationTarget.CLASS) internal annotation class AlbumCardsCompatibility diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/artistcards/annotations/HideArtistCardCompatibility.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/artistcards/annotations/HideArtistCardCompatibility.kt index b1ee4095b8..b3245b815d 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/artistcards/annotations/HideArtistCardCompatibility.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/artistcards/annotations/HideArtistCardCompatibility.kt @@ -3,6 +3,6 @@ package app.revanced.patches.youtube.layout.hide.artistcards.annotations import app.revanced.patcher.annotation.Compatibility import app.revanced.patcher.annotation.Package -@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37"))]) +@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35"))]) @Target(AnnotationTarget.CLASS) internal annotation class HideArtistCardCompatibility diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/breakingnews/annotations/BreakingNewsCompatibility.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/breakingnews/annotations/BreakingNewsCompatibility.kt index cb6d5c5f50..af446cfe8a 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/breakingnews/annotations/BreakingNewsCompatibility.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/breakingnews/annotations/BreakingNewsCompatibility.kt @@ -3,6 +3,6 @@ package app.revanced.patches.youtube.layout.hide.breakingnews.annotations import app.revanced.patcher.annotation.Compatibility import app.revanced.patcher.annotation.Package -@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37"))]) +@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35"))]) @Target(AnnotationTarget.CLASS) internal annotation class BreakingNewsCompatibility diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/comments/annotations/HideCommentsCompatibility.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/comments/annotations/HideCommentsCompatibility.kt index 229759f592..27f8151f0f 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/comments/annotations/HideCommentsCompatibility.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/comments/annotations/HideCommentsCompatibility.kt @@ -3,6 +3,6 @@ package app.revanced.patches.youtube.layout.hide.comments.annotations import app.revanced.patcher.annotation.Compatibility import app.revanced.patcher.annotation.Package -@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37"))]) +@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35"))]) @Target(AnnotationTarget.CLASS) internal annotation class HideCommentsCompatibility diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/crowdfundingbox/annotations/CrowdfundingBoxCompatibility.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/crowdfundingbox/annotations/CrowdfundingBoxCompatibility.kt index e87e901ac0..f6776877b9 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/crowdfundingbox/annotations/CrowdfundingBoxCompatibility.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/crowdfundingbox/annotations/CrowdfundingBoxCompatibility.kt @@ -3,6 +3,6 @@ package app.revanced.patches.youtube.layout.hide.crowdfundingbox.annotations import app.revanced.patcher.annotation.Compatibility import app.revanced.patcher.annotation.Package -@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37"))]) +@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35"))]) @Target(AnnotationTarget.CLASS) internal annotation class CrowdfundingBoxCompatibility diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/endscreencards/annotations/HideEndscreenCardsCompatibility.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/endscreencards/annotations/HideEndscreenCardsCompatibility.kt index 1fa23c9eff..47d2780101 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/endscreencards/annotations/HideEndscreenCardsCompatibility.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/endscreencards/annotations/HideEndscreenCardsCompatibility.kt @@ -3,6 +3,6 @@ package app.revanced.patches.youtube.layout.hide.endscreencards.annotations import app.revanced.patcher.annotation.Compatibility import app.revanced.patcher.annotation.Package -@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37"))]) +@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35"))]) @Target(AnnotationTarget.CLASS) internal annotation class HideEndscreenCardsCompatibility diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/filterbar/annotations/HideFilterBar.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/filterbar/annotations/HideFilterBar.kt index db58b1c916..e45cafd7b5 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/filterbar/annotations/HideFilterBar.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/filterbar/annotations/HideFilterBar.kt @@ -3,6 +3,6 @@ package app.revanced.patches.youtube.layout.hide.filterbar.annotations import app.revanced.patcher.annotation.Compatibility import app.revanced.patcher.annotation.Package -@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37"))]) +@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35"))]) @Target(AnnotationTarget.CLASS) internal annotation class HideFilterBar \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/floatingmicrophone/annotations/HideFloatingMicrophoneButtonCompatibility.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/floatingmicrophone/annotations/HideFloatingMicrophoneButtonCompatibility.kt index 1cbc93dbb7..8ab0a1e5cb 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/floatingmicrophone/annotations/HideFloatingMicrophoneButtonCompatibility.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/floatingmicrophone/annotations/HideFloatingMicrophoneButtonCompatibility.kt @@ -3,6 +3,6 @@ package app.revanced.patches.youtube.layout.hide.floatingmicrophone.annotations import app.revanced.patcher.annotation.Compatibility import app.revanced.patcher.annotation.Package -@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37"))]) +@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35"))]) @Target(AnnotationTarget.CLASS) internal annotation class HideFloatingMicrophoneButtonCompatibility diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/getpremium/annotations/HideGetPremiumCompatibility.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/getpremium/annotations/HideGetPremiumCompatibility.kt index ed4db63fa8..bd210bfc94 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/getpremium/annotations/HideGetPremiumCompatibility.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/getpremium/annotations/HideGetPremiumCompatibility.kt @@ -3,6 +3,6 @@ package app.revanced.patches.youtube.layout.hide.getpremium.annotations import app.revanced.patcher.annotation.Compatibility import app.revanced.patcher.annotation.Package -@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37"))]) +@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35"))]) @Target(AnnotationTarget.CLASS) internal annotation class HideGetPremiumCompatibility diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/infocards/annotations/HideInfocardsCompatibility.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/infocards/annotations/HideInfocardsCompatibility.kt index 34f5acd72c..8a71676e99 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/infocards/annotations/HideInfocardsCompatibility.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/infocards/annotations/HideInfocardsCompatibility.kt @@ -3,6 +3,6 @@ package app.revanced.patches.youtube.layout.hide.infocards.annotations import app.revanced.patcher.annotation.Compatibility import app.revanced.patcher.annotation.Package -@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37"))]) +@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35"))]) @Target(AnnotationTarget.CLASS) internal annotation class HideInfocardsCompatibility diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/loadmorebutton/annotations/HideLoadMoreButtonCompatibility.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/loadmorebutton/annotations/HideLoadMoreButtonCompatibility.kt index 0d9bcc2fc4..5c580599c9 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/loadmorebutton/annotations/HideLoadMoreButtonCompatibility.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/loadmorebutton/annotations/HideLoadMoreButtonCompatibility.kt @@ -3,7 +3,7 @@ package app.revanced.patches.youtube.layout.hide.loadmorebutton.annotations import app.revanced.patcher.annotation.Compatibility import app.revanced.patcher.annotation.Package -@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37"))]) +@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35"))]) @Target(AnnotationTarget.CLASS) internal annotation class HideLoadMoreButtonCompatibility diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/personalinformation/annotations/HideEmailAddressCompatibility.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/personalinformation/annotations/HideEmailAddressCompatibility.kt index ffc6866d38..27abf27230 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/personalinformation/annotations/HideEmailAddressCompatibility.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/personalinformation/annotations/HideEmailAddressCompatibility.kt @@ -3,6 +3,6 @@ package app.revanced.patches.youtube.layout.hide.personalinformation.annotations import app.revanced.patcher.annotation.Compatibility import app.revanced.patcher.annotation.Package -@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37"))]) +@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35"))]) @Target(AnnotationTarget.CLASS) internal annotation class HideEmailAddressCompatibility diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/seekbar/annotations/HideSeekbarCompatibility.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/seekbar/annotations/HideSeekbarCompatibility.kt index 9bf21786de..560e17a8ec 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/seekbar/annotations/HideSeekbarCompatibility.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/seekbar/annotations/HideSeekbarCompatibility.kt @@ -3,6 +3,6 @@ package app.revanced.patches.youtube.layout.hide.seekbar.annotations import app.revanced.patcher.annotation.Compatibility import app.revanced.patcher.annotation.Package -@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37"))]) +@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35"))]) @Target(AnnotationTarget.CLASS) internal annotation class HideSeekbarCompatibility \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/shorts/annotations/HideShortsComponentsCompatibility.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/shorts/annotations/HideShortsComponentsCompatibility.kt index a00aca95b6..a058e84cdc 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/shorts/annotations/HideShortsComponentsCompatibility.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/shorts/annotations/HideShortsComponentsCompatibility.kt @@ -3,6 +3,6 @@ package app.revanced.patches.youtube.layout.hide.shorts.annotations import app.revanced.patcher.annotation.Compatibility import app.revanced.patcher.annotation.Package -@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37"))]) +@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35"))]) @Target(AnnotationTarget.CLASS) internal annotation class HideShortsComponentsCompatibility diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/time/annotations/HideTimeCompatibility.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/time/annotations/HideTimeCompatibility.kt index b51bd3847a..c3f3c77765 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/time/annotations/HideTimeCompatibility.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/time/annotations/HideTimeCompatibility.kt @@ -3,6 +3,6 @@ package app.revanced.patches.youtube.layout.hide.time.annotations import app.revanced.patcher.annotation.Compatibility import app.revanced.patcher.annotation.Package -@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37"))]) +@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35"))]) @Target(AnnotationTarget.CLASS) internal annotation class HideTimeCompatibility \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/watchinvr/annotations/WatchInVRCompatibility.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/watchinvr/annotations/WatchInVRCompatibility.kt index a0b1741983..9eba5cc7c9 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/watchinvr/annotations/WatchInVRCompatibility.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/watchinvr/annotations/WatchInVRCompatibility.kt @@ -3,6 +3,6 @@ package app.revanced.patches.youtube.layout.hide.watchinvr.annotations import app.revanced.patcher.annotation.Compatibility import app.revanced.patcher.annotation.Package -@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37"))]) +@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35"))]) @Target(AnnotationTarget.CLASS) internal annotation class WatchInVRCompatibility \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/watermark/annotations/HideWatermarkCompatibility.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/watermark/annotations/HideWatermarkCompatibility.kt index bc7098171d..8d11da21af 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/watermark/annotations/HideWatermarkCompatibility.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/watermark/annotations/HideWatermarkCompatibility.kt @@ -3,6 +3,6 @@ package app.revanced.patches.youtube.layout.hide.watermark.annotations import app.revanced.patcher.annotation.Compatibility import app.revanced.patcher.annotation.Package -@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37"))]) +@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35"))]) @Target(AnnotationTarget.CLASS) internal annotation class HideWatermarkCompatibility diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/panels/fullscreen/remove/annotations/FullscreenPanelsCompatibility.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/panels/fullscreen/remove/annotations/FullscreenPanelsCompatibility.kt index 2d0a64ac4b..86a2865c2a 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/panels/fullscreen/remove/annotations/FullscreenPanelsCompatibility.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/panels/fullscreen/remove/annotations/FullscreenPanelsCompatibility.kt @@ -3,6 +3,6 @@ package app.revanced.patches.youtube.layout.panels.fullscreen.remove.annotations import app.revanced.patcher.annotation.Compatibility import app.revanced.patcher.annotation.Package -@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37"))]) +@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35"))]) @Target(AnnotationTarget.CLASS) internal annotation class FullscreenPanelsCompatibility diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/panels/popup/annotations/PlayerPopupPanelsCompatibility.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/panels/popup/annotations/PlayerPopupPanelsCompatibility.kt index e6c1d2b7e0..c05d454b4c 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/panels/popup/annotations/PlayerPopupPanelsCompatibility.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/panels/popup/annotations/PlayerPopupPanelsCompatibility.kt @@ -3,6 +3,6 @@ package app.revanced.patches.youtube.layout.panels.popup.annotations import app.revanced.patcher.annotation.Compatibility import app.revanced.patcher.annotation.Package -@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37"))]) +@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35"))]) @Target(AnnotationTarget.CLASS) internal annotation class PlayerPopupPanelsCompatibility diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/returnyoutubedislike/annotations/ReturnYouTubeDislikeCompatibility.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/returnyoutubedislike/annotations/ReturnYouTubeDislikeCompatibility.kt index f0f041421f..aa0f3fcc58 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/returnyoutubedislike/annotations/ReturnYouTubeDislikeCompatibility.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/returnyoutubedislike/annotations/ReturnYouTubeDislikeCompatibility.kt @@ -3,6 +3,6 @@ package app.revanced.patches.youtube.layout.returnyoutubedislike.annotations import app.revanced.patcher.annotation.Compatibility import app.revanced.patcher.annotation.Package -@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37"))]) +@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35"))]) @Target(AnnotationTarget.CLASS) internal annotation class ReturnYouTubeDislikeCompatibility \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/returnyoutubedislike/fingerprints/TextComponentAtomicReferenceFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/returnyoutubedislike/fingerprints/TextComponentAtomicReferenceFingerprint.kt index 2385aa9040..f96af10243 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/returnyoutubedislike/fingerprints/TextComponentAtomicReferenceFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/returnyoutubedislike/fingerprints/TextComponentAtomicReferenceFingerprint.kt @@ -13,8 +13,7 @@ object TextComponentAtomicReferenceFingerprint : MethodFingerprint( access = AccessFlags.PROTECTED or AccessFlags.FINAL, parameters = listOf("L"), opcodes = listOf( - Opcode.MOVE_OBJECT, // available unused register - Opcode.MOVE_OBJECT_FROM16, + Opcode.MOVE_OBJECT_FROM16, // available unused register Opcode.MOVE_OBJECT_FROM16, Opcode.MOVE_OBJECT_FROM16, Opcode.MOVE_OBJECT_FROM16, diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/returnyoutubedislike/patch/ReturnYouTubeDislikePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/returnyoutubedislike/patch/ReturnYouTubeDislikePatch.kt index 9bf0fef91c..b75fddfcf3 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/returnyoutubedislike/patch/ReturnYouTubeDislikePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/returnyoutubedislike/patch/ReturnYouTubeDislikePatch.kt @@ -99,7 +99,7 @@ class ReturnYouTubeDislikePatch : BytecodePatch( val atomicReferenceStartIndex = TextComponentAtomicReferenceFingerprint.result!! .scanResult.patternScanResult!!.startIndex - val insertIndex = atomicReferenceStartIndex + 8 + val insertIndex = atomicReferenceStartIndex + 7 textComponentContextFingerprintResult.mutableMethod.apply { // Get the conversion context obfuscated field name, and the registers for the AtomicReference and CharSequence @@ -111,7 +111,7 @@ class ReturnYouTubeDislikePatch : BytecodePatch( instruction(atomicReferenceStartIndex).registerB val atomicReferenceRegister = - instruction(atomicReferenceStartIndex + 5).registerC + instruction(atomicReferenceStartIndex + 4).registerC val moveCharSequenceInstruction = instruction(insertIndex) val charSequenceRegister = moveCharSequenceInstruction.registerB diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/searchbar/annotations/WideSearchbarCompatibility.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/searchbar/annotations/WideSearchbarCompatibility.kt index 069f42146a..75d3373ec2 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/searchbar/annotations/WideSearchbarCompatibility.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/searchbar/annotations/WideSearchbarCompatibility.kt @@ -3,6 +3,6 @@ package app.revanced.patches.youtube.layout.searchbar.annotations import app.revanced.patcher.annotation.Compatibility import app.revanced.patcher.annotation.Package -@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37"))]) +@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35"))]) @Target(AnnotationTarget.CLASS) internal annotation class WideSearchbarCompatibility \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/sponsorblock/annotations/SponsorBlockCompatibility.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/sponsorblock/annotations/SponsorBlockCompatibility.kt index 9d82b824f8..f805334ffd 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/sponsorblock/annotations/SponsorBlockCompatibility.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/sponsorblock/annotations/SponsorBlockCompatibility.kt @@ -3,6 +3,6 @@ package app.revanced.patches.youtube.layout.sponsorblock.annotations import app.revanced.patcher.annotation.Compatibility import app.revanced.patcher.annotation.Package -@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37"))]) +@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35"))]) @Target(AnnotationTarget.CLASS) internal annotation class SponsorBlockCompatibility \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/sponsorblock/bytecode/patch/SponsorBlockBytecodePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/sponsorblock/bytecode/patch/SponsorBlockBytecodePatch.kt index ca435fdb80..84112ff82f 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/sponsorblock/bytecode/patch/SponsorBlockBytecodePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/sponsorblock/bytecode/patch/SponsorBlockBytecodePatch.kt @@ -103,17 +103,18 @@ class SponsorBlockBytecodePatch : BytecodePatch( val seekbarMethodInstructions = seekbarMethod.implementation!!.instructions /* - * Get the instance of the seekbar rectangle + * Get left and right of seekbar rectangle */ - for ((index, instruction) in seekbarMethodInstructions.withIndex()) { - if (instruction.opcode != Opcode.MOVE_OBJECT_FROM16) continue - seekbarMethod.addInstruction( - index + 1, - "invoke-static/range {p0 .. p0}, $INTEGRATIONS_SEGMENT_PLAYBACK_CONTROLLER_CLASS_DESCRIPTOR->setSponsorBarRect(Ljava/lang/Object;)V" - ) - break + val moveRectangleToRegisterIndex = seekbarMethodInstructions.indexOfFirst { + it.opcode == Opcode.MOVE_OBJECT_FROM16 } + seekbarMethod.addInstruction( + moveRectangleToRegisterIndex + 1, + "invoke-static/range {p0 .. p0}, " + + "$INTEGRATIONS_SEGMENT_PLAYBACK_CONTROLLER_CLASS_DESCRIPTOR->setSponsorBarRect(Ljava/lang/Object;)V" + ) + for ((index, instruction) in seekbarMethodInstructions.withIndex()) { if (instruction.opcode != Opcode.INVOKE_STATIC) continue @@ -125,38 +126,15 @@ class SponsorBlockBytecodePatch : BytecodePatch( // set the thickness of the segment seekbarMethod.addInstruction( insertIndex, - "invoke-static {v${invokeInstruction.registerC}}, $INTEGRATIONS_SEGMENT_PLAYBACK_CONTROLLER_CLASS_DESCRIPTOR->setSponsorBarThickness(I)V" + "invoke-static {v${invokeInstruction.registerC}}, " + + "$INTEGRATIONS_SEGMENT_PLAYBACK_CONTROLLER_CLASS_DESCRIPTOR->setSponsorBarThickness(I)V" ) break } - /* - * Set rectangle absolute left and right positions - */ - val drawRectangleInstructions = seekbarMethodInstructions.withIndex().filter { (_, instruction) -> - instruction is ReferenceInstruction && (instruction.reference as? MethodReference)?.name == "drawRect" - }.map { (index, instruction) -> // TODO: improve code - index to (instruction as FiveRegisterInstruction).registerD - } - - val (indexRight, rectangleRightRegister) = drawRectangleInstructions[0] - val (indexLeft, rectangleLeftRegister) = drawRectangleInstructions[3] - - // order of operation is important here due to the code above which has to be improved - // the reason for that is that we get the index, add instructions and then the offset would be wrong - seekbarMethod.addInstruction( - indexLeft + 1, - "invoke-static {v$rectangleLeftRegister}, $INTEGRATIONS_SEGMENT_PLAYBACK_CONTROLLER_CLASS_DESCRIPTOR->setSponsorBarAbsoluteLeft(Landroid/graphics/Rect;)V" - ) - seekbarMethod.addInstruction( - indexRight + 1, - "invoke-static {v$rectangleRightRegister}, $INTEGRATIONS_SEGMENT_PLAYBACK_CONTROLLER_CLASS_DESCRIPTOR->setSponsorBarAbsoluteRight(Landroid/graphics/Rect;)V" - ) - /* * Draw segment */ - // Find the drawCircle call and draw the segment before it for (i in seekbarMethodInstructions.size - 1 downTo 0) { val invokeInstruction = seekbarMethodInstructions[i] as? ReferenceInstruction ?: continue diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/sponsorblock/resource/patch/SponsorBlockResourcePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/sponsorblock/resource/patch/SponsorBlockResourcePatch.kt index aa2f647a9e..495778c94d 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/sponsorblock/resource/patch/SponsorBlockResourcePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/sponsorblock/resource/patch/SponsorBlockResourcePatch.kt @@ -10,7 +10,6 @@ import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patches.shared.mapping.misc.patch.ResourceMappingPatch import app.revanced.patches.shared.settings.preference.impl.Preference import app.revanced.patches.shared.settings.preference.impl.StringResource -import app.revanced.patches.youtube.layout.sponsorblock.annotations.SponsorBlockCompatibility import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch import app.revanced.util.resources.ResourceUtils import app.revanced.util.resources.ResourceUtils.copyResources @@ -18,7 +17,6 @@ import app.revanced.util.resources.ResourceUtils.copyXmlNode import app.revanced.util.resources.ResourceUtils.mergeStrings @Name("sponsorblock-resource-patch") -@SponsorBlockCompatibility @DependsOn([SettingsPatch::class, ResourceMappingPatch::class]) @Version("0.0.1") class SponsorBlockResourcePatch : ResourcePatch { diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/spoofappversion/annotations/SpoofAppVersionCompatibility.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/spoofappversion/annotations/SpoofAppVersionCompatibility.kt index 3b1e3061e3..c64f17745a 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/spoofappversion/annotations/SpoofAppVersionCompatibility.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/spoofappversion/annotations/SpoofAppVersionCompatibility.kt @@ -3,7 +3,7 @@ package app.revanced.patches.youtube.layout.spoofappversion.annotations import app.revanced.patcher.annotation.Compatibility import app.revanced.patcher.annotation.Package -@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37"))]) +@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35"))]) @Target(AnnotationTarget.CLASS) internal annotation class SpoofAppVersionCompatibility diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/startupshortsreset/annotations/StartupShortsResetCompatibility.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/startupshortsreset/annotations/StartupShortsResetCompatibility.kt index d7f5252388..72b516851d 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/startupshortsreset/annotations/StartupShortsResetCompatibility.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/startupshortsreset/annotations/StartupShortsResetCompatibility.kt @@ -3,6 +3,6 @@ package app.revanced.patches.youtube.layout.startupshortsreset.annotations import app.revanced.patcher.annotation.Compatibility import app.revanced.patcher.annotation.Package -@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37"))]) +@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35"))]) @Target(AnnotationTarget.CLASS) internal annotation class StartupShortsResetCompatibility diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/tabletminiplayer/annotations/TabletMiniPlayerCompatibility.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/tabletminiplayer/annotations/TabletMiniPlayerCompatibility.kt index 80789f9763..ded1563eda 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/tabletminiplayer/annotations/TabletMiniPlayerCompatibility.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/tabletminiplayer/annotations/TabletMiniPlayerCompatibility.kt @@ -3,6 +3,6 @@ package app.revanced.patches.youtube.layout.tabletminiplayer.annotations import app.revanced.patcher.annotation.Compatibility import app.revanced.patcher.annotation.Package -@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37"))]) +@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35"))]) @Target(AnnotationTarget.CLASS) internal annotation class TabletMiniPlayerCompatibility diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/theme/bytecode/patch/ThemeBytecodePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/theme/bytecode/patch/ThemeBytecodePatch.kt index 232daffb0c..1889ed7a88 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/theme/bytecode/patch/ThemeBytecodePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/theme/bytecode/patch/ThemeBytecodePatch.kt @@ -8,8 +8,8 @@ import app.revanced.patcher.patch.* import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch import app.revanced.patches.youtube.layout.seekbar.bytecode.patch.SeekbarColorBytecodePatch -import app.revanced.patches.youtube.layout.theme.resource.ThemeResourcePatch import app.revanced.patches.youtube.layout.theme.annotations.ThemeCompatibility +import app.revanced.patches.youtube.layout.theme.resource.ThemeResourcePatch @Patch @Name("theme") @@ -45,5 +45,14 @@ class ThemeBytecodePatch : BytecodePatch() { description = "The background color of the light theme. Can be a hex color or a resource reference.", ) ) + + var splashScreenBackgroundColor: String? by option( + PatchOption.StringOption( + key = "splashScreenBackgroundColor", + default = "@android:color/black", + title = "Background color for the splash screen", + description = "The background color of the splash screen. Can be a hex color or a resource reference.", + ) + ) } } diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/theme/resource/ThemeResourcePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/theme/resource/ThemeResourcePatch.kt index 338f48f0ef..a69278309f 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/theme/resource/ThemeResourcePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/theme/resource/ThemeResourcePatch.kt @@ -1,7 +1,9 @@ package app.revanced.patches.youtube.layout.theme.resource import app.revanced.patcher.data.ResourceContext -import app.revanced.patcher.patch.* +import app.revanced.patcher.patch.PatchResult +import app.revanced.patcher.patch.PatchResultSuccess +import app.revanced.patcher.patch.ResourcePatch import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patches.shared.mapping.misc.patch.ResourceMappingPatch import app.revanced.patches.shared.settings.preference.impl.InputType @@ -9,9 +11,8 @@ import app.revanced.patches.shared.settings.preference.impl.StringResource import app.revanced.patches.shared.settings.preference.impl.TextPreference import app.revanced.patches.youtube.layout.theme.bytecode.patch.ThemeBytecodePatch.Companion.darkThemeBackgroundColor import app.revanced.patches.youtube.layout.theme.bytecode.patch.ThemeBytecodePatch.Companion.lightThemeBackgroundColor +import app.revanced.patches.youtube.layout.theme.bytecode.patch.ThemeBytecodePatch.Companion.splashScreenBackgroundColor import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch -import app.revanced.util.resources.ResourceUtils -import app.revanced.util.resources.ResourceUtils.copyResources import org.w3c.dom.Element @DependsOn([SettingsPatch::class, ResourceMappingPatch::class]) @@ -29,35 +30,80 @@ class ThemeResourcePatch : ResourcePatch { ), ) - val darkThemeBackgroundColor = darkThemeBackgroundColor!! - val lightThemeBackgroundColor = lightThemeBackgroundColor!! - // Edit theme colors via resources. context.xmlEditor["res/values/colors.xml"].use { editor -> val resourcesNode = editor.file.getElementsByTagName("resources").item(0) as Element - for (i in 0 until resourcesNode.childNodes.length) { - val node = resourcesNode.childNodes.item(i) as? Element ?: continue + val children = resourcesNode.childNodes + for (i in 0 until children.length) { + val node = children.item(i) as? Element ?: continue node.textContent = when (node.getAttribute("name")) { "yt_black0", "yt_black1", "yt_black1_opacity95", "yt_black1_opacity98", "yt_black2", "yt_black3", "yt_black4", "yt_status_bar_background_dark", "material_grey_850" -> darkThemeBackgroundColor + ?: continue "yt_white1", "yt_white1_opacity95", "yt_white1_opacity98", "yt_white2", "yt_white3", "yt_white4", - -> lightThemeBackgroundColor + -> lightThemeBackgroundColor ?: continue else -> continue } } } - // Copy the resource file to change the splash screen color. - context.copyResources( - "theme", ResourceUtils.ResourceGroup("values-night-v31", "styles.xml") - ) + splashScreenBackgroundColor ?: return PatchResultSuccess() + + // Edit splash screen background color for Android 11 and below. + context.xmlEditor["res/values/styles.xml"].use { + val resourcesNode = it.file.getElementsByTagName("resources").item(0) as Element + + val children = resourcesNode.childNodes + for (i in 0 until children.length) { + val node = children.item(i) as? Element ?: continue + + if (node.tagName != "style") continue + + val name = node.getAttribute("name") + if (name != LAUNCHER_STYLE_NAME) continue + + it.file.createElement("item").apply { + setAttribute("name", "android:windowSplashScreenBackground") + textContent = splashScreenBackgroundColor + }.also(node::appendChild) + + break + } + } + + // Edit splash screen background color for Android 12+. + + // Add the splash screen background color to the colors.xml file. + context.xmlEditor["res/values/colors.xml"].use { + val resourcesNode = it.file.getElementsByTagName("resources").item(0) as Element + + it.file.createElement("color").apply { + setAttribute("name", COLOR_NAME) + setAttribute("category", "color") + textContent = splashScreenBackgroundColor + }.also(resourcesNode::appendChild) + } + + // Point to the splash screen background color. + context.xmlEditor["res/drawable/quantum_launchscreen_youtube.xml"].use { + val node = it.file.getElementsByTagName("layer-list").item(0) as Element + + val backgroundColorItem = node.childNodes.item(1) as Element + backgroundColorItem.apply { + setAttribute("android:drawable", "@color/$COLOR_NAME") + } + } return PatchResultSuccess() } -} + private companion object { + private const val LAUNCHER_STYLE_NAME = "Base.Theme.YouTube.Launcher" + private const val COLOR_NAME = "splash_background_color" + } +} \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/autorepeat/annotations/AutoRepeatCompatibility.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/autorepeat/annotations/AutoRepeatCompatibility.kt index 722786c615..ab04bfe8d5 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/autorepeat/annotations/AutoRepeatCompatibility.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/autorepeat/annotations/AutoRepeatCompatibility.kt @@ -3,6 +3,6 @@ package app.revanced.patches.youtube.misc.autorepeat.annotations import app.revanced.patcher.annotation.Compatibility import app.revanced.patcher.annotation.Package -@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37"))]) +@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35"))]) @Target(AnnotationTarget.CLASS) internal annotation class AutoRepeatCompatibility \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/fix/backtoexitgesture/annotation/FixBackToExitGestureCompatibility.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/fix/backtoexitgesture/annotation/FixBackToExitGestureCompatibility.kt index 4fd9bb3145..8a470352b3 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/fix/backtoexitgesture/annotation/FixBackToExitGestureCompatibility.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/fix/backtoexitgesture/annotation/FixBackToExitGestureCompatibility.kt @@ -3,6 +3,6 @@ package app.revanced.patches.youtube.misc.fix.backtoexitgesture.annotation import app.revanced.patcher.annotation.Compatibility import app.revanced.patcher.annotation.Package -@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37"))]) +@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35"))]) @Target(AnnotationTarget.CLASS) internal annotation class FixBackToExitGestureCompatibility \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/shared/misc/fix/spoof/annotations/ClientSpoofCompatibility.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/fix/playback/annotations/ClientSpoofCompatibility.kt similarity index 73% rename from src/main/kotlin/app/revanced/patches/shared/misc/fix/spoof/annotations/ClientSpoofCompatibility.kt rename to src/main/kotlin/app/revanced/patches/youtube/misc/fix/playback/annotations/ClientSpoofCompatibility.kt index 63a9c4c51f..13e9c51b55 100644 --- a/src/main/kotlin/app/revanced/patches/shared/misc/fix/spoof/annotations/ClientSpoofCompatibility.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/fix/playback/annotations/ClientSpoofCompatibility.kt @@ -1,8 +1,8 @@ -package app.revanced.patches.shared.misc.fix.spoof.annotations +package app.revanced.patches.youtube.misc.fix.playback.annotations import app.revanced.patcher.annotation.Compatibility import app.revanced.patcher.annotation.Package -@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37"))]) +@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35"))]) @Target(AnnotationTarget.CLASS) internal annotation class ClientSpoofCompatibility diff --git a/src/main/kotlin/app/revanced/patches/shared/misc/fix/spoof/fingerprints/UserAgentHeaderBuilderFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/fix/playback/fingerprints/UserAgentHeaderBuilderFingerprint.kt similarity index 82% rename from src/main/kotlin/app/revanced/patches/shared/misc/fix/spoof/fingerprints/UserAgentHeaderBuilderFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/misc/fix/playback/fingerprints/UserAgentHeaderBuilderFingerprint.kt index f3cf363e35..5428c2a4d2 100644 --- a/src/main/kotlin/app/revanced/patches/shared/misc/fix/spoof/fingerprints/UserAgentHeaderBuilderFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/fix/playback/fingerprints/UserAgentHeaderBuilderFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.shared.misc.fix.spoof.fingerprints +package app.revanced.patches.youtube.misc.fix.playback.fingerprints import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint diff --git a/src/main/kotlin/app/revanced/patches/shared/misc/fix/spoof/patch/ClientSpoofPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/fix/playback/patch/ClientSpoofPatch.kt similarity index 83% rename from src/main/kotlin/app/revanced/patches/shared/misc/fix/spoof/patch/ClientSpoofPatch.kt rename to src/main/kotlin/app/revanced/patches/youtube/misc/fix/playback/patch/ClientSpoofPatch.kt index e16dbc3502..b06a4bfa01 100644 --- a/src/main/kotlin/app/revanced/patches/shared/misc/fix/spoof/patch/ClientSpoofPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/fix/playback/patch/ClientSpoofPatch.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.shared.misc.fix.spoof.patch +package app.revanced.patches.youtube.misc.fix.playback.patch import app.revanced.extensions.toErrorResult import app.revanced.patcher.annotation.Description @@ -12,9 +12,8 @@ import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch -import app.revanced.patches.shared.misc.fix.spoof.annotations.ClientSpoofCompatibility -import app.revanced.patches.shared.misc.fix.spoof.fingerprints.UserAgentHeaderBuilderFingerprint -import app.revanced.patches.youtube.misc.fix.playback.patch.SpoofSignatureVerificationPatch +import app.revanced.patches.youtube.misc.fix.playback.annotations.ClientSpoofCompatibility +import app.revanced.patches.youtube.misc.fix.playback.fingerprints.UserAgentHeaderBuilderFingerprint import org.jf.dexlib2.iface.instruction.FiveRegisterInstruction @Patch diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/integrations/annotations/IntegrationsCompatibility.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/integrations/annotations/IntegrationsCompatibility.kt index 240059e65b..0bdca1b8aa 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/integrations/annotations/IntegrationsCompatibility.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/integrations/annotations/IntegrationsCompatibility.kt @@ -3,6 +3,6 @@ package app.revanced.patches.youtube.misc.integrations.annotations import app.revanced.patcher.annotation.Compatibility import app.revanced.patcher.annotation.Package -@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37"))]) +@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35"))]) @Target(AnnotationTarget.CLASS) internal annotation class IntegrationsCompatibility \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/links/open/annotations/OpenLinksExternallyCompatibility.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/links/open/annotations/OpenLinksExternallyCompatibility.kt index 74f2712692..9485b3efc8 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/links/open/annotations/OpenLinksExternallyCompatibility.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/links/open/annotations/OpenLinksExternallyCompatibility.kt @@ -3,6 +3,6 @@ package app.revanced.patches.youtube.misc.links.open.annotations import app.revanced.patcher.annotation.Compatibility import app.revanced.patcher.annotation.Package -@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37"))]) +@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35"))]) @Target(AnnotationTarget.CLASS) internal annotation class OpenLinksExternallyCompatibility diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/litho/filter/annotation/LithoFilterCompatibility.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/litho/filter/annotation/LithoFilterCompatibility.kt index ab028a997c..7d483d2761 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/litho/filter/annotation/LithoFilterCompatibility.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/litho/filter/annotation/LithoFilterCompatibility.kt @@ -3,7 +3,7 @@ package app.revanced.patches.youtube.misc.litho.filter.annotation import app.revanced.patcher.annotation.Compatibility import app.revanced.patcher.annotation.Package -@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37"))]) +@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35"))]) @Target(AnnotationTarget.CLASS) internal annotation class LithoFilterCompatibility diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/microg/annotations/MicroGPatchCompatibility.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/microg/annotations/MicroGPatchCompatibility.kt index 41ea35f990..352ed3746c 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/microg/annotations/MicroGPatchCompatibility.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/microg/annotations/MicroGPatchCompatibility.kt @@ -3,6 +3,6 @@ package app.revanced.patches.youtube.misc.microg.annotations import app.revanced.patcher.annotation.Compatibility import app.revanced.patcher.annotation.Package -@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37"))]) +@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35"))]) @Target(AnnotationTarget.CLASS) internal annotation class MicroGPatchCompatibility \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/microg/patch/bytecode/MicroGBytecodePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/microg/patch/bytecode/MicroGBytecodePatch.kt index 9a59268966..8731c413a7 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/microg/patch/bytecode/MicroGBytecodePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/microg/patch/bytecode/MicroGBytecodePatch.kt @@ -10,9 +10,7 @@ import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch import app.revanced.patches.shared.fingerprints.WatchWhileActivityFingerprint -import app.revanced.patches.shared.misc.fix.spoof.patch.ClientSpoofPatch import app.revanced.patches.youtube.layout.buttons.cast.patch.HideCastButtonPatch -import app.revanced.patches.youtube.misc.fix.playback.patch.SpoofSignatureVerificationPatch import app.revanced.patches.youtube.misc.microg.annotations.MicroGPatchCompatibility import app.revanced.patches.youtube.misc.microg.fingerprints.* import app.revanced.patches.youtube.misc.microg.patch.resource.MicroGResourcePatch diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/minimizedplayback/annotations/MinimizedPlaybackCompatibility.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/minimizedplayback/annotations/MinimizedPlaybackCompatibility.kt index 4e88273dae..85a1316bcf 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/minimizedplayback/annotations/MinimizedPlaybackCompatibility.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/minimizedplayback/annotations/MinimizedPlaybackCompatibility.kt @@ -3,6 +3,6 @@ package app.revanced.patches.youtube.misc.minimizedplayback.annotations import app.revanced.patcher.annotation.Compatibility import app.revanced.patcher.annotation.Package -@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37" ) )]) +@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37" , "18.19.35"))]) @Target(AnnotationTarget.CLASS) internal annotation class MinimizedPlaybackCompatibility \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/playercontrols/annotation/PlayerControlsCompatibility.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/playercontrols/annotation/PlayerControlsCompatibility.kt index c74e9e7d55..296b6477bf 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/playercontrols/annotation/PlayerControlsCompatibility.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/playercontrols/annotation/PlayerControlsCompatibility.kt @@ -3,6 +3,6 @@ package app.revanced.patches.youtube.misc.playercontrols.annotation import app.revanced.patcher.annotation.Compatibility import app.revanced.patcher.annotation.Package -@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37"))]) +@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35"))]) @Target(AnnotationTarget.CLASS) internal annotation class PlayerControlsCompatibility \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/playeroverlay/annotation/PlayerOverlaysHookCompatibility.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/playeroverlay/annotation/PlayerOverlaysHookCompatibility.kt index 6bd27f1170..89a6fa3d4e 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/playeroverlay/annotation/PlayerOverlaysHookCompatibility.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/playeroverlay/annotation/PlayerOverlaysHookCompatibility.kt @@ -3,6 +3,6 @@ package app.revanced.patches.youtube.misc.playeroverlay.annotation import app.revanced.patcher.annotation.Compatibility import app.revanced.patcher.annotation.Package -@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37"))]) +@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35"))]) @Target(AnnotationTarget.CLASS) internal annotation class PlayerOverlaysHookCompatibility diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/playertype/annotation/PlayerTypeHookCompatibility.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/playertype/annotation/PlayerTypeHookCompatibility.kt index 82155f1e01..dff4ca516b 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/playertype/annotation/PlayerTypeHookCompatibility.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/playertype/annotation/PlayerTypeHookCompatibility.kt @@ -3,6 +3,6 @@ package app.revanced.patches.youtube.misc.playertype.annotation import app.revanced.patcher.annotation.Compatibility import app.revanced.patcher.annotation.Package -@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37"))]) +@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35"))]) @Target(AnnotationTarget.CLASS) internal annotation class PlayerTypeHookCompatibility diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/videobuffer/annotations/CustomVideoBufferCompatibility.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/videobuffer/annotations/CustomVideoBufferCompatibility.kt index 410368d81f..628499d60b 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/videobuffer/annotations/CustomVideoBufferCompatibility.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/videobuffer/annotations/CustomVideoBufferCompatibility.kt @@ -4,6 +4,6 @@ import app.revanced.patcher.annotation.Compatibility import app.revanced.patcher.annotation.Package // TODO: delete this -@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37"))]) +@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35"))]) @Target(AnnotationTarget.CLASS) internal annotation class CustomVideoBufferCompatibility diff --git a/src/main/kotlin/app/revanced/patches/youtube/video/hdrbrightness/annotations/HDRBrightnessCompatibility.kt b/src/main/kotlin/app/revanced/patches/youtube/video/hdrbrightness/annotations/HDRBrightnessCompatibility.kt index 3661f8b7a1..29e7da0764 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/video/hdrbrightness/annotations/HDRBrightnessCompatibility.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/video/hdrbrightness/annotations/HDRBrightnessCompatibility.kt @@ -3,6 +3,6 @@ package app.revanced.patches.youtube.video.hdrbrightness.annotations import app.revanced.patcher.annotation.Compatibility import app.revanced.patcher.annotation.Package -@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37"))]) +@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35"))]) @Target(AnnotationTarget.CLASS) internal annotation class HDRBrightnessCompatibility diff --git a/src/main/kotlin/app/revanced/patches/youtube/video/information/annotation/VideoInformationCompatibility.kt b/src/main/kotlin/app/revanced/patches/youtube/video/information/annotation/VideoInformationCompatibility.kt index e0dddf3266..2ff6163dfa 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/video/information/annotation/VideoInformationCompatibility.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/video/information/annotation/VideoInformationCompatibility.kt @@ -3,6 +3,6 @@ package app.revanced.patches.youtube.video.information.annotation import app.revanced.patcher.annotation.Compatibility import app.revanced.patcher.annotation.Package -@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37"))]) +@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35"))]) @Target(AnnotationTarget.CLASS) internal annotation class VideoInformationCompatibility diff --git a/src/main/kotlin/app/revanced/patches/youtube/video/oldqualitylayout/annotations/OldQualityLayoutCompatibility.kt b/src/main/kotlin/app/revanced/patches/youtube/video/oldqualitylayout/annotations/OldQualityLayoutCompatibility.kt index b68be3e8c3..701f9974d9 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/video/oldqualitylayout/annotations/OldQualityLayoutCompatibility.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/video/oldqualitylayout/annotations/OldQualityLayoutCompatibility.kt @@ -3,6 +3,6 @@ package app.revanced.patches.youtube.video.oldqualitylayout.annotations import app.revanced.patcher.annotation.Compatibility import app.revanced.patcher.annotation.Package -@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37"))]) +@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35"))]) @Target(AnnotationTarget.CLASS) internal annotation class OldQualityLayoutCompatibility \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/video/oldqualitylayout/fingerprints/QualityMenuViewInflateFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/video/oldqualitylayout/fingerprints/QualityMenuViewInflateFingerprint.kt index 61b0858950..bce667560e 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/video/oldqualitylayout/fingerprints/QualityMenuViewInflateFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/video/oldqualitylayout/fingerprints/QualityMenuViewInflateFingerprint.kt @@ -1,12 +1,12 @@ package app.revanced.patches.youtube.video.oldqualitylayout.fingerprints -import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint -import org.jf.dexlib2.AccessFlags +import app.revanced.patches.youtube.video.oldqualitylayout.patch.OldQualityLayoutResourcePatch import org.jf.dexlib2.Opcode +import org.jf.dexlib2.iface.instruction.WideLiteralInstruction object QualityMenuViewInflateFingerprint : MethodFingerprint( - "L", AccessFlags.FINAL or AccessFlags.PUBLIC, listOf("L", "L", "L"), listOf( + opcodes = listOf( Opcode.INVOKE_SUPER, Opcode.CONST, Opcode.CONST_4, @@ -20,12 +20,15 @@ object QualityMenuViewInflateFingerprint : MethodFingerprint( Opcode.CONST, Opcode.INVOKE_VIRTUAL, Opcode.MOVE_RESULT_OBJECT, - Opcode.CHECK_CAST, - Opcode.CONST, - Opcode.INVOKE_VIRTUAL, - Opcode.MOVE_RESULT_OBJECT, - Opcode.IGET_OBJECT, - Opcode.IGET_OBJECT, - Opcode.CONST_STRING, - ) + Opcode.CHECK_CAST + ), + customFingerprint = { methodDef, _ -> + methodDef.implementation?.instructions?.any { + if (it.opcode != Opcode.CONST) return@any false + + val literal = (it as WideLiteralInstruction).wideLiteral + + literal == OldQualityLayoutResourcePatch.videoQualityBottomSheetListFragmentTitle + } ?: false + } ) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/video/oldqualitylayout/patch/OldQualityLayoutPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/video/oldqualitylayout/patch/OldQualityLayoutPatch.kt index 159f8fe638..1dcdf03037 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/video/oldqualitylayout/patch/OldQualityLayoutPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/video/oldqualitylayout/patch/OldQualityLayoutPatch.kt @@ -10,35 +10,19 @@ import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch -import app.revanced.patches.shared.settings.preference.impl.StringResource -import app.revanced.patches.shared.settings.preference.impl.SwitchPreference +import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch import app.revanced.patches.youtube.video.oldqualitylayout.annotations.OldQualityLayoutCompatibility import app.revanced.patches.youtube.video.oldqualitylayout.fingerprints.QualityMenuViewInflateFingerprint -import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch -import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch import org.jf.dexlib2.iface.instruction.FiveRegisterInstruction @Patch -@DependsOn([IntegrationsPatch::class, SettingsPatch::class]) +@DependsOn([IntegrationsPatch::class, OldQualityLayoutResourcePatch::class]) @Name("old-quality-layout") -@Description("Enables the original video quality flyout in the video player settings") +@Description("Enables the original video quality flyout in the video player settings.") @OldQualityLayoutCompatibility @Version("0.0.1") -// new ReVanced users have no idea what it means to use the "old quality layout menu" -// maybe rename this patch to better describe what it provides (ie: user-selectable-video-resolution ) -class OldQualityLayoutPatch : BytecodePatch( - listOf(QualityMenuViewInflateFingerprint) -) { +class OldQualityLayoutPatch : BytecodePatch(listOf(QualityMenuViewInflateFingerprint)) { override fun execute(context: BytecodeContext): PatchResult { - SettingsPatch.PreferenceScreen.VIDEO.addPreferences( - SwitchPreference( - "revanced_show_old_video_menu", - StringResource("revanced_show_old_video_menu_title", "Use old video quality player menu"), - StringResource("revanced_show_old_video_menu_summary_on", "Old video quality menu is used"), - StringResource("revanced_show_old_video_menu_summary_off", "Old video quality menu is not used") - ) - ) - val inflateFingerprintResult = QualityMenuViewInflateFingerprint.result!! val method = inflateFingerprintResult.mutableMethod val instructions = method.implementation!!.instructions @@ -57,4 +41,4 @@ class OldQualityLayoutPatch : BytecodePatch( return PatchResultSuccess() } -} +} \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/video/oldqualitylayout/patch/OldQualityLayoutResourcePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/video/oldqualitylayout/patch/OldQualityLayoutResourcePatch.kt new file mode 100644 index 0000000000..965486ce51 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/youtube/video/oldqualitylayout/patch/OldQualityLayoutResourcePatch.kt @@ -0,0 +1,36 @@ +package app.revanced.patches.youtube.video.oldqualitylayout.patch + +import app.revanced.patcher.data.ResourceContext +import app.revanced.patcher.patch.PatchResult +import app.revanced.patcher.patch.PatchResultError +import app.revanced.patcher.patch.PatchResultSuccess +import app.revanced.patcher.patch.ResourcePatch +import app.revanced.patcher.patch.annotations.DependsOn +import app.revanced.patches.shared.mapping.misc.patch.ResourceMappingPatch +import app.revanced.patches.shared.settings.preference.impl.StringResource +import app.revanced.patches.shared.settings.preference.impl.SwitchPreference +import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch + +@DependsOn([SettingsPatch::class, ResourceMappingPatch::class]) +class OldQualityLayoutResourcePatch : ResourcePatch { + override fun execute(context: ResourceContext): PatchResult { + SettingsPatch.PreferenceScreen.VIDEO.addPreferences( + SwitchPreference( + "revanced_show_old_video_menu", + StringResource("revanced_show_old_video_menu_title", "Use old video quality player menu"), + StringResource("revanced_show_old_video_menu_summary_on", "Old video quality menu is used"), + StringResource("revanced_show_old_video_menu_summary_off", "Old video quality menu is not used") + ) + ) + + videoQualityBottomSheetListFragmentTitle = + ResourceMappingPatch.resourceMappings.find { it.name == "video_quality_bottom_sheet_list_fragment_title" } + ?.id ?: return PatchResultError("Could not find resource") + + return PatchResultSuccess() + } + + internal companion object { + var videoQualityBottomSheetListFragmentTitle = -1L + } +} diff --git a/src/main/kotlin/app/revanced/patches/youtube/video/quality/annotations/RememberVideoQualityCompatibility.kt b/src/main/kotlin/app/revanced/patches/youtube/video/quality/annotations/RememberVideoQualityCompatibility.kt index 23cf195015..789e422eb1 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/video/quality/annotations/RememberVideoQualityCompatibility.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/video/quality/annotations/RememberVideoQualityCompatibility.kt @@ -3,6 +3,6 @@ package app.revanced.patches.youtube.video.quality.annotations import app.revanced.patcher.annotation.Compatibility import app.revanced.patcher.annotation.Package -@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37"))]) +@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35"))]) @Target(AnnotationTarget.CLASS) internal annotation class RememberVideoQualityCompatibility diff --git a/src/main/kotlin/app/revanced/patches/youtube/video/speed/VideoSpeedCompatibility.kt b/src/main/kotlin/app/revanced/patches/youtube/video/speed/VideoSpeedCompatibility.kt index aec2321316..b97e92931b 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/video/speed/VideoSpeedCompatibility.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/video/speed/VideoSpeedCompatibility.kt @@ -3,6 +3,6 @@ package app.revanced.patches.youtube.video.speed import app.revanced.patcher.annotation.Compatibility import app.revanced.patcher.annotation.Package -@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37"))]) +@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35"))]) @Target(AnnotationTarget.CLASS) internal annotation class VideoSpeedCompatibility diff --git a/src/main/kotlin/app/revanced/patches/youtube/video/videoid/annotation/VideoIdCompatibility.kt b/src/main/kotlin/app/revanced/patches/youtube/video/videoid/annotation/VideoIdCompatibility.kt index 646b3e7d86..660f7d8ad9 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/video/videoid/annotation/VideoIdCompatibility.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/video/videoid/annotation/VideoIdCompatibility.kt @@ -3,6 +3,6 @@ package app.revanced.patches.youtube.video.videoid.annotation import app.revanced.patcher.annotation.Compatibility import app.revanced.patcher.annotation.Package -@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37"))]) +@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35"))]) @Target(AnnotationTarget.CLASS) internal annotation class VideoIdCompatibility diff --git a/src/main/resources/theme/values-night-v31/styles.xml b/src/main/resources/theme/values-night-v31/styles.xml deleted file mode 100644 index 53da895f84..0000000000 --- a/src/main/resources/theme/values-night-v31/styles.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - -