Do not link playback speed settings
Users are confused that the slider does not have all speed options anymore
This basically reverts 6a56260
This commit is contained in:
parent
2f0c627b15
commit
2f7cbefddb
|
@ -19,9 +19,6 @@ import de.danoeh.antennapod.core.util.playback.Playable;
|
||||||
import de.danoeh.antennapod.core.util.playback.PlaybackController;
|
import de.danoeh.antennapod.core.util.playback.PlaybackController;
|
||||||
|
|
||||||
public class PlaybackControlsDialog extends DialogFragment {
|
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 static final String ARGUMENT_IS_PLAYING_VIDEO = "isPlayingVideo";
|
||||||
|
|
||||||
private PlaybackController controller;
|
private PlaybackController controller;
|
||||||
|
@ -77,11 +74,11 @@ public class PlaybackControlsDialog extends DialogFragment {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setupUi() {
|
private void setupUi() {
|
||||||
final SeekBar barPlaybackSpeed = (SeekBar) dialog.findViewById(R.id.playback_speed);
|
final SeekBar barPlaybackSpeed = dialog.findViewById(R.id.playback_speed);
|
||||||
final Button butDecSpeed = (Button) dialog.findViewById(R.id.butDecSpeed);
|
final Button butDecSpeed = dialog.findViewById(R.id.butDecSpeed);
|
||||||
butDecSpeed.setOnClickListener(v -> {
|
butDecSpeed.setOnClickListener(v -> {
|
||||||
if (controller != null && controller.canSetPlaybackSpeed()) {
|
if (controller != null && controller.canSetPlaybackSpeed()) {
|
||||||
barPlaybackSpeed.setProgress(barPlaybackSpeed.getProgress() - 1);
|
barPlaybackSpeed.setProgress(barPlaybackSpeed.getProgress() - 2);
|
||||||
} else {
|
} else {
|
||||||
VariableSpeedDialog.showGetPluginDialog(getContext());
|
VariableSpeedDialog.showGetPluginDialog(getContext());
|
||||||
}
|
}
|
||||||
|
@ -89,29 +86,21 @@ public class PlaybackControlsDialog extends DialogFragment {
|
||||||
final Button butIncSpeed = (Button) dialog.findViewById(R.id.butIncSpeed);
|
final Button butIncSpeed = (Button) dialog.findViewById(R.id.butIncSpeed);
|
||||||
butIncSpeed.setOnClickListener(v -> {
|
butIncSpeed.setOnClickListener(v -> {
|
||||||
if (controller != null && controller.canSetPlaybackSpeed()) {
|
if (controller != null && controller.canSetPlaybackSpeed()) {
|
||||||
barPlaybackSpeed.setProgress(barPlaybackSpeed.getProgress() + 1);
|
barPlaybackSpeed.setProgress(barPlaybackSpeed.getProgress() + 2);
|
||||||
} else {
|
} else {
|
||||||
VariableSpeedDialog.showGetPluginDialog(getContext());
|
VariableSpeedDialog.showGetPluginDialog(getContext());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
final TextView txtvPlaybackSpeed = (TextView) dialog.findViewById(R.id.txtvPlaybackSpeed);
|
final TextView txtvPlaybackSpeed = dialog.findViewById(R.id.txtvPlaybackSpeed);
|
||||||
float currentSpeed = getCurrentSpeed();
|
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));
|
txtvPlaybackSpeed.setText(String.format("%.2fx", currentSpeed));
|
||||||
barPlaybackSpeed.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
|
barPlaybackSpeed.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
|
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
|
||||||
if (controller != null && controller.canSetPlaybackSpeed()) {
|
if (controller != null && controller.canSetPlaybackSpeed()) {
|
||||||
float playbackSpeed = progress * PLAYBACK_SPEED_STEP + minPlaybackSpeed;
|
float playbackSpeed = (progress + 10) / 20.0f;
|
||||||
controller.setPlaybackSpeed(playbackSpeed);
|
controller.setPlaybackSpeed(playbackSpeed);
|
||||||
String speedPref = String.format(Locale.US, "%.2f", playbackSpeed);
|
String speedPref = String.format(Locale.US, "%.2f", playbackSpeed);
|
||||||
|
|
||||||
|
@ -126,8 +115,7 @@ public class PlaybackControlsDialog extends DialogFragment {
|
||||||
txtvPlaybackSpeed.setText(speedStr);
|
txtvPlaybackSpeed.setText(speedStr);
|
||||||
} else if (fromUser) {
|
} else if (fromUser) {
|
||||||
float speed = getCurrentSpeed();
|
float speed = getCurrentSpeed();
|
||||||
barPlaybackSpeed.post(() -> barPlaybackSpeed.setProgress(
|
barPlaybackSpeed.post(() -> barPlaybackSpeed.setProgress(Math.round((20 * speed) - 10)));
|
||||||
(int) ((speed - minPlaybackSpeed) / PLAYBACK_SPEED_STEP)));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -142,7 +130,7 @@ public class PlaybackControlsDialog extends DialogFragment {
|
||||||
public void onStopTrackingTouch(SeekBar seekBar) {
|
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);
|
final SeekBar barLeftVolume = (SeekBar) dialog.findViewById(R.id.volume_left);
|
||||||
barLeftVolume.setProgress(UserPreferences.getLeftVolumePercentage());
|
barLeftVolume.setProgress(UserPreferences.getLeftVolumePercentage());
|
||||||
|
|
Loading…
Reference in New Issue