mirror of
https://github.com/revanced/revanced-patches.git
synced 2025-06-12 05:07:45 +02:00
feat(Swipe controls): Add option to enable/disable fullscreen swipe to next video (#4222)
This commit is contained in:

committed by
GitHub

parent
d6e389cc43
commit
119092fafa
@ -1,12 +1,23 @@
|
||||
package app.revanced.patches.youtube.interaction.swipecontrols
|
||||
|
||||
import app.revanced.patcher.fingerprint
|
||||
import app.revanced.util.literal
|
||||
import com.android.tools.smali.dexlib2.AccessFlags
|
||||
|
||||
internal val swipeControlsHostActivityFingerprint = fingerprint {
|
||||
accessFlags(AccessFlags.PUBLIC, AccessFlags.CONSTRUCTOR)
|
||||
parameters()
|
||||
custom { method, _ ->
|
||||
method.definingClass == "Lapp/revanced/extension/youtube/swipecontrols/SwipeControlsHostActivity;"
|
||||
method.definingClass == EXTENSION_CLASS_DESCRIPTOR
|
||||
}
|
||||
}
|
||||
|
||||
internal const val SWIPE_CHANGE_VIDEO_FEATURE_FLAG = 45631116L
|
||||
|
||||
internal val swipeChangeVideoFingerprint = fingerprint {
|
||||
accessFlags(AccessFlags.PUBLIC, AccessFlags.CONSTRUCTOR)
|
||||
parameters("L")
|
||||
literal {
|
||||
SWIPE_CHANGE_VIDEO_FEATURE_FLAG
|
||||
}
|
||||
}
|
||||
|
@ -10,6 +10,8 @@ import app.revanced.patches.shared.misc.settings.preference.SwitchPreference
|
||||
import app.revanced.patches.shared.misc.settings.preference.TextPreference
|
||||
import app.revanced.patches.youtube.misc.extension.sharedExtensionPatch
|
||||
import app.revanced.patches.youtube.misc.playertype.playerTypeHookPatch
|
||||
import app.revanced.patches.youtube.misc.playservice.is_19_23_or_greater
|
||||
import app.revanced.patches.youtube.misc.playservice.is_19_25_or_greater
|
||||
import app.revanced.patches.youtube.misc.settings.PreferenceScreen
|
||||
import app.revanced.patches.youtube.misc.settings.settingsPatch
|
||||
import app.revanced.patches.youtube.shared.mainActivityFingerprint
|
||||
@ -17,6 +19,8 @@ import app.revanced.util.*
|
||||
import com.android.tools.smali.dexlib2.AccessFlags
|
||||
import com.android.tools.smali.dexlib2.immutable.ImmutableMethod
|
||||
|
||||
internal const val EXTENSION_CLASS_DESCRIPTOR = "Lapp/revanced/extension/youtube/swipecontrols/SwipeControlsHostActivity;"
|
||||
|
||||
private val swipeControlsResourcePatch = resourcePatch {
|
||||
dependsOn(
|
||||
settingsPatch,
|
||||
@ -26,6 +30,12 @@ private val swipeControlsResourcePatch = resourcePatch {
|
||||
execute {
|
||||
addResources("youtube", "interaction.swipecontrols.swipeControlsResourcePatch")
|
||||
|
||||
if (is_19_25_or_greater) {
|
||||
PreferenceScreen.SWIPE_CONTROLS.addPreferences(
|
||||
SwitchPreference("revanced_swipe_change_video")
|
||||
)
|
||||
}
|
||||
|
||||
PreferenceScreen.SWIPE_CONTROLS.addPreferences(
|
||||
SwitchPreference("revanced_swipe_brightness"),
|
||||
SwitchPreference("revanced_swipe_volume"),
|
||||
@ -101,5 +111,16 @@ val swipeControlsPatch = bytecodePatch(
|
||||
).toMutable()
|
||||
}
|
||||
}
|
||||
|
||||
// region patch to enable/disable swipe to change video.
|
||||
|
||||
if (is_19_23_or_greater) {
|
||||
swipeChangeVideoFingerprint.method.insertFeatureFlagBooleanOverride(
|
||||
SWIPE_CHANGE_VIDEO_FEATURE_FLAG,
|
||||
"$EXTENSION_CLASS_DESCRIPTOR->allowSwipeChangeVideo(Z)Z"
|
||||
)
|
||||
}
|
||||
|
||||
// endregion
|
||||
}
|
||||
}
|
||||
|
@ -449,6 +449,9 @@ This feature is only available for older devices"</string>
|
||||
<string name="revanced_swipe_overlay_background_alpha_summary">The visibility of swipe overlay background</string>
|
||||
<string name="revanced_swipe_threshold_title">Swipe magnitude threshold</string>
|
||||
<string name="revanced_swipe_threshold_summary">The amount of threshold for swipe to occur</string>
|
||||
<string name="revanced_swipe_change_video_title">Enable swipe to change videos</string>
|
||||
<string name="revanced_swipe_change_video_summary_on">Swiping in fullscreen mode will change to the next/previous video</string>
|
||||
<string name="revanced_swipe_change_video_summary_off">Swiping in fullscreen mode will not change to the next/previous video</string>
|
||||
</patch>
|
||||
<patch id="layout.autocaptions.autoCaptionsPatch">
|
||||
<string name="revanced_auto_captions_title">Disable auto captions</string>
|
||||
|
Reference in New Issue
Block a user