mirror of
https://github.com/AntennaPod/AntennaPod.git
synced 2025-01-29 18:09:21 +01:00
Merge pull request #3350 from ByteHamster/delete-media-while-playing
Allow to delete currently playing media
This commit is contained in:
commit
d317090a92
@ -100,14 +100,6 @@ public class DownloadedEpisodesListAdapter extends BaseAdapter {
|
|||||||
String pubDateStr = DateUtils.formatAbbrev(context, item.getPubDate());
|
String pubDateStr = DateUtils.formatAbbrev(context, item.getPubDate());
|
||||||
holder.pubDate.setText(pubDateStr);
|
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.setFocusable(false);
|
||||||
holder.butSecondary.setTag(item);
|
holder.butSecondary.setTag(item);
|
||||||
holder.butSecondary.setOnClickListener(secondaryActionListener);
|
holder.butSecondary.setOnClickListener(secondaryActionListener);
|
||||||
|
@ -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) {
|
if(butAction1Icon != null && butAction1Text != 0) {
|
||||||
butAction1.setText(butAction1Icon +"\u0020\u0020" + getActivity().getString(butAction1Text));
|
butAction1.setText(butAction1Icon +"\u0020\u0020" + getActivity().getString(butAction1Text));
|
||||||
Iconify.addIcons(butAction1);
|
Iconify.addIcons(butAction1);
|
||||||
|
@ -111,4 +111,12 @@ public class PlaybackPreferences implements SharedPreferences.OnSharedPreference
|
|||||||
return prefs.getInt(PREF_CURRENT_PLAYER_STATUS, PLAYER_STATUS_OTHER);
|
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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -495,7 +495,7 @@ public class PlaybackService extends MediaBrowserServiceCompat {
|
|||||||
}
|
}
|
||||||
if (stream && !NetworkUtils.isStreamingAllowed() && !allowStreamThisTime) {
|
if (stream && !NetworkUtils.isStreamingAllowed() && !allowStreamThisTime) {
|
||||||
displayStreamingNotAllowedNotification(intent);
|
displayStreamingNotAllowedNotification(intent);
|
||||||
writePlaybackPreferencesNoMediaPlaying();
|
PlaybackPreferences.writeNoMediaPlaying();
|
||||||
stateManager.stopService();
|
stateManager.stopService();
|
||||||
return Service.START_NOT_STICKY;
|
return Service.START_NOT_STICKY;
|
||||||
}
|
}
|
||||||
@ -748,7 +748,7 @@ public class PlaybackService extends MediaBrowserServiceCompat {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case ERROR:
|
case ERROR:
|
||||||
writePlaybackPreferencesNoMediaPlaying();
|
PlaybackPreferences.writeNoMediaPlaying();
|
||||||
stateManager.stopService();
|
stateManager.stopService();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -810,7 +810,7 @@ public class PlaybackService extends MediaBrowserServiceCompat {
|
|||||||
mediaPlayer.pause(true, false);
|
mediaPlayer.pause(true, false);
|
||||||
}
|
}
|
||||||
sendNotificationBroadcast(NOTIFICATION_TYPE_ERROR, what);
|
sendNotificationBroadcast(NOTIFICATION_TYPE_ERROR, what);
|
||||||
writePlaybackPreferencesNoMediaPlaying();
|
PlaybackPreferences.writeNoMediaPlaying();
|
||||||
stateManager.stopService();
|
stateManager.stopService();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -895,7 +895,7 @@ public class PlaybackService extends MediaBrowserServiceCompat {
|
|||||||
.startWhenPrepared(true)
|
.startWhenPrepared(true)
|
||||||
.shouldStream(true)
|
.shouldStream(true)
|
||||||
.getIntent());
|
.getIntent());
|
||||||
writePlaybackPreferencesNoMediaPlaying();
|
PlaybackPreferences.writeNoMediaPlaying();
|
||||||
stateManager.stopService();
|
stateManager.stopService();
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -910,7 +910,7 @@ public class PlaybackService extends MediaBrowserServiceCompat {
|
|||||||
Log.d(TAG, "Playback ended");
|
Log.d(TAG, "Playback ended");
|
||||||
if (stopPlaying) {
|
if (stopPlaying) {
|
||||||
taskManager.cancelPositionSaver();
|
taskManager.cancelPositionSaver();
|
||||||
writePlaybackPreferencesNoMediaPlaying();
|
PlaybackPreferences.writeNoMediaPlaying();
|
||||||
if (!isCasting) {
|
if (!isCasting) {
|
||||||
stateManager.stopForeground(true);
|
stateManager.stopForeground(true);
|
||||||
}
|
}
|
||||||
@ -1016,22 +1016,6 @@ public class PlaybackService extends MediaBrowserServiceCompat {
|
|||||||
EventBus.getDefault().post(new MessageEvent(getString(R.string.sleep_timer_disabled_label)));
|
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) {
|
private int getCurrentPlayerStatusAsInt(PlayerStatus playerStatus) {
|
||||||
int playerStatusAsInt;
|
int playerStatusAsInt;
|
||||||
switch (playerStatus) {
|
switch (playerStatus) {
|
||||||
|
@ -108,23 +108,11 @@ public class DBWriter {
|
|||||||
adapter.setMedia(media);
|
adapter.setMedia(media);
|
||||||
adapter.close();
|
adapter.close();
|
||||||
|
|
||||||
// If media is currently being played, change playback
|
if (media.getId() == PlaybackPreferences.getCurrentlyPlayingFeedMediaId()) {
|
||||||
// type to 'stream' and shutdown playback service
|
PlaybackPreferences.writeNoMediaPlaying();
|
||||||
SharedPreferences prefs = PreferenceManager
|
IntentUtils.sendLocalBroadcast(context, PlaybackService.ACTION_SHUTDOWN_PLAYBACK_SERVICE);
|
||||||
.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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Gpodder: queue delete action for synchronization
|
// Gpodder: queue delete action for synchronization
|
||||||
if(GpodnetPreferences.loggedIn()) {
|
if(GpodnetPreferences.loggedIn()) {
|
||||||
FeedItem item = media.getItem();
|
FeedItem item = media.getItem();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user