mirror of
https://github.com/revanced/revanced-patches.git
synced 2025-06-12 13:17:38 +02:00
feat(YouTube - Playback speed): Add option to change 2x tap and hold speed (#4307)
This commit is contained in:

committed by
GitHub

parent
220e9c78c1
commit
02fb26e945
@ -32,6 +32,11 @@ public class CustomPlaybackSpeedPatch {
|
||||
*/
|
||||
public static final float PLAYBACK_SPEED_MAXIMUM = 8;
|
||||
|
||||
/**
|
||||
* Tap and hold speed.
|
||||
*/
|
||||
private static final float TAP_AND_HOLD_SPEED;
|
||||
|
||||
/**
|
||||
* Custom playback speeds.
|
||||
*/
|
||||
@ -48,12 +53,27 @@ public class CustomPlaybackSpeedPatch {
|
||||
private static String[] preferenceListEntries, preferenceListEntryValues;
|
||||
|
||||
static {
|
||||
final float holdSpeed = Settings.SPEED_TAP_AND_HOLD.get();
|
||||
if (holdSpeed > 0 && holdSpeed <= PLAYBACK_SPEED_MAXIMUM) {
|
||||
TAP_AND_HOLD_SPEED = holdSpeed;
|
||||
} else {
|
||||
showInvalidCustomSpeedToast();
|
||||
Settings.SPEED_TAP_AND_HOLD.resetToDefault();
|
||||
TAP_AND_HOLD_SPEED = Settings.SPEED_TAP_AND_HOLD.get();
|
||||
}
|
||||
|
||||
loadCustomSpeeds();
|
||||
}
|
||||
|
||||
private static void resetCustomSpeeds(@NonNull String toastMessage) {
|
||||
Utils.showToastLong(toastMessage);
|
||||
Settings.CUSTOM_PLAYBACK_SPEEDS.resetToDefault();
|
||||
/**
|
||||
* Injection point.
|
||||
*/
|
||||
public static float tapAndHoldSpeed() {
|
||||
return TAP_AND_HOLD_SPEED;
|
||||
}
|
||||
|
||||
private static void showInvalidCustomSpeedToast() {
|
||||
Utils.showToastLong(str("revanced_custom_playback_speeds_invalid", PLAYBACK_SPEED_MAXIMUM));
|
||||
}
|
||||
|
||||
private static void loadCustomSpeeds() {
|
||||
@ -74,17 +94,18 @@ public class CustomPlaybackSpeedPatch {
|
||||
}
|
||||
|
||||
if (speedFloat >= PLAYBACK_SPEED_MAXIMUM) {
|
||||
resetCustomSpeeds(str("revanced_custom_playback_speeds_invalid", PLAYBACK_SPEED_MAXIMUM));
|
||||
showInvalidCustomSpeedToast();
|
||||
Settings.CUSTOM_PLAYBACK_SPEEDS.resetToDefault();
|
||||
loadCustomSpeeds();
|
||||
return;
|
||||
}
|
||||
|
||||
customPlaybackSpeeds[i] = speedFloat;
|
||||
i++;
|
||||
customPlaybackSpeeds[i++] = speedFloat;
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
Logger.printInfo(() -> "parse error", ex);
|
||||
resetCustomSpeeds(str("revanced_custom_playback_speeds_parse_exception"));
|
||||
Utils.showToastLong(str("revanced_custom_playback_speeds_parse_exception"));
|
||||
Settings.CUSTOM_PLAYBACK_SPEEDS.resetToDefault();
|
||||
loadCustomSpeeds();
|
||||
}
|
||||
}
|
||||
|
@ -50,6 +50,7 @@ public class Settings extends BaseSettings {
|
||||
public static final IntegerSetting VIDEO_QUALITY_DEFAULT_WIFI = new IntegerSetting("revanced_video_quality_default_wifi", -2);
|
||||
public static final IntegerSetting VIDEO_QUALITY_DEFAULT_MOBILE = new IntegerSetting("revanced_video_quality_default_mobile", -2);
|
||||
// Speed
|
||||
public static final FloatSetting SPEED_TAP_AND_HOLD = new FloatSetting("revanced_speed_tap_and_hold", 2.0f, true);
|
||||
public static final BooleanSetting REMEMBER_PLAYBACK_SPEED_LAST_SELECTED = new BooleanSetting("revanced_remember_playback_speed_last_selected", FALSE);
|
||||
public static final BooleanSetting CUSTOM_SPEED_MENU = new BooleanSetting("revanced_custom_speed_menu", TRUE);
|
||||
public static final FloatSetting PLAYBACK_SPEED_DEFAULT = new FloatSetting("revanced_playback_speed_default", -2.0f);
|
||||
|
Reference in New Issue
Block a user