Skip to content
This repository has been archived by the owner on Oct 26, 2024. It is now read-only.

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
LisoUseInAIKyrios committed Oct 25, 2024
1 parent dedb9ed commit 60bb2f7
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,30 +20,30 @@ public final class PlaybackSpeedMenuFilterPatch extends Filter {
*/
public static volatile boolean isPlaybackRateSelectorMenuVisible;

private final StringFilterGroup playbackRateSelectorGroup;
private final StringFilterGroup oldPlaybackMenuGroup;

public PlaybackSpeedMenuFilterPatch() {
// 0.05x litho speed menu.
playbackRateSelectorGroup = new StringFilterGroup(
var playbackRateSelectorGroup = new StringFilterGroup(
Settings.CUSTOM_SPEED_MENU,
"playback_rate_selector_menu_sheet.eml-js"
);

// Old litho based speed menu.
var oldPlaybackMenu = new StringFilterGroup(
oldPlaybackMenuGroup = new StringFilterGroup(
Settings.CUSTOM_SPEED_MENU,
"playback_speed_sheet_content.eml-js");

addPathCallbacks(playbackRateSelectorGroup, oldPlaybackMenu);
addPathCallbacks(playbackRateSelectorGroup, oldPlaybackMenuGroup);
}

@Override
boolean isFiltered(@Nullable String identifier, String path, byte[] protobufBufferArray,
StringFilterGroup matchedGroup, FilterContentType contentType, int contentIndex) {
if (matchedGroup == playbackRateSelectorGroup) {
isPlaybackRateSelectorMenuVisible = true;
} else {
if (matchedGroup == oldPlaybackMenuGroup) {
isOldPlaybackSpeedMenuVisible = true;
} else {
isPlaybackRateSelectorMenuVisible = true;
}

return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,19 +61,22 @@ private static void loadCustomSpeeds() {
}

customPlaybackSpeeds = new float[speedStrings.length];
for (int i = 0, length = speedStrings.length; i < length; i++) {
final float speed = Float.parseFloat(speedStrings[i]);
if (speed <= 0 || arrayContains(customPlaybackSpeeds, speed)) {

int i = 0;
for (String speedString : speedStrings) {
final float speedFloat = Float.parseFloat(speedString);
if (speedFloat <= 0 || arrayContains(customPlaybackSpeeds, speedFloat)) {
throw new IllegalArgumentException();
}

if (speed >= MAXIMUM_PLAYBACK_SPEED) {
if (speedFloat >= MAXIMUM_PLAYBACK_SPEED) {
resetCustomSpeeds(str("revanced_custom_playback_speeds_invalid", MAXIMUM_PLAYBACK_SPEED));
loadCustomSpeeds();
return;
}

customPlaybackSpeeds[i] = speed;
customPlaybackSpeeds[i] = speedFloat;
i++;
}
} catch (Exception ex) {
Logger.printInfo(() -> "parse error", ex);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ public static void userSelectedPlaybackSpeed(float playbackSpeed) {

if (Settings.PLAYBACK_SPEED_DEFAULT.get() == finalPlaybackSpeed) {
// User changed to a different speed and immediately changed back.
// Or the user is going past 8.0x in the glitched out 0.05x menu.
return;
}
Settings.PLAYBACK_SPEED_DEFAULT.save(finalPlaybackSpeed);
Expand Down

0 comments on commit 60bb2f7

Please sign in to comment.