summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorquails4Eva <dpetchey@gmail.com>2024-03-03 19:17:22 +0000
committerGitHub <noreply@github.com>2024-03-03 20:17:22 +0100
commit60f3d77eb2d41d49ad6fd999c39f5792f804a17e (patch)
tree63482639471c4a6c3592663477519af9fdcd6ec0 /app
parent3c77d43e76535465ef5c9976835d42439797fd8f (diff)
downloadAntennaPod-60f3d77eb2d41d49ad6fd999c39f5792f804a17e.zip
Skip silence setting per feed (#6910)
Diffstat (limited to 'app')
-rw-r--r--app/src/main/java/de/danoeh/antennapod/dialog/VariableSpeedDialog.java13
-rw-r--r--app/src/main/java/de/danoeh/antennapod/fragment/FeedSettingsFragment.java27
-rw-r--r--app/src/main/res/layout/playback_speed_feed_setting_dialog.xml6
3 files changed, 38 insertions, 8 deletions
diff --git a/app/src/main/java/de/danoeh/antennapod/dialog/VariableSpeedDialog.java b/app/src/main/java/de/danoeh/antennapod/dialog/VariableSpeedDialog.java
index 8de7dce04..c62f5df7e 100644
--- a/app/src/main/java/de/danoeh/antennapod/dialog/VariableSpeedDialog.java
+++ b/app/src/main/java/de/danoeh/antennapod/dialog/VariableSpeedDialog.java
@@ -37,6 +37,7 @@ public class VariableSpeedDialog extends BottomSheetDialogFragment {
private final List<Float> selectedSpeeds;
private PlaybackSpeedSeekBar speedSeekBar;
private Chip addCurrentSpeedChip;
+ private CheckBox skipSilenceCheckbox;
public VariableSpeedDialog() {
DecimalFormatSymbols format = new DecimalFormatSymbols(Locale.US);
@@ -51,11 +52,13 @@ public class VariableSpeedDialog extends BottomSheetDialogFragment {
@Override
public void loadMediaInfo() {
updateSpeed(new SpeedChangedEvent(controller.getCurrentPlaybackSpeedMultiplier()));
+ updateSkipSilence(controller.getCurrentPlaybackSkipSilence());
}
};
controller.init();
EventBus.getDefault().register(this);
updateSpeed(new SpeedChangedEvent(controller.getCurrentPlaybackSpeedMultiplier()));
+ updateSkipSilence(controller.getCurrentPlaybackSkipSilence());
}
@Override
@@ -72,6 +75,10 @@ public class VariableSpeedDialog extends BottomSheetDialogFragment {
addCurrentSpeedChip.setText(String.format(Locale.getDefault(), "%1$.2f", event.getNewSpeed()));
}
+ public void updateSkipSilence(boolean skipSilence) {
+ skipSilenceCheckbox.setChecked(skipSilence);
+ }
+
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
@@ -97,9 +104,9 @@ public class VariableSpeedDialog extends BottomSheetDialogFragment {
addCurrentSpeedChip.setCloseIconContentDescription(getString(R.string.add_preset));
addCurrentSpeedChip.setOnClickListener(v -> addCurrentSpeed());
- final CheckBox skipSilence = root.findViewById(R.id.skipSilence);
- skipSilence.setChecked(UserPreferences.isSkipSilence());
- skipSilence.setOnCheckedChangeListener((buttonView, isChecked) -> {
+ skipSilenceCheckbox = root.findViewById(R.id.skipSilence);
+ skipSilenceCheckbox.setChecked(UserPreferences.isSkipSilence());
+ skipSilenceCheckbox.setOnCheckedChangeListener((buttonView, isChecked) -> {
UserPreferences.setSkipSilence(isChecked);
controller.setSkipSilence(isChecked);
});
diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/FeedSettingsFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/FeedSettingsFragment.java
index c42134165..4626c061f 100644
--- a/app/src/main/java/de/danoeh/antennapod/fragment/FeedSettingsFragment.java
+++ b/app/src/main/java/de/danoeh/antennapod/fragment/FeedSettingsFragment.java
@@ -241,14 +241,21 @@ public class FeedSettingsFragment extends Fragment {
PlaybackSpeedFeedSettingDialogBinding.inflate(getLayoutInflater());
viewBinding.seekBar.setProgressChangedListener(speed ->
viewBinding.currentSpeedLabel.setText(String.format(Locale.getDefault(), "%.2fx", speed)));
- float speed = feedPreferences.getFeedPlaybackSpeed();
viewBinding.useGlobalCheckbox.setOnCheckedChangeListener((buttonView, isChecked) -> {
viewBinding.seekBar.setEnabled(!isChecked);
viewBinding.seekBar.setAlpha(isChecked ? 0.4f : 1f);
viewBinding.currentSpeedLabel.setAlpha(isChecked ? 0.4f : 1f);
+
+ viewBinding.skipSilenceFeed.setEnabled(!isChecked);
+ viewBinding.skipSilenceFeed.setAlpha(isChecked ? 0.4f : 1f);
});
- viewBinding.useGlobalCheckbox.setChecked(speed == FeedPreferences.SPEED_USE_GLOBAL);
- viewBinding.seekBar.updateSpeed(speed == FeedPreferences.SPEED_USE_GLOBAL ? 1 : speed);
+ float speed = feedPreferences.getFeedPlaybackSpeed();
+ FeedPreferences.SkipSilence skipSilence = feedPreferences.getFeedSkipSilence();
+ boolean isGlobal = speed == FeedPreferences.SPEED_USE_GLOBAL;
+ viewBinding.useGlobalCheckbox.setChecked(isGlobal);
+ viewBinding.seekBar.updateSpeed(isGlobal ? 1 : speed);
+ viewBinding.skipSilenceFeed.setChecked(!isGlobal
+ && skipSilence == FeedPreferences.SkipSilence.AGGRESSIVE);
new MaterialAlertDialogBuilder(getContext())
.setTitle(R.string.playback_speed)
.setView(viewBinding.getRoot())
@@ -256,9 +263,19 @@ public class FeedSettingsFragment extends Fragment {
float newSpeed = viewBinding.useGlobalCheckbox.isChecked()
? FeedPreferences.SPEED_USE_GLOBAL : viewBinding.seekBar.getCurrentSpeed();
feedPreferences.setFeedPlaybackSpeed(newSpeed);
+ FeedPreferences.SkipSilence newSkipSilence;
+ if (viewBinding.useGlobalCheckbox.isChecked()) {
+ newSkipSilence = FeedPreferences.SkipSilence.GLOBAL;
+ } else if (viewBinding.skipSilenceFeed.isChecked()) {
+ newSkipSilence = FeedPreferences.SkipSilence.AGGRESSIVE;
+ } else {
+ newSkipSilence = FeedPreferences.SkipSilence.OFF;
+ }
+ feedPreferences.setFeedSkipSilence(newSkipSilence);
DBWriter.setFeedPreferences(feedPreferences);
- EventBus.getDefault().post(
- new SpeedPresetChangedEvent(feedPreferences.getFeedPlaybackSpeed(), feed.getId()));
+ EventBus.getDefault().post(new SpeedPresetChangedEvent(
+ feedPreferences.getFeedPlaybackSpeed(),
+ feed.getId(), feedPreferences.getFeedSkipSilence()));
})
.setNegativeButton(R.string.cancel_label, null)
.show();
diff --git a/app/src/main/res/layout/playback_speed_feed_setting_dialog.xml b/app/src/main/res/layout/playback_speed_feed_setting_dialog.xml
index 48d69e4a9..50eb4f84f 100644
--- a/app/src/main/res/layout/playback_speed_feed_setting_dialog.xml
+++ b/app/src/main/res/layout/playback_speed_feed_setting_dialog.xml
@@ -34,4 +34,10 @@
</LinearLayout>
+ <CheckBox
+ android:id="@+id/skipSilenceFeed"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:text="@string/pref_skip_silence_title" />
+
</LinearLayout>