Make seek time configurable

A 30-second seek time is way to long for me.  Make the seek duration a
configurable preference.
This commit is contained in:
David Reiss 2014-06-07 14:13:07 -07:00
parent a78c5173dc
commit 500483ba69
6 changed files with 36 additions and 6 deletions

View File

@ -1,6 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string-array name="seek_delta_values">
<item>5</item>
<item>10</item>
<item>15</item>
<item>20</item>
<item>30</item>
<item>45</item>
<item>60</item>
</string-array>
<string-array name="update_intervall_options">
<item>Manual</item>
<item>1 hour</item>

View File

@ -243,6 +243,8 @@
<string name="pref_gpodnet_setlogin_information_sum">Change the login information for your gpodder.net account.</string>
<string name="pref_playback_speed_title">Playback Speeds</string>
<string name="pref_playback_speed_sum">Customize the speeds available for variable speed audio playback</string>
<string name="pref_seek_delta_title">Seek Time</string>
<string name="pref_seek_delta_sum">Seek this many seconds when rewinding or fast-forwarding</string>
<string name="pref_gpodnet_sethostname_title">Set hostname</string>
<string name="pref_gpodnet_sethostname_use_default_host">Use default host</string>

View File

@ -34,6 +34,15 @@
android:key="prefPauseForFocusLoss"
android:summary="@string/pref_pausePlaybackForFocusLoss_sum"
android:title="@string/pref_pausePlaybackForFocusLoss_title" />
<ListPreference
android:defaultValue="30"
android:entries="@array/seek_delta_values"
android:entryValues="@array/seek_delta_values"
android:key="prefSeekDeltaSecs"
android:summary="@string/pref_seek_delta_sum"
android:title="@string/pref_seek_delta_title" />
</PreferenceCategory>
<PreferenceCategory android:title="@string/network_pref">
<ListPreference

View File

@ -48,6 +48,7 @@ public class UserPreferences implements
private static final String PREF_PLAYBACK_SPEED = "prefPlaybackSpeed";
private static final String PREF_PLAYBACK_SPEED_ARRAY = "prefPlaybackSpeedArray";
public static final String PREF_PAUSE_PLAYBACK_FOR_FOCUS_LOSS = "prefPauseForFocusLoss";
private static final String PREF_SEEK_DELTA_SECS = "prefSeekDeltaSecs";
// TODO: Make this value configurable
private static final double PLAYED_DURATION_AUTOFLATTR_THRESHOLD = 0.8;
@ -74,6 +75,7 @@ public class UserPreferences implements
private String playbackSpeed;
private String[] playbackSpeedArray;
private boolean pauseForFocusLoss;
private int seekDeltaSecs;
private boolean isFreshInstall;
private UserPreferences(Context context) {
@ -129,6 +131,7 @@ public class UserPreferences implements
playbackSpeedArray = readPlaybackSpeedArray(sp.getString(
PREF_PLAYBACK_SPEED_ARRAY, null));
pauseForFocusLoss = sp.getBoolean(PREF_PAUSE_PLAYBACK_FOR_FOCUS_LOSS, false);
seekDeltaSecs = Integer.valueOf(sp.getString(PREF_SEEK_DELTA_SECS, "30"));
}
private int readThemeValue(String valueFromPrefs) {
@ -263,6 +266,11 @@ public class UserPreferences implements
return instance.playbackSpeedArray;
}
public static int getSeekDeltaMs() {
instanceAvailable();
return 1000 * instance.seekDeltaSecs;
}
/**
* Returns the capacity of the episode cache. This method will return the
* negative integer EPISODE_CACHE_SIZE_UNLIMITED if the cache size is set to
@ -336,6 +344,8 @@ public class UserPreferences implements
PREF_PLAYBACK_SPEED_ARRAY, null));
} else if (key.equals(PREF_PAUSE_PLAYBACK_FOR_FOCUS_LOSS)) {
pauseForFocusLoss = sp.getBoolean(PREF_PAUSE_PLAYBACK_FOR_FOCUS_LOSS, false);
} else if (key.equals(PREF_SEEK_DELTA_SECS)) {
seekDeltaSecs = Integer.valueOf(sp.getString(PREF_SEEK_DELTA_SECS, "30"));
} else if (key.equals(PREF_PAUSE_ON_HEADSET_DISCONNECT)) {
pauseOnHeadsetDisconnect = sp.getBoolean(PREF_PAUSE_ON_HEADSET_DISCONNECT, true);
}

View File

@ -42,7 +42,6 @@ import de.danoeh.antennapod.util.BitmapDecoder;
import de.danoeh.antennapod.util.QueueAccess;
import de.danoeh.antennapod.util.flattr.FlattrUtils;
import de.danoeh.antennapod.util.playback.Playable;
import de.danoeh.antennapod.util.playback.PlaybackController;
import java.util.List;
@ -313,11 +312,11 @@ public class PlaybackService extends Service {
break;
case KeyEvent.KEYCODE_MEDIA_NEXT:
case KeyEvent.KEYCODE_MEDIA_FAST_FORWARD:
mediaPlayer.seekDelta(PlaybackController.DEFAULT_SEEK_DELTA);
mediaPlayer.seekDelta(UserPreferences.getSeekDeltaMs());
break;
case KeyEvent.KEYCODE_MEDIA_PREVIOUS:
case KeyEvent.KEYCODE_MEDIA_REWIND:
mediaPlayer.seekDelta(-PlaybackController.DEFAULT_SEEK_DELTA);
mediaPlayer.seekDelta(-UserPreferences.getSeekDeltaMs());
break;
default:
String message = String.format(getResources().getString(R.string.unknown_media_key), keycode);

View File

@ -21,6 +21,7 @@ import de.danoeh.antennapod.feed.Chapter;
import de.danoeh.antennapod.feed.FeedMedia;
import de.danoeh.antennapod.feed.MediaType;
import de.danoeh.antennapod.preferences.PlaybackPreferences;
import de.danoeh.antennapod.preferences.UserPreferences;
import de.danoeh.antennapod.service.playback.PlaybackService;
import de.danoeh.antennapod.service.playback.PlaybackServiceMediaPlayer;
import de.danoeh.antennapod.service.playback.PlayerStatus;
@ -37,7 +38,6 @@ import java.util.concurrent.*;
public abstract class PlaybackController {
private static final String TAG = "PlaybackController";
public static final int DEFAULT_SEEK_DELTA = 30000;
public static final int INVALID_TIME = -1;
private final Activity activity;
@ -605,7 +605,7 @@ public abstract class PlaybackController {
@Override
public void onClick(View v) {
if (status == PlayerStatus.PLAYING) {
playbackService.seekDelta(-DEFAULT_SEEK_DELTA);
playbackService.seekDelta(-UserPreferences.getSeekDeltaMs());
}
}
};
@ -616,7 +616,7 @@ public abstract class PlaybackController {
@Override
public void onClick(View v) {
if (status == PlayerStatus.PLAYING) {
playbackService.seekDelta(DEFAULT_SEEK_DELTA);
playbackService.seekDelta(UserPreferences.getSeekDeltaMs());
}
}
};