diff options
author | James Falcon <therealfalcon@gmail.com> | 2013-05-06 21:48:18 -0500 |
---|---|---|
committer | James Falcon <therealfalcon@gmail.com> | 2013-05-06 21:48:18 -0500 |
commit | b48c3807fd23df0a6d953ebdabaaf2330bc4f3d3 (patch) | |
tree | 327374119c2b40b64de192534b8b6e4f242778be /src/de/danoeh/antennapod/activity | |
parent | 5b58466fd21c8bc97fe00698369228ea96566c33 (diff) | |
parent | 2db89cb807ae06b0f59039307e20c32cd9052b57 (diff) | |
download | AntennaPod-b48c3807fd23df0a6d953ebdabaaf2330bc4f3d3.zip |
Merge branch 'playback-speed' into speed
Conflicts:
res/values/arrays.xml
res/values/strings.xml
src/de/danoeh/antennapod/activity/PreferenceActivity.java
src/de/danoeh/antennapod/service/PlaybackService.java
Diffstat (limited to 'src/de/danoeh/antennapod/activity')
3 files changed, 87 insertions, 3 deletions
diff --git a/src/de/danoeh/antennapod/activity/AudioplayerActivity.java b/src/de/danoeh/antennapod/activity/AudioplayerActivity.java index b73a17125..f43f29db3 100644 --- a/src/de/danoeh/antennapod/activity/AudioplayerActivity.java +++ b/src/de/danoeh/antennapod/activity/AudioplayerActivity.java @@ -11,6 +11,7 @@ import android.util.Log; import android.view.View; import android.view.View.OnClickListener; import android.widget.ArrayAdapter; +import android.widget.Button; import android.widget.ImageButton; import android.widget.ImageView.ScaleType; import android.widget.ListView; @@ -57,6 +58,7 @@ public class AudioplayerActivity extends MediaplayerActivity { private TextView txtvTitle; private TextView txtvFeed; + private Button butPlaybackSpeed; private ImageButton butNavLeft; private ImageButton butNavRight; @@ -219,7 +221,7 @@ public class AudioplayerActivity extends MediaplayerActivity { if (savedPosition != -1) { switchToFragment(savedPosition); } - + } @Override @@ -365,6 +367,7 @@ public class AudioplayerActivity extends MediaplayerActivity { txtvFeed = (TextView) findViewById(R.id.txtvFeed); butNavLeft = (ImageButton) findViewById(R.id.butNavLeft); butNavRight = (ImageButton) findViewById(R.id.butNavRight); + butPlaybackSpeed = (Button) findViewById(R.id.butPlaybackSpeed); butNavLeft.setOnClickListener(new OnClickListener() { @@ -392,6 +395,50 @@ 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); + } + } else { + controller.setPlaybackSpeed(PLAYBACK_SPEED_DEFAULT); + } + + } + } + }); + } + + @Override + protected void onPlaybackSpeedChange() { + super.onPlaybackSpeedChange(); + updateButPlaybackSpeed(); + } + + private void updateButPlaybackSpeed() { + double playbackSpeed; + if (controller == null + || (playbackSpeed = controller + .getCurrentPlaybackSpeedMultiplier()) == -1) { + butPlaybackSpeed.setVisibility(View.GONE); + } else { + butPlaybackSpeed.setVisibility(View.VISIBLE); + butPlaybackSpeed.setText(String.format("%.1fx", playbackSpeed)); + } } @Override @@ -423,7 +470,7 @@ public class AudioplayerActivity extends MediaplayerActivity { ((AudioplayerContentFragment) currentlyShownFragment) .onDataSetChanged(media); } - + updateButPlaybackSpeed(); } public void notifyMediaPositionChanged() { diff --git a/src/de/danoeh/antennapod/activity/MediaplayerActivity.java b/src/de/danoeh/antennapod/activity/MediaplayerActivity.java index 16b03809a..9fa9fbf52 100644 --- a/src/de/danoeh/antennapod/activity/MediaplayerActivity.java +++ b/src/de/danoeh/antennapod/activity/MediaplayerActivity.java @@ -132,10 +132,19 @@ public abstract class MediaplayerActivity extends SherlockFragmentActivity public void onPlaybackEnd() { finish(); } + + @Override + public void onPlaybackSpeedChange() { + MediaplayerActivity.this.onPlaybackSpeedChange(); + } }; } + protected void onPlaybackSpeedChange() { + + } + protected void onServiceQueried() { supportInvalidateOptionsMenu(); } diff --git a/src/de/danoeh/antennapod/activity/PreferenceActivity.java b/src/de/danoeh/antennapod/activity/PreferenceActivity.java index a8b11bcbc..21998ea73 100644 --- a/src/de/danoeh/antennapod/activity/PreferenceActivity.java +++ b/src/de/danoeh/antennapod/activity/PreferenceActivity.java @@ -14,6 +14,7 @@ import android.net.wifi.WifiConfiguration; import android.net.wifi.WifiManager; import android.os.Bundle; import android.preference.CheckBoxPreference; +import android.preference.ListPreference; import android.preference.Preference; import android.preference.Preference.OnPreferenceChangeListener; import android.preference.Preference.OnPreferenceClickListener; @@ -178,13 +179,40 @@ public class PreferenceActivity extends SherlockPreferenceActivity { return true; } }); - + buildUpdateIntervalPreference(); buildAutodownloadSelectedNetworsPreference(); setSelectedNetworksEnabled(UserPreferences .isEnableAutodownloadWifiFilter()); } + private void buildUpdateIntervalPreference() { + ListPreference pref = (ListPreference) findPreference(UserPreferences.PREF_UPDATE_INTERVAL); + String[] values = getResources().getStringArray( + R.array.update_intervall_values); + String[] entries = new String[values.length]; + for (int x = 0; x < values.length; x++) { + Integer v = Integer.parseInt(values[x]); + switch (v) { + case 0: + entries[x] = getString(R.string.pref_update_interval_hours_manual); + break; + case 1: + entries[x] = v + + " " + + getString(R.string.pref_update_interval_hours_singular); + break; + default: + entries[x] = v + " " + + getString(R.string.pref_update_interval_hours_plural); + break; + + } + } + pref.setEntries(entries); + + } + private void setSelectedNetworksEnabled(boolean b) { if (selectedNetworks != null) { for (Preference p : selectedNetworks) { |