mirror of
https://github.com/AntennaPod/AntennaPod.git
synced 2024-12-22 22:28:10 +01:00
Merge pull request #3780 from ByteHamster/unlink-speed-settings
Do not link playback speed settings
This commit is contained in:
commit
429499d418
@ -19,9 +19,6 @@ import de.danoeh.antennapod.core.util.playback.Playable;
|
||||
import de.danoeh.antennapod.core.util.playback.PlaybackController;
|
||||
|
||||
public class PlaybackControlsDialog extends DialogFragment {
|
||||
private static final float PLAYBACK_SPEED_STEP = 0.05f;
|
||||
private static final float DEFAULT_MIN_PLAYBACK_SPEED = 0.5f;
|
||||
private static final float DEFAULT_MAX_PLAYBACK_SPEED = 2.5f;
|
||||
private static final String ARGUMENT_IS_PLAYING_VIDEO = "isPlayingVideo";
|
||||
|
||||
private PlaybackController controller;
|
||||
@ -77,11 +74,11 @@ public class PlaybackControlsDialog extends DialogFragment {
|
||||
}
|
||||
|
||||
private void setupUi() {
|
||||
final SeekBar barPlaybackSpeed = (SeekBar) dialog.findViewById(R.id.playback_speed);
|
||||
final Button butDecSpeed = (Button) dialog.findViewById(R.id.butDecSpeed);
|
||||
final SeekBar barPlaybackSpeed = dialog.findViewById(R.id.playback_speed);
|
||||
final Button butDecSpeed = dialog.findViewById(R.id.butDecSpeed);
|
||||
butDecSpeed.setOnClickListener(v -> {
|
||||
if (controller != null && controller.canSetPlaybackSpeed()) {
|
||||
barPlaybackSpeed.setProgress(barPlaybackSpeed.getProgress() - 1);
|
||||
barPlaybackSpeed.setProgress(barPlaybackSpeed.getProgress() - 2);
|
||||
} else {
|
||||
VariableSpeedDialog.showGetPluginDialog(getContext());
|
||||
}
|
||||
@ -89,29 +86,21 @@ public class PlaybackControlsDialog extends DialogFragment {
|
||||
final Button butIncSpeed = (Button) dialog.findViewById(R.id.butIncSpeed);
|
||||
butIncSpeed.setOnClickListener(v -> {
|
||||
if (controller != null && controller.canSetPlaybackSpeed()) {
|
||||
barPlaybackSpeed.setProgress(barPlaybackSpeed.getProgress() + 1);
|
||||
barPlaybackSpeed.setProgress(barPlaybackSpeed.getProgress() + 2);
|
||||
} else {
|
||||
VariableSpeedDialog.showGetPluginDialog(getContext());
|
||||
}
|
||||
});
|
||||
|
||||
final TextView txtvPlaybackSpeed = (TextView) dialog.findViewById(R.id.txtvPlaybackSpeed);
|
||||
final TextView txtvPlaybackSpeed = dialog.findViewById(R.id.txtvPlaybackSpeed);
|
||||
float currentSpeed = getCurrentSpeed();
|
||||
|
||||
String[] availableSpeeds = UserPreferences.getPlaybackSpeedArray();
|
||||
final float minPlaybackSpeed = availableSpeeds.length > 1 ?
|
||||
Float.valueOf(availableSpeeds[0]) : DEFAULT_MIN_PLAYBACK_SPEED;
|
||||
float maxPlaybackSpeed = availableSpeeds.length > 1 ?
|
||||
Float.valueOf(availableSpeeds[availableSpeeds.length - 1]) : DEFAULT_MAX_PLAYBACK_SPEED;
|
||||
int progressMax = (int) ((maxPlaybackSpeed - minPlaybackSpeed) / PLAYBACK_SPEED_STEP);
|
||||
barPlaybackSpeed.setMax(progressMax);
|
||||
|
||||
txtvPlaybackSpeed.setText(String.format("%.2fx", currentSpeed));
|
||||
barPlaybackSpeed.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
|
||||
@Override
|
||||
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
|
||||
if (controller != null && controller.canSetPlaybackSpeed()) {
|
||||
float playbackSpeed = progress * PLAYBACK_SPEED_STEP + minPlaybackSpeed;
|
||||
float playbackSpeed = (progress + 10) / 20.0f;
|
||||
controller.setPlaybackSpeed(playbackSpeed);
|
||||
String speedPref = String.format(Locale.US, "%.2f", playbackSpeed);
|
||||
|
||||
@ -126,8 +115,7 @@ public class PlaybackControlsDialog extends DialogFragment {
|
||||
txtvPlaybackSpeed.setText(speedStr);
|
||||
} else if (fromUser) {
|
||||
float speed = getCurrentSpeed();
|
||||
barPlaybackSpeed.post(() -> barPlaybackSpeed.setProgress(
|
||||
(int) ((speed - minPlaybackSpeed) / PLAYBACK_SPEED_STEP)));
|
||||
barPlaybackSpeed.post(() -> barPlaybackSpeed.setProgress(Math.round((20 * speed) - 10)));
|
||||
}
|
||||
}
|
||||
|
||||
@ -142,7 +130,7 @@ public class PlaybackControlsDialog extends DialogFragment {
|
||||
public void onStopTrackingTouch(SeekBar seekBar) {
|
||||
}
|
||||
});
|
||||
barPlaybackSpeed.setProgress(Math.round((currentSpeed - minPlaybackSpeed) / PLAYBACK_SPEED_STEP));
|
||||
barPlaybackSpeed.setProgress(Math.round((20 * currentSpeed) - 10));
|
||||
|
||||
final SeekBar barLeftVolume = (SeekBar) dialog.findViewById(R.id.volume_left);
|
||||
barLeftVolume.setProgress(UserPreferences.getLeftVolumePercentage());
|
||||
|
Loading…
Reference in New Issue
Block a user