danieloeh/AntennaPod — pull request #253 by peschmae0 (2013-08-12 11:07:51+00:00)
Title: Flattr queue autoflattr

This implements a queue of pending things to flattr (similar to #203 but implemented in a slightly different fashion) and adds support for automatic flattring of played episodes as requested in #87.

The workflow for the user is:
- if autoflattr is enabled, whenever 80% of an episode have been played it is added to the flattr queue (and a toast is displayed)
- manual flattring is done directly (flattring things in the queue along the way) if there is an internet connection. Otherwise the thing is added to the queue.
- when the feeds are updated, things in the queue are flattred (presumably there is an internet connection at that point), an android notification is displayed. Also at that point the flattr status of things is updated from the flattr API

Database changes:
- new column flattr_status for the feed and feeditem tables containing the timestamp when the thing was last flattrd. This value is updated when antennapod flattrs, as well as based on data from the flattr API whenever the feeds are refreshed. The latter may not be 100% reliable as the URL antennapod gets from the feed is not necessarily exactly the one recorded by flattr and returned by their API. I implemented some URI normalization that catches the corner cases I have encountered, there may be more. Also the flattr api does not return information on flattrability (i.e. things that were flattrd last month), so this is done in Antennapod.

I have considered implementing the flattr queue as a list of URLs to flattr as you suggested in #203, but I think it would be a lot more work (i.e. one would have to walk through the entire queue and the list of things that have been flattrd just in order to determine if an item is flattrable (and the corresponding menu item should be shown, as well as in order to avoid trying to flattr things multiple times), similarly to retrieve the feed titles of the things flattrd for showing in the notification).

- new column played_duration for the feedmedia table containing for how long an episode has been played (this is the accumulated play time, *not* the current play position in the episode)