From e68ca0529bf996ef961fe85009092e9b27e1f699 Mon Sep 17 00:00:00 2001 From: Martin Fietz Date: Wed, 22 Apr 2015 19:11:42 +0200 Subject: Mark as unplayed option Users can mark feed items as unplayed from feed item fragment and the queue --- .../danoeh/antennapod/fragment/QueueFragment.java | 34 ++++++++++++++++++++++ .../menuhandler/FeedItemMenuHandler.java | 4 +-- app/src/main/res/menu/queue_context.xml | 10 +++++++ 3 files changed, 45 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/QueueFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/QueueFragment.java index 182d57771..259d4a574 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/QueueFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/QueueFragment.java @@ -38,6 +38,8 @@ import de.danoeh.antennapod.core.feed.Feed; import de.danoeh.antennapod.core.feed.FeedItem; import de.danoeh.antennapod.core.feed.FeedMedia; import de.danoeh.antennapod.core.feed.QueueEvent; +import de.danoeh.antennapod.core.gpoddernet.model.GpodnetEpisodeAction; +import de.danoeh.antennapod.core.preferences.GpodnetPreferences; import de.danoeh.antennapod.core.preferences.UserPreferences; import de.danoeh.antennapod.core.service.download.DownloadService; import de.danoeh.antennapod.core.service.download.Downloader; @@ -307,6 +309,11 @@ public class QueueFragment extends Fragment { menu.findItem(R.id.move_to_top_item).setEnabled(!queue.isEmpty() && queue.get(0) != item); menu.findItem(R.id.move_to_bottom_item).setEnabled(!queue.isEmpty() && queue.get(queue.size() - 1) != item); + if(item.isRead()) { + menu.findItem(R.id.mark_read_item).setVisible(false); + } else { + menu.findItem(R.id.mark_unread_item).setVisible(false); + } } @Override @@ -323,6 +330,33 @@ public class QueueFragment extends Fragment { case R.id.move_to_top_item: DBWriter.moveQueueItemToTop(getActivity(), selectedItem.getId(), true); return true; + case R.id.mark_read_item: + DBWriter.markItemRead(getActivity(), selectedItem, true, false); + selectedItem.setRead(true); + if(GpodnetPreferences.loggedIn()) { + FeedMedia media = selectedItem.getMedia(); + GpodnetEpisodeAction actionPlay = new GpodnetEpisodeAction.Builder(selectedItem, GpodnetEpisodeAction.Action.PLAY) + .currentDeviceId() + .currentTimestamp() + .started(media.getDuration() / 1000) + .position(media.getDuration() / 1000) + .total(media.getDuration() / 1000) + .build(); + GpodnetPreferences.enqueueEpisodeAction(actionPlay); + } + return true; + case R.id.mark_unread_item: + DBWriter.markItemRead(getActivity(), selectedItem, false, false); + selectedItem.setRead(false); + if(GpodnetPreferences.loggedIn()) { + GpodnetEpisodeAction actionNew = new GpodnetEpisodeAction.Builder(selectedItem, GpodnetEpisodeAction.Action.NEW) + .currentDeviceId() + .currentTimestamp() + .build(); + GpodnetPreferences.enqueueEpisodeAction(actionNew); + } + startItemLoader(); + return true; case R.id.move_to_bottom_item: DBWriter.moveQueueItemToBottom(getActivity(), selectedItem.getId(), true); return true; diff --git a/app/src/main/java/de/danoeh/antennapod/menuhandler/FeedItemMenuHandler.java b/app/src/main/java/de/danoeh/antennapod/menuhandler/FeedItemMenuHandler.java index 2b1770ee1..453f984e8 100644 --- a/app/src/main/java/de/danoeh/antennapod/menuhandler/FeedItemMenuHandler.java +++ b/app/src/main/java/de/danoeh/antennapod/menuhandler/FeedItemMenuHandler.java @@ -5,7 +5,6 @@ import android.content.Intent; import android.net.Uri; import de.danoeh.antennapod.R; -import de.danoeh.antennapod.core.BuildConfig; import de.danoeh.antennapod.core.feed.FeedItem; import de.danoeh.antennapod.core.feed.FeedMedia; import de.danoeh.antennapod.core.gpoddernet.model.GpodnetEpisodeAction; @@ -100,8 +99,7 @@ public class FeedItemMenuHandler { mi.setItemVisibility(R.id.share_link_item, false); } - if (!BuildConfig.DEBUG - || !(state == FeedItem.State.IN_PROGRESS || state == FeedItem.State.READ)) { + if (!(state == FeedItem.State.IN_PROGRESS || state == FeedItem.State.READ)) { mi.setItemVisibility(R.id.mark_unread_item, false); } if (!(state == FeedItem.State.NEW || state == FeedItem.State.IN_PROGRESS)) { diff --git a/app/src/main/res/menu/queue_context.xml b/app/src/main/res/menu/queue_context.xml index 327600038..d20e57cc9 100644 --- a/app/src/main/res/menu/queue_context.xml +++ b/app/src/main/res/menu/queue_context.xml @@ -7,6 +7,16 @@ android:menuCategory="container" android:title="@string/move_to_top_label" /> + + + +