diff options
author | ByteHamster <ByteHamster@users.noreply.github.com> | 2021-07-30 22:00:28 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-07-30 22:00:28 +0200 |
commit | 666a11f3a940cad622d53d05f976046c1e5edf5a (patch) | |
tree | a702a5f5aa6d41b623755e2d3119cc0a9b834148 /core | |
parent | 6d2ef33637009a718c73e5e63121606a70f476fc (diff) | |
parent | 4e185f2895d773ae3a966597ab8cc65e4d1c576d (diff) | |
download | AntennaPod-666a11f3a940cad622d53d05f976046c1e5edf5a.zip |
Merge pull request #5309 from ByteHamster/remove-volume-control
Removed left/right volume controls
Diffstat (limited to 'core')
6 files changed, 6 insertions, 75 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 91006d446..76dfab169 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 @@ -8,7 +8,6 @@ import android.text.TextUtils; import android.util.Log; import android.view.KeyEvent; -import androidx.annotation.IntRange; import androidx.annotation.NonNull; import androidx.annotation.VisibleForTesting; import androidx.core.app.NotificationCompat; @@ -40,7 +39,6 @@ import de.danoeh.antennapod.core.storage.ExceptFavoriteCleanupAlgorithm; 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; import de.danoeh.antennapod.model.feed.SortOrder; import de.danoeh.antennapod.core.util.download.AutoUpdateManager; @@ -468,24 +466,6 @@ public class UserPreferences { return readPlaybackSpeedArray(prefs.getString(PREF_PLAYBACK_SPEED_ARRAY, null)); } - public static float getLeftVolume() { - int volume = prefs.getInt(PREF_LEFT_VOLUME, 100); - return Converter.getVolumeFromPercentage(volume); - } - - public static float getRightVolume() { - int volume = prefs.getInt(PREF_RIGHT_VOLUME, 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() { return prefs.getBoolean(PREF_PAUSE_PLAYBACK_FOR_FOCUS_LOSS, false); } @@ -712,14 +692,6 @@ public class UserPreferences { .apply(); } - public static void setVolume(@IntRange(from = 0, to = 100) int leftVolume, - @IntRange(from = 0, to = 100) int rightVolume) { - prefs.edit() - .putInt(PREF_LEFT_VOLUME, leftVolume) - .putInt(PREF_RIGHT_VOLUME, rightVolume) - .apply(); - } - public static void setAutodownloadSelectedNetworks(String[] value) { prefs.edit() .putString(PREF_AUTODL_SELECTED_NETWORKS, TextUtils.join(",", value)) diff --git a/core/src/main/java/de/danoeh/antennapod/core/service/playback/LocalPSMP.java b/core/src/main/java/de/danoeh/antennapod/core/service/playback/LocalPSMP.java index dc29f53d4..3016b96d5 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/service/playback/LocalPSMP.java +++ b/core/src/main/java/de/danoeh/antennapod/core/service/playback/LocalPSMP.java @@ -322,10 +322,7 @@ public class LocalPSMP extends PlaybackServiceMediaPlayer { acquireWifiLockIfNecessary(); setPlaybackParams(PlaybackSpeedUtils.getCurrentPlaybackSpeed(media), UserPreferences.isSkipSilence()); - - float leftVolume = UserPreferences.getLeftVolume(); - float rightVolume = UserPreferences.getRightVolume(); - setVolume(leftVolume, rightVolume); + setVolume(1.0f, 1.0f); if (playerStatus == PlayerStatus.PREPARED && media.getPosition() > 0) { int newPosition = RewindAfterPauseUtils.calculatePositionWithRewind( @@ -891,16 +888,13 @@ public class LocalPSMP extends PlaybackServiceMediaPlayer { if (pausedBecauseOfTransientAudiofocusLoss) { // we paused => play now resume(); } else { // we ducked => raise audio level back - setVolumeSync(UserPreferences.getLeftVolume(), - UserPreferences.getRightVolume()); + setVolumeSync(1.0f, 1.0f); } } else if (focusChange == AudioManager.AUDIOFOCUS_LOSS_TRANSIENT_CAN_DUCK) { if (playerStatus == PlayerStatus.PLAYING) { if (!UserPreferences.shouldPauseForFocusLoss()) { Log.d(TAG, "Lost audio focus temporarily. Ducking..."); - final float DUCK_FACTOR = 0.25f; - setVolumeSync(DUCK_FACTOR * UserPreferences.getLeftVolume(), - DUCK_FACTOR * UserPreferences.getRightVolume()); + setVolumeSync(0.25f, 0.25f); pausedBecauseOfTransientAudiofocusLoss = false; } else { Log.d(TAG, "Lost audio focus temporarily. Could duck, but won't, pausing..."); diff --git a/core/src/main/java/de/danoeh/antennapod/core/service/playback/PlaybackService.java b/core/src/main/java/de/danoeh/antennapod/core/service/playback/PlaybackService.java index 3b03c4993..2da06e226 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/service/playback/PlaybackService.java +++ b/core/src/main/java/de/danoeh/antennapod/core/service/playback/PlaybackService.java @@ -772,25 +772,19 @@ public class PlaybackService extends MediaBrowserServiceCompat { final float[] multiplicators = {0.1f, 0.2f, 0.3f, 0.3f, 0.3f, 0.4f, 0.4f, 0.4f, 0.6f, 0.8f}; float multiplicator = multiplicators[Math.max(0, (int) timeLeft / 1000)]; Log.d(TAG, "onSleepTimerAlmostExpired: " + multiplicator); - float leftVolume = multiplicator * UserPreferences.getLeftVolume(); - float rightVolume = multiplicator * UserPreferences.getRightVolume(); - mediaPlayer.setVolume(leftVolume, rightVolume); + mediaPlayer.setVolume(multiplicator, multiplicator); } @Override public void onSleepTimerExpired() { mediaPlayer.pause(true, true); - float leftVolume = UserPreferences.getLeftVolume(); - float rightVolume = UserPreferences.getRightVolume(); - mediaPlayer.setVolume(leftVolume, rightVolume); + mediaPlayer.setVolume(1.0f, 1.0f); sendNotificationBroadcast(NOTIFICATION_TYPE_SLEEPTIMER_UPDATE, 0); } @Override public void onSleepTimerReset() { - float leftVolume = UserPreferences.getLeftVolume(); - float rightVolume = UserPreferences.getRightVolume(); - mediaPlayer.setVolume(leftVolume, rightVolume); + mediaPlayer.setVolume(1.0f, 1.0f); } @Override @@ -1661,10 +1655,6 @@ public class PlaybackService extends MediaBrowserServiceCompat { mediaPlayer.setPlaybackParams(getCurrentPlaybackSpeed(), skipSilence); } - public void setVolume(float leftVolume, float rightVolume) { - mediaPlayer.setVolume(leftVolume, rightVolume); - } - public float getCurrentPlaybackSpeed() { if(mediaPlayer == null) { return 1.0f; 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 8f9b8ce2f..4014937bd 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 @@ -12,9 +12,6 @@ public final class Converter { private Converter() { } - /** Logging tag. */ - private static final String TAG = "Converter"; - private static final int HOURS_MIL = 3600000; private static final int MINUTES_MIL = 60000; private static final int SECONDS_MIL = 1000; @@ -108,17 +105,4 @@ public final class Converter { float hours = (float) time / 3600f; return String.format(Locale.getDefault(), "%.1f ", hours) + context.getString(R.string.time_hours); } - - /** - * 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))); - } } diff --git a/core/src/main/java/de/danoeh/antennapod/core/util/playback/PlaybackController.java b/core/src/main/java/de/danoeh/antennapod/core/util/playback/PlaybackController.java index 6fe2502ab..cd69147a6 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/util/playback/PlaybackController.java +++ b/core/src/main/java/de/danoeh/antennapod/core/util/playback/PlaybackController.java @@ -496,12 +496,6 @@ public abstract class PlaybackController { } } - public void setVolume(float leftVolume, float rightVolume) { - if (playbackService != null) { - playbackService.setVolume(leftVolume, rightVolume); - } - } - public float getCurrentPlaybackSpeedMultiplier() { if (playbackService != null) { return playbackService.getCurrentPlaybackSpeed(); diff --git a/core/src/main/res/values/strings.xml b/core/src/main/res/values/strings.xml index db4387557..38178e0e2 100644 --- a/core/src/main/res/values/strings.xml +++ b/core/src/main/res/values/strings.xml @@ -775,9 +775,6 @@ <!-- Audio controls --> <string name="audio_controls">Audio controls</string> <string name="playback_speed">Playback Speed</string> - <string name="volume">Volume</string> - <string name="left_short">L</string> - <string name="right_short">R</string> <string name="audio_effects">Audio Effects</string> <string name="stereo_to_mono">Downmix: Stereo to mono</string> <string name="sonic_only">Sonic only</string> |