diff options
author | Martin Fietz <marf@hadiko-99-4.hadiko.uni-karlsruhe.de> | 2015-04-22 19:11:42 +0200 |
---|---|---|
committer | Martin Fietz <Martin.Fietz@gmail.com> | 2015-05-19 11:58:37 +0200 |
commit | e68ca0529bf996ef961fe85009092e9b27e1f699 (patch) | |
tree | 9a030b68d380dbf81a4b4359a0fb82cf9dc2f310 | |
parent | 3301342a761f614370a15afabeaf28a0b364913a (diff) | |
download | AntennaPod-e68ca0529bf996ef961fe85009092e9b27e1f699.zip |
Mark as unplayed option
Users can mark feed items as unplayed from feed item fragment and the queue
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 @@ -8,6 +8,16 @@ android:title="@string/move_to_top_label" /> <item + android:id="@+id/mark_read_item" + android:menuCategory="container" + android:title="@string/mark_read_label" /> + + <item + android:id="@+id/mark_unread_item" + android:menuCategory="container" + android:title="@string/mark_unread_label" /> + + <item android:id="@+id/remove_from_queue_item" android:menuCategory="container" android:title="@string/remove_from_queue_label" /> |