summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/src/main/java/de/danoeh/antennapod/adapter/NavListAdapter.java2
-rw-r--r--app/src/main/java/de/danoeh/antennapod/fragment/AllEpisodesFragment.java56
-rw-r--r--app/src/main/java/de/danoeh/antennapod/fragment/ItemlistFragment.java7
-rw-r--r--app/src/main/java/de/danoeh/antennapod/fragment/QueueFragment.java4
-rw-r--r--app/src/main/res/menu/allepisodes_context.xml56
-rw-r--r--app/src/main/res/menu/feeditem_options.xml17
-rw-r--r--app/src/main/res/menu/feeditemlist_context.xml5
-rw-r--r--app/src/main/res/menu/queue_context.xml21
-rw-r--r--core/src/main/java/de/danoeh/antennapod/core/service/download/DownloadService.java6
-rw-r--r--core/src/main/java/de/danoeh/antennapod/core/service/playback/PlaybackServiceMediaPlayer.java2
-rw-r--r--core/src/main/java/de/danoeh/antennapod/core/storage/DBReader.java2
-rw-r--r--core/src/main/java/de/danoeh/antennapod/core/storage/DBTasks.java1
-rw-r--r--core/src/main/java/de/danoeh/antennapod/core/storage/PodDBAdapter.java9
13 files changed, 171 insertions, 17 deletions
diff --git a/app/src/main/java/de/danoeh/antennapod/adapter/NavListAdapter.java b/app/src/main/java/de/danoeh/antennapod/adapter/NavListAdapter.java
index 818f662cd..ae81779e4 100644
--- a/app/src/main/java/de/danoeh/antennapod/adapter/NavListAdapter.java
+++ b/app/src/main/java/de/danoeh/antennapod/adapter/NavListAdapter.java
@@ -277,7 +277,7 @@ public class NavListAdapter extends BaseAdapter
holder.count.setText(String.valueOf(feedUnreadItems));
holder.count.setTypeface(holder.title.getTypeface());
} else {
- holder.count.setVisibility(View.GONE);
+ holder.count.setVisibility(View.INVISIBLE);
}
return convertView;
}
diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/AllEpisodesFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/AllEpisodesFragment.java
index 8a5cad137..ff5485251 100644
--- a/app/src/main/java/de/danoeh/antennapod/fragment/AllEpisodesFragment.java
+++ b/app/src/main/java/de/danoeh/antennapod/fragment/AllEpisodesFragment.java
@@ -10,6 +10,8 @@ import android.os.Handler;
import android.support.v4.app.Fragment;
import android.support.v4.view.MenuItemCompat;
import android.support.v7.widget.SearchView;
+import android.util.Log;
+import android.view.ContextMenu;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
@@ -41,8 +43,10 @@ import de.danoeh.antennapod.core.service.download.Downloader;
import de.danoeh.antennapod.core.storage.DBReader;
import de.danoeh.antennapod.core.storage.DBTasks;
import de.danoeh.antennapod.core.storage.DBWriter;
+import de.danoeh.antennapod.core.storage.DownloadRequestException;
import de.danoeh.antennapod.core.storage.DownloadRequester;
import de.danoeh.antennapod.core.util.LongList;
+import de.danoeh.antennapod.menuhandler.FeedItemMenuHandler;
import de.danoeh.antennapod.menuhandler.MenuItemUtils;
/**
@@ -67,6 +71,7 @@ public class AllEpisodesFragment extends Fragment {
private AllEpisodesListAdapter listAdapter;
private TextView txtvEmpty;
private ProgressBar progLoading;
+ private ContextMenu contextMenu;
private List<FeedItem> episodes;
private LongList queuedItemsIds;
@@ -293,6 +298,8 @@ public class AllEpisodesFragment extends Fragment {
}
});
+ registerForContextMenu(listView);
+
if (!itemsLoaded) {
progLoading.setVisibility(View.VISIBLE);
txtvEmpty.setVisibility(View.GONE);
@@ -307,6 +314,55 @@ public class AllEpisodesFragment extends Fragment {
return root;
}
+ private final FeedItemMenuHandler.MenuInterface contextMenuInterface = new FeedItemMenuHandler.MenuInterface() {
+ @Override
+ public void setItemVisibility(int id, boolean visible) {
+ if(contextMenu == null) {
+ return;
+ }
+ MenuItem item = contextMenu.findItem(id);
+ if (item != null) {
+ item.setVisible(visible);
+ }
+ }
+ };
+
+ @Override
+ public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
+ super.onCreateContextMenu(menu, v, menuInfo);
+ AdapterView.AdapterContextMenuInfo adapterInfo = (AdapterView.AdapterContextMenuInfo) menuInfo;
+ FeedItem item = itemAccess.getItem(adapterInfo.position);
+
+ MenuInflater inflater = getActivity().getMenuInflater();
+ inflater.inflate(R.menu.allepisodes_context, menu);
+
+ if (item != null) {
+ menu.setHeaderTitle(item.getTitle());
+ }
+
+ contextMenu = menu;
+ FeedItemMenuHandler.onPrepareMenu(contextMenuInterface, item, true, queuedItemsIds);
+ }
+
+ @Override
+ public boolean onContextItemSelected(MenuItem item) {
+ AdapterView.AdapterContextMenuInfo menuInfo = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();
+ FeedItem selectedItem = itemAccess.getItem(menuInfo.position);
+
+ if (selectedItem == null) {
+ Log.i(TAG, "Selected item at position " + menuInfo.position + " was null, ignoring selection");
+ return super.onContextItemSelected(item);
+ }
+
+ try {
+ return FeedItemMenuHandler.onMenuItemClicked(getActivity(), item.getItemId(), selectedItem);
+ } catch (DownloadRequestException e) {
+ e.printStackTrace();
+ Toast.makeText(getActivity(), e.getMessage(), Toast.LENGTH_LONG).show();
+ return true;
+ }
+ }
+
private void onFragmentLoaded() {
if (listAdapter == null) {
listAdapter = new AllEpisodesListAdapter(activity.get(), itemAccess,
diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/ItemlistFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/ItemlistFragment.java
index 463d06376..07ae81100 100644
--- a/app/src/main/java/de/danoeh/antennapod/fragment/ItemlistFragment.java
+++ b/app/src/main/java/de/danoeh/antennapod/fragment/ItemlistFragment.java
@@ -26,6 +26,7 @@ import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.ListAdapter;
import android.widget.ListView;
+import android.widget.RelativeLayout;
import android.widget.TextView;
import com.joanzapata.android.iconify.Iconify;
@@ -301,7 +302,7 @@ public class ItemlistFragment extends ListFragment {
}
contextMenu = menu;
- FeedItemMenuHandler.onPrepareMenu(contextMenuInterface, item, false, queuedItemsIds);
+ FeedItemMenuHandler.onPrepareMenu(contextMenuInterface, item, true, queuedItemsIds);
}
@Override
@@ -428,6 +429,10 @@ public class ItemlistFragment extends ListFragment {
if(feed.getItemFilter() != null) {
FeedItemFilter filter = feed.getItemFilter();
if(filter.getValues().length > 0) {
+ if(feed.hasLastUpdateFailed()) {
+ RelativeLayout.LayoutParams p = (RelativeLayout.LayoutParams) txtvInformation.getLayoutParams();
+ p.addRule(RelativeLayout.BELOW, R.id.txtvFailure);
+ }
txtvInformation.setText("{fa-info-circle} " + this.getString(R.string.filtered_label));
Iconify.addIcons(txtvInformation);
txtvInformation.setVisibility(View.VISIBLE);
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 0ccca3e55..d82c7b8f7 100644
--- a/app/src/main/java/de/danoeh/antennapod/fragment/QueueFragment.java
+++ b/app/src/main/java/de/danoeh/antennapod/fragment/QueueFragment.java
@@ -329,7 +329,7 @@ public class QueueFragment extends Fragment {
for(FeedItem queueItem : queue) {
queueIds.add(queueItem.getId());
}
- FeedItemMenuHandler.onPrepareMenu(contextMenuInterface, item, false, queueIds);
+ FeedItemMenuHandler.onPrepareMenu(contextMenuInterface, item, true, queueIds);
}
@Override
@@ -352,7 +352,6 @@ public class QueueFragment extends Fragment {
}
-
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
super.onCreateView(inflater, container, savedInstanceState);
@@ -435,7 +434,6 @@ public class QueueFragment extends Fragment {
});
-
registerForContextMenu(listView);
if (!itemsLoaded) {
diff --git a/app/src/main/res/menu/allepisodes_context.xml b/app/src/main/res/menu/allepisodes_context.xml
new file mode 100644
index 000000000..f89ad5065
--- /dev/null
+++ b/app/src/main/res/menu/allepisodes_context.xml
@@ -0,0 +1,56 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<menu xmlns:android="http://schemas.android.com/apk/res/android">
+
+ <item
+ android:id="@id/skip_episode_item"
+ android:menuCategory="container"
+ android:title="@string/skip_episode_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/add_to_queue_item"
+ android:menuCategory="container"
+ android:title="@string/add_to_queue_label" />
+ <item
+ android:id="@+id/remove_from_queue_item"
+ android:menuCategory="container"
+ android:title="@string/remove_from_queue_label" />
+
+ <item
+ android:id="@+id/reset_position"
+ android:menuCategory="container"
+ android:title="@string/reset_position" />
+
+ <item
+ android:id="@+id/activate_auto_download"
+ android:menuCategory="container"
+ android:title="@string/activate_auto_download" />
+ <item
+ android:id="@+id/deactivate_auto_download"
+ android:menuCategory="container"
+ android:title="@string/deactivate_auto_download" />
+
+ <item
+ android:id="@+id/share_link_item"
+ android:menuCategory="container"
+ android:title="@string/share_link_label" />
+ <item
+ android:id="@+id/visit_website_item"
+ android:menuCategory="container"
+ android:title="@string/visit_website_label" />
+
+ <item
+ android:id="@+id/support_item"
+ android:menuCategory="container"
+ android:title="@string/support_label" />
+
+</menu> \ No newline at end of file
diff --git a/app/src/main/res/menu/feeditem_options.xml b/app/src/main/res/menu/feeditem_options.xml
index bcffd019a..f8e9b9c75 100644
--- a/app/src/main/res/menu/feeditem_options.xml
+++ b/app/src/main/res/menu/feeditem_options.xml
@@ -31,6 +31,23 @@
</item>
<item
+ android:id="@+id/reset_position"
+ custom:showAsAction="collapseActionView"
+ android:title="@string/reset_position">
+ </item>
+
+ <item
+ android:id="@+id/activate_auto_download"
+ custom:showAsAction="collapseActionView"
+ android:title="@string/activate_auto_download">
+ </item>
+ <item
+ android:id="@+id/deactivate_auto_download"
+ custom:showAsAction="collapseActionView"
+ android:title="@string/deactivate_auto_download">
+ </item>
+
+ <item
android:id="@+id/share_link_item"
custom:showAsAction="collapseActionView"
android:title="@string/share_link_label">
diff --git a/app/src/main/res/menu/feeditemlist_context.xml b/app/src/main/res/menu/feeditemlist_context.xml
index 69b2c6a7a..f89ad5065 100644
--- a/app/src/main/res/menu/feeditemlist_context.xml
+++ b/app/src/main/res/menu/feeditemlist_context.xml
@@ -3,6 +3,11 @@
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item
+ android:id="@id/skip_episode_item"
+ android:menuCategory="container"
+ android:title="@string/skip_episode_label" />
+
+ <item
android:id="@+id/mark_read_item"
android:menuCategory="container"
android:title="@string/mark_read_label" />
diff --git a/app/src/main/res/menu/queue_context.xml b/app/src/main/res/menu/queue_context.xml
index 7c9f8f928..6ab2daabf 100644
--- a/app/src/main/res/menu/queue_context.xml
+++ b/app/src/main/res/menu/queue_context.xml
@@ -8,12 +8,17 @@
android:title="@string/move_to_top_label" />
<item
+ android:id="@+id/move_to_bottom_item"
+ android:menuCategory="container"
+ android:title="@string/move_to_bottom_label" />
+
+ <item
android:id="@+id/mark_read_item"
android:menuCategory="container"
android:title="@string/mark_read_label" />
<item
- android:id="@+id/mark_unread_item_item"
+ android:id="@+id/mark_unread_item"
android:menuCategory="container"
android:title="@string/mark_unread_label" />
@@ -38,8 +43,18 @@
android:title="@string/deactivate_auto_download" />
<item
- android:id="@+id/move_to_bottom_item"
+ android:id="@+id/share_link_item"
android:menuCategory="container"
- android:title="@string/move_to_bottom_label" />
+ android:title="@string/share_link_label" />
+ <item
+ android:id="@+id/visit_website_item"
+ android:menuCategory="container"
+ android:title="@string/visit_website_label" />
+
+ <item
+ android:id="@+id/support_item"
+ android:menuCategory="container"
+ android:title="@string/support_label" />
+
</menu> \ No newline at end of file
diff --git a/core/src/main/java/de/danoeh/antennapod/core/service/download/DownloadService.java b/core/src/main/java/de/danoeh/antennapod/core/service/download/DownloadService.java
index 4e40fbe1e..e7b226eca 100644
--- a/core/src/main/java/de/danoeh/antennapod/core/service/download/DownloadService.java
+++ b/core/src/main/java/de/danoeh/antennapod/core/service/download/DownloadService.java
@@ -1060,9 +1060,11 @@ public class DownloadService extends Service {
@Override
public void run() {
- if (request.isDeleteOnFailure()) {
+ if(request.getFeedfileType() == Feed.FEEDFILETYPE_FEED) {
+ DBWriter.setFeedLastUpdateFailed(DownloadService.this, request.getFeedfileId(), true);
+ } else if (request.isDeleteOnFailure()) {
Log.d(TAG, "Ignoring failed download, deleteOnFailure=true");
- } else {
+ } else {
File dest = new File(request.getDestination());
if (dest.exists() && request.getFeedfileType() == FeedMedia.FEEDFILETYPE_FEEDMEDIA) {
Log.d(TAG, "File has been partially downloaded. Writing file url");
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 39e609a0d..243ee78e4 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
@@ -193,7 +193,7 @@ public class PlaybackServiceMediaPlayer {
if(oldMedia.hasAlmostEnded()) {
Log.d(TAG, "smart mark as read");
FeedItem item = oldMedia.getItem();
- // DBWriter.markItemRead(context, item, true, false);
+ DBWriter.markItemRead(context, item, true, false);
DBWriter.removeQueueItem(context, item, false);
DBWriter.addItemToPlaybackHistory(context, oldMedia);
if (UserPreferences.isAutoDelete()) {
diff --git a/core/src/main/java/de/danoeh/antennapod/core/storage/DBReader.java b/core/src/main/java/de/danoeh/antennapod/core/storage/DBReader.java
index 99ae9a113..f407b65fd 100644
--- a/core/src/main/java/de/danoeh/antennapod/core/storage/DBReader.java
+++ b/core/src/main/java/de/danoeh/antennapod/core/storage/DBReader.java
@@ -319,7 +319,7 @@ public final class DBReader {
cursor.getInt(PodDBAdapter.IDX_FEED_SEL_STD_IS_PAGED) > 0,
cursor.getString(PodDBAdapter.IDX_FEED_SEL_STD_NEXT_PAGE_LINK),
cursor.getString(cursor.getColumnIndex(PodDBAdapter.KEY_HIDE)),
- cursor.getInt(PodDBAdapter.IDX_FEED_SEL_STD_LAST_UPDATE_FAILED) > 0
+ cursor.getInt(cursor.getColumnIndex(PodDBAdapter.KEY_LAST_UPDATE_FAILED)) > 0
);
if (image != null) {
diff --git a/core/src/main/java/de/danoeh/antennapod/core/storage/DBTasks.java b/core/src/main/java/de/danoeh/antennapod/core/storage/DBTasks.java
index c5b701ab3..e570ee709 100644
--- a/core/src/main/java/de/danoeh/antennapod/core/storage/DBTasks.java
+++ b/core/src/main/java/de/danoeh/antennapod/core/storage/DBTasks.java
@@ -302,6 +302,7 @@ public final class DBTasks {
*/
public static void refreshFeed(Context context, Feed feed)
throws DownloadRequestException {
+ Log.d(TAG, "id " + feed.getId());
refreshFeed(context, feed, false);
}
diff --git a/core/src/main/java/de/danoeh/antennapod/core/storage/PodDBAdapter.java b/core/src/main/java/de/danoeh/antennapod/core/storage/PodDBAdapter.java
index c087cb4b5..a1c8d96f0 100644
--- a/core/src/main/java/de/danoeh/antennapod/core/storage/PodDBAdapter.java
+++ b/core/src/main/java/de/danoeh/antennapod/core/storage/PodDBAdapter.java
@@ -302,8 +302,6 @@ public class PodDBAdapter {
public static final int IDX_FEED_SEL_STD_NEXT_PAGE_LINK = 17;
public static final int IDX_FEED_SEL_PREFERENCES_USERNAME = 18;
public static final int IDX_FEED_SEL_PREFERENCES_PASSWORD = 19;
- public static final int IDX_FEED_SEL_STD_LAST_UPDATE_FAILED = 20;
-
/**
* Select all columns from the feeditems-table except description and
@@ -810,9 +808,10 @@ public class PodDBAdapter {
}
public void setFeedLastUpdateFailed(long feedId, boolean failed) {
- ContentValues values = new ContentValues();
- values.put(KEY_LAST_UPDATE_FAILED, failed ? 1 : 0);
- db.update(TABLE_NAME_FEEDS, values, KEY_ID + "=?", new String[]{String.valueOf(feedId)});
+ final String sql = "UPDATE " + TABLE_NAME_FEEDS
+ + " SET " + KEY_LAST_UPDATE_FAILED+ "=" + (failed ? "1" : "0")
+ + " WHERE " + KEY_ID + "="+ feedId;
+ db.execSQL(sql);
}
/**