summaryrefslogtreecommitdiff
path: root/core/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'core/src/main')
-rw-r--r--core/src/main/java/de/danoeh/antennapod/core/preferences/UserPreferences.java21
-rw-r--r--core/src/main/java/de/danoeh/antennapod/core/util/Converter.java13
2 files changed, 23 insertions, 11 deletions
diff --git a/core/src/main/java/de/danoeh/antennapod/core/preferences/UserPreferences.java b/core/src/main/java/de/danoeh/antennapod/core/preferences/UserPreferences.java
index 3631f881b..aa20b69b6 100644
--- a/core/src/main/java/de/danoeh/antennapod/core/preferences/UserPreferences.java
+++ b/core/src/main/java/de/danoeh/antennapod/core/preferences/UserPreferences.java
@@ -31,6 +31,7 @@ import de.danoeh.antennapod.core.storage.APCleanupAlgorithm;
import de.danoeh.antennapod.core.storage.APNullCleanupAlgorithm;
import de.danoeh.antennapod.core.storage.APQueueCleanupAlgorithm;
import de.danoeh.antennapod.core.storage.EpisodeCleanupAlgorithm;
+import de.danoeh.antennapod.core.util.Converter;
/**
* Provides access to preferences set by the user in the settings screen. A
@@ -267,20 +268,20 @@ public class UserPreferences {
public static float getLeftVolume() {
int volume = prefs.getInt(PREF_LEFT_VOLUME, 100);
- if(volume == 100) {
- return 1.0f;
- } else {
- return (float) (1 - (Math.log(100 - volume) / Math.log(100)));
- }
+ return Converter.getVolumeFromPercentage(volume);
}
public static float getRightVolume() {
int volume = prefs.getInt(PREF_RIGHT_VOLUME, 100);
- if(volume == 100) {
- return 1.0f;
- } else {
- return (float) (1 - (Math.log(100 - volume) / Math.log(100)));
- }
+ return Converter.getVolumeFromPercentage(volume);
+ }
+
+ public static int getLeftVolumePercentage() {
+ return prefs.getInt(PREF_LEFT_VOLUME, 100);
+ }
+
+ public static int getRightVolumePercentage() {
+ return prefs.getInt(PREF_RIGHT_VOLUME, 100);
}
public static boolean shouldPauseForFocusLoss() {
diff --git a/core/src/main/java/de/danoeh/antennapod/core/util/Converter.java b/core/src/main/java/de/danoeh/antennapod/core/util/Converter.java
index 2e3afefa9..5b046d7a7 100644
--- a/core/src/main/java/de/danoeh/antennapod/core/util/Converter.java
+++ b/core/src/main/java/de/danoeh/antennapod/core/util/Converter.java
@@ -118,5 +118,16 @@ public final class Converter {
result += minutes;
return result;
}
-
+
+ /**
+ * Converts the volume as read as the progress from a SeekBar scaled to 100 and as saved in
+ * UserPreferences to the format taken by setVolume methods.
+ * @param progress integer between 0 to 100 taken from the SeekBar progress
+ * @return the appropriate volume as float taken by setVolume methods
+ */
+ public static float getVolumeFromPercentage(int progress){
+ if (progress==100)
+ return 1f;
+ return (float) (1 - (Math.log(101 - progress) / Math.log(101)));
+ }
}