Merge pull request #1605 from mfietz/issue/1603-change-speed-confusion
Eliminate confusion from UI elements that change playback speed
This commit is contained in:
commit
f5f3477ac0
|
@ -421,15 +421,23 @@ public abstract class MediaplayerActivity extends AppCompatActivity implements O
|
|||
})
|
||||
.show();
|
||||
final SeekBar barPlaybackSpeed = (SeekBar) dialog.findViewById(R.id.playback_speed);
|
||||
|
||||
final Button butDecSpeed = (Button) dialog.findViewById(R.id.butDecSpeed);
|
||||
butDecSpeed.setOnClickListener(v -> {
|
||||
barPlaybackSpeed.setProgress(barPlaybackSpeed.getProgress() - 2);
|
||||
if(controller != null && controller.canSetPlaybackSpeed()) {
|
||||
barPlaybackSpeed.setProgress(barPlaybackSpeed.getProgress() - 2);
|
||||
} else {
|
||||
VariableSpeedDialog.showGetPluginDialog(this);
|
||||
}
|
||||
});
|
||||
final Button butIncSpeed = (Button) dialog.findViewById(R.id.butIncSpeed);
|
||||
butIncSpeed.setOnClickListener(v -> {
|
||||
barPlaybackSpeed.setProgress(barPlaybackSpeed.getProgress() + 2);
|
||||
if(controller != null && controller.canSetPlaybackSpeed()) {
|
||||
barPlaybackSpeed.setProgress(barPlaybackSpeed.getProgress() + 2);
|
||||
} else {
|
||||
VariableSpeedDialog.showGetPluginDialog(this);
|
||||
}
|
||||
});
|
||||
|
||||
final TextView txtvPlaybackSpeed = (TextView) dialog.findViewById(R.id.txtvPlaybackSpeed);
|
||||
float currentSpeed = 1.0f;
|
||||
try {
|
||||
|
@ -443,15 +451,25 @@ public abstract class MediaplayerActivity extends AppCompatActivity implements O
|
|||
barPlaybackSpeed.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
|
||||
@Override
|
||||
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
|
||||
float playbackSpeed = (progress + 10) / 20.0f;
|
||||
controller.setPlaybackSpeed(playbackSpeed);
|
||||
String speed = String.format("%.2f", playbackSpeed);
|
||||
UserPreferences.setPlaybackSpeed(speed);
|
||||
txtvPlaybackSpeed.setText(speed + "x");
|
||||
if(controller != null && controller.canSetPlaybackSpeed()) {
|
||||
float playbackSpeed = (progress + 10) / 20.0f;
|
||||
controller.setPlaybackSpeed(playbackSpeed);
|
||||
String speed = String.format("%.2f", playbackSpeed);
|
||||
UserPreferences.setPlaybackSpeed(speed);
|
||||
txtvPlaybackSpeed.setText(speed + "x");
|
||||
} else if(fromUser) {
|
||||
float speed = Float.valueOf(UserPreferences.getPlaybackSpeed());
|
||||
barPlaybackSpeed.post(() -> {
|
||||
barPlaybackSpeed.setProgress((int) (20 * speed) - 10);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStartTrackingTouch(SeekBar seekBar) {
|
||||
if(controller != null && !controller.canSetPlaybackSpeed()) {
|
||||
VariableSpeedDialog.showGetPluginDialog(MediaplayerActivity.this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -734,7 +752,7 @@ public abstract class MediaplayerActivity extends AppCompatActivity implements O
|
|||
UserPreferences.setPlaybackSpeed(newSpeed);
|
||||
controller.setPlaybackSpeed(Float.parseFloat(newSpeed));
|
||||
} else {
|
||||
VariableSpeedDialog.showDialog(this);
|
||||
VariableSpeedDialog.showGetPluginDialog(this);
|
||||
}
|
||||
});
|
||||
butPlaybackSpeed.setOnLongClickListener(v -> {
|
||||
|
|
|
@ -35,11 +35,15 @@ public class VariableSpeedDialog {
|
|||
|| Build.VERSION.SDK_INT >= 23) {
|
||||
showSpeedSelectorDialog(context);
|
||||
} else {
|
||||
showGetPluginDialog(context);
|
||||
showGetPluginDialog(context, true);
|
||||
}
|
||||
}
|
||||
|
||||
private static void showGetPluginDialog(final Context context) {
|
||||
public static void showGetPluginDialog(final Context context) {
|
||||
showGetPluginDialog(context, false);
|
||||
}
|
||||
|
||||
private static void showGetPluginDialog(final Context context, boolean showSpeedSelector) {
|
||||
MaterialDialog.Builder builder = new MaterialDialog.Builder(context);
|
||||
builder.title(R.string.no_playback_plugin_title);
|
||||
builder.content(R.string.no_playback_plugin_or_sonic_msg);
|
||||
|
@ -49,7 +53,9 @@ public class VariableSpeedDialog {
|
|||
builder.onPositive((dialog, which) -> {
|
||||
if (Build.VERSION.SDK_INT >= 16) { // just to be safe
|
||||
UserPreferences.enableSonic(true);
|
||||
showSpeedSelectorDialog(context);
|
||||
if(showSpeedSelector) {
|
||||
showSpeedSelectorDialog(context);
|
||||
}
|
||||
}
|
||||
});
|
||||
builder.onNegative((dialog, which) -> {
|
||||
|
|
|
@ -11,6 +11,7 @@ import android.content.SharedPreferences;
|
|||
import android.content.res.TypedArray;
|
||||
import android.media.MediaPlayer;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Build;
|
||||
import android.os.IBinder;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.support.annotation.NonNull;
|
||||
|
@ -34,6 +35,7 @@ import de.danoeh.antennapod.core.feed.Chapter;
|
|||
import de.danoeh.antennapod.core.feed.FeedMedia;
|
||||
import de.danoeh.antennapod.core.feed.MediaType;
|
||||
import de.danoeh.antennapod.core.preferences.PlaybackPreferences;
|
||||
import de.danoeh.antennapod.core.preferences.UserPreferences;
|
||||
import de.danoeh.antennapod.core.service.playback.PlaybackService;
|
||||
import de.danoeh.antennapod.core.service.playback.PlaybackServiceMediaPlayer;
|
||||
import de.danoeh.antennapod.core.service.playback.PlayerStatus;
|
||||
|
@ -677,6 +679,11 @@ public abstract class PlaybackController {
|
|||
}
|
||||
|
||||
public boolean canSetPlaybackSpeed() {
|
||||
if (org.antennapod.audio.MediaPlayer.isPrestoLibraryInstalled(activity.getApplicationContext())
|
||||
|| UserPreferences.useSonic()
|
||||
|| Build.VERSION.SDK_INT >= 23) {
|
||||
return true;
|
||||
}
|
||||
return playbackService != null && playbackService.canSetSpeed();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue