Skip silence setting per feed (#6910)

This commit is contained in:
quails4Eva 2024-03-03 19:17:22 +00:00 committed by GitHub
parent 3c77d43e76
commit 60f3d77eb2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
16 changed files with 198 additions and 21 deletions

View File

@ -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);
});

View File

@ -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();

View File

@ -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>

View File

@ -4,6 +4,7 @@ import android.util.Log;
import de.danoeh.antennapod.model.feed.Feed;
import de.danoeh.antennapod.model.feed.FeedItem;
import de.danoeh.antennapod.model.feed.FeedMedia;
import de.danoeh.antennapod.model.feed.FeedPreferences;
import de.danoeh.antennapod.model.playback.MediaType;
import de.danoeh.antennapod.core.preferences.PlaybackPreferences;
import de.danoeh.antennapod.storage.preferences.UserPreferences;
@ -50,4 +51,25 @@ public final class PlaybackSpeedUtils {
return playbackSpeed;
}
/**
* Returns the currently configured skip silence for the specified media.
*/
public static FeedPreferences.SkipSilence getCurrentSkipSilencePreference(Playable media) {
FeedPreferences.SkipSilence skipSilence = FeedPreferences.SkipSilence.GLOBAL;
if (media != null) {
skipSilence = PlaybackPreferences.getCurrentlyPlayingTemporarySkipSilence();
if (skipSilence == FeedPreferences.SkipSilence.GLOBAL && media instanceof FeedMedia) {
FeedItem item = ((FeedMedia) media).getItem();
if (item != null && item.getFeed() != null && item.getFeed().getPreferences() != null) {
skipSilence = item.getFeed().getPreferences().getFeedSkipSilence();
}
}
}
if (skipSilence == FeedPreferences.SkipSilence.GLOBAL) {
skipSilence = UserPreferences.isSkipSilence()
? FeedPreferences.SkipSilence.AGGRESSIVE : FeedPreferences.SkipSilence.OFF;
}
return skipSilence;
}
}

View File

@ -10,6 +10,7 @@ import android.util.Log;
import de.danoeh.antennapod.core.storage.DBReader;
import de.danoeh.antennapod.event.PlayerStatusEvent;
import de.danoeh.antennapod.model.feed.FeedMedia;
import de.danoeh.antennapod.model.feed.FeedPreferences;
import de.danoeh.antennapod.model.playback.MediaType;
import de.danoeh.antennapod.model.playback.Playable;
import de.danoeh.antennapod.playback.base.PlayerStatus;
@ -64,6 +65,12 @@ public class PlaybackPreferences implements SharedPreferences.OnSharedPreference
private static final String PREF_CURRENTLY_PLAYING_TEMPORARY_PLAYBACK_SPEED
= "de.danoeh.antennapod.preferences.temporaryPlaybackSpeed";
/**
* A temporary skip silence preference which overrides the per-feed skip silence for the currently playing
* media. Considered unset if set to null;
*/
private static final String PREF_CURRENTLY_PLAYING_TEMPORARY_SKIP_SILENCE
= "de.danoeh.antennapod.preferences.temporarySkipSilence";
/**
* Value of PREF_CURRENTLY_PLAYING_MEDIA if no media is playing.
@ -123,6 +130,11 @@ public class PlaybackPreferences implements SharedPreferences.OnSharedPreference
return prefs.getFloat(PREF_CURRENTLY_PLAYING_TEMPORARY_PLAYBACK_SPEED, SPEED_USE_GLOBAL);
}
public static FeedPreferences.SkipSilence getCurrentlyPlayingTemporarySkipSilence() {
return FeedPreferences.SkipSilence.fromCode(prefs.getInt(
PREF_CURRENTLY_PLAYING_TEMPORARY_SKIP_SILENCE, FeedPreferences.SkipSilence.GLOBAL.code));
}
public static void writeNoMediaPlaying() {
SharedPreferences.Editor editor = prefs.edit();
editor.putLong(PREF_CURRENTLY_PLAYING_MEDIA_TYPE, NO_MEDIA_PLAYING);
@ -170,9 +182,17 @@ public class PlaybackPreferences implements SharedPreferences.OnSharedPreference
editor.apply();
}
public static void clearCurrentlyPlayingTemporaryPlaybackSpeed() {
public static void setCurrentlyPlayingTemporarySkipSilence(boolean skipSilence) {
SharedPreferences.Editor editor = prefs.edit();
editor.putInt(PREF_CURRENTLY_PLAYING_TEMPORARY_SKIP_SILENCE, skipSilence
? FeedPreferences.SkipSilence.AGGRESSIVE.code : FeedPreferences.SkipSilence.OFF.code);
editor.apply();
}
public static void clearCurrentlyPlayingTemporaryPlaybackSettings() {
SharedPreferences.Editor editor = prefs.edit();
editor.remove(PREF_CURRENTLY_PLAYING_TEMPORARY_PLAYBACK_SPEED);
editor.remove(PREF_CURRENTLY_PLAYING_TEMPORARY_SKIP_SILENCE);
editor.apply();
}

View File

@ -166,6 +166,10 @@ public class ExoPlayerWrapper {
return playbackParameters.speed;
}
public boolean getCurrentSkipSilence() {
return exoPlayer.getSkipSilenceEnabled();
}
public int getDuration() {
if (exoPlayer.getDuration() == C.TIME_UNSET) {
return Playable.INVALID_TIME;

View File

@ -161,7 +161,9 @@ public class LocalPSMP extends PlaybackServiceMediaPlayer {
try {
callback.ensureMediaInfoLoaded(media);
callback.onMediaChanged(false);
setPlaybackParams(PlaybackSpeedUtils.getCurrentPlaybackSpeed(media), UserPreferences.isSkipSilence());
setPlaybackParams(PlaybackSpeedUtils.getCurrentPlaybackSpeed(media),
PlaybackSpeedUtils.getCurrentSkipSilencePreference(media)
== FeedPreferences.SkipSilence.AGGRESSIVE);
if (stream) {
if (playable instanceof FeedMedia) {
FeedMedia feedMedia = (FeedMedia) playable;
@ -212,7 +214,9 @@ public class LocalPSMP extends PlaybackServiceMediaPlayer {
Log.d(TAG, "Resuming/Starting playback");
acquireWifiLockIfNecessary();
setPlaybackParams(PlaybackSpeedUtils.getCurrentPlaybackSpeed(media), UserPreferences.isSkipSilence());
setPlaybackParams(PlaybackSpeedUtils.getCurrentPlaybackSpeed(media),
PlaybackSpeedUtils.getCurrentSkipSilencePreference(media)
== FeedPreferences.SkipSilence.AGGRESSIVE);
setVolume(1.0f, 1.0f);
if (playerStatus == PlayerStatus.PREPARED && media.getPosition() > 0) {
@ -461,6 +465,18 @@ public class LocalPSMP extends PlaybackServiceMediaPlayer {
return retVal;
}
@Override
public boolean getSkipSilence() {
boolean retVal = false;
if ((playerStatus == PlayerStatus.PLAYING
|| playerStatus == PlayerStatus.PAUSED
|| playerStatus == PlayerStatus.INITIALIZED
|| playerStatus == PlayerStatus.PREPARED)) {
retVal = mediaPlayer.getCurrentSkipSilence();
}
return retVal;
}
/**
* Sets the playback volume.
* This method is executed on an internal executor service.

View File

@ -750,7 +750,7 @@ public class PlaybackService extends MediaBrowserServiceCompat {
}
if (!playable.getIdentifier().equals(PlaybackPreferences.getCurrentlyPlayingFeedMediaId())) {
PlaybackPreferences.clearCurrentlyPlayingTemporaryPlaybackSpeed();
PlaybackPreferences.clearCurrentlyPlayingTemporaryPlaybackSettings();
}
mediaPlayer.playMediaObject(playable, stream, true, true);
@ -1047,7 +1047,7 @@ public class PlaybackService extends MediaBrowserServiceCompat {
*/
private void onPlaybackEnded(MediaType mediaType, boolean stopPlaying) {
Log.d(TAG, "Playback ended");
PlaybackPreferences.clearCurrentlyPlayingTemporaryPlaybackSpeed();
PlaybackPreferences.clearCurrentlyPlayingTemporaryPlaybackSettings();
if (stopPlaying) {
taskManager.cancelPositionSaver();
cancelPositionObserver();
@ -1604,8 +1604,15 @@ public class PlaybackService extends MediaBrowserServiceCompat {
if (((FeedMedia) getPlayable()).getItem().getFeed().getId() == event.getFeedId()) {
if (event.getSpeed() == SPEED_USE_GLOBAL) {
setSpeed(UserPreferences.getPlaybackSpeed(getPlayable().getMediaType()));
setSkipSilence(UserPreferences.isSkipSilence());
} else {
setSpeed(event.getSpeed());
FeedPreferences.SkipSilence skipSilence = event.getSkipSilence();
if (skipSilence == FeedPreferences.SkipSilence.GLOBAL) {
setSkipSilence(UserPreferences.isSkipSilence());
} else {
setSkipSilence(skipSilence == FeedPreferences.SkipSilence.AGGRESSIVE);
}
}
}
}
@ -1669,20 +1676,29 @@ public class PlaybackService extends MediaBrowserServiceCompat {
UserPreferences.setPlaybackSpeed(speed);
}
mediaPlayer.setPlaybackParams(speed, UserPreferences.isSkipSilence());
mediaPlayer.setPlaybackParams(speed, getCurrentSkipSilence());
}
public void skipSilence(boolean skipSilence) {
public void setSkipSilence(boolean skipSilence) {
PlaybackPreferences.setCurrentlyPlayingTemporarySkipSilence(skipSilence);
UserPreferences.setSkipSilence(skipSilence);
mediaPlayer.setPlaybackParams(getCurrentPlaybackSpeed(), skipSilence);
}
public float getCurrentPlaybackSpeed() {
if(mediaPlayer == null) {
if (mediaPlayer == null) {
return 1.0f;
}
return mediaPlayer.getPlaybackSpeed();
}
public boolean getCurrentSkipSilence() {
if (mediaPlayer == null) {
return false;
}
return mediaPlayer.getSkipSilence();
}
public boolean isStartWhenPrepared() {
return mediaPlayer.isStartWhenPrepared();
}

View File

@ -18,6 +18,7 @@ import de.danoeh.antennapod.event.playback.PlaybackPositionEvent;
import de.danoeh.antennapod.model.feed.FeedMedia;
import de.danoeh.antennapod.event.playback.PlaybackServiceEvent;
import de.danoeh.antennapod.event.playback.SpeedChangedEvent;
import de.danoeh.antennapod.model.feed.FeedPreferences;
import de.danoeh.antennapod.model.playback.MediaType;
import de.danoeh.antennapod.core.feed.util.PlaybackSpeedUtils;
import de.danoeh.antennapod.core.preferences.PlaybackPreferences;
@ -407,7 +408,7 @@ public abstract class PlaybackController {
public void setSkipSilence(boolean skipSilence) {
if (playbackService != null) {
playbackService.skipSilence(skipSilence);
playbackService.setSkipSilence(skipSilence);
}
}
@ -419,6 +420,15 @@ public abstract class PlaybackController {
}
}
public boolean getCurrentPlaybackSkipSilence() {
if (playbackService != null) {
return playbackService.getCurrentSkipSilence();
} else {
return PlaybackSpeedUtils.getCurrentSkipSilencePreference(getMedia())
== FeedPreferences.SkipSilence.AGGRESSIVE;
}
}
public List<String> getAudioTracks() {
if (playbackService == null) {
return Collections.emptyList();

View File

@ -1,18 +1,26 @@
package de.danoeh.antennapod.event.settings;
import de.danoeh.antennapod.model.feed.FeedPreferences;
public class SpeedPresetChangedEvent {
private final float speed;
private final FeedPreferences.SkipSilence skipSilence;
private final long feedId;
public SpeedPresetChangedEvent(float speed, long feedId) {
public SpeedPresetChangedEvent(float speed, long feedId, FeedPreferences.SkipSilence skipSilence) {
this.speed = speed;
this.feedId = feedId;
this.skipSilence = skipSilence;
}
public float getSpeed() {
return speed;
}
public FeedPreferences.SkipSilence getSkipSilence() {
return skipSilence;
}
public long getFeedId() {
return feedId;
}

View File

@ -59,6 +59,25 @@ public class FeedPreferences implements Serializable {
}
}
public enum SkipSilence {
OFF(0), GLOBAL(1), AGGRESSIVE(2);
public final int code;
SkipSilence(int code) {
this.code = code;
}
public static SkipSilence fromCode(int code) {
for (SkipSilence s : values()) {
if (s.code == code) {
return s;
}
}
return GLOBAL;
}
}
@NonNull
private FeedFilter filter;
private long feedID;
@ -72,6 +91,7 @@ public class FeedPreferences implements Serializable {
private float feedPlaybackSpeed;
private int feedSkipIntro;
private int feedSkipEnding;
private SkipSilence feedSkipSilence;
private boolean showEpisodeNotification;
private final Set<String> tags = new HashSet<>();
@ -79,13 +99,14 @@ public class FeedPreferences implements Serializable {
VolumeAdaptionSetting volumeAdaptionSetting, NewEpisodesAction newEpisodesAction,
String username, String password) {
this(feedID, autoDownload, true, autoDeleteAction, volumeAdaptionSetting, username, password,
new FeedFilter(), SPEED_USE_GLOBAL, 0, 0, false, newEpisodesAction, new HashSet<>());
new FeedFilter(), SPEED_USE_GLOBAL, 0, 0, SkipSilence.GLOBAL,
false, newEpisodesAction, new HashSet<>());
}
public FeedPreferences(long feedID, boolean autoDownload, boolean keepUpdated,
AutoDeleteAction autoDeleteAction, VolumeAdaptionSetting volumeAdaptionSetting,
String username, String password, @NonNull FeedFilter filter,
float feedPlaybackSpeed, int feedSkipIntro, int feedSkipEnding,
float feedPlaybackSpeed, int feedSkipIntro, int feedSkipEnding, SkipSilence feedSkipSilence,
boolean showEpisodeNotification, NewEpisodesAction newEpisodesAction,
Set<String> tags) {
this.feedID = feedID;
@ -99,6 +120,7 @@ public class FeedPreferences implements Serializable {
this.feedPlaybackSpeed = feedPlaybackSpeed;
this.feedSkipIntro = feedSkipIntro;
this.feedSkipEnding = feedSkipEnding;
this.feedSkipSilence = feedSkipSilence;
this.showEpisodeNotification = showEpisodeNotification;
this.newEpisodesAction = newEpisodesAction;
this.tags.addAll(tags);
@ -241,6 +263,14 @@ public class FeedPreferences implements Serializable {
return feedSkipEnding;
}
public void setFeedSkipSilence(SkipSilence skipSilence) {
feedSkipSilence = skipSilence;
}
public SkipSilence getFeedSkipSilence() {
return feedSkipSilence;
}
public Set<String> getTags() {
return tags;
}

View File

@ -151,6 +151,8 @@ public abstract class PlaybackServiceMediaPlayer {
*/
public abstract float getPlaybackSpeed();
public abstract boolean getSkipSilence();
/**
* Sets the playback volume.
* This method is executed on an internal executor service.

View File

@ -427,6 +427,12 @@ public class CastPsmp extends PlaybackServiceMediaPlayer {
return status != null ? (float) status.getPlaybackRate() : 1.0f;
}
@Override
public boolean getSkipSilence() {
// Don't think this is supported
return false;
}
@Override
public void setVolume(float volumeLeft, float volumeRight) {
Log.d(TAG, "Setting the Stream volume on Remote Media Player");

View File

@ -334,6 +334,10 @@ class DBUpgrader {
db.execSQL("ALTER TABLE " + PodDBAdapter.TABLE_NAME_FEEDS
+ " ADD COLUMN " + PodDBAdapter.KEY_NEW_EPISODES_ACTION + " INTEGER DEFAULT 0");
}
if (oldVersion < 3040000) {
db.execSQL("ALTER TABLE " + PodDBAdapter.TABLE_NAME_FEEDS
+ " ADD COLUMN " + PodDBAdapter.KEY_FEED_SKIP_SILENCE + " INTEGER");
}
}
}

View File

@ -52,7 +52,7 @@ public class PodDBAdapter {
private static final String TAG = "PodDBAdapter";
public static final String DATABASE_NAME = "Antennapod.db";
public static final int VERSION = 3010000;
public static final int VERSION = 3040000;
/**
* Maximum number of arguments for IN-operator.
@ -113,6 +113,7 @@ public class PodDBAdapter {
public static final String KEY_EXCLUDE_FILTER = "exclude_filter";
public static final String KEY_MINIMAL_DURATION_FILTER = "minimal_duration_filter";
public static final String KEY_FEED_PLAYBACK_SPEED = "feed_playback_speed";
public static final String KEY_FEED_SKIP_SILENCE = "feed_skip_silence";
public static final String KEY_FEED_SKIP_INTRO = "feed_skip_intro";
public static final String KEY_FEED_SKIP_ENDING = "feed_skip_ending";
public static final String KEY_FEED_TAGS = "tags";
@ -155,6 +156,7 @@ public class PodDBAdapter {
+ KEY_LAST_UPDATE_FAILED + " INTEGER DEFAULT 0,"
+ KEY_AUTO_DELETE_ACTION + " INTEGER DEFAULT 0,"
+ KEY_FEED_PLAYBACK_SPEED + " REAL DEFAULT " + SPEED_USE_GLOBAL + ","
+ KEY_FEED_SKIP_SILENCE + " INTEGER DEFAULT " + FeedPreferences.SkipSilence.GLOBAL.code + ","
+ KEY_FEED_VOLUME_ADAPTION + " INTEGER DEFAULT 0,"
+ KEY_FEED_TAGS + " TEXT,"
+ KEY_FEED_SKIP_INTRO + " INTEGER DEFAULT 0,"
@ -307,6 +309,7 @@ public class PodDBAdapter {
+ TABLE_NAME_FEEDS + "." + KEY_EXCLUDE_FILTER + ", "
+ TABLE_NAME_FEEDS + "." + KEY_MINIMAL_DURATION_FILTER + ", "
+ TABLE_NAME_FEEDS + "." + KEY_FEED_PLAYBACK_SPEED + ", "
+ TABLE_NAME_FEEDS + "." + KEY_FEED_SKIP_SILENCE + ", "
+ TABLE_NAME_FEEDS + "." + KEY_FEED_TAGS + ", "
+ TABLE_NAME_FEEDS + "." + KEY_FEED_SKIP_INTRO + ", "
+ TABLE_NAME_FEEDS + "." + KEY_FEED_SKIP_ENDING + ", "
@ -456,6 +459,7 @@ public class PodDBAdapter {
values.put(KEY_EXCLUDE_FILTER, prefs.getFilter().getExcludeFilterRaw());
values.put(KEY_MINIMAL_DURATION_FILTER, prefs.getFilter().getMinimalDurationFilter());
values.put(KEY_FEED_PLAYBACK_SPEED, prefs.getFeedPlaybackSpeed());
values.put(KEY_FEED_SKIP_SILENCE, prefs.getFeedSkipSilence().code);
values.put(KEY_FEED_TAGS, prefs.getTagsAsString());
values.put(KEY_FEED_SKIP_INTRO, prefs.getFeedSkipIntro());
values.put(KEY_FEED_SKIP_ENDING, prefs.getFeedSkipEnding());

View File

@ -31,6 +31,7 @@ public abstract class FeedPreferencesCursorMapper {
int indexExcludeFilter = cursor.getColumnIndexOrThrow(PodDBAdapter.KEY_EXCLUDE_FILTER);
int indexMinimalDurationFilter = cursor.getColumnIndexOrThrow(PodDBAdapter.KEY_MINIMAL_DURATION_FILTER);
int indexFeedPlaybackSpeed = cursor.getColumnIndexOrThrow(PodDBAdapter.KEY_FEED_PLAYBACK_SPEED);
int indexFeedSkipSilence = cursor.getColumnIndexOrThrow(PodDBAdapter.KEY_FEED_SKIP_SILENCE);
int indexAutoSkipIntro = cursor.getColumnIndexOrThrow(PodDBAdapter.KEY_FEED_SKIP_INTRO);
int indexAutoSkipEnding = cursor.getColumnIndexOrThrow(PodDBAdapter.KEY_FEED_SKIP_ENDING);
int indexEpisodeNotification = cursor.getColumnIndexOrThrow(PodDBAdapter.KEY_EPISODE_NOTIFICATION);
@ -52,6 +53,8 @@ public abstract class FeedPreferencesCursorMapper {
float feedPlaybackSpeed = cursor.getFloat(indexFeedPlaybackSpeed);
int feedAutoSkipIntro = cursor.getInt(indexAutoSkipIntro);
int feedAutoSkipEnding = cursor.getInt(indexAutoSkipEnding);
FeedPreferences.SkipSilence feedSkipSilence =
FeedPreferences.SkipSilence.fromCode(cursor.getInt(indexFeedSkipSilence));
FeedPreferences.NewEpisodesAction feedNewEpisodesAction =
FeedPreferences.NewEpisodesAction.fromCode(cursor.getInt(indexNewEpisodesAction));
boolean showNotification = cursor.getInt(indexEpisodeNotification) > 0;
@ -59,6 +62,7 @@ public abstract class FeedPreferencesCursorMapper {
if (TextUtils.isEmpty(tagsString)) {
tagsString = FeedPreferences.TAG_ROOT;
}
return new FeedPreferences(feedId,
autoDownload,
autoRefresh,
@ -70,6 +74,7 @@ public abstract class FeedPreferencesCursorMapper {
feedPlaybackSpeed,
feedAutoSkipIntro,
feedAutoSkipEnding,
feedSkipSilence,
showNotification,
feedNewEpisodesAction,
new HashSet<>(Arrays.asList(tagsString.split(FeedPreferences.TAG_SEPARATOR))));