mirror of
https://github.com/revanced/revanced-patches.git
synced 2025-12-10 11:23:57 +01:00
feat(YouTube): Add an option to disable toasts when changing default playback speed or quality (#5230)
This commit is contained in:
@@ -64,6 +64,7 @@ public class RememberVideoQualityPatch {
|
|||||||
else videoQualityWifi.save(defaultQuality);
|
else videoQualityWifi.save(defaultQuality);
|
||||||
networkTypeMessage = str("revanced_remember_video_quality_wifi");
|
networkTypeMessage = str("revanced_remember_video_quality_wifi");
|
||||||
}
|
}
|
||||||
|
if (Settings.REMEMBER_VIDEO_QUALITY_LAST_SELECTED_TOAST.get())
|
||||||
Utils.showToastShort(str(
|
Utils.showToastShort(str(
|
||||||
useShortsPreference ? "revanced_remember_video_quality_toast_shorts" : "revanced_remember_video_quality_toast",
|
useShortsPreference ? "revanced_remember_video_quality_toast_shorts" : "revanced_remember_video_quality_toast",
|
||||||
networkTypeMessage, (defaultQuality + "p")
|
networkTypeMessage, (defaultQuality + "p")
|
||||||
|
|||||||
@@ -617,9 +617,9 @@ public class CustomPlaybackSpeedPatch {
|
|||||||
* @return The rounded speed, constrained to the specified bounds.
|
* @return The rounded speed, constrained to the specified bounds.
|
||||||
*/
|
*/
|
||||||
private static float roundSpeedToNearestIncrement(float speed) {
|
private static float roundSpeedToNearestIncrement(float speed) {
|
||||||
// Round to nearest 0.05 speed.
|
// Round to nearest 0.05 speed. Must use double precision otherwise rounding error can occur.
|
||||||
final float roundedSpeed = Math.round(speed / 0.05f) * 0.05f;
|
final double roundedSpeed = Math.round(speed / 0.05) * 0.05;
|
||||||
return Utils.clamp(roundedSpeed, 0.05f, PLAYBACK_SPEED_MAXIMUM);
|
return Utils.clamp((float) roundedSpeed, 0.05f, PLAYBACK_SPEED_MAXIMUM);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -57,6 +57,7 @@ public final class RememberPlaybackSpeedPatch {
|
|||||||
}
|
}
|
||||||
Settings.PLAYBACK_SPEED_DEFAULT.save(finalPlaybackSpeed);
|
Settings.PLAYBACK_SPEED_DEFAULT.save(finalPlaybackSpeed);
|
||||||
|
|
||||||
|
if (Settings.REMEMBER_PLAYBACK_SPEED_LAST_SELECTED_TOAST.get())
|
||||||
Utils.showToastShort(str("revanced_remember_playback_speed_toast", (finalPlaybackSpeed + "x")));
|
Utils.showToastShort(str("revanced_remember_playback_speed_toast", (finalPlaybackSpeed + "x")));
|
||||||
}, TOAST_DELAY_MILLISECONDS);
|
}, TOAST_DELAY_MILLISECONDS);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,6 +52,8 @@ 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_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);
|
public static final IntegerSetting VIDEO_QUALITY_DEFAULT_MOBILE = new IntegerSetting("revanced_video_quality_default_mobile", -2);
|
||||||
public static final BooleanSetting REMEMBER_VIDEO_QUALITY_LAST_SELECTED = new BooleanSetting("revanced_remember_video_quality_last_selected", FALSE);
|
public static final BooleanSetting REMEMBER_VIDEO_QUALITY_LAST_SELECTED = new BooleanSetting("revanced_remember_video_quality_last_selected", FALSE);
|
||||||
|
public static final BooleanSetting REMEMBER_VIDEO_QUALITY_LAST_SELECTED_TOAST = new BooleanSetting("revanced_remember_video_quality_last_selected_toast", TRUE, false,
|
||||||
|
parent(REMEMBER_VIDEO_QUALITY_LAST_SELECTED));
|
||||||
public static final IntegerSetting SHORTS_QUALITY_DEFAULT_WIFI = new IntegerSetting("revanced_shorts_quality_default_wifi", -2, true);
|
public static final IntegerSetting SHORTS_QUALITY_DEFAULT_WIFI = new IntegerSetting("revanced_shorts_quality_default_wifi", -2, true);
|
||||||
public static final IntegerSetting SHORTS_QUALITY_DEFAULT_MOBILE = new IntegerSetting("revanced_shorts_quality_default_mobile", -2, true);
|
public static final IntegerSetting SHORTS_QUALITY_DEFAULT_MOBILE = new IntegerSetting("revanced_shorts_quality_default_mobile", -2, true);
|
||||||
public static final BooleanSetting REMEMBER_SHORTS_QUALITY_LAST_SELECTED = new BooleanSetting("revanced_remember_shorts_quality_last_selected", FALSE);
|
public static final BooleanSetting REMEMBER_SHORTS_QUALITY_LAST_SELECTED = new BooleanSetting("revanced_remember_shorts_quality_last_selected", FALSE);
|
||||||
@@ -60,6 +62,8 @@ public class Settings extends BaseSettings {
|
|||||||
// Speed
|
// Speed
|
||||||
public static final FloatSetting SPEED_TAP_AND_HOLD = new FloatSetting("revanced_speed_tap_and_hold", 2.0f, true);
|
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 REMEMBER_PLAYBACK_SPEED_LAST_SELECTED = new BooleanSetting("revanced_remember_playback_speed_last_selected", FALSE);
|
||||||
|
public static final BooleanSetting REMEMBER_PLAYBACK_SPEED_LAST_SELECTED_TOAST = new BooleanSetting("revanced_remember_playback_speed_last_selected_toast", TRUE, false,
|
||||||
|
parent(REMEMBER_PLAYBACK_SPEED_LAST_SELECTED));
|
||||||
public static final BooleanSetting CUSTOM_SPEED_MENU = new BooleanSetting("revanced_custom_speed_menu", TRUE);
|
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);
|
public static final FloatSetting PLAYBACK_SPEED_DEFAULT = new FloatSetting("revanced_playback_speed_default", -2.0f);
|
||||||
public static final StringSetting CUSTOM_PLAYBACK_SPEEDS = new StringSetting("revanced_custom_playback_speeds",
|
public static final StringSetting CUSTOM_PLAYBACK_SPEEDS = new StringSetting("revanced_custom_playback_speeds",
|
||||||
|
|||||||
@@ -42,7 +42,6 @@ public class PlaybackSpeedDialogButton {
|
|||||||
: Settings.PLAYBACK_SPEED_DEFAULT.get();
|
: Settings.PLAYBACK_SPEED_DEFAULT.get();
|
||||||
|
|
||||||
VideoInformation.overridePlaybackSpeed(speed);
|
VideoInformation.overridePlaybackSpeed(speed);
|
||||||
showToastShort(str("revanced_custom_playback_speeds_reset_toast", (speed + "x")));
|
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
Logger.printException(() -> "speed button reset failure", ex);
|
Logger.printException(() -> "speed button reset failure", ex);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -57,7 +57,8 @@ val rememberVideoQualityPatch = bytecodePatch {
|
|||||||
entriesKey = "revanced_shorts_quality_default_entries",
|
entriesKey = "revanced_shorts_quality_default_entries",
|
||||||
entryValuesKey = "revanced_shorts_quality_default_entry_values"
|
entryValuesKey = "revanced_shorts_quality_default_entry_values"
|
||||||
),
|
),
|
||||||
SwitchPreference("revanced_remember_shorts_quality_last_selected")
|
SwitchPreference("revanced_remember_shorts_quality_last_selected"),
|
||||||
|
SwitchPreference("revanced_remember_video_quality_last_selected_toast")
|
||||||
))
|
))
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -39,7 +39,8 @@ internal val rememberPlaybackSpeedPatch = bytecodePatch {
|
|||||||
entryValuesKey = null,
|
entryValuesKey = null,
|
||||||
tag = "app.revanced.extension.youtube.settings.preference.CustomVideoSpeedListPreference"
|
tag = "app.revanced.extension.youtube.settings.preference.CustomVideoSpeedListPreference"
|
||||||
),
|
),
|
||||||
SwitchPreference("revanced_remember_playback_speed_last_selected")
|
SwitchPreference("revanced_remember_playback_speed_last_selected"),
|
||||||
|
SwitchPreference("revanced_remember_playback_speed_last_selected_toast")
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -1465,6 +1465,9 @@ Enabling this can unlock higher video qualities"</string>
|
|||||||
<string name="revanced_remember_video_quality_last_selected_title">Remember video quality changes</string>
|
<string name="revanced_remember_video_quality_last_selected_title">Remember video quality changes</string>
|
||||||
<string name="revanced_remember_video_quality_last_selected_summary_on">Quality changes apply to all videos</string>
|
<string name="revanced_remember_video_quality_last_selected_summary_on">Quality changes apply to all videos</string>
|
||||||
<string name="revanced_remember_video_quality_last_selected_summary_off">Quality changes only apply to the current video</string>
|
<string name="revanced_remember_video_quality_last_selected_summary_off">Quality changes only apply to the current video</string>
|
||||||
|
<string name="revanced_remember_video_quality_last_selected_toast_title">Show toast on video quality changes</string>
|
||||||
|
<string name="revanced_remember_video_quality_last_selected_toast_summary_on">A toast is shown when the default video quality is changed</string>
|
||||||
|
<string name="revanced_remember_video_quality_last_selected_toast_summary_off">A toast is not shown when the default video quality is changed</string>
|
||||||
<string name="revanced_video_quality_default_wifi_title">Default video quality on Wi-Fi network</string>
|
<string name="revanced_video_quality_default_wifi_title">Default video quality on Wi-Fi network</string>
|
||||||
<string name="revanced_video_quality_default_mobile_title">Default video quality on mobile network</string>
|
<string name="revanced_video_quality_default_mobile_title">Default video quality on mobile network</string>
|
||||||
<string name="revanced_remember_shorts_quality_last_selected_title">Remember Shorts quality changes</string>
|
<string name="revanced_remember_shorts_quality_last_selected_title">Remember Shorts quality changes</string>
|
||||||
@@ -1491,7 +1494,6 @@ Enabling this can unlock higher video qualities"</string>
|
|||||||
<string name="revanced_custom_playback_speeds_invalid">Custom speeds must be less than %s</string>
|
<string name="revanced_custom_playback_speeds_invalid">Custom speeds must be less than %s</string>
|
||||||
<string name="revanced_custom_playback_speeds_parse_exception">Invalid custom playback speeds</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_custom_playback_speeds_auto">Auto</string>
|
||||||
<string name="revanced_custom_playback_speeds_reset_toast">Playback speed reset to: %s</string>
|
|
||||||
<string name="revanced_speed_tap_and_hold_title">Custom tap and hold speed</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</string>
|
||||||
</patch>
|
</patch>
|
||||||
@@ -1499,6 +1501,9 @@ Enabling this can unlock higher video qualities"</string>
|
|||||||
<string name="revanced_remember_playback_speed_last_selected_title">Remember playback speed changes</string>
|
<string name="revanced_remember_playback_speed_last_selected_title">Remember playback speed changes</string>
|
||||||
<string name="revanced_remember_playback_speed_last_selected_summary_on">Playback speed changes apply to all videos</string>
|
<string name="revanced_remember_playback_speed_last_selected_summary_on">Playback speed changes apply to all videos</string>
|
||||||
<string name="revanced_remember_playback_speed_last_selected_summary_off">Playback speed changes only apply to the current video</string>
|
<string name="revanced_remember_playback_speed_last_selected_summary_off">Playback speed changes only apply to the current video</string>
|
||||||
|
<string name="revanced_remember_playback_speed_last_selected_toast_title">Show toast on playback speed changes</string>
|
||||||
|
<string name="revanced_remember_playback_speed_last_selected_toast_summary_on">A toast is shown when the default playback speed is changed</string>
|
||||||
|
<string name="revanced_remember_playback_speed_last_selected_toast_summary_off">A toast is not shown when the default playback speed is changed</string>
|
||||||
<string name="revanced_playback_speed_default_title">Default playback speed</string>
|
<string name="revanced_playback_speed_default_title">Default playback speed</string>
|
||||||
<string name="revanced_remember_playback_speed_toast">Changed default speed to: %s</string>
|
<string name="revanced_remember_playback_speed_toast">Changed default speed to: %s</string>
|
||||||
</patch>
|
</patch>
|
||||||
|
|||||||
Reference in New Issue
Block a user