diff options
author | ByteHamster <info@bytehamster.com> | 2021-11-06 23:01:49 +0100 |
---|---|---|
committer | ByteHamster <info@bytehamster.com> | 2021-11-06 23:01:49 +0100 |
commit | dd4997db275f25e190d5a90727ccc4e751aa4141 (patch) | |
tree | 3e5541888d87041115764879c53220347c551a31 /core | |
parent | 46ba314e4d8ee2ecc44766007efa2cd201b54655 (diff) | |
download | AntennaPod-dd4997db275f25e190d5a90727ccc4e751aa4141.zip |
Respect remaining time setting in widget
Diffstat (limited to 'core')
-rw-r--r-- | core/src/main/java/de/danoeh/antennapod/core/widget/WidgetUpdater.java | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/core/src/main/java/de/danoeh/antennapod/core/widget/WidgetUpdater.java b/core/src/main/java/de/danoeh/antennapod/core/widget/WidgetUpdater.java index 62d56521c..ed3f1800d 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/widget/WidgetUpdater.java +++ b/core/src/main/java/de/danoeh/antennapod/core/widget/WidgetUpdater.java @@ -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)); + } } } |