Hide 'mark all read' and 'refresh all feeds' - items when they aren't
needed
This commit is contained in:
parent
b99a810a1b
commit
663993afb2
|
@ -135,6 +135,7 @@ public class MainActivity extends SherlockFragmentActivity {
|
||||||
|
|
||||||
boolean hasFeeds = !manager.getFeeds().isEmpty();
|
boolean hasFeeds = !manager.getFeeds().isEmpty();
|
||||||
menu.findItem(R.id.opml_export).setVisible(hasFeeds);
|
menu.findItem(R.id.opml_export).setVisible(hasFeeds);
|
||||||
|
menu.findItem(R.id.all_feed_refresh).setVisible(hasFeeds);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -79,6 +79,25 @@ public class Feed extends FeedFile {
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true if at least one item in the itemlist is unread.If the
|
||||||
|
* 'display only episodes' - preference is set to true, this method will
|
||||||
|
* only count items with episodes.
|
||||||
|
*/
|
||||||
|
public boolean hasNewItems() {
|
||||||
|
boolean displayOnlyEpisodes = PreferenceManager
|
||||||
|
.getDefaultSharedPreferences(PodcastApp.getInstance())
|
||||||
|
.getBoolean(PodcastApp.PREF_DISPLAY_ONLY_EPISODES, false);
|
||||||
|
for (FeedItem item : items) {
|
||||||
|
if (!item.isRead()) {
|
||||||
|
if (!displayOnlyEpisodes || item.getMedia() != null) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the number of FeedItems. If the 'display only episodes' -
|
* Returns the number of FeedItems. If the 'display only episodes' -
|
||||||
* preference is set to true, this method will only count items with
|
* preference is set to true, this method will only count items with
|
||||||
|
|
|
@ -33,6 +33,8 @@ public class FeedMenuHandler {
|
||||||
public static boolean onPrepareOptionsMenu(Menu menu, Feed selectedFeed) {
|
public static boolean onPrepareOptionsMenu(Menu menu, Feed selectedFeed) {
|
||||||
if (AppConfig.DEBUG)
|
if (AppConfig.DEBUG)
|
||||||
Log.d(TAG, "Preparing options menu");
|
Log.d(TAG, "Preparing options menu");
|
||||||
|
menu.findItem(R.id.mark_all_read_item).setVisible(
|
||||||
|
selectedFeed.hasNewItems());
|
||||||
if (selectedFeed.getPaymentLink() != null) {
|
if (selectedFeed.getPaymentLink() != null) {
|
||||||
menu.findItem(R.id.support_item).setVisible(true);
|
menu.findItem(R.id.support_item).setVisible(true);
|
||||||
}
|
}
|
||||||
|
@ -73,7 +75,8 @@ public class FeedMenuHandler {
|
||||||
context.startActivity(new Intent(Intent.ACTION_VIEW, uri));
|
context.startActivity(new Intent(Intent.ACTION_VIEW, uri));
|
||||||
break;
|
break;
|
||||||
case R.id.support_item:
|
case R.id.support_item:
|
||||||
new FlattrClickWorker(context, selectedFeed.getPaymentLink()).executeAsync();
|
new FlattrClickWorker(context, selectedFeed.getPaymentLink())
|
||||||
|
.executeAsync();
|
||||||
break;
|
break;
|
||||||
case R.id.share_link_item:
|
case R.id.share_link_item:
|
||||||
ShareUtils.shareFeedlink(context, selectedFeed);
|
ShareUtils.shareFeedlink(context, selectedFeed);
|
||||||
|
|
Loading…
Reference in New Issue