mirror of
https://github.com/AntennaPod/AntennaPod.git
synced 2025-12-01 12:31:45 +00:00
Added menu item to update a single feed
This commit is contained in:
@ -1,10 +1,11 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
|
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
|
||||||
<item android:id="@+id/mark_all_read_item" android:title="@string/mark_all_read_label" android:showAsAction="ifRoom|withText"></item><item android:id="@+id/show_info_item" android:icon="@drawable/action_about" android:title="@string/show_info_label" android:showAsAction="always"></item><item android:id="@+id/remove_item" android:title="@string/remove_feed_label" android:icon="@drawable/content_discard" android:visible="true" android:showAsAction="collapseActionView"></item>
|
<item android:id="@+id/refresh_item" android:title="@string/refresh_label" android:showAsAction="collapseActionView"></item><item android:id="@+id/mark_all_read_item" android:title="@string/mark_all_read_label" android:showAsAction="ifRoom|withText"></item><item android:id="@+id/show_info_item" android:icon="@drawable/action_about" android:title="@string/show_info_label" android:showAsAction="always"></item><item android:id="@+id/remove_item" android:title="@string/remove_feed_label" android:icon="@drawable/content_discard" android:visible="true" android:showAsAction="collapseActionView"></item>
|
||||||
<item android:id="@+id/visit_website_item" android:showAsAction="ifRoom|collapseActionView" android:icon="@drawable/location_web_site" android:title="@string/visit_website_label" android:visible="true"></item>
|
<item android:id="@+id/visit_website_item" android:showAsAction="ifRoom|collapseActionView" android:icon="@drawable/location_web_site" android:title="@string/visit_website_label" android:visible="true"></item>
|
||||||
<item android:id="@+id/support_item" android:title="@string/support_label" android:showAsAction="collapseActionView" android:visible="false"></item>
|
<item android:id="@+id/support_item" android:title="@string/support_label" android:showAsAction="collapseActionView" android:visible="false"></item>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</menu>
|
</menu>
|
||||||
@ -8,7 +8,7 @@
|
|||||||
</item>
|
</item>
|
||||||
<item
|
<item
|
||||||
android:id="@+id/all_feed_refresh"
|
android:id="@+id/all_feed_refresh"
|
||||||
android:title="Refresh"
|
android:title="@string/refresh_label"
|
||||||
android:icon="@drawable/navigation_refresh"
|
android:icon="@drawable/navigation_refresh"
|
||||||
android:showAsAction="ifRoom|collapseActionView">
|
android:showAsAction="ifRoom|collapseActionView">
|
||||||
</item>
|
</item>
|
||||||
|
|||||||
@ -92,5 +92,6 @@
|
|||||||
<string name="pref_mobileUpdate_title">Mobile Updates</string>
|
<string name="pref_mobileUpdate_title">Mobile Updates</string>
|
||||||
<string name="pref_mobileUpdate_sum">Allow updates over the mobile data connection</string>
|
<string name="pref_mobileUpdate_sum">Allow updates over the mobile data connection</string>
|
||||||
<string name="download_report_title">All downloads completed</string>
|
<string name="download_report_title">All downloads completed</string>
|
||||||
|
<string name="refresh_label">Refresh</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
@ -12,6 +12,7 @@ import com.actionbarsherlock.app.SherlockFragmentActivity;
|
|||||||
import com.actionbarsherlock.view.Menu;
|
import com.actionbarsherlock.view.Menu;
|
||||||
import com.actionbarsherlock.view.MenuInflater;
|
import com.actionbarsherlock.view.MenuInflater;
|
||||||
import com.actionbarsherlock.view.MenuItem;
|
import com.actionbarsherlock.view.MenuItem;
|
||||||
|
import com.actionbarsherlock.view.Window;
|
||||||
|
|
||||||
import de.podfetcher.R;
|
import de.podfetcher.R;
|
||||||
import de.podfetcher.asynctask.FeedRemover;
|
import de.podfetcher.asynctask.FeedRemover;
|
||||||
@ -34,6 +35,8 @@ public class FeedItemlistActivity extends SherlockFragmentActivity {
|
|||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
|
||||||
|
|
||||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||||
setContentView(R.layout.feeditemlist_activity);
|
setContentView(R.layout.feeditemlist_activity);
|
||||||
|
|
||||||
|
|||||||
@ -172,10 +172,14 @@ public class FeedManager {
|
|||||||
public void refreshAllFeeds(Context context) {
|
public void refreshAllFeeds(Context context) {
|
||||||
Log.d(TAG, "Refreshing all feeds.");
|
Log.d(TAG, "Refreshing all feeds.");
|
||||||
for (Feed feed : feeds) {
|
for (Feed feed : feeds) {
|
||||||
|
refreshFeed(context, feed);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void refreshFeed(Context context, Feed feed) {
|
||||||
requester.downloadFeed(context, new Feed(feed.getDownload_url(),
|
requester.downloadFeed(context, new Feed(feed.getDownload_url(),
|
||||||
new Date()));
|
new Date()));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public long addDownloadStatus(Context context, DownloadStatus status) {
|
public long addDownloadStatus(Context context, DownloadStatus status) {
|
||||||
PodDBAdapter adapter = new PodDBAdapter(context);
|
PodDBAdapter adapter = new PodDBAdapter(context);
|
||||||
|
|||||||
@ -21,6 +21,7 @@ import com.actionbarsherlock.view.MenuItem;
|
|||||||
import de.podfetcher.R;
|
import de.podfetcher.R;
|
||||||
import de.podfetcher.activity.ItemviewActivity;
|
import de.podfetcher.activity.ItemviewActivity;
|
||||||
import de.podfetcher.adapter.FeedItemlistAdapter;
|
import de.podfetcher.adapter.FeedItemlistAdapter;
|
||||||
|
import de.podfetcher.feed.Feed;
|
||||||
import de.podfetcher.feed.FeedItem;
|
import de.podfetcher.feed.FeedItem;
|
||||||
import de.podfetcher.feed.FeedManager;
|
import de.podfetcher.feed.FeedManager;
|
||||||
import de.podfetcher.service.DownloadService;
|
import de.podfetcher.service.DownloadService;
|
||||||
@ -31,7 +32,7 @@ import de.podfetcher.util.FeedItemMenuHandler;
|
|||||||
public class ItemlistFragment extends SherlockListFragment implements
|
public class ItemlistFragment extends SherlockListFragment implements
|
||||||
ActionMode.Callback {
|
ActionMode.Callback {
|
||||||
|
|
||||||
private static final String TAG = "FeedItemlistFragment";
|
private static final String TAG = "ItemlistFragment";
|
||||||
public static final String EXTRA_SELECTED_FEEDITEM = "extra.de.podfetcher.activity.selected_feeditem";
|
public static final String EXTRA_SELECTED_FEEDITEM = "extra.de.podfetcher.activity.selected_feeditem";
|
||||||
public static final String ARGUMENT_FEED_ID = "argument.de.podfetcher.feed_id";
|
public static final String ARGUMENT_FEED_ID = "argument.de.podfetcher.feed_id";
|
||||||
protected FeedItemlistAdapter fila;
|
protected FeedItemlistAdapter fila;
|
||||||
@ -40,6 +41,11 @@ public class ItemlistFragment extends SherlockListFragment implements
|
|||||||
|
|
||||||
/** The feed which the activity displays */
|
/** The feed which the activity displays */
|
||||||
protected ArrayList<FeedItem> items;
|
protected ArrayList<FeedItem> items;
|
||||||
|
/**
|
||||||
|
* This is only not null if the fragment displays the items of a specific
|
||||||
|
* feed
|
||||||
|
*/
|
||||||
|
protected Feed feed;
|
||||||
|
|
||||||
protected FeedItem selectedItem;
|
protected FeedItem selectedItem;
|
||||||
protected ActionMode mActionMode;
|
protected ActionMode mActionMode;
|
||||||
@ -80,7 +86,8 @@ public class ItemlistFragment extends SherlockListFragment implements
|
|||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
if (items == null) {
|
if (items == null) {
|
||||||
long feedId = getArguments().getLong(ARGUMENT_FEED_ID);
|
long feedId = getArguments().getLong(ARGUMENT_FEED_ID);
|
||||||
items = FeedManager.getInstance().getFeed(feedId).getItems();
|
feed = FeedManager.getInstance().getFeed(feedId);
|
||||||
|
items = feed.getItems();
|
||||||
}
|
}
|
||||||
fila = new FeedItemlistAdapter(getActivity(), 0, items,
|
fila = new FeedItemlistAdapter(getActivity(), 0, items,
|
||||||
onButActionClicked, showFeedtitle);
|
onButActionClicked, showFeedtitle);
|
||||||
@ -100,6 +107,7 @@ public class ItemlistFragment extends SherlockListFragment implements
|
|||||||
public void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
fila.notifyDataSetChanged();
|
fila.notifyDataSetChanged();
|
||||||
|
updateProgressBarVisibility();
|
||||||
IntentFilter filter = new IntentFilter();
|
IntentFilter filter = new IntentFilter();
|
||||||
filter.addAction(DownloadService.ACTION_DOWNLOAD_HANDLED);
|
filter.addAction(DownloadService.ACTION_DOWNLOAD_HANDLED);
|
||||||
filter.addAction(DownloadRequester.ACTION_DOWNLOAD_QUEUED);
|
filter.addAction(DownloadRequester.ACTION_DOWNLOAD_QUEUED);
|
||||||
@ -123,9 +131,24 @@ public class ItemlistFragment extends SherlockListFragment implements
|
|||||||
public void onReceive(Context context, Intent intent) {
|
public void onReceive(Context context, Intent intent) {
|
||||||
Log.d(TAG, "Received contentUpdate Intent.");
|
Log.d(TAG, "Received contentUpdate Intent.");
|
||||||
fila.notifyDataSetChanged();
|
fila.notifyDataSetChanged();
|
||||||
|
updateProgressBarVisibility();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
private void updateProgressBarVisibility() {
|
||||||
|
if (feed != null) {
|
||||||
|
if (DownloadService.isRunning
|
||||||
|
&& DownloadRequester.getInstance().isDownloadingFile(feed)) {
|
||||||
|
getSherlockActivity()
|
||||||
|
.setSupportProgressBarIndeterminateVisibility(true);
|
||||||
|
} else {
|
||||||
|
getSherlockActivity()
|
||||||
|
.setSupportProgressBarIndeterminateVisibility(false);
|
||||||
|
}
|
||||||
|
getSherlockActivity().invalidateOptionsMenu();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private final OnClickListener onButActionClicked = new OnClickListener() {
|
private final OnClickListener onButActionClicked = new OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
|
|||||||
@ -11,6 +11,7 @@ import de.podfetcher.R;
|
|||||||
|
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.database.Cursor;
|
import android.database.Cursor;
|
||||||
|
import android.annotation.SuppressLint;
|
||||||
import android.app.DownloadManager;
|
import android.app.DownloadManager;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
@ -54,6 +55,7 @@ public class DownloadRequester {
|
|||||||
return downloader;
|
return downloader;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressLint("NewApi")
|
||||||
private long download(Context context, FeedFile item, File dest) {
|
private long download(Context context, FeedFile item, File dest) {
|
||||||
if (dest.exists()) {
|
if (dest.exists()) {
|
||||||
Log.d(TAG, "File already exists. Deleting !");
|
Log.d(TAG, "File already exists. Deleting !");
|
||||||
@ -158,6 +160,16 @@ public class DownloadRequester {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Checks if feedfile is in the downloads list */
|
||||||
|
public boolean isDownloadingFile(FeedFile item) {
|
||||||
|
for (FeedFile f : downloads) {
|
||||||
|
if (f.getDownload_url().equals(item.getDownload_url())) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/** Remove an object from the downloads-list of the requester. */
|
/** Remove an object from the downloads-list of the requester. */
|
||||||
public void removeDownload(FeedFile f) {
|
public void removeDownload(FeedFile f) {
|
||||||
downloads.remove(f);
|
downloads.remove(f);
|
||||||
|
|||||||
@ -3,6 +3,7 @@ package de.podfetcher.util;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
import com.actionbarsherlock.view.ActionMode;
|
import com.actionbarsherlock.view.ActionMode;
|
||||||
import com.actionbarsherlock.view.Menu;
|
import com.actionbarsherlock.view.Menu;
|
||||||
@ -14,9 +15,12 @@ import de.podfetcher.activity.FeedInfoActivity;
|
|||||||
import de.podfetcher.feed.Feed;
|
import de.podfetcher.feed.Feed;
|
||||||
import de.podfetcher.feed.FeedItem;
|
import de.podfetcher.feed.FeedItem;
|
||||||
import de.podfetcher.feed.FeedManager;
|
import de.podfetcher.feed.FeedManager;
|
||||||
|
import de.podfetcher.service.DownloadService;
|
||||||
|
import de.podfetcher.storage.DownloadRequester;
|
||||||
|
|
||||||
/** Handles interactions with the FeedItemMenu. */
|
/** Handles interactions with the FeedItemMenu. */
|
||||||
public class FeedMenuHandler {
|
public class FeedMenuHandler {
|
||||||
|
private static final String TAG = "FeedMenuHandler";
|
||||||
|
|
||||||
public static boolean onCreateOptionsMenu(MenuInflater inflater, Menu menu) {
|
public static boolean onCreateOptionsMenu(MenuInflater inflater, Menu menu) {
|
||||||
inflater.inflate(R.menu.feedlist, menu);
|
inflater.inflate(R.menu.feedlist, menu);
|
||||||
@ -24,9 +28,18 @@ public class FeedMenuHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static boolean onPrepareOptionsMenu(Menu menu, Feed selectedFeed) {
|
public static boolean onPrepareOptionsMenu(Menu menu, Feed selectedFeed) {
|
||||||
|
Log.d(TAG, "Preparing options menu");
|
||||||
if (selectedFeed.getPaymentLink() != null) {
|
if (selectedFeed.getPaymentLink() != null) {
|
||||||
menu.findItem(R.id.support_item).setVisible(true);
|
menu.findItem(R.id.support_item).setVisible(true);
|
||||||
}
|
}
|
||||||
|
MenuItem refresh = menu.findItem(R.id.refresh_item);
|
||||||
|
if (DownloadService.isRunning
|
||||||
|
&& DownloadRequester.getInstance().isDownloadingFile(
|
||||||
|
selectedFeed)) {
|
||||||
|
refresh.setVisible(false);
|
||||||
|
} else {
|
||||||
|
refresh.setVisible(true);
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -37,9 +50,13 @@ public class FeedMenuHandler {
|
|||||||
switch (item.getItemId()) {
|
switch (item.getItemId()) {
|
||||||
case R.id.show_info_item:
|
case R.id.show_info_item:
|
||||||
Intent startIntent = new Intent(context, FeedInfoActivity.class);
|
Intent startIntent = new Intent(context, FeedInfoActivity.class);
|
||||||
startIntent.putExtra(FeedInfoActivity.EXTRA_FEED_ID, selectedFeed.getId());
|
startIntent.putExtra(FeedInfoActivity.EXTRA_FEED_ID,
|
||||||
|
selectedFeed.getId());
|
||||||
context.startActivity(startIntent);
|
context.startActivity(startIntent);
|
||||||
break;
|
break;
|
||||||
|
case R.id.refresh_item:
|
||||||
|
manager.refreshFeed(context, selectedFeed);
|
||||||
|
break;
|
||||||
case R.id.mark_all_read_item:
|
case R.id.mark_all_read_item:
|
||||||
manager.markFeedRead(context, selectedFeed);
|
manager.markFeedRead(context, selectedFeed);
|
||||||
break;
|
break;
|
||||||
|
|||||||
Reference in New Issue
Block a user