summaryrefslogtreecommitdiff
path: root/src/de/danoeh/antennapod/activity
diff options
context:
space:
mode:
authordaniel oeh <daniel.oeh@gmail.com>2013-08-16 21:22:35 +0200
committerdaniel oeh <daniel.oeh@gmail.com>2013-08-16 21:22:35 +0200
commit8337739ab44af3c52b30f194fa06c09ba30a2dc2 (patch)
tree2012519a90e76040d8bd0da00adc4b889a46f30b /src/de/danoeh/antennapod/activity
parentf6c5251b98b5ae1bc31a1d1940530174588c3e27 (diff)
parent0a607117d6c8d26d48adede0c903e0b7772a4327 (diff)
downloadAntennaPod-8337739ab44af3c52b30f194fa06c09ba30a2dc2.zip
Merge branch 'playback-speed' of git://github.com/TheRealFalcon/AntennaPod into playback-speed-tmp
Conflicts: src/de/danoeh/antennapod/activity/AudioplayerActivity.java src/de/danoeh/antennapod/activity/PreferenceActivity.java src/de/danoeh/antennapod/service/PlaybackService.java src/de/danoeh/antennapod/util/playback/PlaybackController.java
Diffstat (limited to 'src/de/danoeh/antennapod/activity')
-rw-r--r--src/de/danoeh/antennapod/activity/AudioplayerActivity.java69
-rw-r--r--src/de/danoeh/antennapod/activity/PreferenceActivity.java12
2 files changed, 55 insertions, 26 deletions
diff --git a/src/de/danoeh/antennapod/activity/AudioplayerActivity.java b/src/de/danoeh/antennapod/activity/AudioplayerActivity.java
index cf82d936d..db4373036 100644
--- a/src/de/danoeh/antennapod/activity/AudioplayerActivity.java
+++ b/src/de/danoeh/antennapod/activity/AudioplayerActivity.java
@@ -12,6 +12,7 @@ import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
+import android.view.View.OnLongClickListener;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.ImageButton;
@@ -23,11 +24,14 @@ import de.danoeh.antennapod.AppConfig;
import de.danoeh.antennapod.R;
import de.danoeh.antennapod.adapter.ChapterListAdapter;
import de.danoeh.antennapod.asynctask.ImageLoader;
+import de.danoeh.antennapod.dialog.VariableSpeedDialog;
import de.danoeh.antennapod.feed.Chapter;
import de.danoeh.antennapod.feed.MediaType;
import de.danoeh.antennapod.feed.SimpleChapter;
import de.danoeh.antennapod.fragment.CoverFragment;
import de.danoeh.antennapod.fragment.ItemDescriptionFragment;
+import de.danoeh.antennapod.preferences.UserPreferences;
+import de.danoeh.antennapod.preferences.UserPreferences;
import de.danoeh.antennapod.service.PlaybackService;
import de.danoeh.antennapod.util.playback.ExternalMedia;
import de.danoeh.antennapod.util.playback.Playable;
@@ -396,29 +400,46 @@ public class AudioplayerActivity extends MediaplayerActivity {
butPlaybackSpeed.setOnClickListener(new OnClickListener() {
- @Override
- public void onClick(View v) {
- final double PLAYBACK_SPEED_STEP = 0.5;
- final double PLAYBACK_SPEED_MAX = 2.0;
- final double PLAYBACK_SPEED_DEFAULT = 1.0;
-
- if (controller != null && controller.canSetPlaybackSpeed()) {
- double currentPlaybackSpeed = controller
- .getCurrentPlaybackSpeedMultiplier();
- if (currentPlaybackSpeed != -1) {
- if (currentPlaybackSpeed >= PLAYBACK_SPEED_MAX) {
- controller.setPlaybackSpeed(PLAYBACK_SPEED_DEFAULT);
- } else {
- controller.setPlaybackSpeed(currentPlaybackSpeed
- + PLAYBACK_SPEED_STEP);
+ @Override
+ public void onClick(View v) {
+ if (controller != null && controller.canSetPlaybackSpeed()) {
+ String[] availableSpeeds = UserPreferences
+ .getPlaybackSpeedArray();
+ String currentSpeed = UserPreferences.getPlaybackSpeed();
+
+ // Provide initial value in case the speed list has changed
+ // out from under us
+ // and our current speed isn't in the new list
+ String newSpeed;
+ if (availableSpeeds.length > 0) {
+ newSpeed = availableSpeeds[0];
+ } else {
+ newSpeed = "1.0";
+ }
+
+ for (int i = 0; i < availableSpeeds.length; i++) {
+ if (availableSpeeds[i].equals(currentSpeed)) {
+ if (i == availableSpeeds.length - 1) {
+ newSpeed = availableSpeeds[0];
+ } else {
+ newSpeed = availableSpeeds[i + 1];
+ }
+ break;
}
- } else {
- controller.setPlaybackSpeed(PLAYBACK_SPEED_DEFAULT);
}
-
- }
- }
- });
+ UserPreferences.setPlaybackSpeed(newSpeed);
+ controller.setPlaybackSpeed(Float.parseFloat(newSpeed));
+ }
+ }
+ });
+
+ butPlaybackSpeed.setOnLongClickListener(new OnLongClickListener() {
+ @Override
+ public boolean onLongClick(View v) {
+ VariableSpeedDialog.showDialog(AudioplayerActivity.this);
+ return true;
+ }
+ });
}
@Override
@@ -428,14 +449,12 @@ public class AudioplayerActivity extends MediaplayerActivity {
}
private void updateButPlaybackSpeed() {
- double playbackSpeed;
if (controller == null
- || (playbackSpeed = controller
- .getCurrentPlaybackSpeedMultiplier()) == -1) {
+ || (controller.getCurrentPlaybackSpeedMultiplier() == -1)) {
butPlaybackSpeed.setVisibility(View.GONE);
} else {
butPlaybackSpeed.setVisibility(View.VISIBLE);
- butPlaybackSpeed.setText(String.format("%.1fx", playbackSpeed));
+ butPlaybackSpeed.setText(UserPreferences.getPlaybackSpeed());
}
}
diff --git a/src/de/danoeh/antennapod/activity/PreferenceActivity.java b/src/de/danoeh/antennapod/activity/PreferenceActivity.java
index 880724c28..96471d06d 100644
--- a/src/de/danoeh/antennapod/activity/PreferenceActivity.java
+++ b/src/de/danoeh/antennapod/activity/PreferenceActivity.java
@@ -25,6 +25,7 @@ import de.danoeh.antennapod.AppConfig;
import de.danoeh.antennapod.R;
import de.danoeh.antennapod.asynctask.FlattrClickWorker;
import de.danoeh.antennapod.asynctask.OpmlExportWorker;
+import de.danoeh.antennapod.dialog.VariableSpeedDialog;
import de.danoeh.antennapod.preferences.UserPreferences;
import de.danoeh.antennapod.util.flattr.FlattrUtils;
@@ -41,7 +42,8 @@ public class PreferenceActivity extends android.preference.PreferenceActivity {
private static final String PREF_ABOUT = "prefAbout";
private static final String PREF_CHOOSE_DATA_DIR = "prefChooseDataDir";
private static final String AUTO_DL_PREF_SCREEN = "prefAutoDownloadSettings";
-
+ private static final String PREF_PLAYBACK_SPEED_LAUNCHER = "prefPlaybackSpeedLauncher";
+
private CheckBoxPreference[] selectedNetworks;
@SuppressWarnings("deprecation")
@@ -156,6 +158,14 @@ public class PreferenceActivity extends android.preference.PreferenceActivity {
return true;
}
});
+ findPreference(PREF_PLAYBACK_SPEED_LAUNCHER)
+ .setOnPreferenceClickListener(new OnPreferenceClickListener() {
+ @Override
+ public boolean onPreferenceClick(Preference preference) {
+ VariableSpeedDialog.showDialog(PreferenceActivity.this);
+ return true;
+ }
+ });
buildUpdateIntervalPreference();
buildAutodownloadSelectedNetworsPreference();
setSelectedNetworksEnabled(UserPreferences