diff options
author | daniel oeh <daniel.oeh@gmail.com> | 2014-02-27 20:15:27 +0100 |
---|---|---|
committer | daniel oeh <daniel.oeh@gmail.com> | 2014-02-27 20:15:27 +0100 |
commit | 7c6c3ef1019e93001ee5fca9093ba21443c5cae6 (patch) | |
tree | 1ff10392255ab6d5ea54db5ee30bb6979bfd8166 /src | |
parent | bece620c4355363ec3a6b49d58ec1b3ab79c20db (diff) | |
download | AntennaPod-7c6c3ef1019e93001ee5fca9093ba21443c5cae6.zip |
Do not add things to the flattr queue if the user isn't logged in
- Bugfix: The no-token dialog was shown every time a feed was refreshed if the user wasn't logged in and had clicked the "flattr this" button before
Diffstat (limited to 'src')
5 files changed, 35 insertions, 8 deletions
diff --git a/src/de/danoeh/antennapod/activity/MediaplayerActivity.java b/src/de/danoeh/antennapod/activity/MediaplayerActivity.java index 0555e199d..27ac7afd8 100644 --- a/src/de/danoeh/antennapod/activity/MediaplayerActivity.java +++ b/src/de/danoeh/antennapod/activity/MediaplayerActivity.java @@ -23,7 +23,7 @@ import de.danoeh.antennapod.feed.FeedItem; import de.danoeh.antennapod.feed.FeedMedia; import de.danoeh.antennapod.preferences.UserPreferences; import de.danoeh.antennapod.service.playback.PlaybackService; -import de.danoeh.antennapod.storage.DBWriter; +import de.danoeh.antennapod.storage.DBTasks; import de.danoeh.antennapod.util.Converter; import de.danoeh.antennapod.util.ShareUtils; import de.danoeh.antennapod.util.StorageUtils; @@ -320,8 +320,7 @@ public abstract class MediaplayerActivity extends ActionBarActivity case R.id.support_item: if (media instanceof FeedMedia) { FeedItem feedItem = ((FeedMedia) media).getItem(); - feedItem.getFlattrStatus().setFlattrQueue(); - DBWriter.setFlattredStatus(this, feedItem, true); + DBTasks.flattrItemIfLoggedIn(this, feedItem); } break; case R.id.share_link_item: diff --git a/src/de/danoeh/antennapod/asynctask/FlattrClickWorker.java b/src/de/danoeh/antennapod/asynctask/FlattrClickWorker.java index 5c63b2691..3034bbaff 100644 --- a/src/de/danoeh/antennapod/asynctask/FlattrClickWorker.java +++ b/src/de/danoeh/antennapod/asynctask/FlattrClickWorker.java @@ -89,7 +89,6 @@ public class FlattrClickWorker extends AsyncTask<Void, String, Void> { protected void onNoAccessToken() { Log.w(TAG, "No access token was available"); - FlattrUtils.showNoTokenDialog(context, ""); } protected void onFlattrError() { diff --git a/src/de/danoeh/antennapod/storage/DBTasks.java b/src/de/danoeh/antennapod/storage/DBTasks.java index c6a0dad17..8ef5f0888 100644 --- a/src/de/danoeh/antennapod/storage/DBTasks.java +++ b/src/de/danoeh/antennapod/storage/DBTasks.java @@ -17,6 +17,7 @@ import de.danoeh.antennapod.util.NetworkUtils; import de.danoeh.antennapod.util.QueueAccess; import de.danoeh.antennapod.util.comparator.FeedItemPubdateComparator; import de.danoeh.antennapod.util.exception.MediaFileNotFoundException; +import de.danoeh.antennapod.util.flattr.FlattrUtils; import java.util.*; import java.util.concurrent.*; @@ -805,4 +806,34 @@ public final class DBTasks { } } + /** + * Adds the given FeedItem to the flattr queue if the user is logged in. Otherwise, a dialog + * will be opened that lets the user go either to the login screen or the website of the flattr thing. + * @param context + * @param item + */ + public static void flattrItemIfLoggedIn(Context context, FeedItem item) { + if (FlattrUtils.hasToken()) { + item.getFlattrStatus().setFlattrQueue(); + DBWriter.setFlattredStatus(context, item, true); + } else { + FlattrUtils.showNoTokenDialog(context, item.getPaymentLink()); + } + } + + /** + * Adds the given Feed to the flattr queue if the user is logged in. Otherwise, a dialog + * will be opened that lets the user go either to the login screen or the website of the flattr thing. + * @param context + * @param feed + */ + public static void flattrFeedIfLoggedIn(Context context, Feed feed) { + if (FlattrUtils.hasToken()) { + feed.getFlattrStatus().setFlattrQueue(); + DBWriter.setFlattredStatus(context, feed, true); + } else { + FlattrUtils.showNoTokenDialog(context, feed.getPaymentLink()); + } + } + } diff --git a/src/de/danoeh/antennapod/util/menuhandler/FeedItemMenuHandler.java b/src/de/danoeh/antennapod/util/menuhandler/FeedItemMenuHandler.java index 510f3bae8..615c1c93e 100644 --- a/src/de/danoeh/antennapod/util/menuhandler/FeedItemMenuHandler.java +++ b/src/de/danoeh/antennapod/util/menuhandler/FeedItemMenuHandler.java @@ -155,8 +155,7 @@ public class FeedItemMenuHandler { context.startActivity(new Intent(Intent.ACTION_VIEW, uri)); break; case R.id.support_item: - selectedItem.getFlattrStatus().setFlattrQueue(); - DBWriter.setFlattredStatus(context, selectedItem, true); + DBTasks.flattrItemIfLoggedIn(context, selectedItem); break; case R.id.share_link_item: ShareUtils.shareFeedItemLink(context, selectedItem); diff --git a/src/de/danoeh/antennapod/util/menuhandler/FeedMenuHandler.java b/src/de/danoeh/antennapod/util/menuhandler/FeedMenuHandler.java index 86808b609..537335618 100644 --- a/src/de/danoeh/antennapod/util/menuhandler/FeedMenuHandler.java +++ b/src/de/danoeh/antennapod/util/menuhandler/FeedMenuHandler.java @@ -84,8 +84,7 @@ public class FeedMenuHandler { context.startActivity(new Intent(Intent.ACTION_VIEW, uri)); break; case R.id.support_item: - selectedFeed.getFlattrStatus().setFlattrQueue(); - DBWriter.setFlattredStatus(context, selectedFeed, true); + DBTasks.flattrFeedIfLoggedIn(context, selectedFeed); break; case R.id.share_link_item: ShareUtils.shareFeedlink(context, selectedFeed); |