summaryrefslogtreecommitdiff
path: root/core/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'core/src/main')
-rw-r--r--core/src/main/java/de/danoeh/antennapod/core/feed/EventDistributor.java5
-rw-r--r--core/src/main/java/de/danoeh/antennapod/core/feed/FeedMedia.java19
-rw-r--r--core/src/main/java/de/danoeh/antennapod/core/preferences/PlaybackPreferences.java27
-rw-r--r--core/src/main/java/de/danoeh/antennapod/core/service/playback/PlaybackService.java76
-rw-r--r--core/src/main/java/de/danoeh/antennapod/core/service/playback/PlaybackServiceMediaPlayer.java7
-rw-r--r--core/src/main/res/values/strings.xml12
-rw-r--r--core/src/main/res/values/styles.xml1
7 files changed, 140 insertions, 7 deletions
diff --git a/core/src/main/java/de/danoeh/antennapod/core/feed/EventDistributor.java b/core/src/main/java/de/danoeh/antennapod/core/feed/EventDistributor.java
index f8815dcf0..5a2cfa40e 100644
--- a/core/src/main/java/de/danoeh/antennapod/core/feed/EventDistributor.java
+++ b/core/src/main/java/de/danoeh/antennapod/core/feed/EventDistributor.java
@@ -31,6 +31,7 @@ public class EventDistributor extends Observable {
public static final int PLAYBACK_HISTORY_UPDATE = 16;
public static final int DOWNLOAD_QUEUED = 32;
public static final int DOWNLOAD_HANDLED = 64;
+ public static final int PLAYER_STATUS_UPDATE = 128;
private Handler handler;
private AbstractQueue<Integer> events;
@@ -124,6 +125,10 @@ public class EventDistributor extends Observable {
addEvent(DOWNLOAD_HANDLED);
}
+ public void sendPlayerStatusUpdateBroadcast() {
+ addEvent(PLAYER_STATUS_UPDATE);
+ }
+
public static abstract class EventListener implements Observer {
@Override
diff --git a/core/src/main/java/de/danoeh/antennapod/core/feed/FeedMedia.java b/core/src/main/java/de/danoeh/antennapod/core/feed/FeedMedia.java
index 2434ee0cf..69e96c503 100644
--- a/core/src/main/java/de/danoeh/antennapod/core/feed/FeedMedia.java
+++ b/core/src/main/java/de/danoeh/antennapod/core/feed/FeedMedia.java
@@ -127,6 +127,25 @@ public class FeedMedia extends FeedFile implements Playable {
&& PlaybackPreferences.getCurrentlyPlayingFeedMediaId() == id;
}
+ /**
+ * Reads playback preferences to determine whether this FeedMedia object is
+ * currently being played and the current player status is playing.
+ */
+ public boolean isCurrentlyPlaying() {
+ return isPlaying() &&
+ ((PlaybackPreferences.getCurrentPlayerStatus() == PlaybackPreferences.PLAYER_STATUS_PLAYING));
+ }
+
+ /**
+ * Reads playback preferences to determine whether this FeedMedia object is
+ * currently being played and the current player status is paused.
+ */
+ public boolean isCurrentlyPaused() {
+ return isPlaying() &&
+ ((PlaybackPreferences.getCurrentPlayerStatus() == PlaybackPreferences.PLAYER_STATUS_PAUSED));
+ }
+
+
@Override
public int getTypeAsInt() {
return FEEDFILETYPE_FEEDMEDIA;
diff --git a/core/src/main/java/de/danoeh/antennapod/core/preferences/PlaybackPreferences.java b/core/src/main/java/de/danoeh/antennapod/core/preferences/PlaybackPreferences.java
index d88543f73..714f1b051 100644
--- a/core/src/main/java/de/danoeh/antennapod/core/preferences/PlaybackPreferences.java
+++ b/core/src/main/java/de/danoeh/antennapod/core/preferences/PlaybackPreferences.java
@@ -8,6 +8,7 @@ import android.util.Log;
import org.apache.commons.lang3.Validate;
import de.danoeh.antennapod.core.BuildConfig;
+import de.danoeh.antennapod.core.feed.EventDistributor;
/**
* Provides access to preferences set by the playback service. A private
@@ -43,14 +44,27 @@ public class PlaybackPreferences implements
/** True if last played media was a video. */
public static final String PREF_CURRENT_EPISODE_IS_VIDEO = "de.danoeh.antennapod.preferences.lastIsVideo";
+ /** The current player status as int. */
+ public static final String PREF_CURRENT_PLAYER_STATUS = "de.danoeh.antennapod.preferences.currentPlayerStatus";
+
/** Value of PREF_CURRENTLY_PLAYING_MEDIA if no media is playing. */
public static final long NO_MEDIA_PLAYING = -1;
+ /** Value of PREF_CURRENT_PLAYER_STATUS if media player status is playing. */
+ public static final int PLAYER_STATUS_PLAYING = 1;
+
+ /** Value of PREF_CURRENT_PLAYER_STATUS if media player status is paused. */
+ public static final int PLAYER_STATUS_PAUSED = 2;
+
+ /** Value of PREF_CURRENT_PLAYER_STATUS if media player status is neither playing nor paused. */
+ public static final int PLAYER_STATUS_OTHER = 3;
+
private long currentlyPlayingFeedId;
private long currentlyPlayingFeedMediaId;
private long currentlyPlayingMedia;
private boolean currentEpisodeIsStream;
private boolean currentEpisodeIsVideo;
+ private int currentPlayerStatus;
private static PlaybackPreferences instance;
private Context context;
@@ -87,6 +101,8 @@ public class PlaybackPreferences implements
NO_MEDIA_PLAYING);
currentEpisodeIsStream = sp.getBoolean(PREF_CURRENT_EPISODE_IS_STREAM, true);
currentEpisodeIsVideo = sp.getBoolean(PREF_CURRENT_EPISODE_IS_VIDEO, false);
+ currentPlayerStatus = sp.getInt(PREF_CURRENT_PLAYER_STATUS,
+ PLAYER_STATUS_OTHER);
}
@Override
@@ -109,6 +125,11 @@ public class PlaybackPreferences implements
currentlyPlayingFeedMediaId = sp.getLong(
PREF_CURRENTLY_PLAYING_FEEDMEDIA_ID, NO_MEDIA_PLAYING);
}
+ else if (key.equals(PREF_CURRENT_PLAYER_STATUS)) {
+ currentPlayerStatus = sp.getInt(PREF_CURRENT_PLAYER_STATUS,
+ PLAYER_STATUS_OTHER);
+ EventDistributor.getInstance().sendPlayerStatusUpdateBroadcast();
+ }
}
private static void instanceAvailable() {
@@ -143,4 +164,10 @@ public class PlaybackPreferences implements
return instance.currentEpisodeIsVideo;
}
+ public static int getCurrentPlayerStatus() {
+ instanceAvailable();
+ return instance.currentPlayerStatus;
+ }
+
+
}
diff --git a/core/src/main/java/de/danoeh/antennapod/core/service/playback/PlaybackService.java b/core/src/main/java/de/danoeh/antennapod/core/service/playback/PlaybackService.java
index aabbcc185..6f3eedcb2 100644
--- a/core/src/main/java/de/danoeh/antennapod/core/service/playback/PlaybackService.java
+++ b/core/src/main/java/de/danoeh/antennapod/core/service/playback/PlaybackService.java
@@ -101,6 +101,18 @@ public class PlaybackService extends Service {
public static final String ACTION_SKIP_CURRENT_EPISODE = "action.de.danoeh.antennapod.core.service.skipCurrentEpisode";
/**
+ * If the PlaybackService receives this action, it will pause playback.
+ */
+ public static final String ACTION_PAUSE_PLAY_CURRENT_EPISODE = "action.de.danoeh.antennapod.core.service.pausePlayCurrentEpisode";
+
+
+ /**
+ * If the PlaybackService receives this action, it will resume playback.
+ */
+ public static final String ACTION_RESUME_PLAY_CURRENT_EPISODE = "action.de.danoeh.antennapod.core.service.resumePlayCurrentEpisode";
+
+
+ /**
* Used in NOTIFICATION_TYPE_RELOAD.
*/
public static final int EXTRA_CODE_AUDIO = 1;
@@ -216,6 +228,10 @@ public class PlaybackService extends Service {
AudioManager.ACTION_AUDIO_BECOMING_NOISY));
registerReceiver(skipCurrentEpisodeReceiver, new IntentFilter(
ACTION_SKIP_CURRENT_EPISODE));
+ registerReceiver(pausePlayCurrentEpisodeReceiver, new IntentFilter(
+ ACTION_PAUSE_PLAY_CURRENT_EPISODE));
+ registerReceiver(pauseResumeCurrentEpisodeReceiver, new IntentFilter(
+ ACTION_RESUME_PLAY_CURRENT_EPISODE));
remoteControlClient = setupRemoteControlClient();
taskManager = new PlaybackServiceTaskManager(this, taskManagerCallback);
mediaPlayer = new PlaybackServiceMediaPlayer(this, mediaPlayerCallback);
@@ -427,6 +443,7 @@ public class PlaybackService extends Service {
// remove notifcation on pause
stopForeground(true);
}
+ writePlayerStatusPlaybackPreferences();
break;
@@ -443,9 +460,11 @@ public class PlaybackService extends Service {
taskManager.startPositionSaver();
taskManager.startWidgetUpdater();
+ writePlayerStatusPlaybackPreferences();
setupNotification(newInfo);
started = true;
break;
+
case ERROR:
writePlaybackPreferencesNoMediaPlaying();
break;
@@ -634,9 +653,26 @@ public class PlaybackService extends Service {
editor.putLong(
PlaybackPreferences.PREF_CURRENTLY_PLAYING_FEEDMEDIA_ID,
PlaybackPreferences.NO_MEDIA_PLAYING);
+ editor.putInt(
+ PlaybackPreferences.PREF_CURRENT_PLAYER_STATUS,
+ PlaybackPreferences.PLAYER_STATUS_OTHER);
editor.commit();
}
+ private int getCurrentPlayerStatusAsInt(PlayerStatus playerStatus) {
+ int playerStatusAsInt;
+ switch (playerStatus) {
+ case PLAYING:
+ playerStatusAsInt = PlaybackPreferences.PLAYER_STATUS_PLAYING;
+ break;
+ case PAUSED:
+ playerStatusAsInt = PlaybackPreferences.PLAYER_STATUS_PAUSED;
+ break;
+ default:
+ playerStatusAsInt = PlaybackPreferences.PLAYER_STATUS_OTHER;
+ }
+ return playerStatusAsInt;
+ }
private void writePlaybackPreferences() {
if (BuildConfig.DEBUG)
@@ -647,6 +683,7 @@ public class PlaybackService extends Service {
PlaybackServiceMediaPlayer.PSMPInfo info = mediaPlayer.getPSMPInfo();
MediaType mediaType = mediaPlayer.getCurrentMediaType();
boolean stream = mediaPlayer.isStreaming();
+ int playerStatus = getCurrentPlayerStatusAsInt(info.playerStatus);
if (info.playable != null) {
editor.putLong(PlaybackPreferences.PREF_CURRENTLY_PLAYING_MEDIA,
@@ -683,6 +720,23 @@ public class PlaybackService extends Service {
PlaybackPreferences.PREF_CURRENTLY_PLAYING_FEEDMEDIA_ID,
PlaybackPreferences.NO_MEDIA_PLAYING);
}
+ editor.putInt(
+ PlaybackPreferences.PREF_CURRENT_PLAYER_STATUS, playerStatus);
+
+ editor.commit();
+ }
+
+ private void writePlayerStatusPlaybackPreferences() {
+ if (BuildConfig.DEBUG)
+ Log.d(TAG, "Writing player status playback preferences");
+
+ SharedPreferences.Editor editor = PreferenceManager
+ .getDefaultSharedPreferences(getApplicationContext()).edit();
+ PlaybackServiceMediaPlayer.PSMPInfo info = mediaPlayer.getPSMPInfo();
+ int playerStatus = getCurrentPlayerStatusAsInt(info.playerStatus);
+
+ editor.putInt(
+ PlaybackPreferences.PREF_CURRENT_PLAYER_STATUS, playerStatus);
editor.commit();
}
@@ -1101,6 +1155,28 @@ public class PlaybackService extends Service {
}
};
+ private BroadcastReceiver pauseResumeCurrentEpisodeReceiver = new BroadcastReceiver() {
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ if (StringUtils.equals(intent.getAction(), ACTION_RESUME_PLAY_CURRENT_EPISODE)) {
+ if (BuildConfig.DEBUG)
+ Log.d(TAG, "Received RESUME_PLAY_CURRENT_EPISODE intent");
+ mediaPlayer.resume();
+ }
+ }
+ };
+
+ private BroadcastReceiver pausePlayCurrentEpisodeReceiver = new BroadcastReceiver() {
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ if (StringUtils.equals(intent.getAction(), ACTION_PAUSE_PLAY_CURRENT_EPISODE)) {
+ if (BuildConfig.DEBUG)
+ Log.d(TAG, "Received PAUSE_PLAY_CURRENT_EPISODE intent");
+ mediaPlayer.pause(false, false);
+ }
+ }
+ };
+
public static MediaType getCurrentMediaType() {
return currentMediaType;
}
diff --git a/core/src/main/java/de/danoeh/antennapod/core/service/playback/PlaybackServiceMediaPlayer.java b/core/src/main/java/de/danoeh/antennapod/core/service/playback/PlaybackServiceMediaPlayer.java
index c143d7f2c..b7c02011d 100644
--- a/core/src/main/java/de/danoeh/antennapod/core/service/playback/PlaybackServiceMediaPlayer.java
+++ b/core/src/main/java/de/danoeh/antennapod/core/service/playback/PlaybackServiceMediaPlayer.java
@@ -169,7 +169,8 @@ public class PlaybackServiceMediaPlayer {
if (media != null) {
- if (!forceReset && media.getIdentifier().equals(playable.getIdentifier())) {
+ if (!forceReset && media.getIdentifier().equals(playable.getIdentifier())
+ && playerStatus == PlayerStatus.PLAYING) {
// episode is already playing -> ignore method call
if (BuildConfig.DEBUG)
Log.d(TAG, "Method call to playMediaObject was ignored: media file already playing.");
@@ -179,6 +180,10 @@ public class PlaybackServiceMediaPlayer {
if (playerStatus == PlayerStatus.PAUSED || playerStatus == PlayerStatus.PLAYING || playerStatus == PlayerStatus.PREPARED) {
mediaPlayer.stop();
}
+ // set temporarily to pause in order to update list with current position
+ if (playerStatus == PlayerStatus.PLAYING) {
+ setPlayerStatus(PlayerStatus.PAUSED, media);
+ }
setPlayerStatus(PlayerStatus.INDETERMINATE, null);
}
}
diff --git a/core/src/main/res/values/strings.xml b/core/src/main/res/values/strings.xml
index 6d5a98a19..186651224 100644
--- a/core/src/main/res/values/strings.xml
+++ b/core/src/main/res/values/strings.xml
@@ -71,7 +71,7 @@
<!-- 'Add Feed' Activity labels -->
<string name="feedurl_label">Feed URL</string>
- <string name="etxtFeedurlHint">URL of feed or website</string>
+ <string name="etxtFeedurlHint">www.example.com/feed</string>
<string name="txtvfeedurl_label">Add Podcast by URL</string>
<string name="podcastdirectories_label">Find podcast in directory</string>
<string name="podcastdirectories_descr">You can search for new podcasts by name, category or popularity in the gpodder.net directory, or search the iTunes store.</string>
@@ -294,8 +294,9 @@
<!-- OPML import and export -->
<string name="opml_import_txtv_button_lable">OPML files allow you to move your podcasts from one podcatcher to another.</string>
- <string name="opml_import_explanation">To import an OPML file, you have to place it in the following directory and press the button below to start the import process. </string>
- <string name="start_import_label">Start import</string>
+ <string name="opml_import_explanation_1">Choose a specific file path from the local filesystem.</string>
+ <string name="opml_import_explanation_2">Use an external applications like Dropbox, Google Drive or your favourite file manager to open an OPML file.</string>
+ <string name="opml_import_explanation_3">Many applications like Google Mail, Dropbox, Google Drive and most file managers can <i>open</i> OPML files <i>with</i> AntennaPod.</string> <string name="start_import_label">Start import</string>
<string name="opml_import_label">OPML import</string>
<string name="opml_directory_error">ERROR!</string>
<string name="reading_opml_label">Reading OPML file</string>
@@ -303,11 +304,12 @@
<string name="opml_import_error_dir_empty">The import directory is empty.</string>
<string name="select_all_label">Select all</string>
<string name="deselect_all_label">Deselect all</string>
- <string name="choose_file_to_import_label">Choose file to import</string>
+ <string name="choose_file_from_filesystem">From local filesystem</string>
+ <string name="choose_file_from_external_application">Use external application</string>
<string name="opml_export_label">OPML export</string>
<string name="exporting_label">Exporting...</string>
<string name="export_error_label">Export error</string>
- <string name="opml_export_success_title">Opml export successful.</string>
+ <string name="opml_export_success_title">OPML export successful.</string>
<string name="opml_export_success_sum">The .opml file was written to:\u0020</string>
<!-- Sleep timer -->
diff --git a/core/src/main/res/values/styles.xml b/core/src/main/res/values/styles.xml
index e8b0e2b2b..4ac4a79fd 100644
--- a/core/src/main/res/values/styles.xml
+++ b/core/src/main/res/values/styles.xml
@@ -219,7 +219,6 @@
<style name="AntennaPod.TextView.Heading" parent="@android:style/TextAppearance.Medium">
<item name="android:textSize">@dimen/text_size_large</item>
- <item name="android:textStyle">italic</item>
<item name="android:textColor">?android:attr/textColorPrimary</item>
</style>