From a0121ae7b60de88f0f2113ad0cefdb538f370780 Mon Sep 17 00:00:00 2001 From: LisoUseInAIKyrios <118716522+LisoUseInAIKyrios@users.noreply.github.com> Date: Sun, 19 Nov 2023 17:03:35 +0200 Subject: [PATCH] feat(YouTube): Add `Disable rolling number animations` patch (#3298) --- .../SwipeControlsBytecodePatch.kt | 2 +- .../autoplay/HideAutoplayButtonPatch.kt | 2 +- .../DisableRollingNumberAnimationPatch.kt | 78 +++++++++++++++++++ .../layout/hide/seekbar/HideSeekbarPatch.kt | 4 +- .../ReturnYouTubeDislikePatch.kt | 19 ++--- ...ngNumberMeasureAnimatedTextFingerprint.kt} | 2 +- ...ingNumberMeasureStaticLabelFingerprint.kt} | 2 +- .../RollingNumberTextViewFingerprint.kt | 2 +- .../sponsorblock/SponsorBlockBytecodePatch.kt | 4 +- .../misc/announcements/AnnouncementsPatch.kt | 2 +- .../misc/microg/MicroGBytecodePatch.kt | 2 +- .../PlayerControlsBytecodePatch.kt | 2 +- .../LayoutConstructorFingerprint.kt | 2 +- ...umberTextViewAnimationUpdateFingerprint.kt | 30 +++++++ .../fingerprints/SeekbarOnDrawFingerprint.kt | 3 +- .../WatchWhileActivityFingerprint.kt | 2 +- 16 files changed, 133 insertions(+), 25 deletions(-) create mode 100644 src/main/kotlin/app/revanced/patches/youtube/layout/hide/rollingnumber/DisableRollingNumberAnimationPatch.kt rename src/main/kotlin/app/revanced/patches/youtube/layout/returnyoutubedislike/fingerprints/{RollingNumberMeasureTextFingerprint.kt => RollingNumberMeasureAnimatedTextFingerprint.kt} (90%) rename src/main/kotlin/app/revanced/patches/youtube/layout/returnyoutubedislike/fingerprints/{RollingNumberStaticLabelMeasureTextFingerprint.kt => RollingNumberMeasureStaticLabelFingerprint.kt} (89%) rename src/main/kotlin/app/revanced/patches/{ => youtube}/shared/fingerprints/LayoutConstructorFingerprint.kt (86%) create mode 100644 src/main/kotlin/app/revanced/patches/youtube/shared/fingerprints/RollingNumberTextViewAnimationUpdateFingerprint.kt rename src/main/kotlin/app/revanced/patches/{ => youtube}/shared/fingerprints/SeekbarOnDrawFingerprint.kt (76%) rename src/main/kotlin/app/revanced/patches/{ => youtube}/shared/fingerprints/WatchWhileActivityFingerprint.kt (87%) diff --git a/src/main/kotlin/app/revanced/patches/youtube/interaction/swipecontrols/SwipeControlsBytecodePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/interaction/swipecontrols/SwipeControlsBytecodePatch.kt index 640e9fc5f..5bda6e2fa 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/interaction/swipecontrols/SwipeControlsBytecodePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/interaction/swipecontrols/SwipeControlsBytecodePatch.kt @@ -7,10 +7,10 @@ import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.annotation.CompatiblePackage import app.revanced.patcher.patch.annotation.Patch import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod.Companion.toMutable -import app.revanced.patches.shared.fingerprints.WatchWhileActivityFingerprint import app.revanced.patches.youtube.interaction.swipecontrols.fingerprints.SwipeControlsHostActivityFingerprint import app.revanced.patches.youtube.misc.integrations.IntegrationsPatch import app.revanced.patches.youtube.misc.playertype.PlayerTypeHookPatch +import app.revanced.patches.youtube.shared.fingerprints.WatchWhileActivityFingerprint import com.android.tools.smali.dexlib2.AccessFlags import com.android.tools.smali.dexlib2.immutable.ImmutableMethod diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/autoplay/HideAutoplayButtonPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/autoplay/HideAutoplayButtonPatch.kt index f1d1e4b0f..e1c5e5a4e 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/autoplay/HideAutoplayButtonPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/autoplay/HideAutoplayButtonPatch.kt @@ -9,12 +9,12 @@ import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.annotation.CompatiblePackage import app.revanced.patcher.patch.annotation.Patch import app.revanced.patcher.util.smali.ExternalLabel -import app.revanced.patches.shared.fingerprints.LayoutConstructorFingerprint import app.revanced.patches.shared.mapping.misc.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.integrations.IntegrationsPatch import app.revanced.patches.youtube.misc.settings.SettingsPatch +import app.revanced.patches.youtube.shared.fingerprints.LayoutConstructorFingerprint import com.android.tools.smali.dexlib2.iface.instruction.Instruction import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/rollingnumber/DisableRollingNumberAnimationPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/rollingnumber/DisableRollingNumberAnimationPatch.kt new file mode 100644 index 000000000..85f4ea244 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/rollingnumber/DisableRollingNumberAnimationPatch.kt @@ -0,0 +1,78 @@ +package app.revanced.patches.youtube.layout.hide.rollingnumber + +import app.revanced.extensions.exception +import app.revanced.patcher.data.BytecodeContext +import app.revanced.patcher.extensions.InstructionExtensions.addInstructions +import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels +import app.revanced.patcher.extensions.InstructionExtensions.getInstruction +import app.revanced.patcher.patch.BytecodePatch +import app.revanced.patcher.patch.annotation.CompatiblePackage +import app.revanced.patcher.patch.annotation.Patch +import app.revanced.patcher.util.smali.ExternalLabel +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.IntegrationsPatch +import app.revanced.patches.youtube.misc.settings.SettingsPatch +import app.revanced.patches.youtube.shared.fingerprints.RollingNumberTextViewAnimationUpdateFingerprint +import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction + +@Patch( + name = "Disable rolling number animations", + description = "Disables rolling number animations of video view count, upload time, and user likes", + dependencies = [IntegrationsPatch::class, SettingsPatch::class], + compatiblePackages = [ + CompatiblePackage( + "com.google.android.youtube", [ + "18.43.45", + "18.44.41", + "18.45.41" + ] + ) + ] +) +@Suppress("unused") +object DisableRollingNumberAnimationPatch : BytecodePatch( + setOf( + RollingNumberTextViewAnimationUpdateFingerprint + ) +) { + private const val INTEGRATIONS_CLASS_DESCRIPTOR = + "Lapp/revanced/integrations/patches/DisableRollingNumberAnimationsPatch;" + + override fun execute(context: BytecodeContext) { + SettingsPatch.PreferenceScreen.LAYOUT.addPreferences( + SwitchPreference( + "revanced_disable_rolling_number_animations", + StringResource("revanced_disable_rolling_number_animations_title", "Disable rolling number animations"), + StringResource("revanced_disable_rolling_number_animations_summary_on", "Rolling numbers are not animated"), + StringResource("revanced_disable_rolling_number_animations_summary_off", "Rolling numbers are animated") + ) + ) + + // Animations are disabled by preventing an Image from being applied to the text span, + // which prevents the animations from appearing. + RollingNumberTextViewAnimationUpdateFingerprint.result?.apply { + val patternScanResult = scanResult.patternScanResult!! + val blockStartIndex = patternScanResult.startIndex + val blockEndIndex = patternScanResult.endIndex + 1 + mutableMethod.apply { + val freeRegister = getInstruction(blockStartIndex).registerA + + // ReturnYouTubeDislike also makes changes to this same method, + // and must add control flow label to a noop instruction to + // ensure RYD patch adds it's changes after the control flow label. + addInstructions(blockEndIndex, "nop") + + addInstructionsWithLabels( + blockStartIndex, + """ + invoke-static { }, $INTEGRATIONS_CLASS_DESCRIPTOR->disableRollingNumberAnimations()Z + move-result v$freeRegister + if-nez v$freeRegister, :disable_animations + """, + ExternalLabel("disable_animations", getInstruction(blockEndIndex)) + ) + } + } ?: throw RollingNumberTextViewAnimationUpdateFingerprint.exception + } +} diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/seekbar/HideSeekbarPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/seekbar/HideSeekbarPatch.kt index d0fcdb8e5..374e73bf0 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/seekbar/HideSeekbarPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/seekbar/HideSeekbarPatch.kt @@ -5,14 +5,14 @@ import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWith import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.annotation.CompatiblePackage import app.revanced.patcher.patch.annotation.Patch -import app.revanced.patches.youtube.shared.fingerprints.SeekbarFingerprint -import app.revanced.patches.shared.fingerprints.SeekbarOnDrawFingerprint import app.revanced.patches.shared.settings.preference.impl.StringResource import app.revanced.patches.shared.settings.preference.impl.SwitchPreference import app.revanced.patches.youtube.layout.seekbar.SeekbarColorBytecodePatch import app.revanced.patches.youtube.layout.seekbar.SeekbarPreferencesPatch import app.revanced.patches.youtube.misc.integrations.IntegrationsPatch import app.revanced.patches.youtube.misc.settings.SettingsPatch +import app.revanced.patches.youtube.shared.fingerprints.SeekbarFingerprint +import app.revanced.patches.youtube.shared.fingerprints.SeekbarOnDrawFingerprint @Patch( name = "Hide seekbar", diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/returnyoutubedislike/ReturnYouTubeDislikePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/returnyoutubedislike/ReturnYouTubeDislikePatch.kt index 4ad80d2a8..1caff009b 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/returnyoutubedislike/ReturnYouTubeDislikePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/returnyoutubedislike/ReturnYouTubeDislikePatch.kt @@ -11,13 +11,13 @@ import app.revanced.patcher.extensions.InstructionExtensions.getInstruction import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction import app.revanced.patcher.fingerprint.MethodFingerprint import app.revanced.patcher.patch.BytecodePatch -import app.revanced.patcher.patch.PatchException import app.revanced.patcher.patch.annotation.CompatiblePackage import app.revanced.patcher.patch.annotation.Patch import app.revanced.patches.youtube.layout.returnyoutubedislike.fingerprints.* import app.revanced.patches.youtube.misc.integrations.IntegrationsPatch import app.revanced.patches.youtube.misc.litho.filter.LithoFilterPatch import app.revanced.patches.youtube.misc.playertype.PlayerTypeHookPatch +import app.revanced.patches.youtube.shared.fingerprints.RollingNumberTextViewAnimationUpdateFingerprint import app.revanced.patches.youtube.video.videoid.VideoIdPatch import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction @@ -55,8 +55,9 @@ object ReturnYouTubeDislikePatch : BytecodePatch( DislikeFingerprint, RemoveLikeFingerprint, RollingNumberSetterFingerprint, + RollingNumberMeasureTextParentFingerprint, RollingNumberTextViewFingerprint, - RollingNumberMeasureTextParentFingerprint + RollingNumberTextViewAnimationUpdateFingerprint ) ) { private const val INTEGRATIONS_CLASS_DESCRIPTOR = @@ -184,7 +185,7 @@ object ReturnYouTubeDislikePatch : BytecodePatch( // Rolling Number text views use the measured width of the raw string for layout. // Modify the measure text calculation to include the left drawable separator if needed. - RollingNumberMeasureTextFingerprint.also { + RollingNumberMeasureAnimatedTextFingerprint.also { if (!it.resolve(context, RollingNumberMeasureTextParentFingerprint.result!!.classDef)) throw it.exception }.result?.also { @@ -205,11 +206,11 @@ object ReturnYouTubeDislikePatch : BytecodePatch( """ ) } - } ?: throw RollingNumberMeasureTextFingerprint.exception + } ?: throw RollingNumberMeasureAnimatedTextFingerprint.exception // Additional text measurement method. Used if YouTube decides not to animate the likes count // and sometimes used for initial video load. - RollingNumberStaticLabelMeasureTextFingerprint.also { + RollingNumberMeasureStaticLabelFingerprint.also { if (!it.resolve(context, RollingNumberMeasureTextParentFingerprint.result!!.classDef)) throw it.exception }.result?.also { @@ -225,7 +226,7 @@ object ReturnYouTubeDislikePatch : BytecodePatch( """ ) } - } ?: throw RollingNumberStaticLabelMeasureTextFingerprint.exception + } ?: throw RollingNumberMeasureStaticLabelFingerprint.exception // The rolling number Span is missing styling since it's initially set as a String. // Modify the UI text view and use the styled like/dislike Span. @@ -235,9 +236,9 @@ object ReturnYouTubeDislikePatch : BytecodePatch( // Videos less than 24 hours after uploaded, like counts will be updated in real time. // Whenever like counts are updated, TextView is set in this method. - val realTimeUpdateTextViewMethod = it.mutableClass.methods.find { method -> - method.parameterTypes.first() == "Landroid/graphics/Bitmap;" - } ?: throw PatchException("Failed to find realTimeUpdateTextViewMethod") + val realTimeUpdateTextViewMethod = + RollingNumberTextViewAnimationUpdateFingerprint.result?.mutableMethod + ?: throw RollingNumberTextViewAnimationUpdateFingerprint.exception arrayOf( initiallyCreatedTextViewMethod, diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/returnyoutubedislike/fingerprints/RollingNumberMeasureTextFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/returnyoutubedislike/fingerprints/RollingNumberMeasureAnimatedTextFingerprint.kt similarity index 90% rename from src/main/kotlin/app/revanced/patches/youtube/layout/returnyoutubedislike/fingerprints/RollingNumberMeasureTextFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/layout/returnyoutubedislike/fingerprints/RollingNumberMeasureAnimatedTextFingerprint.kt index e3469e454..8a44416ac 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/returnyoutubedislike/fingerprints/RollingNumberMeasureTextFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/returnyoutubedislike/fingerprints/RollingNumberMeasureAnimatedTextFingerprint.kt @@ -8,7 +8,7 @@ import com.android.tools.smali.dexlib2.Opcode /** * Resolves to class found in [RollingNumberMeasureTextParentFingerprint]. */ -object RollingNumberMeasureTextFingerprint : MethodFingerprint( +object RollingNumberMeasureAnimatedTextFingerprint : MethodFingerprint( returnType = "F", accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL, parameters = listOf("Ljava/lang/String;"), diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/returnyoutubedislike/fingerprints/RollingNumberStaticLabelMeasureTextFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/returnyoutubedislike/fingerprints/RollingNumberMeasureStaticLabelFingerprint.kt similarity index 89% rename from src/main/kotlin/app/revanced/patches/youtube/layout/returnyoutubedislike/fingerprints/RollingNumberStaticLabelMeasureTextFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/layout/returnyoutubedislike/fingerprints/RollingNumberMeasureStaticLabelFingerprint.kt index faed48d17..4c35f9bb3 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/returnyoutubedislike/fingerprints/RollingNumberStaticLabelMeasureTextFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/returnyoutubedislike/fingerprints/RollingNumberMeasureStaticLabelFingerprint.kt @@ -8,7 +8,7 @@ import com.android.tools.smali.dexlib2.Opcode /** * Resolves to class found in [RollingNumberMeasureTextParentFingerprint]. */ -object RollingNumberStaticLabelMeasureTextFingerprint : MethodFingerprint( +object RollingNumberMeasureStaticLabelFingerprint : MethodFingerprint( returnType = "F", accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL, parameters = listOf("Ljava/lang/String;"), diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/returnyoutubedislike/fingerprints/RollingNumberTextViewFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/returnyoutubedislike/fingerprints/RollingNumberTextViewFingerprint.kt index 9c79cf4f5..2a67f7bf6 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/returnyoutubedislike/fingerprints/RollingNumberTextViewFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/returnyoutubedislike/fingerprints/RollingNumberTextViewFingerprint.kt @@ -17,7 +17,7 @@ object RollingNumberTextViewFingerprint : MethodFingerprint( Opcode.INVOKE_VIRTUAL, Opcode.RETURN_VOID ), - customFingerprint = custom@{ _, classDef -> + customFingerprint = { _, classDef -> classDef.superclass == "Landroid/support/v7/widget/AppCompatTextView;" } ) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/sponsorblock/SponsorBlockBytecodePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/sponsorblock/SponsorBlockBytecodePatch.kt index 971c55fc3..0794cf0db 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/sponsorblock/SponsorBlockBytecodePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/sponsorblock/SponsorBlockBytecodePatch.kt @@ -11,8 +11,6 @@ import app.revanced.patcher.patch.PatchException import app.revanced.patcher.patch.annotation.CompatiblePackage import app.revanced.patcher.patch.annotation.Patch import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod -import app.revanced.patches.shared.fingerprints.LayoutConstructorFingerprint -import app.revanced.patches.shared.fingerprints.SeekbarOnDrawFingerprint import app.revanced.patches.shared.mapping.misc.ResourceMappingPatch import app.revanced.patches.youtube.layout.sponsorblock.fingerprints.AppendTimeFingerprint import app.revanced.patches.youtube.layout.sponsorblock.fingerprints.ControlsOverlayFingerprint @@ -22,7 +20,9 @@ import app.revanced.patches.youtube.misc.autorepeat.fingerprints.AutoRepeatParen import app.revanced.patches.youtube.misc.integrations.IntegrationsPatch import app.revanced.patches.youtube.misc.playercontrols.PlayerControlsBytecodePatch import app.revanced.patches.youtube.misc.playertype.PlayerTypeHookPatch +import app.revanced.patches.youtube.shared.fingerprints.LayoutConstructorFingerprint import app.revanced.patches.youtube.shared.fingerprints.SeekbarFingerprint +import app.revanced.patches.youtube.shared.fingerprints.SeekbarOnDrawFingerprint import app.revanced.patches.youtube.video.information.VideoInformationPatch import app.revanced.patches.youtube.video.videoid.VideoIdPatch import com.android.tools.smali.dexlib2.Opcode diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/announcements/AnnouncementsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/announcements/AnnouncementsPatch.kt index 3d1aaa86a..ad4c193ff 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/announcements/AnnouncementsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/announcements/AnnouncementsPatch.kt @@ -7,10 +7,10 @@ import app.revanced.patcher.extensions.InstructionExtensions.getInstructions import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.annotation.CompatiblePackage import app.revanced.patcher.patch.annotation.Patch -import app.revanced.patches.shared.fingerprints.WatchWhileActivityFingerprint 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.SettingsPatch +import app.revanced.patches.youtube.shared.fingerprints.WatchWhileActivityFingerprint import com.android.tools.smali.dexlib2.Opcode @Patch( diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/microg/MicroGBytecodePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/microg/MicroGBytecodePatch.kt index 1a8a04425..c00cf584a 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/microg/MicroGBytecodePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/microg/MicroGBytecodePatch.kt @@ -5,7 +5,7 @@ import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.annotation.CompatiblePackage import app.revanced.patcher.patch.annotation.Patch import app.revanced.patches.all.misc.packagename.ChangePackageNamePatch -import app.revanced.patches.shared.fingerprints.WatchWhileActivityFingerprint +import app.revanced.patches.youtube.shared.fingerprints.WatchWhileActivityFingerprint import app.revanced.patches.youtube.layout.buttons.cast.HideCastButtonPatch import app.revanced.patches.youtube.misc.fix.playback.ClientSpoofPatch import app.revanced.patches.youtube.misc.microg.fingerprints.* diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/playercontrols/PlayerControlsBytecodePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/playercontrols/PlayerControlsBytecodePatch.kt index 7de9f5eb8..0968f1013 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/playercontrols/PlayerControlsBytecodePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/playercontrols/PlayerControlsBytecodePatch.kt @@ -6,7 +6,7 @@ import app.revanced.patcher.extensions.InstructionExtensions.addInstruction import app.revanced.patcher.fingerprint.MethodFingerprintResult import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.annotation.Patch -import app.revanced.patches.shared.fingerprints.LayoutConstructorFingerprint +import app.revanced.patches.youtube.shared.fingerprints.LayoutConstructorFingerprint import app.revanced.patches.youtube.misc.playercontrols.fingerprints.BottomControlsInflateFingerprint import app.revanced.patches.youtube.misc.playercontrols.fingerprints.PlayerControlsVisibilityFingerprint import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction diff --git a/src/main/kotlin/app/revanced/patches/shared/fingerprints/LayoutConstructorFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/shared/fingerprints/LayoutConstructorFingerprint.kt similarity index 86% rename from src/main/kotlin/app/revanced/patches/shared/fingerprints/LayoutConstructorFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/shared/fingerprints/LayoutConstructorFingerprint.kt index ba802526e..107339044 100644 --- a/src/main/kotlin/app/revanced/patches/shared/fingerprints/LayoutConstructorFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/shared/fingerprints/LayoutConstructorFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.shared.fingerprints +package app.revanced.patches.youtube.shared.fingerprints import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.MethodFingerprint diff --git a/src/main/kotlin/app/revanced/patches/youtube/shared/fingerprints/RollingNumberTextViewAnimationUpdateFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/shared/fingerprints/RollingNumberTextViewAnimationUpdateFingerprint.kt new file mode 100644 index 000000000..536bb03eb --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/youtube/shared/fingerprints/RollingNumberTextViewAnimationUpdateFingerprint.kt @@ -0,0 +1,30 @@ +package app.revanced.patches.youtube.shared.fingerprints + +import app.revanced.patcher.extensions.or +import app.revanced.patcher.fingerprint.MethodFingerprint +import com.android.tools.smali.dexlib2.AccessFlags +import com.android.tools.smali.dexlib2.Opcode + +object RollingNumberTextViewAnimationUpdateFingerprint : MethodFingerprint( + returnType = "V", + accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL, + parameters = listOf("Landroid/graphics/Bitmap;"), + opcodes = listOf( + Opcode.NEW_INSTANCE, // bitmap ImageSpan + Opcode.INVOKE_VIRTUAL, + Opcode.MOVE_RESULT_OBJECT, + Opcode.CONST_4, + Opcode.INVOKE_DIRECT, + Opcode.INVOKE_VIRTUAL, + Opcode.MOVE_RESULT, + Opcode.CONST_16, + Opcode.INVOKE_VIRTUAL, + Opcode.INVOKE_VIRTUAL, + Opcode.MOVE_RESULT, + Opcode.INT_TO_FLOAT, + Opcode.INVOKE_VIRTUAL, // set textview padding using bitmap width + ), + customFingerprint = { _, classDef -> + classDef.superclass == "Landroid/support/v7/widget/AppCompatTextView;" + } +) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/shared/fingerprints/SeekbarOnDrawFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/shared/fingerprints/SeekbarOnDrawFingerprint.kt similarity index 76% rename from src/main/kotlin/app/revanced/patches/shared/fingerprints/SeekbarOnDrawFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/shared/fingerprints/SeekbarOnDrawFingerprint.kt index aa3544220..3903fd426 100644 --- a/src/main/kotlin/app/revanced/patches/shared/fingerprints/SeekbarOnDrawFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/shared/fingerprints/SeekbarOnDrawFingerprint.kt @@ -1,5 +1,4 @@ -package app.revanced.patches.shared.fingerprints - +package app.revanced.patches.youtube.shared.fingerprints import app.revanced.patcher.fingerprint.MethodFingerprint diff --git a/src/main/kotlin/app/revanced/patches/shared/fingerprints/WatchWhileActivityFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/shared/fingerprints/WatchWhileActivityFingerprint.kt similarity index 87% rename from src/main/kotlin/app/revanced/patches/shared/fingerprints/WatchWhileActivityFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/shared/fingerprints/WatchWhileActivityFingerprint.kt index 1fe4393aa..84d8be836 100644 --- a/src/main/kotlin/app/revanced/patches/shared/fingerprints/WatchWhileActivityFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/shared/fingerprints/WatchWhileActivityFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.shared.fingerprints +package app.revanced.patches.youtube.shared.fingerprints import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.MethodFingerprint