mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-06-13 05:37:40 +02:00
feat(YouTube): add Change player flyout panel toggles
patch
This commit is contained in:
@ -0,0 +1,117 @@
|
||||
package app.revanced.patches.youtube.flyoutpanel.player
|
||||
|
||||
import app.revanced.patcher.data.BytecodeContext
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
|
||||
import app.revanced.patcher.fingerprint.MethodFingerprint
|
||||
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.flyoutpanel.player.fingerprints.AdditionalSettingsConfigFingerprint
|
||||
import app.revanced.patches.youtube.flyoutpanel.player.fingerprints.CinematicLightingFingerprint
|
||||
import app.revanced.patches.youtube.flyoutpanel.player.fingerprints.PlaybackLoopInitFingerprint
|
||||
import app.revanced.patches.youtube.flyoutpanel.player.fingerprints.PlaybackLoopOnClickListenerFingerprint
|
||||
import app.revanced.patches.youtube.flyoutpanel.player.fingerprints.StableVolumeFingerprint
|
||||
import app.revanced.patches.youtube.utils.integrations.Constants.FLYOUT_PANEL
|
||||
import app.revanced.patches.youtube.utils.settings.SettingsPatch
|
||||
import app.revanced.util.exception
|
||||
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
|
||||
|
||||
@Patch(
|
||||
name = "Change player flyout panel toggles",
|
||||
description = "Adds an option to use text toggles instead of switch toggles within the additional settings menu.",
|
||||
dependencies = [SettingsPatch::class],
|
||||
compatiblePackages = [
|
||||
CompatiblePackage(
|
||||
"com.google.android.youtube",
|
||||
[
|
||||
"18.25.40",
|
||||
"18.27.36",
|
||||
"18.29.38",
|
||||
"18.30.37",
|
||||
"18.31.40",
|
||||
"18.32.39",
|
||||
"18.33.40",
|
||||
"18.34.38",
|
||||
"18.35.36",
|
||||
"18.36.39",
|
||||
"18.37.36",
|
||||
"18.38.44",
|
||||
"18.39.41",
|
||||
"18.40.34",
|
||||
"18.41.39",
|
||||
"18.42.41",
|
||||
"18.43.45",
|
||||
"18.44.41",
|
||||
"18.45.43"
|
||||
]
|
||||
)
|
||||
]
|
||||
)
|
||||
@Suppress("unused")
|
||||
object ChangeTogglePatch : BytecodePatch(
|
||||
setOf(
|
||||
AdditionalSettingsConfigFingerprint,
|
||||
CinematicLightingFingerprint,
|
||||
PlaybackLoopOnClickListenerFingerprint,
|
||||
StableVolumeFingerprint
|
||||
)
|
||||
) {
|
||||
override fun execute(context: BytecodeContext) {
|
||||
val additionalSettingsConfigResult = AdditionalSettingsConfigFingerprint.result
|
||||
?: throw AdditionalSettingsConfigFingerprint.exception
|
||||
|
||||
val additionalSettingsConfigMethod = additionalSettingsConfigResult.mutableMethod
|
||||
val methodToCall = additionalSettingsConfigMethod.definingClass + "->" + additionalSettingsConfigMethod.name + "()Z"
|
||||
|
||||
// Resolves fingerprints
|
||||
val playbackLoopOnClickListenerResult = PlaybackLoopOnClickListenerFingerprint.result
|
||||
?: throw PlaybackLoopOnClickListenerFingerprint.exception
|
||||
PlaybackLoopInitFingerprint.resolve(context, playbackLoopOnClickListenerResult.classDef)
|
||||
|
||||
arrayOf(
|
||||
CinematicLightingFingerprint,
|
||||
PlaybackLoopInitFingerprint,
|
||||
PlaybackLoopOnClickListenerFingerprint,
|
||||
StableVolumeFingerprint
|
||||
).forEach { fingerprint ->
|
||||
fingerprint.injectCall(methodToCall)
|
||||
}
|
||||
|
||||
/**
|
||||
* Add settings
|
||||
*/
|
||||
SettingsPatch.addPreference(
|
||||
arrayOf(
|
||||
"PREFERENCE: FLYOUT_PANEL_SETTINGS",
|
||||
"SETTINGS: PLAYER_FLYOUT_PANEL_ADDITIONAL_SETTINGS_HEADER",
|
||||
"SETTINGS: CHANGE_PLAYER_FLYOUT_PANEL_TOGGLE"
|
||||
)
|
||||
)
|
||||
|
||||
SettingsPatch.updatePatchStatus("Change player flyout panel toggles")
|
||||
|
||||
}
|
||||
|
||||
private fun MethodFingerprint.injectCall(descriptor: String) {
|
||||
result?.let {
|
||||
it.mutableMethod.apply {
|
||||
val insertIndex = implementation!!.instructions.indexOfFirst { instruction ->
|
||||
instruction.opcode == Opcode.INVOKE_VIRTUAL
|
||||
&& (instruction as ReferenceInstruction).reference.toString().endsWith(descriptor)
|
||||
} + 2
|
||||
val insertRegister =
|
||||
getInstruction<OneRegisterInstruction>(insertIndex - 1).registerA
|
||||
|
||||
addInstructions(
|
||||
insertIndex, """
|
||||
invoke-static {v$insertRegister}, $FLYOUT_PANEL->changeSwitchToggle(Z)Z
|
||||
move-result v$insertRegister
|
||||
"""
|
||||
)
|
||||
}
|
||||
} ?: throw exception
|
||||
}
|
||||
}
|
@ -84,6 +84,7 @@ object PlayerFlyoutPanelPatch : BytecodePatch(
|
||||
arrayOf(
|
||||
"PREFERENCE: FLYOUT_PANEL_SETTINGS",
|
||||
"SETTINGS: PLAYER_FLYOUT_PANEL_HEADER",
|
||||
"SETTINGS: PLAYER_FLYOUT_PANEL_ADDITIONAL_SETTINGS_HEADER",
|
||||
"SETTINGS: HIDE_PLAYER_FLYOUT_PANEL"
|
||||
)
|
||||
)
|
||||
|
@ -0,0 +1,8 @@
|
||||
package app.revanced.patches.youtube.flyoutpanel.player.fingerprints
|
||||
|
||||
import app.revanced.util.fingerprint.LiteralValueFingerprint
|
||||
|
||||
object AdditionalSettingsConfigFingerprint : LiteralValueFingerprint(
|
||||
returnType = "Z",
|
||||
literalSupplier = { 45412662 }
|
||||
)
|
@ -0,0 +1,12 @@
|
||||
package app.revanced.patches.youtube.flyoutpanel.player.fingerprints
|
||||
|
||||
import app.revanced.patcher.extensions.or
|
||||
import app.revanced.patcher.fingerprint.MethodFingerprint
|
||||
import com.android.tools.smali.dexlib2.AccessFlags
|
||||
|
||||
object CinematicLightingFingerprint : MethodFingerprint(
|
||||
returnType = "V",
|
||||
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
|
||||
parameters = listOf("Ljava/lang/Object;"),
|
||||
strings = listOf("menu_item_cinematic_lighting")
|
||||
)
|
@ -0,0 +1,15 @@
|
||||
package app.revanced.patches.youtube.flyoutpanel.player.fingerprints
|
||||
|
||||
import app.revanced.patcher.extensions.or
|
||||
import app.revanced.patcher.fingerprint.MethodFingerprint
|
||||
import com.android.tools.smali.dexlib2.AccessFlags
|
||||
|
||||
/**
|
||||
* Resolves with the class found in [PlaybackLoopOnClickListenerFingerprint].
|
||||
*/
|
||||
object PlaybackLoopInitFingerprint : MethodFingerprint(
|
||||
returnType = "V",
|
||||
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
|
||||
parameters = listOf("L"),
|
||||
strings = listOf("menu_item_single_video_playback_loop")
|
||||
)
|
@ -0,0 +1,12 @@
|
||||
package app.revanced.patches.youtube.flyoutpanel.player.fingerprints
|
||||
|
||||
import app.revanced.patcher.extensions.or
|
||||
import app.revanced.patcher.fingerprint.MethodFingerprint
|
||||
import com.android.tools.smali.dexlib2.AccessFlags
|
||||
|
||||
object PlaybackLoopOnClickListenerFingerprint : MethodFingerprint(
|
||||
returnType = "V",
|
||||
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
|
||||
parameters = listOf("I", "Z"),
|
||||
strings = listOf("menu_item_single_video_playback_loop")
|
||||
)
|
@ -0,0 +1,12 @@
|
||||
package app.revanced.patches.youtube.flyoutpanel.player.fingerprints
|
||||
|
||||
import app.revanced.patcher.extensions.or
|
||||
import app.revanced.patcher.fingerprint.MethodFingerprint
|
||||
import com.android.tools.smali.dexlib2.AccessFlags
|
||||
|
||||
object StableVolumeFingerprint : MethodFingerprint(
|
||||
returnType = "V",
|
||||
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
|
||||
parameters = listOf("Ljava/lang/Object;"),
|
||||
strings = listOf("menu_item_stable_volume")
|
||||
)
|
@ -55,6 +55,9 @@ Tap here to learn more about DeArrow."</string>
|
||||
<string name="revanced_bypass_ambient_mode_restrictions_summary_off">Ambient mode is disabled in battery saver mode.</string>
|
||||
<string name="revanced_bypass_ambient_mode_restrictions_summary_on">Ambient mode is enabled in battery saver mode.</string>
|
||||
<string name="revanced_bypass_ambient_mode_restrictions_title">Bypass ambient mode restrictions</string>
|
||||
<string name="revanced_change_player_flyout_panel_toggle_summary_off">Switch toggles are used.</string>
|
||||
<string name="revanced_change_player_flyout_panel_toggle_summary_on">Text toggles are used.</string>
|
||||
<string name="revanced_change_player_flyout_panel_toggle_title">Change toggle type</string>
|
||||
<string name="revanced_change_start_page_entry_default">Default</string>
|
||||
<string name="revanced_change_start_page_entry_explore">Explore</string>
|
||||
<string name="revanced_change_start_page_entry_history">History</string>
|
||||
|
@ -111,9 +111,15 @@
|
||||
<SwitchPreference android:title="@string/revanced_hide_player_flyout_panel_more_info_title" android:key="revanced_hide_player_flyout_panel_more_info" android:defaultValue="false" android:summaryOn="@string/revanced_hide_player_flyout_panel_more_info_summary_on" android:summaryOff="@string/revanced_hide_player_flyout_panel_more_info_summary_off" />
|
||||
<SwitchPreference android:title="@string/revanced_hide_player_flyout_panel_playback_speed_title" android:key="revanced_hide_player_flyout_panel_playback_speed" android:defaultValue="false" android:summaryOn="@string/revanced_hide_player_flyout_panel_playback_speed_summary_on" android:summaryOff="@string/revanced_hide_player_flyout_panel_playback_speed_summary_off" />
|
||||
<SwitchPreference android:title="@string/revanced_hide_player_flyout_panel_quality_footer_title" android:key="revanced_hide_player_flyout_panel_quality_footer" android:defaultValue="false" android:summaryOn="@string/revanced_hide_player_flyout_panel_quality_footer_summary_on" android:summaryOff="@string/revanced_hide_player_flyout_panel_quality_footer_summary_off" />
|
||||
<SwitchPreference android:title="@string/revanced_hide_player_flyout_panel_report_title" android:key="revanced_hide_player_flyout_panel_report" android:defaultValue="true" android:summaryOn="@string/revanced_hide_player_flyout_panel_report_summary_on" android:summaryOff="@string/revanced_hide_player_flyout_panel_report_summary_off" />
|
||||
<SwitchPreference android:title="@string/revanced_hide_player_flyout_panel_report_title" android:key="revanced_hide_player_flyout_panel_report" android:defaultValue="true" android:summaryOn="@string/revanced_hide_player_flyout_panel_report_summary_on" android:summaryOff="@string/revanced_hide_player_flyout_panel_report_summary_off" />SETTINGS: HIDE_PLAYER_FLYOUT_PANEL -->
|
||||
|
||||
<Preference android:title=" " android:selectable="false" android:summary="@string/revanced_player_flyout_panel_additional_settings_title" />
|
||||
<!-- SETTINGS: PLAYER_FLYOUT_PANEL_ADDITIONAL_SETTINGS_HEADER
|
||||
<Preference android:title=" " android:selectable="false" android:summary="@string/revanced_player_flyout_panel_additional_settings_title" />SETTINGS: PLAYER_FLYOUT_PANEL_ADDITIONAL_SETTINGS_HEADER -->
|
||||
|
||||
<!-- SETTINGS: CHANGE_PLAYER_FLYOUT_PANEL_TOGGLE
|
||||
<SwitchPreference android:title="@string/revanced_change_player_flyout_panel_toggle_title" android:key="revanced_change_player_flyout_panel_toggle" android:defaultValue="true" android:summaryOn="@string/revanced_change_player_flyout_panel_toggle_summary_on" android:summaryOff="@string/revanced_change_player_flyout_panel_toggle_summary_off" />SETTINGS: CHANGE_PLAYER_FLYOUT_PANEL_TOGGLE -->
|
||||
|
||||
<!-- SETTINGS: HIDE_PLAYER_FLYOUT_PANEL
|
||||
<SwitchPreference android:title="@string/revanced_hide_player_flyout_panel_ambient_mode_title" android:key="revanced_hide_player_flyout_panel_ambient_mode" android:defaultValue="false" android:summaryOn="@string/revanced_hide_player_flyout_panel_ambient_mode_summary_on" android:summaryOff="@string/revanced_hide_player_flyout_panel_ambient_mode_summary_off" />
|
||||
<SwitchPreference android:title="@string/revanced_hide_player_flyout_panel_help_title" android:key="revanced_hide_player_flyout_panel_help" android:defaultValue="true" android:summaryOn="@string/revanced_hide_player_flyout_panel_help_summary_on" android:summaryOff="@string/revanced_hide_player_flyout_panel_help_summary_off" />
|
||||
<SwitchPreference android:title="@string/revanced_hide_player_flyout_panel_listen_with_youtube_music_title" android:key="revanced_hide_player_flyout_panel_listen_with_youtube_music" android:defaultValue="true" android:summaryOn="@string/revanced_hide_player_flyout_panel_listen_with_youtube_music_summary_on" android:summaryOff="@string/revanced_hide_player_flyout_panel_listen_with_youtube_music_summary_off" />
|
||||
@ -394,6 +400,7 @@
|
||||
<Preference android:title="Hide comment component" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>
|
||||
|
||||
<Preference android:title=" " android:selectable="false" android:summary="@string/revanced_flyout_menu" />
|
||||
<Preference android:title="Change player flyout panel toggles" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>
|
||||
<Preference android:title="Enable old quality layout" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>
|
||||
<Preference android:title="Hide feed flyout panel" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>
|
||||
<Preference android:title="Hide player flyout panel" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>
|
||||
|
Reference in New Issue
Block a user