summaryrefslogtreecommitdiff
path: root/src/de
diff options
context:
space:
mode:
Diffstat (limited to 'src/de')
-rw-r--r--src/de/danoeh/antennapod/activity/AudioplayerActivity.java51
-rw-r--r--src/de/danoeh/antennapod/activity/MediaplayerActivity.java9
-rw-r--r--src/de/danoeh/antennapod/activity/PreferenceActivity.java30
-rw-r--r--src/de/danoeh/antennapod/feed/FeedManager.java15
-rw-r--r--src/de/danoeh/antennapod/fragment/ExternalPlayerFragment.java6
-rw-r--r--src/de/danoeh/antennapod/fragment/ItemDescriptionFragment.java26
-rw-r--r--src/de/danoeh/antennapod/service/PlaybackService.java30
-rw-r--r--src/de/danoeh/antennapod/syndication/namespace/NSRSS20.java15
-rw-r--r--src/de/danoeh/antennapod/util/playback/PlaybackController.java22
9 files changed, 178 insertions, 26 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) {
diff --git a/src/de/danoeh/antennapod/feed/FeedManager.java b/src/de/danoeh/antennapod/feed/FeedManager.java
index b2d97a311..a1a8c6c32 100644
--- a/src/de/danoeh/antennapod/feed/FeedManager.java
+++ b/src/de/danoeh/antennapod/feed/FeedManager.java
@@ -677,8 +677,12 @@ public class FeedManager {
int deletedEpisodes = performAutoCleanup(context,
getPerformAutoCleanupArgs(undownloadedEpisodes));
int episodeSpaceLeft = undownloadedEpisodes;
- if (UserPreferences.getEpisodeCacheSize() < downloadedEpisodes
- + undownloadedEpisodes) {
+ boolean cacheIsUnlimited = UserPreferences.getEpisodeCacheSize() == UserPreferences
+ .getEpisodeCacheSizeUnlimited();
+
+ if (!cacheIsUnlimited
+ && UserPreferences.getEpisodeCacheSize() < downloadedEpisodes
+ + undownloadedEpisodes) {
episodeSpaceLeft = UserPreferences.getEpisodeCacheSize()
- (downloadedEpisodes - deletedEpisodes);
}
@@ -733,7 +737,9 @@ public class FeedManager {
* that the number of episodes fits into the episode cache.
* */
private int getPerformAutoCleanupArgs(final int episodeNumber) {
- if (episodeNumber >= 0 && UserPreferences.getEpisodeCacheSize() != UserPreferences.getEpisodeCacheSizeUnlimited()) {
+ if (episodeNumber >= 0
+ && UserPreferences.getEpisodeCacheSize() != UserPreferences
+ .getEpisodeCacheSizeUnlimited()) {
int downloadedEpisodes = getNumberOfDownloadedEpisodes();
if (downloadedEpisodes + episodeNumber >= UserPreferences
.getEpisodeCacheSize()) {
@@ -765,7 +771,8 @@ public class FeedManager {
List<FeedItem> delete;
for (Feed feed : feeds) {
for (FeedItem item : feed.getItems()) {
- if (item.hasMedia() && item.getMedia().isDownloaded() && !isInQueue(item) && item.isRead()) {
+ if (item.hasMedia() && item.getMedia().isDownloaded()
+ && !isInQueue(item) && item.isRead()) {
candidates.add(item);
}
}
diff --git a/src/de/danoeh/antennapod/fragment/ExternalPlayerFragment.java b/src/de/danoeh/antennapod/fragment/ExternalPlayerFragment.java
index a50e820b6..e46017328 100644
--- a/src/de/danoeh/antennapod/fragment/ExternalPlayerFragment.java
+++ b/src/de/danoeh/antennapod/fragment/ExternalPlayerFragment.java
@@ -174,6 +174,12 @@ public class ExternalPlayerFragment extends SherlockFragment {
.newOnPlayButtonClickListener());
}
}
+
+ @Override
+ public void onPlaybackSpeedChange() {
+ // TODO Auto-generated method stub
+
+ }
};
}
diff --git a/src/de/danoeh/antennapod/fragment/ItemDescriptionFragment.java b/src/de/danoeh/antennapod/fragment/ItemDescriptionFragment.java
index 160784a90..10f43718f 100644
--- a/src/de/danoeh/antennapod/fragment/ItemDescriptionFragment.java
+++ b/src/de/danoeh/antennapod/fragment/ItemDescriptionFragment.java
@@ -446,17 +446,21 @@ public class ItemDescriptionFragment extends SherlockFragment {
if (saveState) {
if (AppConfig.DEBUG)
Log.d(TAG, "Restoring from preferences");
- SharedPreferences prefs = getActivity().getSharedPreferences(PREF,
- Activity.MODE_PRIVATE);
- String id = prefs.getString(PREF_PLAYABLE_ID, "");
- int scrollY = prefs.getInt(PREF_SCROLL_Y, -1);
- if (scrollY != -1 && media != null
- && id.equals(media.getIdentifier().toString())
- && webvDescription != null) {
- if (AppConfig.DEBUG)
- Log.d(TAG, "Restored scroll Position: " + scrollY);
- webvDescription.scrollTo(webvDescription.getScrollX(), scrollY);
- return true;
+ Activity activity = getActivity();
+ if (activity != null) {
+ SharedPreferences prefs = activity.getSharedPreferences(
+ PREF, Activity.MODE_PRIVATE);
+ String id = prefs.getString(PREF_PLAYABLE_ID, "");
+ int scrollY = prefs.getInt(PREF_SCROLL_Y, -1);
+ if (scrollY != -1 && media != null
+ && id.equals(media.getIdentifier().toString())
+ && webvDescription != null) {
+ if (AppConfig.DEBUG)
+ Log.d(TAG, "Restored scroll Position: " + scrollY);
+ webvDescription.scrollTo(webvDescription.getScrollX(),
+ scrollY);
+ return true;
+ }
}
}
return false;
diff --git a/src/de/danoeh/antennapod/service/PlaybackService.java b/src/de/danoeh/antennapod/service/PlaybackService.java
index 99d1afa7f..afd8de68f 100644
--- a/src/de/danoeh/antennapod/service/PlaybackService.java
+++ b/src/de/danoeh/antennapod/service/PlaybackService.java
@@ -110,6 +110,7 @@ public class PlaybackService extends Service {
public static final int NOTIFICATION_TYPE_BUFFER_END = 6;
/** No more episodes are going to be played. */
public static final int NOTIFICATION_TYPE_PLAYBACK_END = 7;
+ public static final int NOTIFICATION_TYPE_PLAYBACK_SPEED_CHANGE = 8;
/**
* Returned by getPositionSafe() or getDurationSafe() if the playbackService
@@ -395,12 +396,14 @@ public class PlaybackService extends Service {
}
// Intent values appear to be valid
// check if already playing and playbackType is the same
- } else if (media == null || playable != media
+ } else if (media == null
+ || !playable.getIdentifier().equals(media.getIdentifier())
|| playbackType != shouldStream) {
pause(true, false);
sendNotificationBroadcast(NOTIFICATION_TYPE_RELOAD, 0);
if (media == null
- || playable.getIdentifier() != media.getIdentifier()) {
+ || !playable.getIdentifier().equals(
+ media.getIdentifier())) {
media = playable;
}
@@ -1531,30 +1534,34 @@ public class PlaybackService extends Service {
}
public boolean canSetSpeed() {
- if (media.getMediaType() == MediaType.AUDIO) {
+ if (media != null && media.getMediaType() == MediaType.AUDIO) {
return ((AudioPlayer) player).canSetSpeed();
}
return false;
}
public boolean canSetPitch() {
- if (media.getMediaType() == MediaType.AUDIO) {
+ if (media != null && media.getMediaType() == MediaType.AUDIO) {
return ((AudioPlayer) player).canSetPitch();
}
return false;
}
public void setSpeed(float speed) {
- if (media.getMediaType() == MediaType.AUDIO) {
+ if (media != null && media.getMediaType() == MediaType.AUDIO) {
AudioPlayer audioPlayer = (AudioPlayer) player;
if (audioPlayer.canSetSpeed()) {
audioPlayer.setPlaybackSpeed(speed);
+ if (AppConfig.DEBUG)
+ Log.d(TAG, "Playback speed was set to " + speed);
+ sendNotificationBroadcast(
+ NOTIFICATION_TYPE_PLAYBACK_SPEED_CHANGE, 0);
}
}
}
public void setPitch(float pitch) {
- if (media.getMediaType() == MediaType.AUDIO) {
+ if (media != null && media.getMediaType() == MediaType.AUDIO) {
AudioPlayer audioPlayer = (AudioPlayer) player;
if (audioPlayer.canSetPitch()) {
audioPlayer.setPlaybackPitch(pitch);
@@ -1562,6 +1569,17 @@ public class PlaybackService extends Service {
}
}
+ public double getCurrentPlaybackSpeed() {
+ if (media.getMediaType() == MediaType.AUDIO
+ && player instanceof AudioPlayer) {
+ AudioPlayer audioPlayer = (AudioPlayer) player;
+ if (audioPlayer.canSetSpeed()) {
+ return audioPlayer.getCurrentSpeedMultiplier();
+ }
+ }
+ return -1;
+ }
+
/**
* call getDuration() on mediaplayer or return INVALID_TIME if player is in
* an invalid state. This method should be used instead of calling
diff --git a/src/de/danoeh/antennapod/syndication/namespace/NSRSS20.java b/src/de/danoeh/antennapod/syndication/namespace/NSRSS20.java
index 4d0b42132..5a2c6005e 100644
--- a/src/de/danoeh/antennapod/syndication/namespace/NSRSS20.java
+++ b/src/de/danoeh/antennapod/syndication/namespace/NSRSS20.java
@@ -78,6 +78,15 @@ public class NSRSS20 extends Namespace {
@Override
public void handleElementEnd(String localName, HandlerState state) {
if (localName.equals(ITEM)) {
+ if (state.getCurrentItem() != null) {
+ // the title tag is optional in RSS 2.0. The description is used
+ // as a
+ // title if the item has no title-tag.
+ if (state.getCurrentItem().getTitle() == null) {
+ state.getCurrentItem().setTitle(
+ state.getCurrentItem().getDescription());
+ }
+ }
state.setCurrentItem(null);
} else if (state.getTagstack().size() >= 2
&& state.getContentBuf() != null) {
@@ -98,7 +107,8 @@ public class NSRSS20 extends Namespace {
state.getCurrentItem().setTitle(content);
} else if (second.equals(CHANNEL)) {
state.getFeed().setTitle(content);
- } else if (second.equals(IMAGE) && third != null && third.equals(CHANNEL)) {
+ } else if (second.equals(IMAGE) && third != null
+ && third.equals(CHANNEL)) {
state.getFeed().getImage().setTitle(content);
}
} else if (top.equals(LINK)) {
@@ -110,7 +120,8 @@ public class NSRSS20 extends Namespace {
} else if (top.equals(PUBDATE) && second.equals(ITEM)) {
state.getCurrentItem().setPubDate(
SyndDateUtils.parseRFC822Date(content));
- } else if (top.equals(URL) && second.equals(IMAGE) && third != null && third.equals(CHANNEL)) {
+ } else if (top.equals(URL) && second.equals(IMAGE) && third != null
+ && third.equals(CHANNEL)) {
state.getFeed().getImage().setDownload_url(content);
} else if (localName.equals(DESCR)) {
if (second.equals(CHANNEL)) {
diff --git a/src/de/danoeh/antennapod/util/playback/PlaybackController.java b/src/de/danoeh/antennapod/util/playback/PlaybackController.java
index cebb11cf0..0060c756f 100644
--- a/src/de/danoeh/antennapod/util/playback/PlaybackController.java
+++ b/src/de/danoeh/antennapod/util/playback/PlaybackController.java
@@ -327,6 +327,8 @@ public abstract class PlaybackController {
break;
case PlaybackService.NOTIFICATION_TYPE_PLAYBACK_END:
onPlaybackEnd();
+ case PlaybackService.NOTIFICATION_TYPE_PLAYBACK_SPEED_CHANGE:
+ onPlaybackSpeedChange();
break;
}
@@ -354,6 +356,8 @@ public abstract class PlaybackController {
}
}
};
+
+ public abstract void onPlaybackSpeedChange();
public abstract void onShutdownNotification();
@@ -654,6 +658,24 @@ public abstract class PlaybackController {
return false;
}
+ public boolean canSetPlaybackSpeed() {
+ return playbackService != null && playbackService.canSetSpeed();
+ }
+
+ public void setPlaybackSpeed(double speed) {
+ if (playbackService != null) {
+ playbackService.setSpeed(speed);
+ }
+ }
+
+ public double getCurrentPlaybackSpeedMultiplier() {
+ if (canSetPlaybackSpeed()) {
+ return playbackService.getCurrentPlaybackSpeed();
+ } else {
+ return -1;
+ }
+ }
+
/**
* Returns true if PlaybackController can communicate with the playback
* service.