feat(YouTube - Playback speed): Allows disabling tap and hold speed
Co-authored-by: inotia00 <108592928+inotia00@users.noreply.github.com>
This commit is contained in:
parent
5c7fc97059
commit
b71e4f95ff
3 changed files with 34 additions and 2 deletions
|
|
@ -60,6 +60,11 @@ public class CustomPlaybackSpeedPatch {
|
|||
*/
|
||||
private static final float PROGRESS_BAR_VALUE_SCALE = 100;
|
||||
|
||||
/**
|
||||
* Disable tap and hold speed, true when TAP_AND_HOLD_SPEED is 0.
|
||||
*/
|
||||
private static final boolean DISABLE_TAP_AND_HOLD_SPEED;
|
||||
|
||||
/**
|
||||
* Tap and hold speed.
|
||||
*/
|
||||
|
|
@ -96,7 +101,12 @@ public class CustomPlaybackSpeedPatch {
|
|||
speedFormatter.setMaximumFractionDigits(2);
|
||||
|
||||
final float holdSpeed = Settings.SPEED_TAP_AND_HOLD.get();
|
||||
if (holdSpeed > 0 && holdSpeed <= PLAYBACK_SPEED_MAXIMUM) {
|
||||
DISABLE_TAP_AND_HOLD_SPEED = holdSpeed == 0;
|
||||
|
||||
if (DISABLE_TAP_AND_HOLD_SPEED) {
|
||||
// A value for handling exceptions, but this is not used.
|
||||
TAP_AND_HOLD_SPEED = Settings.SPEED_TAP_AND_HOLD.defaultValue;
|
||||
} else if (holdSpeed > 0 && holdSpeed <= PLAYBACK_SPEED_MAXIMUM) {
|
||||
TAP_AND_HOLD_SPEED = holdSpeed;
|
||||
} else {
|
||||
showInvalidCustomSpeedToast();
|
||||
|
|
@ -108,6 +118,14 @@ public class CustomPlaybackSpeedPatch {
|
|||
customPlaybackSpeedsMax = customPlaybackSpeeds[customPlaybackSpeeds.length - 1];
|
||||
}
|
||||
|
||||
/**
|
||||
* Injection point.
|
||||
* Called before {@link #getTapAndHoldSpeed()}
|
||||
*/
|
||||
public static boolean disableTapAndHoldSpeed(boolean original) {
|
||||
return !DISABLE_TAP_AND_HOLD_SPEED && original;
|
||||
}
|
||||
|
||||
/**
|
||||
* Injection point.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -186,6 +186,18 @@ internal val customPlaybackSpeedPatch = bytecodePatch(
|
|||
move-result v$speedRegister
|
||||
"""
|
||||
)
|
||||
|
||||
val enabledIndex = it[3].index
|
||||
val enabledRegister =
|
||||
getInstruction<OneRegisterInstruction>(enabledIndex).registerA
|
||||
|
||||
addInstructions(
|
||||
enabledIndex,
|
||||
"""
|
||||
invoke-static { v$enabledRegister }, $EXTENSION_CLASS_DESCRIPTOR->disableTapAndHoldSpeed(Z)Z
|
||||
move-result v$enabledRegister
|
||||
"""
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1742,7 +1742,9 @@ Enabling this can unlock higher video qualities"</string>
|
|||
<string name="revanced_custom_playback_speeds_parse_exception">Invalid custom playback speeds</string>
|
||||
<string name="revanced_custom_playback_speeds_auto">Auto</string>
|
||||
<string name="revanced_speed_tap_and_hold_title">Custom tap and hold speed</string>
|
||||
<string name="revanced_speed_tap_and_hold_summary">Playback speed between 0-8</string>
|
||||
<string name="revanced_speed_tap_and_hold_summary">"Playback speed between 0-8
|
||||
|
||||
Set to 0, to disable tap and hold speed"</string>
|
||||
</patch>
|
||||
<patch id="video.speed.remember.rememberPlaybackSpeedPatch">
|
||||
<string name="revanced_remember_playback_speed_last_selected_title">Remember playback speed changes</string>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue