Respect remaining time setting in widget

This commit is contained in:
ByteHamster 2021-11-06 23:01:49 +01:00
parent 46ba314e4d
commit dd4997db27
1 changed files with 10 additions and 7 deletions

View File

@ -20,6 +20,7 @@ import com.bumptech.glide.request.RequestOptions;
import java.util.concurrent.TimeUnit;
import de.danoeh.antennapod.core.R;
import de.danoeh.antennapod.core.preferences.UserPreferences;
import de.danoeh.antennapod.model.playback.MediaType;
import de.danoeh.antennapod.core.glide.ApGlideSettings;
import de.danoeh.antennapod.core.receiver.MediaButtonReceiver;
@ -218,14 +219,16 @@ public abstract class WidgetUpdater {
}
private static String getProgressString(int position, int duration, float speed) {
if (position >= 0 && duration > 0) {
TimeSpeedConverter converter = new TimeSpeedConverter(speed);
position = converter.convert(position);
duration = converter.convert(duration);
return Converter.getDurationStringLong(position) + " / "
+ Converter.getDurationStringLong(duration);
} else {
if (position < 0 || duration <= 0) {
return null;
}
TimeSpeedConverter converter = new TimeSpeedConverter(speed);
if (UserPreferences.shouldShowRemainingTime()) {
return Converter.getDurationStringLong(converter.convert(position)) + " / -"
+ Converter.getDurationStringLong(converter.convert(Math.max(0, duration - position)));
} else {
return Converter.getDurationStringLong(converter.convert(position)) + " / "
+ Converter.getDurationStringLong(converter.convert(duration));
}
}
}