diff --git a/app/src/main/java/de/danoeh/antennapod/adapter/DownloadedEpisodesListAdapter.java b/app/src/main/java/de/danoeh/antennapod/adapter/DownloadedEpisodesListAdapter.java index cd636af43..98d55dd97 100644 --- a/app/src/main/java/de/danoeh/antennapod/adapter/DownloadedEpisodesListAdapter.java +++ b/app/src/main/java/de/danoeh/antennapod/adapter/DownloadedEpisodesListAdapter.java @@ -100,14 +100,6 @@ public class DownloadedEpisodesListAdapter extends BaseAdapter { String pubDateStr = DateUtils.formatAbbrev(context, item.getPubDate()); holder.pubDate.setText(pubDateStr); - FeedItem.State state = item.getState(); - if (state == FeedItem.State.PLAYING && PlaybackService.isRunning) { - holder.butSecondary.setEnabled(false); - holder.butSecondary.setAlpha(0.5f); - } else { - holder.butSecondary.setEnabled(true); - holder.butSecondary.setAlpha(1.0f); - } holder.butSecondary.setFocusable(false); holder.butSecondary.setTag(item); holder.butSecondary.setOnClickListener(secondaryActionListener); diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/ItemFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/ItemFragment.java index 432ada44e..bdaf46e03 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/ItemFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/ItemFragment.java @@ -446,15 +446,6 @@ public class ItemFragment extends Fragment implements OnSwipeGesture { } } - FeedItem.State state = item.getState(); - if (butAction2Text == R.string.delete_label && state == FeedItem.State.PLAYING && PlaybackService.isRunning) { - butAction2.setEnabled(false); - butAction2.setAlpha(0.5f); - } else { - butAction2.setEnabled(true); - butAction2.setAlpha(1.0f); - } - if(butAction1Icon != null && butAction1Text != 0) { butAction1.setText(butAction1Icon +"\u0020\u0020" + getActivity().getString(butAction1Text)); Iconify.addIcons(butAction1); 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 dfe056f14..a4cc22d8b 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 @@ -111,4 +111,12 @@ public class PlaybackPreferences implements SharedPreferences.OnSharedPreference return prefs.getInt(PREF_CURRENT_PLAYER_STATUS, PLAYER_STATUS_OTHER); } + public static void writeNoMediaPlaying() { + SharedPreferences.Editor editor = prefs.edit(); + editor.putLong(PREF_CURRENTLY_PLAYING_MEDIA, NO_MEDIA_PLAYING); + editor.putLong(PREF_CURRENTLY_PLAYING_FEED_ID, NO_MEDIA_PLAYING); + editor.putLong(PREF_CURRENTLY_PLAYING_FEEDMEDIA_ID, NO_MEDIA_PLAYING); + editor.putInt(PREF_CURRENT_PLAYER_STATUS, PLAYER_STATUS_OTHER); + editor.apply(); + } } 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 f7a13d81e..8d3dda524 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 @@ -495,7 +495,7 @@ public class PlaybackService extends MediaBrowserServiceCompat { } if (stream && !NetworkUtils.isStreamingAllowed() && !allowStreamThisTime) { displayStreamingNotAllowedNotification(intent); - writePlaybackPreferencesNoMediaPlaying(); + PlaybackPreferences.writeNoMediaPlaying(); stateManager.stopService(); return Service.START_NOT_STICKY; } @@ -748,7 +748,7 @@ public class PlaybackService extends MediaBrowserServiceCompat { break; case ERROR: - writePlaybackPreferencesNoMediaPlaying(); + PlaybackPreferences.writeNoMediaPlaying(); stateManager.stopService(); break; @@ -810,7 +810,7 @@ public class PlaybackService extends MediaBrowserServiceCompat { mediaPlayer.pause(true, false); } sendNotificationBroadcast(NOTIFICATION_TYPE_ERROR, what); - writePlaybackPreferencesNoMediaPlaying(); + PlaybackPreferences.writeNoMediaPlaying(); stateManager.stopService(); return true; } @@ -895,7 +895,7 @@ public class PlaybackService extends MediaBrowserServiceCompat { .startWhenPrepared(true) .shouldStream(true) .getIntent()); - writePlaybackPreferencesNoMediaPlaying(); + PlaybackPreferences.writeNoMediaPlaying(); stateManager.stopService(); return null; } @@ -910,7 +910,7 @@ public class PlaybackService extends MediaBrowserServiceCompat { Log.d(TAG, "Playback ended"); if (stopPlaying) { taskManager.cancelPositionSaver(); - writePlaybackPreferencesNoMediaPlaying(); + PlaybackPreferences.writeNoMediaPlaying(); if (!isCasting) { stateManager.stopForeground(true); } @@ -1016,22 +1016,6 @@ public class PlaybackService extends MediaBrowserServiceCompat { EventBus.getDefault().post(new MessageEvent(getString(R.string.sleep_timer_disabled_label))); } - private void writePlaybackPreferencesNoMediaPlaying() { - SharedPreferences.Editor editor = PreferenceManager - .getDefaultSharedPreferences(getApplicationContext()).edit(); - editor.putLong(PlaybackPreferences.PREF_CURRENTLY_PLAYING_MEDIA, - PlaybackPreferences.NO_MEDIA_PLAYING); - editor.putLong(PlaybackPreferences.PREF_CURRENTLY_PLAYING_FEED_ID, - PlaybackPreferences.NO_MEDIA_PLAYING); - 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) { diff --git a/core/src/main/java/de/danoeh/antennapod/core/storage/DBWriter.java b/core/src/main/java/de/danoeh/antennapod/core/storage/DBWriter.java index 7d525a376..6f8498710 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/storage/DBWriter.java +++ b/core/src/main/java/de/danoeh/antennapod/core/storage/DBWriter.java @@ -108,23 +108,11 @@ public class DBWriter { adapter.setMedia(media); adapter.close(); - // If media is currently being played, change playback - // type to 'stream' and shutdown playback service - SharedPreferences prefs = PreferenceManager - .getDefaultSharedPreferences(context); - if (PlaybackPreferences.getCurrentlyPlayingMedia() == FeedMedia.PLAYABLE_TYPE_FEEDMEDIA) { - if (media.getId() == PlaybackPreferences - .getCurrentlyPlayingFeedMediaId()) { - SharedPreferences.Editor editor = prefs.edit(); - editor.putBoolean( - PlaybackPreferences.PREF_CURRENT_EPISODE_IS_STREAM, - true); - editor.commit(); - } - if (PlaybackPreferences.getCurrentlyPlayingFeedMediaId() == media.getId()) { - IntentUtils.sendLocalBroadcast(context, PlaybackService.ACTION_SHUTDOWN_PLAYBACK_SERVICE); - } + if (media.getId() == PlaybackPreferences.getCurrentlyPlayingFeedMediaId()) { + PlaybackPreferences.writeNoMediaPlaying(); + IntentUtils.sendLocalBroadcast(context, PlaybackService.ACTION_SHUTDOWN_PLAYBACK_SERVICE); } + // Gpodder: queue delete action for synchronization if(GpodnetPreferences.loggedIn()) { FeedItem item = media.getItem();