feat(YouTube): integrate Change Shorts repeat state patch into the Shorts components patch

This commit is contained in:
inotia00 2024-07-03 18:42:57 +09:00
parent 2a07a98b59
commit 2a6d11d74b
5 changed files with 11 additions and 32 deletions

View File

@ -59,6 +59,7 @@ object ShortsComponentPatch : BaseBytecodePatch(
SharedResourceIdPatch::class,
ShortsAnimationPatch::class,
ShortsNavigationBarPatch::class,
ShortsRepeatPatch::class,
ShortsToolBarPatch::class,
VideoInformationPatch::class
),

View File

@ -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(

View File

@ -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

View File

@ -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

View File

@ -486,10 +486,8 @@
<SwitchPreference android:title="@string/revanced_hide_shorts_toolbar_title" android:key="revanced_hide_shorts_toolbar" android:summaryOn="@string/revanced_hide_shorts_toolbar_summary_on" android:summaryOff="@string/revanced_hide_shorts_toolbar_summary_off" />
<SwitchPreference android:title="@string/revanced_hide_shorts_navigation_bar_title" android:key="revanced_hide_shorts_navigation_bar" android:summaryOn="@string/revanced_hide_shorts_navigation_bar_summary_on" android:summaryOff="@string/revanced_hide_shorts_navigation_bar_summary_off" />
<SwitchPreference android:title="@string/revanced_replace_channel_handle_title" android:key="revanced_replace_channel_handle" android:summaryOn="@string/revanced_replace_channel_handle_summary_on" android:summaryOff="@string/revanced_replace_channel_handle_summary_off" />
</PreferenceScreen>SETTINGS: SHORTS_COMPONENTS -->
<!-- SETTINGS: CHANGE_SHORTS_REPEAT_STATE
<ListPreference android:entries="@array/revanced_change_shorts_repeat_state_entries" android:title="@string/revanced_change_shorts_repeat_state_title" android:key="revanced_change_shorts_repeat_state" android:entryValues="@array/revanced_change_shorts_repeat_state_entry_values" />SETTINGS: CHANGE_SHORTS_REPEAT_STATE -->
</PreferenceScreen>
<ListPreference android:entries="@array/revanced_change_shorts_repeat_state_entries" android:title="@string/revanced_change_shorts_repeat_state_title" android:key="revanced_change_shorts_repeat_state" android:entryValues="@array/revanced_change_shorts_repeat_state_entry_values" />SETTINGS: SHORTS_COMPONENTS -->
<!-- SETTINGS: DISABLE_RESUMING_SHORTS_PLAYER
<SwitchPreference android:title="@string/revanced_disable_resuming_shorts_player_title" android:key="revanced_disable_resuming_shorts_player" android:summaryOn="@string/revanced_disable_resuming_shorts_player_summary_on" android:summaryOff="@string/revanced_disable_resuming_shorts_player_summary_off" />SETTINGS: DISABLE_RESUMING_SHORTS_PLAYER -->
@ -684,7 +682,6 @@
</PreferenceCategory>
<PreferenceCategory android:title="@string/revanced_preference_screen_shorts_title" >
<Preference android:title="Change Shorts repeat state" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>
<Preference android:title="Disable resuming Shorts on startup" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>
<Preference android:title="Shorts components" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>
<Preference android:title="Shorts outline button" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>