mirror of
https://github.com/revanced/revanced-integrations.git
synced 2024-12-31 23:25:50 +01:00
fix(YouTube - Playback speed): Remember playback speed with new speed menu (#725)
This commit is contained in:
parent
c1bde72525
commit
fd9ffa53b7
@ -2,14 +2,18 @@ package app.revanced.integrations.youtube.patches.playback.speed;
|
||||
|
||||
import static app.revanced.integrations.shared.StringRef.str;
|
||||
|
||||
import app.revanced.integrations.youtube.patches.VideoInformation;
|
||||
import app.revanced.integrations.youtube.settings.Settings;
|
||||
import app.revanced.integrations.shared.Logger;
|
||||
import app.revanced.integrations.shared.Utils;
|
||||
import app.revanced.integrations.youtube.patches.VideoInformation;
|
||||
import app.revanced.integrations.youtube.settings.Settings;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public final class RememberPlaybackSpeedPatch {
|
||||
|
||||
private static final long TOAST_DELAY_MILLISECONDS = 750;
|
||||
|
||||
private static long lastTimeSpeedChanged;
|
||||
|
||||
/**
|
||||
* Injection point.
|
||||
*/
|
||||
@ -27,7 +31,17 @@ public final class RememberPlaybackSpeedPatch {
|
||||
public static void userSelectedPlaybackSpeed(float playbackSpeed) {
|
||||
if (Settings.REMEMBER_PLAYBACK_SPEED_LAST_SELECTED.get()) {
|
||||
Settings.PLAYBACK_SPEED_DEFAULT.save(playbackSpeed);
|
||||
Utils.showToastLong(str("revanced_remember_playback_speed_toast", (playbackSpeed + "x")));
|
||||
|
||||
// Prevent toast spamming if using the 0.05x adjustments.
|
||||
// Show exactly one toast after the user stops interacting with the speed menu.
|
||||
final long now = System.currentTimeMillis();
|
||||
lastTimeSpeedChanged = now;
|
||||
|
||||
Utils.runOnMainThreadDelayed(() -> {
|
||||
if (lastTimeSpeedChanged == now) {
|
||||
Utils.showToastLong(str("revanced_remember_playback_speed_toast", (playbackSpeed + "x")));
|
||||
} // else, the user made additional speed adjustments and this call is outdated.
|
||||
}, TOAST_DELAY_MILLISECONDS);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user