mirror of
https://github.com/AntennaPod/AntennaPod.git
synced 2025-01-31 19:04:52 +01:00
Merge pull request #5309 from ByteHamster/remove-volume-control
Removed left/right volume controls
This commit is contained in:
commit
666a11f3a9
@ -10,11 +10,9 @@ import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.fragment.app.DialogFragment;
|
||||
import android.widget.Button;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.SeekBar;
|
||||
import android.widget.TextView;
|
||||
import de.danoeh.antennapod.R;
|
||||
import de.danoeh.antennapod.core.preferences.UserPreferences;
|
||||
import de.danoeh.antennapod.core.util.Converter;
|
||||
import de.danoeh.antennapod.core.util.playback.PlaybackController;
|
||||
import de.danoeh.antennapod.view.PlaybackSpeedSeekBar;
|
||||
|
||||
@ -63,11 +61,7 @@ public class PlaybackControlsDialog extends DialogFragment {
|
||||
dialog = new AlertDialog.Builder(getContext())
|
||||
.setTitle(R.string.audio_controls)
|
||||
.setView(R.layout.audio_controls)
|
||||
.setPositiveButton(R.string.close_label, (dialog1, which) -> {
|
||||
final SeekBar left = dialog.findViewById(R.id.volume_left);
|
||||
final SeekBar right = dialog.findViewById(R.id.volume_right);
|
||||
UserPreferences.setVolume(left.getProgress(), right.getProgress());
|
||||
}).create();
|
||||
.setPositiveButton(R.string.close_label, null).create();
|
||||
return dialog;
|
||||
}
|
||||
|
||||
@ -79,10 +73,6 @@ public class PlaybackControlsDialog extends DialogFragment {
|
||||
speedSeekBar.setProgressChangedListener(speed
|
||||
-> txtvPlaybackSpeed.setText(String.format(Locale.getDefault(), "%.2fx", speed)));
|
||||
|
||||
final SeekBar barLeftVolume = dialog.findViewById(R.id.volume_left);
|
||||
barLeftVolume.setProgress(UserPreferences.getLeftVolumePercentage());
|
||||
final SeekBar barRightVolume = dialog.findViewById(R.id.volume_right);
|
||||
barRightVolume.setProgress(UserPreferences.getRightVolumePercentage());
|
||||
final CheckBox stereoToMono = dialog.findViewById(R.id.stereo_to_mono);
|
||||
stereoToMono.setChecked(UserPreferences.stereoToMono());
|
||||
if (controller != null && !controller.canDownmix()) {
|
||||
@ -91,10 +81,6 @@ public class PlaybackControlsDialog extends DialogFragment {
|
||||
stereoToMono.setText(getString(R.string.stereo_to_mono) + " [" + sonicOnly + "]");
|
||||
}
|
||||
|
||||
if (UserPreferences.useExoplayer()) {
|
||||
barRightVolume.setEnabled(false);
|
||||
}
|
||||
|
||||
final CheckBox skipSilence = dialog.findViewById(R.id.skipSilence);
|
||||
skipSilence.setChecked(UserPreferences.isSkipSilence());
|
||||
if (!UserPreferences.useExoplayer()) {
|
||||
@ -106,39 +92,6 @@ public class PlaybackControlsDialog extends DialogFragment {
|
||||
UserPreferences.setSkipSilence(isChecked);
|
||||
controller.setSkipSilence(isChecked);
|
||||
});
|
||||
|
||||
barLeftVolume.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
|
||||
@Override
|
||||
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
|
||||
controller.setVolume(
|
||||
Converter.getVolumeFromPercentage(progress),
|
||||
Converter.getVolumeFromPercentage(barRightVolume.getProgress()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStartTrackingTouch(SeekBar seekBar) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStopTrackingTouch(SeekBar seekBar) {
|
||||
}
|
||||
});
|
||||
barRightVolume.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
|
||||
@Override
|
||||
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
|
||||
controller.setVolume(
|
||||
Converter.getVolumeFromPercentage(barLeftVolume.getProgress()),
|
||||
Converter.getVolumeFromPercentage(progress));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStartTrackingTouch(SeekBar seekBar) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStopTrackingTouch(SeekBar seekBar) {
|
||||
}
|
||||
});
|
||||
stereoToMono.setOnCheckedChangeListener((buttonView, isChecked) -> {
|
||||
UserPreferences.stereoToMono(isChecked);
|
||||
if (controller != null) {
|
||||
|
@ -1,9 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<ScrollView
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:padding="16dp">
|
||||
|
||||
<LinearLayout
|
||||
@ -17,7 +17,7 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:visibility="gone"
|
||||
android:layout_marginBottom="8dp"/>
|
||||
android:layout_marginBottom="8dp" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
@ -27,9 +27,9 @@
|
||||
<TextView
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
style="@style/AntennaPod.TextView.ListItemPrimaryTitle"
|
||||
android:layout_weight="1"
|
||||
android:text="@string/playback_speed" />
|
||||
android:text="@string/playback_speed"
|
||||
style="@style/AntennaPod.TextView.ListItemPrimaryTitle" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/txtvPlaybackSpeed"
|
||||
@ -42,67 +42,14 @@
|
||||
<de.danoeh.antennapod.view.PlaybackSpeedSeekBar
|
||||
android:id="@+id/speed_seek_bar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"/>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="12dp"
|
||||
android:layout_marginBottom="4dp"
|
||||
style="@style/AntennaPod.TextView.ListItemPrimaryTitle"
|
||||
android:text="@string/volume" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="8dp"
|
||||
android:layout_marginStart="8dp"
|
||||
android:orientation="horizontal"
|
||||
android:gravity="center">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/txtvLeft"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/left_short" />
|
||||
|
||||
<SeekBar
|
||||
android:id="@+id/volume_left"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:max="100" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginLeft="8dp"
|
||||
android:layout_marginStart="8dp"
|
||||
android:orientation="horizontal"
|
||||
android:gravity="center">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/txtvRight"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/right_short" />
|
||||
|
||||
<SeekBar
|
||||
android:id="@+id/volume_right"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:max="100" />
|
||||
|
||||
</LinearLayout>
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="20dp"
|
||||
style="@style/AntennaPod.TextView.ListItemPrimaryTitle"
|
||||
android:text="@string/audio_effects" />
|
||||
android:text="@string/audio_effects"
|
||||
style="@style/AntennaPod.TextView.ListItemPrimaryTitle" />
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/skipSilence"
|
||||
@ -115,5 +62,7 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/stereo_to_mono" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</ScrollView>
|
||||
|
@ -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))
|
||||
|
@ -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...");
|
||||
|
@ -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;
|
||||
|
@ -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)));
|
||||
}
|
||||
}
|
||||
|
@ -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();
|
||||
|
@ -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>
|
||||
|
Loading…
x
Reference in New Issue
Block a user