From 2a6d11d74bd87bc4a9c18c7eaefdf4b6ec19846e Mon Sep 17 00:00:00 2001
From: inotia00 <108592928+inotia00@users.noreply.github.com>
Date: Wed, 3 Jul 2024 18:42:57 +0900
Subject: [PATCH] feat(YouTube): integrate `Change Shorts repeat state` patch
into the `Shorts components` patch
---
.../shorts/components/ShortsComponentPatch.kt | 1 +
.../ShortsRepeatPatch.kt | 31 ++++---------------
.../ReelEnumConstructorFingerprint.kt | 2 +-
.../fingerprints/ReelEnumStaticFingerprint.kt | 2 +-
.../youtube/settings/xml/revanced_prefs.xml | 7 ++---
5 files changed, 11 insertions(+), 32 deletions(-)
rename src/main/kotlin/app/revanced/patches/youtube/shorts/{repeat => components}/ShortsRepeatPatch.kt (79%)
rename src/main/kotlin/app/revanced/patches/youtube/shorts/{repeat => components}/fingerprints/ReelEnumConstructorFingerprint.kt (81%)
rename src/main/kotlin/app/revanced/patches/youtube/shorts/{repeat => components}/fingerprints/ReelEnumStaticFingerprint.kt (82%)
diff --git a/src/main/kotlin/app/revanced/patches/youtube/shorts/components/ShortsComponentPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/shorts/components/ShortsComponentPatch.kt
index f78d771f9..dff5f5ffd 100644
--- a/src/main/kotlin/app/revanced/patches/youtube/shorts/components/ShortsComponentPatch.kt
+++ b/src/main/kotlin/app/revanced/patches/youtube/shorts/components/ShortsComponentPatch.kt
@@ -59,6 +59,7 @@ object ShortsComponentPatch : BaseBytecodePatch(
SharedResourceIdPatch::class,
ShortsAnimationPatch::class,
ShortsNavigationBarPatch::class,
+ ShortsRepeatPatch::class,
ShortsToolBarPatch::class,
VideoInformationPatch::class
),
diff --git a/src/main/kotlin/app/revanced/patches/youtube/shorts/repeat/ShortsRepeatPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/shorts/components/ShortsRepeatPatch.kt
similarity index 79%
rename from src/main/kotlin/app/revanced/patches/youtube/shorts/repeat/ShortsRepeatPatch.kt
rename to src/main/kotlin/app/revanced/patches/youtube/shorts/components/ShortsRepeatPatch.kt
index eb4d9c90a..b7484a31c 100644
--- a/src/main/kotlin/app/revanced/patches/youtube/shorts/repeat/ShortsRepeatPatch.kt
+++ b/src/main/kotlin/app/revanced/patches/youtube/shorts/components/ShortsRepeatPatch.kt
@@ -1,32 +1,25 @@
-package app.revanced.patches.youtube.shorts.repeat
+package app.revanced.patches.youtube.shorts.components
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
+import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
-import app.revanced.patches.youtube.shorts.repeat.fingerprints.ReelEnumConstructorFingerprint
-import app.revanced.patches.youtube.shorts.repeat.fingerprints.ReelEnumStaticFingerprint
-import app.revanced.patches.youtube.utils.compatibility.Constants.COMPATIBLE_PACKAGE
+import app.revanced.patches.youtube.shorts.components.fingerprints.ReelEnumConstructorFingerprint
+import app.revanced.patches.youtube.shorts.components.fingerprints.ReelEnumStaticFingerprint
import app.revanced.patches.youtube.utils.integrations.Constants.SHORTS_CLASS_DESCRIPTOR
-import app.revanced.patches.youtube.utils.settings.SettingsPatch
import app.revanced.util.containsReferenceInstructionIndex
import app.revanced.util.findMutableMethodOf
import app.revanced.util.getStringInstructionIndex
import app.revanced.util.getTargetIndexOrThrow
-import app.revanced.util.patch.BaseBytecodePatch
import app.revanced.util.resultOrThrow
import com.android.tools.smali.dexlib2.Opcode
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction
-@Suppress("unused")
-object ShortsRepeatPatch : BaseBytecodePatch(
- name = "Change Shorts repeat state",
- description = "Adds an option to control whether Shorts should repeat, autoplay, or pause upon ending.",
- dependencies = setOf(SettingsPatch::class),
- compatiblePackages = COMPATIBLE_PACKAGE,
- fingerprints = setOf(ReelEnumConstructorFingerprint)
+object ShortsRepeatPatch : BytecodePatch(
+ setOf(ReelEnumConstructorFingerprint)
) {
override fun execute(context: BytecodeContext) {
@@ -55,18 +48,6 @@ object ShortsRepeatPatch : BaseBytecodePatch(
context.injectHook(endScreenReference, enumMethodCall)
}
}
-
- /**
- * Add settings
- */
- SettingsPatch.addPreference(
- arrayOf(
- "PREFERENCE_SCREEN: SHORTS",
- "SETTINGS: CHANGE_SHORTS_REPEAT_STATE"
- )
- )
-
- SettingsPatch.updatePatchStatus(this)
}
private fun MutableMethod.injectEnum(
diff --git a/src/main/kotlin/app/revanced/patches/youtube/shorts/repeat/fingerprints/ReelEnumConstructorFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/shorts/components/fingerprints/ReelEnumConstructorFingerprint.kt
similarity index 81%
rename from src/main/kotlin/app/revanced/patches/youtube/shorts/repeat/fingerprints/ReelEnumConstructorFingerprint.kt
rename to src/main/kotlin/app/revanced/patches/youtube/shorts/components/fingerprints/ReelEnumConstructorFingerprint.kt
index 86e5acfa8..b20db5d2a 100644
--- a/src/main/kotlin/app/revanced/patches/youtube/shorts/repeat/fingerprints/ReelEnumConstructorFingerprint.kt
+++ b/src/main/kotlin/app/revanced/patches/youtube/shorts/components/fingerprints/ReelEnumConstructorFingerprint.kt
@@ -1,4 +1,4 @@
-package app.revanced.patches.youtube.shorts.repeat.fingerprints
+package app.revanced.patches.youtube.shorts.components.fingerprints
import app.revanced.patcher.fingerprint.MethodFingerprint
diff --git a/src/main/kotlin/app/revanced/patches/youtube/shorts/repeat/fingerprints/ReelEnumStaticFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/shorts/components/fingerprints/ReelEnumStaticFingerprint.kt
similarity index 82%
rename from src/main/kotlin/app/revanced/patches/youtube/shorts/repeat/fingerprints/ReelEnumStaticFingerprint.kt
rename to src/main/kotlin/app/revanced/patches/youtube/shorts/components/fingerprints/ReelEnumStaticFingerprint.kt
index fc9851abe..0a02eb90b 100644
--- a/src/main/kotlin/app/revanced/patches/youtube/shorts/repeat/fingerprints/ReelEnumStaticFingerprint.kt
+++ b/src/main/kotlin/app/revanced/patches/youtube/shorts/components/fingerprints/ReelEnumStaticFingerprint.kt
@@ -1,4 +1,4 @@
-package app.revanced.patches.youtube.shorts.repeat.fingerprints
+package app.revanced.patches.youtube.shorts.components.fingerprints
import app.revanced.patcher.extensions.or
import app.revanced.patcher.fingerprint.MethodFingerprint
diff --git a/src/main/resources/youtube/settings/xml/revanced_prefs.xml b/src/main/resources/youtube/settings/xml/revanced_prefs.xml
index f486c1bb9..e93f97555 100644
--- a/src/main/resources/youtube/settings/xml/revanced_prefs.xml
+++ b/src/main/resources/youtube/settings/xml/revanced_prefs.xml
@@ -486,10 +486,8 @@
- SETTINGS: SHORTS_COMPONENTS -->
-
-
+
+ SETTINGS: SHORTS_COMPONENTS -->
@@ -684,7 +682,6 @@
-