diff options
Diffstat (limited to 'app/src/main/java/de/danoeh/antennapod/adapter/ActionButtonUtils.java')
-rw-r--r-- | app/src/main/java/de/danoeh/antennapod/adapter/ActionButtonUtils.java | 40 |
1 files changed, 31 insertions, 9 deletions
diff --git a/app/src/main/java/de/danoeh/antennapod/adapter/ActionButtonUtils.java b/app/src/main/java/de/danoeh/antennapod/adapter/ActionButtonUtils.java index 8d3e73429..8e347a819 100644 --- a/app/src/main/java/de/danoeh/antennapod/adapter/ActionButtonUtils.java +++ b/app/src/main/java/de/danoeh/antennapod/adapter/ActionButtonUtils.java @@ -10,7 +10,9 @@ import org.apache.commons.lang3.Validate; import de.danoeh.antennapod.R; import de.danoeh.antennapod.core.feed.FeedItem; import de.danoeh.antennapod.core.feed.FeedMedia; +import de.danoeh.antennapod.core.storage.DBReader; import de.danoeh.antennapod.core.storage.DownloadRequester; +import de.danoeh.antennapod.core.util.LongList; /** * Utility methods for the action button that is displayed on the right hand side @@ -26,9 +28,21 @@ public class ActionButtonUtils { Validate.notNull(context); this.context = context; - drawables = context.obtainStyledAttributes(new int[]{ - R.attr.av_play, R.attr.navigation_cancel, R.attr.av_download, R.attr.av_pause, R.attr.navigation_accept}); - labels = new int[]{R.string.play_label, R.string.cancel_download_label, R.string.download_label, R.string.mark_read_label}; + drawables = context.obtainStyledAttributes(new int[] { + R.attr.av_play, + R.attr.navigation_cancel, + R.attr.av_download, + R.attr.av_pause, + R.attr.navigation_accept, + R.attr.content_new + }); + labels = new int[] { + R.string.play_label, + R.string.cancel_download_label, + R.string.download_label, + R.string.mark_read_label, + R.string.add_to_queue_label + }; } /** @@ -50,18 +64,26 @@ public class ActionButtonUtils { butSecondary.setContentDescription(context.getString(labels[1])); } else { // item is not downloaded and not being downloaded - butSecondary.setVisibility(View.VISIBLE); - butSecondary.setImageDrawable(drawables.getDrawable(2)); - butSecondary.setContentDescription(context.getString(labels[2])); + LongList queueIds = DBReader.getQueueIDList(context); + if(DefaultActionButtonCallback.userAllowedMobileDownloads() || + !DefaultActionButtonCallback.userChoseAddToQueue() || queueIds.contains(item.getId())) { + butSecondary.setVisibility(View.VISIBLE); + butSecondary.setImageDrawable(drawables.getDrawable(2)); + butSecondary.setContentDescription(context.getString(labels[2])); + } else { + // mobile download not allowed yet, item is not in queue and user chose add to queue + butSecondary.setVisibility(View.VISIBLE); + butSecondary.setImageDrawable(drawables.getDrawable(5)); + butSecondary.setContentDescription(context.getString(labels[4])); + } } } else { - // item is not being downloaded + // item is downloaded butSecondary.setVisibility(View.VISIBLE); if (media.isCurrentlyPlaying()) { butSecondary.setImageDrawable(drawables.getDrawable(3)); } else { - butSecondary - .setImageDrawable(drawables.getDrawable(0)); + butSecondary.setImageDrawable(drawables.getDrawable(0)); } butSecondary.setContentDescription(context.getString(labels[0])); } |