mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-06-13 05:37:40 +02:00
feat(YouTube - Swipe controls): Add settings - Disable swipe to enter fullscreen mode
, Disable swipe to exit fullscreen mode
& Change default values - Disable swipe to change video
, Disable watch panel gestures
This commit is contained in:
@ -515,8 +515,10 @@ public class Settings extends BaseSettings {
|
||||
*/
|
||||
@Deprecated // Patch is obsolete and no longer works with 19.09+
|
||||
public static final BooleanSetting DISABLE_HDR_AUTO_BRIGHTNESS = new BooleanSetting("revanced_disable_hdr_auto_brightness", TRUE, true, parent(ENABLE_SWIPE_BRIGHTNESS));
|
||||
public static final BooleanSetting DISABLE_SWIPE_TO_SWITCH_VIDEO = new BooleanSetting("revanced_disable_swipe_to_switch_video", FALSE, true);
|
||||
public static final BooleanSetting DISABLE_WATCH_PANEL_GESTURES = new BooleanSetting("revanced_disable_watch_panel_gestures", FALSE, true);
|
||||
public static final BooleanSetting DISABLE_SWIPE_TO_SWITCH_VIDEO = new BooleanSetting("revanced_disable_swipe_to_switch_video", TRUE, true);
|
||||
public static final BooleanSetting DISABLE_SWIPE_TO_ENTER_FULLSCREEN_MODE_BELOW_THE_PLAYER = new BooleanSetting("revanced_disable_swipe_to_enter_fullscreen_mode_below_the_player", TRUE, true);
|
||||
public static final BooleanSetting DISABLE_SWIPE_TO_ENTER_FULLSCREEN_MODE_IN_THE_PLAYER = new BooleanSetting("revanced_disable_swipe_to_enter_fullscreen_mode_in_the_player", FALSE, true);
|
||||
public static final BooleanSetting DISABLE_SWIPE_TO_EXIT_FULLSCREEN_MODE = new BooleanSetting("revanced_disable_swipe_to_exit_fullscreen_mode", FALSE, true);
|
||||
public static final BooleanSetting SWIPE_BRIGHTNESS_AUTO = new BooleanSetting("revanced_swipe_brightness_auto", TRUE, false, false);
|
||||
public static final FloatSetting SWIPE_BRIGHTNESS_VALUE = new FloatSetting("revanced_swipe_brightness_value", -1.0f, false, false);
|
||||
|
||||
|
@ -5,8 +5,12 @@ import app.revanced.patches.youtube.utils.resourceid.autoNavScrollCancelPadding
|
||||
import app.revanced.patches.youtube.utils.resourceid.fullScreenEngagementOverlay
|
||||
import app.revanced.util.containsLiteralInstruction
|
||||
import app.revanced.util.fingerprint.legacyFingerprint
|
||||
import app.revanced.util.getReference
|
||||
import app.revanced.util.indexOfFirstInstruction
|
||||
import app.revanced.util.or
|
||||
import com.android.tools.smali.dexlib2.AccessFlags
|
||||
import com.android.tools.smali.dexlib2.Opcode
|
||||
import com.android.tools.smali.dexlib2.iface.reference.MethodReference
|
||||
|
||||
internal val fullScreenEngagementOverlayFingerprint = legacyFingerprint(
|
||||
name = "fullScreenEngagementOverlayFingerprint",
|
||||
@ -73,3 +77,47 @@ internal val watchPanelGesturesChannelBarFingerprint = legacyFingerprint(
|
||||
method.containsLiteralInstruction(WATCH_PANEL_GESTURES_SECONDARY_FEATURE_FLAG)
|
||||
}
|
||||
)
|
||||
|
||||
/**
|
||||
* fuzzyPatternScanThreshold is required to maintain compatibility with YouTube v18.29.38 ~ v18.32.39.
|
||||
*
|
||||
* TODO: Remove fuzzyPatternScanThreshold if support for YouTube v18.29.38 to v18.32.39 is dropped.
|
||||
*/
|
||||
internal val playerGestureConfigSyntheticFingerprint = legacyFingerprint(
|
||||
name = "playerGestureConfigSyntheticFingerprint",
|
||||
fuzzyPatternScanThreshold = 5,
|
||||
returnType = "V",
|
||||
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
|
||||
parameters = listOf("Ljava/lang/Object;"),
|
||||
opcodes = listOf(
|
||||
Opcode.SGET_OBJECT,
|
||||
Opcode.INVOKE_VIRTUAL,
|
||||
Opcode.MOVE_RESULT,
|
||||
Opcode.IF_EQZ,
|
||||
Opcode.IF_EQZ,
|
||||
Opcode.IGET_OBJECT,
|
||||
Opcode.INVOKE_INTERFACE,
|
||||
Opcode.MOVE_RESULT_OBJECT,
|
||||
Opcode.INVOKE_VIRTUAL, // playerGestureConfig.downAndOutLandscapeAllowed
|
||||
Opcode.MOVE_RESULT,
|
||||
Opcode.CHECK_CAST,
|
||||
Opcode.IPUT_BOOLEAN,
|
||||
Opcode.INVOKE_INTERFACE,
|
||||
Opcode.MOVE_RESULT_OBJECT,
|
||||
Opcode.INVOKE_VIRTUAL, // playerGestureConfig.downAndOutPortraitAllowed
|
||||
Opcode.MOVE_RESULT,
|
||||
Opcode.IPUT_BOOLEAN,
|
||||
Opcode.RETURN_VOID,
|
||||
),
|
||||
customFingerprint = { method, classDef ->
|
||||
// This method is always called "a" because this kind of class always has a single method.
|
||||
method.name == "a" &&
|
||||
classDef.methods.count() == 2 &&
|
||||
method.indexOfFirstInstruction {
|
||||
val reference = getReference<MethodReference>()
|
||||
reference?.definingClass == "Lcom/google/android/libraries/youtube/innertube/model/media/PlayerConfigModel;" &&
|
||||
reference.parameterTypes.isEmpty() &&
|
||||
reference.returnType == "Z"
|
||||
} >= 0
|
||||
},
|
||||
)
|
@ -1,6 +1,7 @@
|
||||
package app.revanced.patches.youtube.swipe.controls
|
||||
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
|
||||
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.extensions.InstructionExtensions.removeInstruction
|
||||
@ -29,9 +30,11 @@ import app.revanced.patches.youtube.utils.settings.settingsPatch
|
||||
import app.revanced.util.ResourceGroup
|
||||
import app.revanced.util.copyResources
|
||||
import app.revanced.util.fingerprint.injectLiteralInstructionBooleanCall
|
||||
import app.revanced.util.fingerprint.matchOrThrow
|
||||
import app.revanced.util.fingerprint.methodOrThrow
|
||||
import app.revanced.util.fingerprint.mutableClassOrThrow
|
||||
import app.revanced.util.getReference
|
||||
import app.revanced.util.getWalkerMethod
|
||||
import app.revanced.util.indexOfFirstInstructionOrThrow
|
||||
import app.revanced.util.indexOfFirstLiteralInstruction
|
||||
import app.revanced.util.indexOfFirstLiteralInstructionOrThrow
|
||||
@ -107,7 +110,7 @@ val swipeControlsPatch = bytecodePatch(
|
||||
|
||||
var settingArray = arrayOf(
|
||||
"PREFERENCE_SCREEN: SWIPE_CONTROLS",
|
||||
"SETTINGS: DISABLE_WATCH_PANEL_GESTURES"
|
||||
"SETTINGS: DISABLE_SWIPE_TO_ENTER_FULLSCREEN_MODE_BELOW_THE_PLAYER"
|
||||
)
|
||||
|
||||
// region patch for disable HDR auto brightness
|
||||
@ -143,12 +146,12 @@ val swipeControlsPatch = bytecodePatch(
|
||||
|
||||
// endregion
|
||||
|
||||
// region patch for disable watch panel gestures
|
||||
// region patch for disable swipe to enter fullscreen mode (below the player)
|
||||
|
||||
if (!is_19_36_or_greater) {
|
||||
watchPanelGesturesFingerprint.injectLiteralInstructionBooleanCall(
|
||||
WATCH_PANEL_GESTURES_PRIMARY_FEATURE_FLAG,
|
||||
"$EXTENSION_SWIPE_CONTROLS_PATCH_CLASS_DESCRIPTOR->disableWatchPanelGestures()Z"
|
||||
"$EXTENSION_SWIPE_CONTROLS_PATCH_CLASS_DESCRIPTOR->disableSwipeToEnterFullscreenModeBelowThePlayer()Z"
|
||||
)
|
||||
} else {
|
||||
watchPanelGesturesAlternativeFingerprint.methodOrThrow().apply {
|
||||
@ -188,7 +191,7 @@ val swipeControlsPatch = bytecodePatch(
|
||||
|
||||
addInstructionsWithLabels(
|
||||
targetIndex, """
|
||||
invoke-static {}, $EXTENSION_SWIPE_CONTROLS_PATCH_CLASS_DESCRIPTOR->disableWatchPanelGestures()Z
|
||||
invoke-static {}, $EXTENSION_SWIPE_CONTROLS_PATCH_CLASS_DESCRIPTOR->disableSwipeToEnterFullscreenModeBelowThePlayer()Z
|
||||
move-result v${fieldInstruction.registerA}
|
||||
if-eqz v${fieldInstruction.registerA}, :disable
|
||||
iget-object v${fieldInstruction.registerA}, v${fieldInstruction.registerB}, $fieldReference
|
||||
@ -201,12 +204,38 @@ val swipeControlsPatch = bytecodePatch(
|
||||
if (is_19_15_or_greater) {
|
||||
watchPanelGesturesChannelBarFingerprint.injectLiteralInstructionBooleanCall(
|
||||
WATCH_PANEL_GESTURES_SECONDARY_FEATURE_FLAG,
|
||||
"$EXTENSION_SWIPE_CONTROLS_PATCH_CLASS_DESCRIPTOR->disableWatchPanelGestures()Z"
|
||||
"$EXTENSION_SWIPE_CONTROLS_PATCH_CLASS_DESCRIPTOR->disableSwipeToEnterFullscreenModeBelowThePlayer()Z"
|
||||
)
|
||||
}
|
||||
|
||||
// endregion
|
||||
|
||||
// region patch for disable swipe to enter fullscreen mode (in the player) and disable swipe to exit fullscreen mode
|
||||
|
||||
playerGestureConfigSyntheticFingerprint.matchOrThrow().let {
|
||||
val endIndex = it.patternMatch!!.endIndex
|
||||
|
||||
mapOf(
|
||||
3 to "disableSwipeToEnterFullscreenModeInThePlayer",
|
||||
9 to "disableSwipeToExitFullscreenMode"
|
||||
).forEach { (offSet, methodName) ->
|
||||
it.getWalkerMethod(endIndex - offSet).apply {
|
||||
val index = implementation!!.instructions.lastIndex
|
||||
val register = getInstruction<OneRegisterInstruction>(index).registerA
|
||||
|
||||
addInstructions(
|
||||
index,
|
||||
"""
|
||||
invoke-static {v$register}, $EXTENSION_SWIPE_CONTROLS_PATCH_CLASS_DESCRIPTOR->$methodName(Z)Z
|
||||
move-result v$register
|
||||
"""
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// endregion
|
||||
|
||||
// region copy resources
|
||||
|
||||
getContext().copyResources(
|
||||
|
@ -134,16 +134,17 @@ fun Pair<String, Fingerprint>.injectLiteralInstructionViewCall(
|
||||
|
||||
internal fun legacyFingerprint(
|
||||
name: String,
|
||||
fuzzyPatternScanThreshold: Int = 0,
|
||||
accessFlags: Int? = null,
|
||||
returnType: String? = null,
|
||||
parameters: List<String>? = null,
|
||||
opcodes: List<Opcode?>? = null,
|
||||
strings: List<String>? = null,
|
||||
literals: List<Long>? = null,
|
||||
customFingerprint: ((methodDef: Method, classDef: ClassDef) -> Boolean)? = null
|
||||
customFingerprint: ((methodDef: Method, classDef: ClassDef) -> Boolean)? = null,
|
||||
) = Pair(
|
||||
name,
|
||||
fingerprint {
|
||||
fingerprint(fuzzyPatternScanThreshold = fuzzyPatternScanThreshold) {
|
||||
if (accessFlags != null) {
|
||||
accessFlags(accessFlags)
|
||||
}
|
||||
|
@ -1484,12 +1484,18 @@ No margins on top and bottom of player."</string>
|
||||
<string name="revanced_disable_hdr_auto_brightness_title">Disable auto HDR brightness</string>
|
||||
<string name="revanced_disable_hdr_auto_brightness_summary_on">Auto HDR brightness is disabled.</string>
|
||||
<string name="revanced_disable_hdr_auto_brightness_summary_off">Auto HDR brightness is enabled.</string>
|
||||
<string name="revanced_disable_watch_panel_gestures_title">Disable watch panel gestures</string>
|
||||
<string name="revanced_disable_watch_panel_gestures_summary_on">Entering fullscreen when swiping down below the video player is disabled.</string>
|
||||
<string name="revanced_disable_watch_panel_gestures_summary_off">Entering fullscreen when swiping down below the video player is enabled.</string>
|
||||
<string name="revanced_disable_swipe_to_switch_video_title">Disable swipe to change video</string>
|
||||
<string name="revanced_disable_swipe_to_switch_video_summary_on">Swiping up / down will not play the next / previous video.</string>
|
||||
<string name="revanced_disable_swipe_to_switch_video_summary_off">Swiping up / down will play the next / previous video.</string>
|
||||
<string name="revanced_disable_swipe_to_switch_video_summary_on">Swiping up / down in fullscreen mode will not change to the next / previous video.</string>
|
||||
<string name="revanced_disable_swipe_to_switch_video_summary_off">Swiping up / down in fullscreen mode will change to the next / previous video.</string>
|
||||
<string name="revanced_disable_swipe_to_enter_fullscreen_mode_below_the_player_title">Disable swipe to enter fullscreen mode (below the player)</string>
|
||||
<string name="revanced_disable_swipe_to_enter_fullscreen_mode_below_the_player_summary_on">Swiping down below the player will not enter fullscreen mode.</string>
|
||||
<string name="revanced_disable_swipe_to_enter_fullscreen_mode_below_the_player_summary_off">Swiping down below the player will enter fullscreen mode.</string>
|
||||
<string name="revanced_disable_swipe_to_enter_fullscreen_mode_in_the_player_title">Disable swipe to enter fullscreen mode (in the player)</string>
|
||||
<string name="revanced_disable_swipe_to_enter_fullscreen_mode_in_the_player_summary_on">Swiping up in the player will not enter fullscreen mode.</string>
|
||||
<string name="revanced_disable_swipe_to_enter_fullscreen_mode_in_the_player_summary_off">Swiping up in the player will enter fullscreen mode.</string>
|
||||
<string name="revanced_disable_swipe_to_exit_fullscreen_mode_title">Disable swipe to exit fullscreen mode</string>
|
||||
<string name="revanced_disable_swipe_to_exit_fullscreen_mode_summary_on">Swiping down in fullscreen will not exit fullscreen mode.</string>
|
||||
<string name="revanced_disable_swipe_to_exit_fullscreen_mode_summary_off">Swiping down in fullscreen will exit fullscreen mode.</string>
|
||||
<string name="revanced_swipe_lowest_value_auto_brightness_overlay_text">Auto</string>
|
||||
|
||||
|
||||
|
@ -672,10 +672,12 @@
|
||||
<!-- SETTINGS: DISABLE_SWIPE_TO_SWITCH_VIDEO
|
||||
<SwitchPreference android:title="@string/revanced_disable_swipe_to_switch_video_title" android:key="revanced_disable_swipe_to_switch_video" android:summaryOn="@string/revanced_disable_swipe_to_switch_video_summary_on" android:summaryOff="@string/revanced_disable_swipe_to_switch_video_summary_off" />SETTINGS: DISABLE_SWIPE_TO_SWITCH_VIDEO -->
|
||||
|
||||
<!-- SETTINGS: DISABLE_WATCH_PANEL_GESTURES
|
||||
<SwitchPreference android:title="@string/revanced_disable_watch_panel_gestures_title" android:key="revanced_disable_watch_panel_gestures" android:summaryOn="@string/revanced_disable_watch_panel_gestures_summary_on" android:summaryOff="@string/revanced_disable_watch_panel_gestures_summary_off" />SETTINGS: DISABLE_WATCH_PANEL_GESTURES -->
|
||||
<!-- SETTINGS: DISABLE_SWIPE_TO_ENTER_FULLSCREEN_MODE_BELOW_THE_PLAYER
|
||||
<SwitchPreference android:title="@string/revanced_disable_swipe_to_enter_fullscreen_mode_below_the_player_title" android:key="revanced_disable_swipe_to_enter_fullscreen_mode_below_the_player" android:summaryOn="@string/revanced_disable_swipe_to_enter_fullscreen_mode_below_the_player_summary_on" android:summaryOff="@string/revanced_disable_swipe_to_enter_fullscreen_mode_below_the_player_summary_off" />SETTINGS: DISABLE_SWIPE_TO_ENTER_FULLSCREEN_MODE_BELOW_THE_PLAYER -->
|
||||
|
||||
<!-- PREFERENCE_SCREEN: SWIPE_CONTROLS
|
||||
<SwitchPreference android:title="@string/revanced_disable_swipe_to_enter_fullscreen_mode_in_the_player_title" android:key="revanced_disable_swipe_to_enter_fullscreen_mode_in_the_player" android:summaryOn="@string/revanced_disable_swipe_to_enter_fullscreen_mode_in_the_player_summary_on" android:summaryOff="@string/revanced_disable_swipe_to_enter_fullscreen_mode_in_the_player_summary_off" />
|
||||
<SwitchPreference android:title="@string/revanced_disable_swipe_to_exit_fullscreen_mode_title" android:key="revanced_disable_swipe_to_exit_fullscreen_mode" android:summaryOn="@string/revanced_disable_swipe_to_exit_fullscreen_mode_summary_on" android:summaryOff="@string/revanced_disable_swipe_to_exit_fullscreen_mode_summary_off" />
|
||||
</PreferenceScreen>PREFERENCE_SCREEN: SWIPE_CONTROLS -->
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user