summaryrefslogtreecommitdiff
path: root/core/src/main/java
diff options
context:
space:
mode:
authordamoasda <46045854+damoasda@users.noreply.github.com>2019-08-04 09:59:32 +0200
committerGitHub <noreply@github.com>2019-08-04 09:59:32 +0200
commit51f348caa3054189ad426f1ff7f43e5f2940dd99 (patch)
treedddc3c27d77935fb7d45860c939f5b06720b0745 /core/src/main/java
parent9b7a61471d342a2db4a2a6fe0681e748f15ca903 (diff)
parent5173dd0118ab6683013c45297c0eb589d0a52a65 (diff)
downloadAntennaPod-51f348caa3054189ad426f1ff7f43e5f2940dd99.zip
Merge branch 'develop' into Queue-Sort-Order
Diffstat (limited to 'core/src/main/java')
-rw-r--r--core/src/main/java/de/danoeh/antennapod/core/FlattrCallbacks.java36
-rw-r--r--core/src/main/java/de/danoeh/antennapod/core/UpdateManager.java81
-rw-r--r--core/src/main/java/de/danoeh/antennapod/core/asynctask/FlattrClickWorker.java231
-rw-r--r--core/src/main/java/de/danoeh/antennapod/core/asynctask/FlattrStatusFetcher.java45
-rw-r--r--core/src/main/java/de/danoeh/antennapod/core/asynctask/FlattrTokenFetcher.java86
-rw-r--r--core/src/main/java/de/danoeh/antennapod/core/event/DownloaderUpdate.java5
-rw-r--r--core/src/main/java/de/danoeh/antennapod/core/feed/Feed.java29
-rw-r--r--core/src/main/java/de/danoeh/antennapod/core/feed/FeedItem.java19
-rw-r--r--core/src/main/java/de/danoeh/antennapod/core/feed/FeedMedia.java13
-rw-r--r--core/src/main/java/de/danoeh/antennapod/core/preferences/UserPreferences.java42
-rw-r--r--core/src/main/java/de/danoeh/antennapod/core/service/PlayerWidgetJobService.java11
-rw-r--r--core/src/main/java/de/danoeh/antennapod/core/service/playback/LocalPSMP.java2
-rw-r--r--core/src/main/java/de/danoeh/antennapod/core/storage/DBReader.java31
-rw-r--r--core/src/main/java/de/danoeh/antennapod/core/storage/DBTasks.java44
-rw-r--r--core/src/main/java/de/danoeh/antennapod/core/storage/DBUpgrader.java4
-rw-r--r--core/src/main/java/de/danoeh/antennapod/core/storage/DBWriter.java118
-rw-r--r--core/src/main/java/de/danoeh/antennapod/core/storage/PodDBAdapter.java90
-rw-r--r--core/src/main/java/de/danoeh/antennapod/core/util/flattr/FlattrServiceCreator.java32
-rw-r--r--core/src/main/java/de/danoeh/antennapod/core/util/flattr/FlattrStatus.java68
-rw-r--r--core/src/main/java/de/danoeh/antennapod/core/util/flattr/FlattrThing.java7
-rw-r--r--core/src/main/java/de/danoeh/antennapod/core/util/flattr/FlattrUtils.java220
-rw-r--r--core/src/main/java/de/danoeh/antennapod/core/util/flattr/SimpleFlattrThing.java30
22 files changed, 33 insertions, 1211 deletions
diff --git a/core/src/main/java/de/danoeh/antennapod/core/FlattrCallbacks.java b/core/src/main/java/de/danoeh/antennapod/core/FlattrCallbacks.java
deleted file mode 100644
index 5fa6faa13..000000000
--- a/core/src/main/java/de/danoeh/antennapod/core/FlattrCallbacks.java
+++ /dev/null
@@ -1,36 +0,0 @@
-package de.danoeh.antennapod.core;
-
-import android.app.PendingIntent;
-import android.content.Context;
-import android.content.Intent;
-
-import org.shredzone.flattr4j.oauth.AccessToken;
-
-/**
- * Callbacks for the flattr integration of the app.
- */
-public interface FlattrCallbacks {
-
- /**
- * Returns if true if the flattr integration should be activated,
- * false otherwise.
- */
- boolean flattrEnabled();
-
- /**
- * Returns an intent that starts the activity that is responsible for
- * letting users log into their flattr account.
- *
- * @return The intent that starts the authentication activity or null
- * if flattr integration is disabled (i.e. flattrEnabled() == false).
- */
- Intent getFlattrAuthenticationActivityIntent(Context context);
-
- PendingIntent getFlattrFailedNotificationContentIntent(Context context);
-
- String getFlattrAppKey();
-
- String getFlattrAppSecret();
-
- void handleFlattrAuthenticationSuccess(AccessToken token);
-}
diff --git a/core/src/main/java/de/danoeh/antennapod/core/UpdateManager.java b/core/src/main/java/de/danoeh/antennapod/core/UpdateManager.java
deleted file mode 100644
index 1b4cbc0ea..000000000
--- a/core/src/main/java/de/danoeh/antennapod/core/UpdateManager.java
+++ /dev/null
@@ -1,81 +0,0 @@
-package de.danoeh.antennapod.core;
-
-
-import android.content.Context;
-import android.content.SharedPreferences;
-import android.content.pm.PackageInfo;
-import android.content.pm.PackageManager;
-import android.os.Build;
-import android.util.Log;
-
-import org.antennapod.audio.MediaPlayer;
-
-import de.danoeh.antennapod.core.preferences.UserPreferences;
-
-/*
- * This class's job is do perform maintenance tasks whenever the app has been updated
- */
-class UpdateManager {
-
- private UpdateManager(){}
-
- private static final String TAG = UpdateManager.class.getSimpleName();
-
- private static final String PREF_NAME = "app_version";
- private static final String KEY_VERSION_CODE = "version_code";
-
- private static int currentVersionCode;
-
- private static Context context;
- private static SharedPreferences prefs;
-
- public static void init(Context context) {
- UpdateManager.context = context;
- prefs = context.getSharedPreferences(PREF_NAME, Context.MODE_PRIVATE);
- PackageManager pm = context.getPackageManager();
- try {
- PackageInfo info = pm.getPackageInfo(context.getPackageName(), 0);
- currentVersionCode = info.versionCode;
- } catch (PackageManager.NameNotFoundException e) {
- Log.e(TAG, "Failed to obtain package info for package name: " + context.getPackageName(), e);
- currentVersionCode = 0;
- return;
- }
- final int oldVersionCode = getStoredVersionCode();
- Log.d(TAG, "old: " + oldVersionCode + ", current: " + currentVersionCode);
- if(oldVersionCode < currentVersionCode) {
- onUpgrade(oldVersionCode, currentVersionCode);
- setCurrentVersionCode();
- }
- }
-
- private static int getStoredVersionCode() {
- return prefs.getInt(KEY_VERSION_CODE, -1);
- }
-
- private static void setCurrentVersionCode() {
- prefs.edit().putInt(KEY_VERSION_CODE, currentVersionCode).apply();
- }
-
- private static void onUpgrade(final int oldVersionCode, final int newVersionCode) {
- if (oldVersionCode < 1050004) {
- if(MediaPlayer.isPrestoLibraryInstalled(context) && Build.VERSION.SDK_INT >= 16) {
- UserPreferences.enableSonic();
- }
- }
-
- if (oldVersionCode < 1070196) {
- // migrate episode cleanup value (unit changed from days to hours)
- int oldValueInDays = UserPreferences.getEpisodeCleanupValue();
- if (oldValueInDays > 0) {
- UserPreferences.setEpisodeCleanupValue(oldValueInDays * 24);
- } // else 0 or special negative values, no change needed
- }
- if (oldVersionCode < 1070197) {
- if (prefs.getBoolean("prefMobileUpdate", false)) {
- prefs.edit().putString(UserPreferences.PREF_MOBILE_UPDATE, "everything").apply();
- }
- }
- }
-
-}
diff --git a/core/src/main/java/de/danoeh/antennapod/core/asynctask/FlattrClickWorker.java b/core/src/main/java/de/danoeh/antennapod/core/asynctask/FlattrClickWorker.java
deleted file mode 100644
index 318e404c8..000000000
--- a/core/src/main/java/de/danoeh/antennapod/core/asynctask/FlattrClickWorker.java
+++ /dev/null
@@ -1,231 +0,0 @@
-package de.danoeh.antennapod.core.asynctask;
-
-import android.app.Notification;
-import android.app.NotificationManager;
-import android.app.PendingIntent;
-import android.content.Context;
-import android.os.AsyncTask;
-import android.support.annotation.NonNull;
-import android.support.v4.app.NotificationCompat;
-import android.util.Log;
-import android.widget.Toast;
-
-import org.shredzone.flattr4j.exception.FlattrException;
-
-import java.util.LinkedList;
-import java.util.List;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.Future;
-import java.util.concurrent.atomic.AtomicInteger;
-
-import de.danoeh.antennapod.core.BuildConfig;
-import de.danoeh.antennapod.core.ClientConfig;
-import de.danoeh.antennapod.core.R;
-import de.danoeh.antennapod.core.storage.DBReader;
-import de.danoeh.antennapod.core.storage.DBWriter;
-import de.danoeh.antennapod.core.util.NetworkUtils;
-import de.danoeh.antennapod.core.util.flattr.FlattrThing;
-import de.danoeh.antennapod.core.util.flattr.FlattrUtils;
-import de.danoeh.antennapod.core.util.gui.NotificationUtils;
-
-/**
- * Performs a click action in a background thread.
- * <p/>
- * When started, the flattr click worker will try to flattr every item that is in the flattr queue. If no network
- * connection is available it will shut down immediately. The FlattrClickWorker can also be given one additional
- * FlattrThing which will be flattrd immediately.
- * <p/>
- * The FlattrClickWorker will display a toast notification for every item that has been flattrd. If the FlattrClickWorker failed
- * to flattr something, a notification will be displayed.
- */
-public class FlattrClickWorker extends AsyncTask<Void, Integer, FlattrClickWorker.ExitCode> {
- private static final String TAG = "FlattrClickWorker";
-
- private static final int NOTIFICATION_ID = 4;
-
- private final Context context;
-
- public enum ExitCode {EXIT_NORMAL, NO_TOKEN, NO_NETWORK, NO_THINGS}
-
- private final AtomicInteger countFailed = new AtomicInteger();
- private final AtomicInteger countSuccess = new AtomicInteger();
-
- private volatile FlattrThing extraFlattrThing;
-
- /**
- * Only relevant if just one thing is flattrd
- */
- private volatile FlattrException exception;
-
- /**
- * Creates a new FlattrClickWorker which will only flattr all things in the queue.
- * <p/>
- * The FlattrClickWorker has to be started by calling executeAsync().
- *
- * @param context A context for accessing the database and posting notifications. Must not be null.
- */
- public FlattrClickWorker(@NonNull Context context) {
- this.context = context.getApplicationContext();
- }
-
- /**
- * Creates a new FlattrClickWorker which will flattr all things in the queue and one additional
- * FlattrThing.
- * <p/>
- * The FlattrClickWorker has to be started by calling executeAsync().
- *
- * @param context A context for accessing the database and posting notifications. Must not be null.
- * @param extraFlattrThing The additional thing to flattr
- */
- public FlattrClickWorker(Context context, FlattrThing extraFlattrThing) {
- this(context);
- this.extraFlattrThing = extraFlattrThing;
- }
-
-
- @Override
- protected ExitCode doInBackground(Void... params) {
-
- if (!FlattrUtils.hasToken()) {
- return ExitCode.NO_TOKEN;
- }
-
- if (!NetworkUtils.networkAvailable()) {
- return ExitCode.NO_NETWORK;
- }
-
- final List<FlattrThing> flattrQueue = DBReader.getFlattrQueue();
- if (extraFlattrThing != null) {
- flattrQueue.add(extraFlattrThing);
- } else if (flattrQueue.size() == 1) {
- // if only one item is flattrd, the report can specifically mentioned that this item has failed
- extraFlattrThing = flattrQueue.get(0);
- }
-
- if (flattrQueue.isEmpty()) {
- return ExitCode.NO_THINGS;
- }
-
- List<Future<?>> dbFutures = new LinkedList<>();
- for (FlattrThing thing : flattrQueue) {
- if (BuildConfig.DEBUG) Log.d(TAG, "Processing " + thing.getTitle());
-
- try {
- thing.getFlattrStatus().setUnflattred(); // pop from queue to prevent unflattrable things from getting stuck in flattr queue infinitely
- FlattrUtils.clickUrl(context, thing.getPaymentLink());
- thing.getFlattrStatus().setFlattred();
- publishProgress(R.string.flattr_click_success);
- countSuccess.incrementAndGet();
-
- } catch (FlattrException e) {
- e.printStackTrace();
- int failed = countFailed.incrementAndGet();
- if (failed == 1) {
- exception = e;
- }
- }
-
- Future<?> f = DBWriter.setFlattredStatus(context, thing, false);
- if (f != null) {
- dbFutures.add(f);
- }
- }
-
- for (Future<?> f : dbFutures) {
- try {
- f.get();
- } catch (InterruptedException | ExecutionException e) {
- e.printStackTrace();
- }
- }
-
- return ExitCode.EXIT_NORMAL;
- }
-
- @Override
- protected void onPostExecute(ExitCode exitCode) {
- super.onPostExecute(exitCode);
- switch (exitCode) {
- case EXIT_NORMAL:
- if (countFailed.get() > 0) {
- postFlattrFailedNotification();
- }
- break;
- case NO_NETWORK:
- postToastNotification(R.string.flattr_click_enqueued);
- break;
- case NO_TOKEN:
- postNoTokenNotification();
- break;
- case NO_THINGS: // nothing to notify here
- break;
- }
- }
-
- @Override
- protected void onProgressUpdate(Integer... values) {
- super.onProgressUpdate(values);
- postToastNotification(values[0]);
- }
-
- private void postToastNotification(int msg) {
- Toast.makeText(context, context.getString(msg), Toast.LENGTH_LONG).show();
- }
-
- private void postNoTokenNotification() {
- PendingIntent contentIntent = PendingIntent.getActivity(context, 0,
- ClientConfig.flattrCallbacks.getFlattrAuthenticationActivityIntent(context), 0);
-
- Notification notification = new NotificationCompat.Builder(context, NotificationUtils.CHANNEL_ID_ERROR)
- .setStyle(new NotificationCompat.BigTextStyle().bigText(context.getString(R.string.no_flattr_token_notification_msg)))
- .setContentIntent(contentIntent)
- .setContentTitle(context.getString(R.string.no_flattr_token_title))
- .setTicker(context.getString(R.string.no_flattr_token_title))
- .setSmallIcon(R.drawable.stat_notify_sync_error)
- .setOngoing(false)
- .setAutoCancel(true)
- .build();
- ((NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE)).notify(NOTIFICATION_ID, notification);
- }
-
- private void postFlattrFailedNotification() {
- int failed = countFailed.get();
- if (failed == 0) {
- return;
- }
-
- PendingIntent contentIntent = ClientConfig.flattrCallbacks.getFlattrFailedNotificationContentIntent(context);
- String title;
- String subtext;
-
- if (failed == 1) {
- title = context.getString(R.string.flattrd_failed_label);
- String exceptionMsg = (exception.getMessage() != null) ? exception.getMessage() : "";
- subtext = context.getString(R.string.flattr_click_failure, extraFlattrThing.getTitle())
- + "\n" + exceptionMsg;
- } else {
- title = context.getString(R.string.flattrd_label);
- subtext = context.getString(R.string.flattr_click_success_count, countSuccess.get()) + "\n"
- + context.getString(R.string.flattr_click_failure_count, failed);
- }
-
- Notification notification = new NotificationCompat.Builder(context, NotificationUtils.CHANNEL_ID_ERROR)
- .setStyle(new NotificationCompat.BigTextStyle().bigText(subtext))
- .setContentIntent(contentIntent)
- .setContentTitle(title)
- .setTicker(title)
- .setSmallIcon(R.drawable.stat_notify_sync_error)
- .setOngoing(false)
- .setAutoCancel(true)
- .build();
- ((NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE)).notify(NOTIFICATION_ID, notification);
- }
-
-
- /**
- * Starts the FlattrClickWorker as an AsyncTask.
- */
- public void executeAsync() {
- executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
- }
-}
diff --git a/core/src/main/java/de/danoeh/antennapod/core/asynctask/FlattrStatusFetcher.java b/core/src/main/java/de/danoeh/antennapod/core/asynctask/FlattrStatusFetcher.java
deleted file mode 100644
index 6d9ab2bd3..000000000
--- a/core/src/main/java/de/danoeh/antennapod/core/asynctask/FlattrStatusFetcher.java
+++ /dev/null
@@ -1,45 +0,0 @@
-package de.danoeh.antennapod.core.asynctask;
-
-import android.content.Context;
-import android.util.Log;
-
-import org.shredzone.flattr4j.exception.FlattrException;
-import org.shredzone.flattr4j.model.Flattr;
-
-import java.util.List;
-import java.util.concurrent.ExecutionException;
-
-import de.danoeh.antennapod.core.BuildConfig;
-import de.danoeh.antennapod.core.storage.DBWriter;
-import de.danoeh.antennapod.core.util.flattr.FlattrUtils;
-
-/**
- * Fetch list of flattred things and flattr status in database in a background thread.
- */
-
-public class FlattrStatusFetcher extends Thread {
- private static final String TAG = "FlattrStatusFetcher";
-
- public FlattrStatusFetcher(Context context) {
- super();
- }
-
- @Override
- public void run() {
- if (BuildConfig.DEBUG) Log.d(TAG, "Starting background work: Retrieving Flattr status");
-
- Thread.currentThread().setPriority(Thread.MIN_PRIORITY);
-
- try {
- List<Flattr> flattredThings = FlattrUtils.retrieveFlattredThings();
- DBWriter.setFlattredStatus(flattredThings).get();
- } catch (FlattrException e) {
- e.printStackTrace();
- Log.d(TAG, "flattrQueue exception retrieving list with flattred items " + e.getMessage());
- } catch (InterruptedException | ExecutionException e) {
- e.printStackTrace();
- }
-
- if (BuildConfig.DEBUG) Log.d(TAG, "Finished background work: Retrieved Flattr status");
- }
-}
diff --git a/core/src/main/java/de/danoeh/antennapod/core/asynctask/FlattrTokenFetcher.java b/core/src/main/java/de/danoeh/antennapod/core/asynctask/FlattrTokenFetcher.java
deleted file mode 100644
index 985cabbf8..000000000
--- a/core/src/main/java/de/danoeh/antennapod/core/asynctask/FlattrTokenFetcher.java
+++ /dev/null
@@ -1,86 +0,0 @@
-package de.danoeh.antennapod.core.asynctask;
-
-
-import android.app.ProgressDialog;
-import android.content.Context;
-import android.net.Uri;
-import android.os.AsyncTask;
-import android.util.Log;
-
-import org.shredzone.flattr4j.exception.FlattrException;
-import org.shredzone.flattr4j.oauth.AccessToken;
-import org.shredzone.flattr4j.oauth.AndroidAuthenticator;
-
-import de.danoeh.antennapod.core.BuildConfig;
-import de.danoeh.antennapod.core.ClientConfig;
-import de.danoeh.antennapod.core.R;
-import de.danoeh.antennapod.core.util.flattr.FlattrUtils;
-
-/**
- * Fetches the access token in the background in order to avoid networkOnMainThread exception.
- */
-
-public class FlattrTokenFetcher extends AsyncTask<Void, Void, AccessToken> {
- private static final String TAG = "FlattrTokenFetcher";
- private final Context context;
- private final AndroidAuthenticator auth;
- private AccessToken token;
- private final Uri uri;
- private ProgressDialog dialog;
- private FlattrException exception;
-
- public FlattrTokenFetcher(Context context, AndroidAuthenticator auth, Uri uri) {
- super();
- this.context = context;
- this.auth = auth;
- this.uri = uri;
- }
-
- @Override
- protected void onPostExecute(AccessToken result) {
- if (result != null) {
- FlattrUtils.storeToken(result);
- }
- dialog.dismiss();
- if (exception == null) {
- ClientConfig.flattrCallbacks.handleFlattrAuthenticationSuccess(result);
- } else {
- FlattrUtils.showErrorDialog(context, exception.getMessage());
- }
- }
-
-
- @Override
- protected void onPreExecute() {
- super.onPreExecute();
- dialog = new ProgressDialog(context);
- dialog.setMessage(context.getString(R.string.processing_label));
- dialog.setIndeterminate(true);
- dialog.setCancelable(false);
- dialog.show();
- }
-
-
- @Override
- protected AccessToken doInBackground(Void... params) {
- try {
- token = auth.fetchAccessToken(uri);
- } catch (FlattrException e) {
- e.printStackTrace();
- exception = e;
- return null;
- }
- if (token != null) {
- if (BuildConfig.DEBUG) Log.d(TAG, "Successfully got token");
- return token;
- } else {
- Log.w(TAG, "Flattr token was null");
- return null;
- }
- }
-
- public void executeAsync() {
- executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
- }
-
-}
diff --git a/core/src/main/java/de/danoeh/antennapod/core/event/DownloaderUpdate.java b/core/src/main/java/de/danoeh/antennapod/core/event/DownloaderUpdate.java
index dcb033267..7ca6f78de 100644
--- a/core/src/main/java/de/danoeh/antennapod/core/event/DownloaderUpdate.java
+++ b/core/src/main/java/de/danoeh/antennapod/core/event/DownloaderUpdate.java
@@ -1,5 +1,7 @@
package de.danoeh.antennapod.core.event;
+import android.support.annotation.NonNull;
+
import java.util.Arrays;
import java.util.List;
@@ -11,6 +13,7 @@ import de.danoeh.antennapod.core.util.LongList;
public class DownloaderUpdate {
/* Downloaders that are currently running */
+ @NonNull
public final List<Downloader> downloaders;
/**
@@ -25,7 +28,7 @@ public class DownloaderUpdate {
*/
public final long[] mediaIds;
- public DownloaderUpdate(List<Downloader> downloaders) {
+ DownloaderUpdate(@NonNull List<Downloader> downloaders) {
this.downloaders = downloaders;
LongList feedIds1 = new LongList(), mediaIds1 = new LongList();
for(Downloader d1 : downloaders) {
diff --git a/core/src/main/java/de/danoeh/antennapod/core/feed/Feed.java b/core/src/main/java/de/danoeh/antennapod/core/feed/Feed.java
index 3395653f3..5718c06c2 100644
--- a/core/src/main/java/de/danoeh/antennapod/core/feed/Feed.java
+++ b/core/src/main/java/de/danoeh/antennapod/core/feed/Feed.java
@@ -11,15 +11,12 @@ import java.util.List;
import de.danoeh.antennapod.core.asynctask.ImageResource;
import de.danoeh.antennapod.core.storage.DBWriter;
import de.danoeh.antennapod.core.storage.PodDBAdapter;
-import de.danoeh.antennapod.core.util.flattr.FlattrStatus;
-import de.danoeh.antennapod.core.util.flattr.FlattrThing;
-
/**
* Data Object for a whole feed
*
* @author daniel
*/
-public class Feed extends FeedFile implements FlattrThing, ImageResource {
+public class Feed extends FeedFile implements ImageResource {
public static final int FEEDFILETYPE_FEED = 0;
public static final String TYPE_RSS2 = "rss";
@@ -52,7 +49,6 @@ public class Feed extends FeedFile implements FlattrThing, ImageResource {
*/
private String lastUpdate;
- private FlattrStatus flattrStatus;
private String paymentLink;
/**
* Feed type, for example RSS 2 or Atom
@@ -97,7 +93,7 @@ public class Feed extends FeedFile implements FlattrThing, ImageResource {
*/
public Feed(long id, String lastUpdate, String title, String customTitle, String link, String description, String paymentLink,
String author, String language, String type, String feedIdentifier, String imageUrl, String fileUrl,
- String downloadUrl, boolean downloaded, FlattrStatus status, boolean paged, String nextPageLink,
+ String downloadUrl, boolean downloaded, boolean paged, String nextPageLink,
String filter, boolean lastUpdateFailed) {
super(fileUrl, downloadUrl, downloaded);
this.id = id;
@@ -112,7 +108,6 @@ public class Feed extends FeedFile implements FlattrThing, ImageResource {
this.type = type;
this.feedIdentifier = feedIdentifier;
this.imageUrl = imageUrl;
- this.flattrStatus = status;
this.paged = paged;
this.nextPageLink = nextPageLink;
this.items = new ArrayList<>();
@@ -125,13 +120,13 @@ public class Feed extends FeedFile implements FlattrThing, ImageResource {
}
/**
- * This constructor is used for test purposes and uses a default flattr status object.
+ * This constructor is used for test purposes
*/
public Feed(long id, String lastUpdate, String title, String link, String description, String paymentLink,
String author, String language, String type, String feedIdentifier, String imageUrl, String fileUrl,
String downloadUrl, boolean downloaded) {
this(id, lastUpdate, title, null, link, description, paymentLink, author, language, type, feedIdentifier, imageUrl,
- fileUrl, downloadUrl, downloaded, new FlattrStatus(), false, null, null, false);
+ fileUrl, downloadUrl, downloaded, false, null, null, false);
}
/**
@@ -139,7 +134,6 @@ public class Feed extends FeedFile implements FlattrThing, ImageResource {
*/
public Feed() {
super();
- this.flattrStatus = new FlattrStatus();
}
/**
@@ -149,7 +143,6 @@ public class Feed extends FeedFile implements FlattrThing, ImageResource {
public Feed(String url, String lastUpdate) {
super(null, url, false);
this.lastUpdate = lastUpdate;
- this.flattrStatus = new FlattrStatus();
}
/**
@@ -159,7 +152,6 @@ public class Feed extends FeedFile implements FlattrThing, ImageResource {
public Feed(String url, String lastUpdate, String title) {
this(url, lastUpdate);
this.feedTitle = title;
- this.flattrStatus = new FlattrStatus();
}
/**
@@ -186,7 +178,6 @@ public class Feed extends FeedFile implements FlattrThing, ImageResource {
int indexFileUrl = cursor.getColumnIndex(PodDBAdapter.KEY_FILE_URL);
int indexDownloadUrl = cursor.getColumnIndex(PodDBAdapter.KEY_DOWNLOAD_URL);
int indexDownloaded = cursor.getColumnIndex(PodDBAdapter.KEY_DOWNLOADED);
- int indexFlattrStatus = cursor.getColumnIndex(PodDBAdapter.KEY_FLATTR_STATUS);
int indexIsPaged = cursor.getColumnIndex(PodDBAdapter.KEY_IS_PAGED);
int indexNextPageLink = cursor.getColumnIndex(PodDBAdapter.KEY_NEXT_PAGE_LINK);
int indexHide = cursor.getColumnIndex(PodDBAdapter.KEY_HIDE);
@@ -209,7 +200,6 @@ public class Feed extends FeedFile implements FlattrThing, ImageResource {
cursor.getString(indexFileUrl),
cursor.getString(indexDownloadUrl),
cursor.getInt(indexDownloaded) > 0,
- new FlattrStatus(cursor.getLong(indexFlattrStatus)),
cursor.getInt(indexIsPaged) > 0,
cursor.getString(indexNextPageLink),
cursor.getString(indexHide),
@@ -291,9 +281,6 @@ public class Feed extends FeedFile implements FlattrThing, ImageResource {
if (other.paymentLink != null) {
paymentLink = other.paymentLink;
}
- if (other.flattrStatus != null) {
- flattrStatus = other.flattrStatus;
- }
// this feed's nextPage might already point to a higher page, so we only update the nextPage value
// if this feed is not paged and the other feed is.
if (!this.paged && other.paged) {
@@ -444,14 +431,6 @@ public class Feed extends FeedFile implements FlattrThing, ImageResource {
this.feedIdentifier = feedIdentifier;
}
- public void setFlattrStatus(FlattrStatus status) {
- this.flattrStatus = status;
- }
-
- public FlattrStatus getFlattrStatus() {
- return flattrStatus;
- }
-
public String getPaymentLink() {
return paymentLink;
}
diff --git a/core/src/main/java/de/danoeh/antennapod/core/feed/FeedItem.java b/core/src/main/java/de/danoeh/antennapod/core/feed/FeedItem.java
index 0f0343f25..3495164a6 100644
--- a/core/src/main/java/de/danoeh/antennapod/core/feed/FeedItem.java
+++ b/core/src/main/java/de/danoeh/antennapod/core/feed/FeedItem.java
@@ -18,15 +18,13 @@ import de.danoeh.antennapod.core.asynctask.ImageResource;
import de.danoeh.antennapod.core.storage.DBReader;
import de.danoeh.antennapod.core.storage.PodDBAdapter;
import de.danoeh.antennapod.core.util.ShownotesProvider;
-import de.danoeh.antennapod.core.util.flattr.FlattrStatus;
-import de.danoeh.antennapod.core.util.flattr.FlattrThing;
/**
* Data Object for a XML message
*
* @author daniel
*/
-public class FeedItem extends FeedComponent implements ShownotesProvider, FlattrThing, ImageResource {
+public class FeedItem extends FeedComponent implements ShownotesProvider, ImageResource {
/** tag that indicates this item is in the queue */
public static final String TAG_QUEUE = "Queue";
@@ -60,7 +58,6 @@ public class FeedItem extends FeedComponent implements ShownotesProvider, Flattr
public static final int PLAYED = 1;
private String paymentLink;
- private final FlattrStatus flattrStatus;
/**
* Is true if the database contains any chapters that belong to this item. This attribute is only
@@ -92,7 +89,6 @@ public class FeedItem extends FeedComponent implements ShownotesProvider, Flattr
public FeedItem() {
this.state = UNPLAYED;
- this.flattrStatus = new FlattrStatus();
this.hasChapters = false;
}
@@ -100,7 +96,7 @@ public class FeedItem extends FeedComponent implements ShownotesProvider, Flattr
* This constructor is used by DBReader.
* */
public FeedItem(long id, String title, String link, Date pubDate, String paymentLink, long feedId,
- FlattrStatus flattrStatus, boolean hasChapters, String imageUrl, int state,
+ boolean hasChapters, String imageUrl, int state,
String itemIdentifier, long autoDownload) {
this.id = id;
this.title = title;
@@ -108,7 +104,6 @@ public class FeedItem extends FeedComponent implements ShownotesProvider, Flattr
this.pubDate = pubDate;
this.paymentLink = paymentLink;
this.feedId = feedId;
- this.flattrStatus = flattrStatus;
this.hasChapters = hasChapters;
this.imageUrl = imageUrl;
this.state = state;
@@ -127,7 +122,6 @@ public class FeedItem extends FeedComponent implements ShownotesProvider, Flattr
this.pubDate = (pubDate != null) ? (Date) pubDate.clone() : null;
this.state = state;
this.feed = feed;
- this.flattrStatus = new FlattrStatus();
this.hasChapters = false;
}
@@ -142,7 +136,6 @@ public class FeedItem extends FeedComponent implements ShownotesProvider, Flattr
this.pubDate = (pubDate != null) ? (Date) pubDate.clone() : null;
this.state = state;
this.feed = feed;
- this.flattrStatus = new FlattrStatus();
this.hasChapters = hasChapters;
}
@@ -153,7 +146,6 @@ public class FeedItem extends FeedComponent implements ShownotesProvider, Flattr
int indexPubDate = cursor.getColumnIndex(PodDBAdapter.KEY_PUBDATE);
int indexPaymentLink = cursor.getColumnIndex(PodDBAdapter.KEY_PAYMENT_LINK);
int indexFeedId = cursor.getColumnIndex(PodDBAdapter.KEY_FEED);
- int indexFlattrStatus = cursor.getColumnIndex(PodDBAdapter.KEY_FLATTR_STATUS);
int indexHasChapters = cursor.getColumnIndex(PodDBAdapter.KEY_HAS_CHAPTERS);
int indexRead = cursor.getColumnIndex(PodDBAdapter.KEY_READ);
int indexItemIdentifier = cursor.getColumnIndex(PodDBAdapter.KEY_ITEM_IDENTIFIER);
@@ -167,13 +159,12 @@ public class FeedItem extends FeedComponent implements ShownotesProvider, Flattr
String paymentLink = cursor.getString(indexPaymentLink);
long feedId = cursor.getLong(indexFeedId);
boolean hasChapters = cursor.getInt(indexHasChapters) > 0;
- FlattrStatus flattrStatus = new FlattrStatus(cursor.getLong(indexFlattrStatus));
int state = cursor.getInt(indexRead);
String itemIdentifier = cursor.getString(indexItemIdentifier);
long autoDownload = cursor.getLong(indexAutoDownload);
String imageUrl = cursor.getString(indexImageUrl);
- return new FeedItem(id, title, link, pubDate, paymentLink, feedId, flattrStatus,
+ return new FeedItem(id, title, link, pubDate, paymentLink, feedId,
hasChapters, imageUrl, state, itemIdentifier, autoDownload);
}
@@ -329,10 +320,6 @@ public class FeedItem extends FeedComponent implements ShownotesProvider, Flattr
public void setContentEncoded(String contentEncoded) {
this.contentEncoded = contentEncoded;
}
-
- public FlattrStatus getFlattrStatus() {
- return flattrStatus;
- }
public String getPaymentLink() {
return paymentLink;
diff --git a/core/src/main/java/de/danoeh/antennapod/core/feed/FeedMedia.java b/core/src/main/java/de/danoeh/antennapod/core/feed/FeedMedia.java
index f3a43e2d0..218570632 100644
--- a/core/src/main/java/de/danoeh/antennapod/core/feed/FeedMedia.java
+++ b/core/src/main/java/de/danoeh/antennapod/core/feed/FeedMedia.java
@@ -25,7 +25,6 @@ import de.danoeh.antennapod.core.storage.DBTasks;
import de.danoeh.antennapod.core.storage.DBWriter;
import de.danoeh.antennapod.core.storage.PodDBAdapter;
import de.danoeh.antennapod.core.util.ChapterUtils;
-import de.danoeh.antennapod.core.util.flattr.FlattrUtils;
import de.danoeh.antennapod.core.util.playback.Playable;
public class FeedMedia extends FeedFile implements Playable {
@@ -49,7 +48,7 @@ public class FeedMedia extends FeedFile implements Playable {
private int duration;
private int position; // Current position in file
private long lastPlayedTime; // Last time this media was played (in ms)
- private int played_duration; // How many ms of this file have been played (for autoflattring)
+ private int played_duration; // How many ms of this file have been played
private long size; // File size in Byte
private String mime_type;
@Nullable private volatile FeedItem item;
@@ -526,16 +525,6 @@ public class FeedMedia extends FeedFile implements Playable {
.build();
GpodnetPreferences.enqueueEpisodeAction(action);
}
- // Auto flattr
- float autoFlattrThreshold = UserPreferences.getAutoFlattrPlayedDurationThreshold();
- if (FlattrUtils.hasToken() &&
- UserPreferences.isAutoFlattr() &&
- item.getPaymentLink() != null &&
- item.getFlattrStatus().getUnflattred() &&
- ((completed && autoFlattrThreshold <= 1.0f) ||
- (played_duration >= autoFlattrThreshold * duration))) {
- DBTasks.flattrItemIfLoggedIn(context, item);
- }
}
}
diff --git a/core/src/main/java/de/danoeh/antennapod/core/preferences/UserPreferences.java b/core/src/main/java/de/danoeh/antennapod/core/preferences/UserPreferences.java
index cfa217a12..9348ca807 100644
--- a/core/src/main/java/de/danoeh/antennapod/core/preferences/UserPreferences.java
+++ b/core/src/main/java/de/danoeh/antennapod/core/preferences/UserPreferences.java
@@ -95,8 +95,6 @@ public class UserPreferences {
private static final String PREF_PROXY_PASSWORD = "prefProxyPassword";
// Services
- private static final String PREF_AUTO_FLATTR = "pref_auto_flattr";
- private static final String PREF_AUTO_FLATTR_PLAYED_DURATION_THRESHOLD = "prefAutoFlattrPlayedDurationThreshold";
private static final String PREF_GPODNET_NOTIFICATIONS = "pref_gpodnet_notifications";
// Other
@@ -318,10 +316,6 @@ public class UserPreferences {
return prefs.getBoolean(PREF_DELETE_REMOVES_FROM_QUEUE, false);
}
- public static boolean isAutoFlattr() {
- return prefs.getBoolean(PREF_AUTO_FLATTR, false);
- }
-
public static String getPlaybackSpeed() {
return prefs.getString(PREF_PLAYBACK_SPEED, "1.00");
}
@@ -450,16 +444,7 @@ public class UserPreferences {
}
public static int getRewindSecs() {
- return prefs.getInt(PREF_REWIND_SECS, 30);
- }
-
-
- /**
- * Returns the time after which an episode should be auto-flattr'd in percent of the episode's
- * duration.
- */
- public static float getAutoFlattrPlayedDurationThreshold() {
- return prefs.getFloat(PREF_AUTO_FLATTR_PLAYED_DURATION_THRESHOLD, 0.8f);
+ return prefs.getInt(PREF_REWIND_SECS, 10);
}
public static String[] getAutodownloadSelectedNetworks() {
@@ -588,23 +573,6 @@ public class UserPreferences {
AutoUpdateManager.disableAutoUpdate();
}
- /**
- * Change the auto-flattr settings
- *
- * @param enabled Whether automatic flattring should be enabled at all
- * @param autoFlattrThreshold The percentage of playback time after which an episode should be
- * flattrd. Must be a value between 0 and 1 (inclusive)
- * */
- public static void setAutoFlattrSettings( boolean enabled, float autoFlattrThreshold) {
- if(autoFlattrThreshold < 0.0 || autoFlattrThreshold > 1.0) {
- throw new IllegalArgumentException("Flattr threshold must be in range [0.0, 1.0]");
- }
- prefs.edit()
- .putBoolean(PREF_AUTO_FLATTR, enabled)
- .putFloat(PREF_AUTO_FLATTR_PLAYED_DURATION_THRESHOLD, autoFlattrThreshold)
- .apply();
- }
-
public static boolean gpodnetNotificationsEnabled() {
return prefs.getBoolean(PREF_GPODNET_NOTIFICATIONS, true);
}
@@ -681,12 +649,16 @@ public class UserPreferences {
return selectedSpeeds;
}
+ public static String getMediaPlayer() {
+ return prefs.getString(PREF_MEDIA_PLAYER, PREF_MEDIA_PLAYER_EXOPLAYER);
+ }
+
public static boolean useSonic() {
- return prefs.getString(PREF_MEDIA_PLAYER, "sonic").equals("sonic");
+ return getMediaPlayer().equals("sonic");
}
public static boolean useExoplayer() {
- return prefs.getString(PREF_MEDIA_PLAYER, "sonic").equals(PREF_MEDIA_PLAYER_EXOPLAYER);
+ return getMediaPlayer().equals(PREF_MEDIA_PLAYER_EXOPLAYER);
}
public static void enableSonic() {
diff --git a/core/src/main/java/de/danoeh/antennapod/core/service/PlayerWidgetJobService.java b/core/src/main/java/de/danoeh/antennapod/core/service/PlayerWidgetJobService.java
index 1165d689a..b26d3011d 100644
--- a/core/src/main/java/de/danoeh/antennapod/core/service/PlayerWidgetJobService.java
+++ b/core/src/main/java/de/danoeh/antennapod/core/service/PlayerWidgetJobService.java
@@ -41,6 +41,7 @@ public class PlayerWidgetJobService extends SafeJobIntentService {
private PlaybackService playbackService;
private final Object waitForService = new Object();
+ private final Object waitUsingService = new Object();
private static final int JOB_ID = -17001;
@@ -67,7 +68,11 @@ public class PlayerWidgetJobService extends SafeJobIntentService {
}
}
- updateViews();
+ synchronized (waitUsingService) {
+ if (playbackService != null) {
+ updateViews();
+ }
+ }
if (playbackService != null) {
try {
@@ -230,7 +235,9 @@ public class PlayerWidgetJobService extends SafeJobIntentService {
@Override
public void onServiceDisconnected(ComponentName name) {
- playbackService = null;
+ synchronized (waitUsingService) {
+ playbackService = null;
+ }
Log.d(TAG, "Disconnected from service");
}
diff --git a/core/src/main/java/de/danoeh/antennapod/core/service/playback/LocalPSMP.java b/core/src/main/java/de/danoeh/antennapod/core/service/playback/LocalPSMP.java
index 7988526d9..9a8353806 100644
--- a/core/src/main/java/de/danoeh/antennapod/core/service/playback/LocalPSMP.java
+++ b/core/src/main/java/de/danoeh/antennapod/core/service/playback/LocalPSMP.java
@@ -243,7 +243,7 @@ public class LocalPSMP extends PlaybackServiceMediaPlayer {
callback.onMediaChanged(false);
if (stream) {
mediaPlayer.setDataSource(media.getStreamUrl());
- } else if (new File(media.getLocalMediaUrl()).canRead()) {
+ } else if (media.getLocalMediaUrl() != null && new File(media.getLocalMediaUrl()).canRead()) {
mediaPlayer.setDataSource(media.getLocalMediaUrl());
} else {
throw new IOException("Unable to read local file " + media.getLocalMediaUrl());
diff --git a/core/src/main/java/de/danoeh/antennapod/core/storage/DBReader.java b/core/src/main/java/de/danoeh/antennapod/core/storage/DBReader.java
index 1b579f99a..19faa5aed 100644
--- a/core/src/main/java/de/danoeh/antennapod/core/storage/DBReader.java
+++ b/core/src/main/java/de/danoeh/antennapod/core/storage/DBReader.java
@@ -26,7 +26,6 @@ import de.danoeh.antennapod.core.util.LongList;
import de.danoeh.antennapod.core.util.comparator.DownloadStatusComparator;
import de.danoeh.antennapod.core.util.comparator.FeedItemPubdateComparator;
import de.danoeh.antennapod.core.util.comparator.PlaybackCompletionDateComparator;
-import de.danoeh.antennapod.core.util.flattr.FlattrThing;
/**
* Provides methods for reading data from the AntennaPod database.
@@ -1004,36 +1003,6 @@ public final class DBReader {
}
/**
- * Returns the flattr queue as a List of FlattrThings. The list consists of Feeds and FeedItems.
- *
- * @return The flattr queue as a List.
- */
- public static List<FlattrThing> getFlattrQueue() {
- Log.d(TAG, "getFlattrQueue() called with: " + "");
- PodDBAdapter adapter = PodDBAdapter.getInstance();
- adapter.open();
- List<FlattrThing> result = new ArrayList<>();
-
- // load feeds
- Cursor feedCursor = adapter.getFeedsInFlattrQueueCursor();
- if (feedCursor.moveToFirst()) {
- do {
- result.add(extractFeedFromCursorRow(feedCursor));
- } while (feedCursor.moveToNext());
- }
- feedCursor.close();
-
- //load feed items
- Cursor feedItemCursor = adapter.getFeedItemsInFlattrQueueCursor();
- result.addAll(extractItemlistFromCursor(adapter, feedItemCursor));
- feedItemCursor.close();
-
- adapter.close();
- Log.d(TAG, "Returning flattrQueueIterator for queue with " + result.size() + " items.");
- return result;
- }
-
- /**
* Returns data necessary for displaying the navigation drawer. This includes
* the list of subscriptions, the number of items in the queue and the number of unread
* items.
diff --git a/core/src/main/java/de/danoeh/antennapod/core/storage/DBTasks.java b/core/src/main/java/de/danoeh/antennapod/core/storage/DBTasks.java
index dab8e19b5..e68bff16e 100644
--- a/core/src/main/java/de/danoeh/antennapod/core/storage/DBTasks.java
+++ b/core/src/main/java/de/danoeh/antennapod/core/storage/DBTasks.java
@@ -20,8 +20,6 @@ import java.util.concurrent.FutureTask;
import java.util.concurrent.atomic.AtomicBoolean;
import de.danoeh.antennapod.core.ClientConfig;
-import de.danoeh.antennapod.core.asynctask.FlattrClickWorker;
-import de.danoeh.antennapod.core.asynctask.FlattrStatusFetcher;
import de.danoeh.antennapod.core.feed.EventDistributor;
import de.danoeh.antennapod.core.feed.Feed;
import de.danoeh.antennapod.core.feed.FeedItem;
@@ -35,7 +33,6 @@ import de.danoeh.antennapod.core.util.IntentUtils;
import de.danoeh.antennapod.core.util.LongList;
import de.danoeh.antennapod.core.util.comparator.FeedItemPubdateComparator;
import de.danoeh.antennapod.core.util.exception.MediaFileNotFoundException;
-import de.danoeh.antennapod.core.util.flattr.FlattrUtils;
import de.danoeh.antennapod.core.util.playback.PlaybackServiceStarter;
import static android.content.Context.MODE_PRIVATE;
@@ -182,14 +179,6 @@ public final class DBTasks {
SharedPreferences prefs = context.getSharedPreferences(PREF_NAME, MODE_PRIVATE);
prefs.edit().putLong(PREF_LAST_REFRESH, System.currentTimeMillis()).apply();
- if (FlattrUtils.hasToken()) {
- Log.d(TAG, "Flattring all pending things.");
- new FlattrClickWorker(context).executeAsync(); // flattr pending things
-
- Log.d(TAG, "Fetching flattr status.");
- new FlattrStatusFetcher(context).start();
-
- }
if (ClientConfig.gpodnetCallbacks.gpodnetEnabled()) {
GpodnetSyncService.sendSyncIntent(context);
}
@@ -771,37 +760,4 @@ public final class DBTasks {
this.result = result;
}
}
-
- /**
- * 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.showNoTokenDialogOrRedirect(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.showNoTokenDialogOrRedirect(context, feed.getPaymentLink());
- }
- }
-
}
diff --git a/core/src/main/java/de/danoeh/antennapod/core/storage/DBUpgrader.java b/core/src/main/java/de/danoeh/antennapod/core/storage/DBUpgrader.java
index 0beb765e7..306f8d104 100644
--- a/core/src/main/java/de/danoeh/antennapod/core/storage/DBUpgrader.java
+++ b/core/src/main/java/de/danoeh/antennapod/core/storage/DBUpgrader.java
@@ -76,10 +76,10 @@ class DBUpgrader {
}
if (oldVersion <= 10) {
db.execSQL("ALTER TABLE " + PodDBAdapter.TABLE_NAME_FEEDS
- + " ADD COLUMN " + PodDBAdapter.KEY_FLATTR_STATUS
+ + " ADD COLUMN flattr_status"
+ " INTEGER");
db.execSQL("ALTER TABLE " + PodDBAdapter.TABLE_NAME_FEED_ITEMS
- + " ADD COLUMN " + PodDBAdapter.KEY_FLATTR_STATUS
+ + " ADD COLUMN flattr_status"
+ " INTEGER");
db.execSQL("ALTER TABLE " + PodDBAdapter.TABLE_NAME_FEED_MEDIA
+ " ADD COLUMN " + PodDBAdapter.KEY_PLAYED_DURATION
diff --git a/core/src/main/java/de/danoeh/antennapod/core/storage/DBWriter.java b/core/src/main/java/de/danoeh/antennapod/core/storage/DBWriter.java
index 515b463db..2de811788 100644
--- a/core/src/main/java/de/danoeh/antennapod/core/storage/DBWriter.java
+++ b/core/src/main/java/de/danoeh/antennapod/core/storage/DBWriter.java
@@ -9,7 +9,6 @@ import android.support.annotation.NonNull;
import android.util.Log;
import org.greenrobot.eventbus.EventBus;
-import org.shredzone.flattr4j.model.Flattr;
import java.io.File;
import java.io.UnsupportedEncodingException;
@@ -26,7 +25,6 @@ import java.util.concurrent.Future;
import de.danoeh.antennapod.core.ClientConfig;
import de.danoeh.antennapod.core.R;
-import de.danoeh.antennapod.core.asynctask.FlattrClickWorker;
import de.danoeh.antennapod.core.event.FavoritesEvent;
import de.danoeh.antennapod.core.event.FeedItemEvent;
import de.danoeh.antennapod.core.event.MessageEvent;
@@ -47,9 +45,6 @@ import de.danoeh.antennapod.core.util.IntentUtils;
import de.danoeh.antennapod.core.util.LongList;
import de.danoeh.antennapod.core.util.Permutor;
import de.danoeh.antennapod.core.util.QueueSorter;
-import de.danoeh.antennapod.core.util.flattr.FlattrStatus;
-import de.danoeh.antennapod.core.util.flattr.FlattrThing;
-import de.danoeh.antennapod.core.util.flattr.SimpleFlattrThing;
/**
* Provides methods for writing data to AntennaPod's database.
@@ -685,7 +680,7 @@ public class DBWriter {
*
* @param feedId ID of the Feed.
*/
- public static Future<?> markFeedSeen(final long feedId) {
+ public static Future<?> removeFeedNewFlag(final long feedId) {
return dbExec.submit(() -> {
final PodDBAdapter adapter = PodDBAdapter.getInstance();
adapter.open();
@@ -729,7 +724,7 @@ public class DBWriter {
/**
* Sets the 'read'-attribute of all NEW FeedItems to UNPLAYED.
*/
- public static Future<?> markNewItemsSeen() {
+ public static Future<?> removeAllNewFlags() {
return dbExec.submit(() -> {
final PodDBAdapter adapter = PodDBAdapter.getInstance();
adapter.open();
@@ -855,44 +850,6 @@ public class DBWriter {
}
/**
- * Saves the FlattrStatus of a FeedItem object in the database.
- *
- * @param startFlattrClickWorker true if FlattrClickWorker should be started after the FlattrStatus has been saved
- */
- private static Future<?> setFeedItemFlattrStatus(final Context context,
- final FeedItem item,
- final boolean startFlattrClickWorker) {
- return dbExec.submit(() -> {
- PodDBAdapter adapter = PodDBAdapter.getInstance();
- adapter.open();
- adapter.setFeedItemFlattrStatus(item);
- adapter.close();
- if (startFlattrClickWorker) {
- new FlattrClickWorker(context).executeAsync();
- }
- });
- }
-
- /**
- * Saves the FlattrStatus of a Feed object in the database.
- *
- * @param startFlattrClickWorker true if FlattrClickWorker should be started after the FlattrStatus has been saved
- */
- private static Future<?> setFeedFlattrStatus(final Context context,
- final Feed feed,
- final boolean startFlattrClickWorker) {
- return dbExec.submit(() -> {
- PodDBAdapter adapter = PodDBAdapter.getInstance();
- adapter.open();
- adapter.setFeedFlattrStatus(feed);
- adapter.close();
- if (startFlattrClickWorker) {
- new FlattrClickWorker(context).executeAsync();
- }
- });
- }
-
- /**
* Saves if a feed's last update failed
*
* @param lastUpdateFailed true if last update failed
@@ -917,77 +874,6 @@ public class DBWriter {
});
}
-
- /**
- * format an url for querying the database
- * (postfix a / and apply percent-encoding)
- */
- private static String formatURIForQuery(String uri) {
- try {
- return URLEncoder.encode(uri.endsWith("/") ? uri.substring(0, uri.length() - 1) : uri, "UTF-8");
- } catch (UnsupportedEncodingException e) {
- Log.e(TAG, e.getMessage());
- return "";
- }
- }
-
-
- /**
- * Set flattr status of the passed thing (either a FeedItem or a Feed)
- *
- * @param context
- * @param thing
- * @param startFlattrClickWorker true if FlattrClickWorker should be started after the FlattrStatus has been saved
- * @return
- */
- public static Future<?> setFlattredStatus(Context context, FlattrThing thing, boolean startFlattrClickWorker) {
- // must propagate this to back db
- if (thing instanceof FeedItem) {
- return setFeedItemFlattrStatus(context, (FeedItem) thing, startFlattrClickWorker);
- } else if (thing instanceof Feed) {
- return setFeedFlattrStatus(context, (Feed) thing, startFlattrClickWorker);
- } else if (thing instanceof SimpleFlattrThing) {
- // SimpleFlattrThings are generated on the fly and do not have DB backing
- } else {
- Log.e(TAG, "flattrQueue processing - thing is neither FeedItem nor Feed nor SimpleFlattrThing");
- }
-
- return null;
- }
-
- /**
- * Reset flattr status to unflattrd for all items
- */
- public static Future<?> clearAllFlattrStatus() {
- Log.d(TAG, "clearAllFlattrStatus()");
- return dbExec.submit(() -> {
- PodDBAdapter adapter = PodDBAdapter.getInstance();
- adapter.open();
- adapter.clearAllFlattrStatus();
- adapter.close();
- });
- }
-
- /**
- * Set flattr status of the feeds/feeditems in flattrList to flattred at the given timestamp,
- * where the information has been retrieved from the flattr API
- */
- public static Future<?> setFlattredStatus(final List<Flattr> flattrList) {
- Log.d(TAG, "setFlattredStatus to status retrieved from flattr api running with " + flattrList.size() + " items");
- // clear flattr status in db
- clearAllFlattrStatus();
-
- // submit list with flattred things having normalized URLs to db
- return dbExec.submit(() -> {
- PodDBAdapter adapter = PodDBAdapter.getInstance();
- adapter.open();
- for (Flattr flattr : flattrList) {
- adapter.setItemFlattrStatus(formatURIForQuery(flattr.getThing().getUrl()), new FlattrStatus(flattr.getCreated().getTime()));
- }
- adapter.close();
- });
- }
-
/**
* Sort the FeedItems in the queue with the given Permutor.
*
diff --git a/core/src/main/java/de/danoeh/antennapod/core/storage/PodDBAdapter.java b/core/src/main/java/de/danoeh/antennapod/core/storage/PodDBAdapter.java
index 405c246c9..f7956372b 100644
--- a/core/src/main/java/de/danoeh/antennapod/core/storage/PodDBAdapter.java
+++ b/core/src/main/java/de/danoeh/antennapod/core/storage/PodDBAdapter.java
@@ -38,7 +38,6 @@ import de.danoeh.antennapod.core.feed.FeedPreferences;
import de.danoeh.antennapod.core.preferences.UserPreferences;
import de.danoeh.antennapod.core.service.download.DownloadStatus;
import de.danoeh.antennapod.core.util.LongIntMap;
-import de.danoeh.antennapod.core.util.flattr.FlattrStatus;
import org.greenrobot.eventbus.EventBus;
// TODO Remove media column from feeditem table
@@ -96,7 +95,6 @@ public class PodDBAdapter {
public static final String KEY_HAS_CHAPTERS = "has_simple_chapters";
public static final String KEY_TYPE = "type";
public static final String KEY_ITEM_IDENTIFIER = "item_identifier";
- public static final String KEY_FLATTR_STATUS = "flattr_status";
public static final String KEY_FEED_IDENTIFIER = "feed_identifier";
public static final String KEY_REASON_DETAILED = "reason_detailed";
public static final String KEY_DOWNLOADSTATUS_TITLE = "title";
@@ -139,7 +137,6 @@ public class PodDBAdapter {
+ KEY_LASTUPDATE + " TEXT," + KEY_LANGUAGE + " TEXT," + KEY_AUTHOR
+ " TEXT," + KEY_IMAGE_URL + " TEXT," + KEY_TYPE + " TEXT,"
+ KEY_FEED_IDENTIFIER + " TEXT," + KEY_AUTO_DOWNLOAD + " INTEGER DEFAULT 1,"
- + KEY_FLATTR_STATUS + " INTEGER,"
+ KEY_USERNAME + " TEXT,"
+ KEY_PASSWORD + " TEXT,"
+ KEY_INCLUDE_FILTER + " TEXT DEFAULT '',"
@@ -158,7 +155,6 @@ public class PodDBAdapter {
+ KEY_DESCRIPTION + " TEXT," + KEY_PAYMENT_LINK + " TEXT,"
+ KEY_MEDIA + " INTEGER," + KEY_FEED + " INTEGER,"
+ KEY_HAS_CHAPTERS + " INTEGER," + KEY_ITEM_IDENTIFIER + " TEXT,"
- + KEY_FLATTR_STATUS + " INTEGER,"
+ KEY_IMAGE_URL + " TEXT,"
+ KEY_AUTO_DOWNLOAD + " INTEGER)";
@@ -239,7 +235,6 @@ public class PodDBAdapter {
TABLE_NAME_FEEDS + "." + KEY_FEED_IDENTIFIER,
TABLE_NAME_FEEDS + "." + KEY_AUTO_DOWNLOAD,
TABLE_NAME_FEEDS + "." + KEY_KEEP_UPDATED,
- TABLE_NAME_FEEDS + "." + KEY_FLATTR_STATUS,
TABLE_NAME_FEEDS + "." + KEY_IS_PAGED,
TABLE_NAME_FEEDS + "." + KEY_NEXT_PAGE_LINK,
TABLE_NAME_FEEDS + "." + KEY_USERNAME,
@@ -266,7 +261,6 @@ public class PodDBAdapter {
TABLE_NAME_FEED_ITEMS + "." + KEY_FEED,
TABLE_NAME_FEED_ITEMS + "." + KEY_HAS_CHAPTERS,
TABLE_NAME_FEED_ITEMS + "." + KEY_ITEM_IDENTIFIER,
- TABLE_NAME_FEED_ITEMS + "." + KEY_FLATTR_STATUS,
TABLE_NAME_FEED_ITEMS + "." + KEY_IMAGE_URL,
TABLE_NAME_FEED_ITEMS + "." + KEY_AUTO_DOWNLOAD
};
@@ -382,9 +376,6 @@ public class PodDBAdapter {
values.put(KEY_TYPE, feed.getType());
values.put(KEY_FEED_IDENTIFIER, feed.getFeedIdentifier());
- Log.d(TAG, "Setting feed with flattr status " + feed.getTitle() + ": " + feed.getFlattrStatus().toLong());
-
- values.put(KEY_FLATTR_STATUS, feed.getFlattrStatus().toLong());
values.put(KEY_IS_PAGED, feed.isPaged());
values.put(KEY_NEXT_PAGE_LINK, feed.getNextPageLink());
if (feed.getItemFilter() != null && feed.getItemFilter().getValues().length > 0) {
@@ -516,31 +507,6 @@ public class PodDBAdapter {
}
/**
- * Update the flattr status of a feed
- */
- public void setFeedFlattrStatus(Feed feed) {
- ContentValues values = new ContentValues();
- values.put(KEY_FLATTR_STATUS, feed.getFlattrStatus().toLong());
- db.update(TABLE_NAME_FEEDS, values, KEY_ID + "=?", new String[]{String.valueOf(feed.getId())});
- }
-
- /**
- * Get all feeds in the flattr queue.
- */
- public Cursor getFeedsInFlattrQueueCursor() {
- return db.query(TABLE_NAME_FEEDS, FEED_SEL_STD, KEY_FLATTR_STATUS + "=?",
- new String[]{String.valueOf(FlattrStatus.STATUS_QUEUE)}, null, null, null);
- }
-
- /**
- * Get all feed items in the flattr queue.
- */
- public Cursor getFeedItemsInFlattrQueueCursor() {
- return db.query(TABLE_NAME_FEED_ITEMS, FEEDITEM_SEL_FI_SMALL, KEY_FLATTR_STATUS + "=?",
- new String[]{String.valueOf(FlattrStatus.STATUS_QUEUE)}, null, null, null);
- }
-
- /**
* Updates the download URL of a Feed.
*/
public void setFeedDownloadUrl(String original, String updated) {
@@ -578,61 +544,6 @@ public class PodDBAdapter {
}
/**
- * Update the flattr status of a FeedItem
- */
- public void setFeedItemFlattrStatus(FeedItem feedItem) {
- ContentValues values = new ContentValues();
- values.put(KEY_FLATTR_STATUS, feedItem.getFlattrStatus().toLong());
- db.update(TABLE_NAME_FEED_ITEMS, values, KEY_ID + "=?", new String[]{String.valueOf(feedItem.getId())});
- }
-
- /**
- * Update the flattr status of a feed or feed item specified by its payment link
- * and the new flattr status to use
- */
- public void setItemFlattrStatus(String url, FlattrStatus status) {
- //Log.d(TAG, "setItemFlattrStatus(" + url + ") = " + status.toString());
- ContentValues values = new ContentValues();
- values.put(KEY_FLATTR_STATUS, status.toLong());
-
- // regexps in sqlite would be neat!
- String[] query_urls = new String[]{
- "*" + url + "&*",
- "*" + url + "%2F&*",
- "*" + url + "",
- "*" + url + "%2F"
- };
-
- if (db.update(TABLE_NAME_FEEDS, values,
- KEY_PAYMENT_LINK + " GLOB ?"
- + " OR " + KEY_PAYMENT_LINK + " GLOB ?"
- + " OR " + KEY_PAYMENT_LINK + " GLOB ?"
- + " OR " + KEY_PAYMENT_LINK + " GLOB ?", query_urls
- ) > 0) {
- Log.i(TAG, "setItemFlattrStatus found match for " + url + " = " + status.toLong() + " in Feeds table");
- return;
- }
- if (db.update(TABLE_NAME_FEED_ITEMS, values,
- KEY_PAYMENT_LINK + " GLOB ?"
- + " OR " + KEY_PAYMENT_LINK + " GLOB ?"
- + " OR " + KEY_PAYMENT_LINK + " GLOB ?"
- + " OR " + KEY_PAYMENT_LINK + " GLOB ?", query_urls
- ) > 0) {
- Log.i(TAG, "setItemFlattrStatus found match for " + url + " = " + status.toLong() + " in FeedsItems table");
- }
- }
-
- /**
- * Reset flattr status to unflattrd for all items
- */
- public void clearAllFlattrStatus() {
- ContentValues values = new ContentValues();
- values.put(KEY_FLATTR_STATUS, 0);
- db.update(TABLE_NAME_FEEDS, values, null, null);
- db.update(TABLE_NAME_FEED_ITEMS, values, null, null);
- }
-
- /**
* Inserts or updates a feeditem entry
*
* @param item The FeedItem
@@ -665,7 +576,6 @@ public class PodDBAdapter {
}
values.put(KEY_HAS_CHAPTERS, item.getChapters() != null || item.hasChapters());
values.put(KEY_ITEM_IDENTIFIER, item.getItemIdentifier());
- values.put(KEY_FLATTR_STATUS, item.getFlattrStatus().toLong());
values.put(KEY_AUTO_DOWNLOAD, item.getAutoDownload());
values.put(KEY_IMAGE_URL, item.getImageUrl());
diff --git a/core/src/main/java/de/danoeh/antennapod/core/util/flattr/FlattrServiceCreator.java b/core/src/main/java/de/danoeh/antennapod/core/util/flattr/FlattrServiceCreator.java
deleted file mode 100644
index d4d5843d2..000000000
--- a/core/src/main/java/de/danoeh/antennapod/core/util/flattr/FlattrServiceCreator.java
+++ /dev/null
@@ -1,32 +0,0 @@
-package de.danoeh.antennapod.core.util.flattr;
-
-import android.util.Log;
-
-import org.shredzone.flattr4j.FlattrFactory;
-import org.shredzone.flattr4j.FlattrService;
-import org.shredzone.flattr4j.oauth.AccessToken;
-
-import de.danoeh.antennapod.core.BuildConfig;
-
-/** Ensures that only one instance of the FlattrService class exists at a time */
-
-class FlattrServiceCreator {
- private FlattrServiceCreator(){}
-
- public static final String TAG = "FlattrServiceCreator";
-
- private static volatile FlattrService flattrService;
-
- public static synchronized FlattrService getService(AccessToken token) {
- if (flattrService == null) {
- flattrService = FlattrFactory.getInstance().createFlattrService(token);
- }
- return flattrService;
- }
-
- public static synchronized void deleteFlattrService() {
- if (BuildConfig.DEBUG) Log.d(TAG, "Deleting service instance");
- flattrService = null;
- }
-}
-
diff --git a/core/src/main/java/de/danoeh/antennapod/core/util/flattr/FlattrStatus.java b/core/src/main/java/de/danoeh/antennapod/core/util/flattr/FlattrStatus.java
deleted file mode 100644
index 40a9fc7d5..000000000
--- a/core/src/main/java/de/danoeh/antennapod/core/util/flattr/FlattrStatus.java
+++ /dev/null
@@ -1,68 +0,0 @@
-package de.danoeh.antennapod.core.util.flattr;
-
-import java.util.Calendar;
-
-public class FlattrStatus {
- private static final int STATUS_UNFLATTERED = 0;
- public static final int STATUS_QUEUE = 1;
- private static final int STATUS_FLATTRED = 2;
-
- private int status = STATUS_UNFLATTERED;
- private Calendar lastFlattred;
-
- public FlattrStatus() {
- status = STATUS_UNFLATTERED;
- lastFlattred = Calendar.getInstance();
- }
-
- public FlattrStatus(long status) {
- lastFlattred = Calendar.getInstance();
- fromLong(status);
- }
-
- public void setFlattred() {
- status = STATUS_FLATTRED;
- lastFlattred = Calendar.getInstance();
- }
-
- public void setUnflattred() {
- status = STATUS_UNFLATTERED;
- }
-
- public boolean getUnflattred() {
- return status == STATUS_UNFLATTERED;
- }
-
- public void setFlattrQueue() {
- if (flattrable())
- status = STATUS_QUEUE;
- }
-
- private void fromLong(long status) {
- if (status == STATUS_UNFLATTERED || status == STATUS_QUEUE)
- this.status = (int) status;
- else {
- this.status = STATUS_FLATTRED;
- lastFlattred.setTimeInMillis(status);
- }
- }
-
- public long toLong() {
- if (status == STATUS_UNFLATTERED || status == STATUS_QUEUE)
- return status;
- else {
- return lastFlattred.getTimeInMillis();
- }
- }
-
- public boolean flattrable() {
- Calendar firstOfMonth = Calendar.getInstance();
- firstOfMonth.set(Calendar.DAY_OF_MONTH, Calendar.getInstance().getActualMinimum(Calendar.DAY_OF_MONTH));
-
- return (status == STATUS_UNFLATTERED) || (status == STATUS_FLATTRED && firstOfMonth.after(lastFlattred) );
- }
-
- public boolean getFlattrQueue() {
- return status == STATUS_QUEUE;
- }
-}
diff --git a/core/src/main/java/de/danoeh/antennapod/core/util/flattr/FlattrThing.java b/core/src/main/java/de/danoeh/antennapod/core/util/flattr/FlattrThing.java
deleted file mode 100644
index d5bb88771..000000000
--- a/core/src/main/java/de/danoeh/antennapod/core/util/flattr/FlattrThing.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package de.danoeh.antennapod.core.util.flattr;
-
-public interface FlattrThing {
- String getTitle();
- String getPaymentLink();
- FlattrStatus getFlattrStatus();
-}
diff --git a/core/src/main/java/de/danoeh/antennapod/core/util/flattr/FlattrUtils.java b/core/src/main/java/de/danoeh/antennapod/core/util/flattr/FlattrUtils.java
deleted file mode 100644
index 919fc82f2..000000000
--- a/core/src/main/java/de/danoeh/antennapod/core/util/flattr/FlattrUtils.java
+++ /dev/null
@@ -1,220 +0,0 @@
-package de.danoeh.antennapod.core.util.flattr;
-
-import android.content.Context;
-import android.content.Intent;
-import android.content.SharedPreferences;
-import android.net.Uri;
-import android.preference.PreferenceManager;
-import android.support.v7.app.AlertDialog;
-import android.text.TextUtils;
-import android.util.Log;
-
-import org.shredzone.flattr4j.FlattrService;
-import org.shredzone.flattr4j.exception.FlattrException;
-import org.shredzone.flattr4j.model.Flattr;
-import org.shredzone.flattr4j.model.Thing;
-import org.shredzone.flattr4j.oauth.AccessToken;
-import org.shredzone.flattr4j.oauth.AndroidAuthenticator;
-import org.shredzone.flattr4j.oauth.Scope;
-
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.EnumSet;
-import java.util.List;
-import java.util.TimeZone;
-
-import de.danoeh.antennapod.core.ClientConfig;
-import de.danoeh.antennapod.core.R;
-import de.danoeh.antennapod.core.asynctask.FlattrTokenFetcher;
-import de.danoeh.antennapod.core.storage.DBWriter;
-
-/**
- * Utility methods for doing something with flattr.
- */
-
-public class FlattrUtils {
- private FlattrUtils(){}
-
- private static final String TAG = "FlattrUtils";
-
- private static final String HOST_NAME = "de.danoeh.antennapod";
-
- private static final String PREF_ACCESS_TOKEN = "de.danoeh.antennapod.preference.flattrAccessToken";
-
- private static volatile AccessToken cachedToken;
-
- private static AndroidAuthenticator createAuthenticator() {
- return new AndroidAuthenticator(HOST_NAME, ClientConfig.flattrCallbacks.getFlattrAppKey(),
- ClientConfig.flattrCallbacks.getFlattrAppSecret());
- }
-
- public static void startAuthProcess(Context context) throws FlattrException {
- AndroidAuthenticator auth = createAuthenticator();
- auth.setScope(EnumSet.of(Scope.FLATTR));
- Intent intent = auth.createAuthenticateIntent();
- context.startActivity(intent);
- }
-
- private static AccessToken retrieveToken() {
- if (cachedToken == null) {
- Log.d(TAG, "Retrieving access token");
- String token = PreferenceManager.getDefaultSharedPreferences(
- ClientConfig.applicationCallbacks.getApplicationInstance())
- .getString(PREF_ACCESS_TOKEN, null);
- if (token != null) {
- Log.d(TAG, "Found access token. Caching.");
- cachedToken = new AccessToken(token);
- } else {
- Log.d(TAG, "No access token found");
- return null;
- }
- }
- return cachedToken;
-
- }
-
- /**
- * Returns true if FLATTR_APP_KEY and FLATTR_APP_SECRET in BuildConfig are not null and not empty
- */
- public static boolean hasAPICredentials() {
- return !TextUtils.isEmpty(ClientConfig.flattrCallbacks.getFlattrAppKey())
- && !TextUtils.isEmpty(ClientConfig.flattrCallbacks.getFlattrAppSecret());
- }
-
- public static boolean hasToken() {
- return retrieveToken() != null;
- }
-
- public static void storeToken(AccessToken token) {
- Log.d(TAG, "Storing token");
- SharedPreferences.Editor editor = PreferenceManager
- .getDefaultSharedPreferences(ClientConfig.applicationCallbacks.getApplicationInstance()).edit();
- if (token != null) {
- editor.putString(PREF_ACCESS_TOKEN, token.getToken());
- } else {
- editor.putString(PREF_ACCESS_TOKEN, null);
- }
- editor.commit();
- cachedToken = token;
- }
-
- private static void deleteToken() {
- Log.d(TAG, "Deleting flattr token");
- storeToken(null);
- }
-
- public static void clickUrl(Context context, String url)
- throws FlattrException {
- if (hasToken()) {
- FlattrService fs = FlattrServiceCreator.getService(retrieveToken());
- fs.flattr(url);
- } else {
- Log.e(TAG, "clickUrl was called with null access token");
- }
- }
-
- public static List<Flattr> retrieveFlattredThings()
- throws FlattrException {
- ArrayList<Flattr> myFlattrs = new ArrayList<>();
-
- if (hasToken()) {
- FlattrService fs = FlattrServiceCreator.getService(retrieveToken());
-
- Calendar firstOfMonth = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
- firstOfMonth.set(Calendar.MILLISECOND, 0);
- firstOfMonth.set(Calendar.SECOND, 0);
- firstOfMonth.set(Calendar.MINUTE, 0);
- firstOfMonth.set(Calendar.HOUR_OF_DAY, 0);
- firstOfMonth.set(Calendar.DAY_OF_MONTH, Calendar.getInstance().getActualMinimum(Calendar.DAY_OF_MONTH));
-
- Date firstOfMonthDate = firstOfMonth.getTime();
-
- // subscriptions some times get flattrd slightly before midnight - give it an hour leeway
- firstOfMonthDate = new Date(firstOfMonthDate.getTime() - 60 * 60 * 1000);
-
- final int FLATTR_COUNT = 30;
- final int FLATTR_MAXPAGE = 5;
-
- for (int page = 0; page < FLATTR_MAXPAGE; page++) {
- for (Flattr fl : fs.getMyFlattrs(FLATTR_COUNT, page)) {
- if (fl.getCreated().after(firstOfMonthDate))
- myFlattrs.add(fl);
- else
- break;
- }
- }
-
- Log.d(TAG, "Got my flattrs list of length " + Integer.toString(myFlattrs.size()) + " comparison date" + firstOfMonthDate);
- for (Flattr fl : myFlattrs) {
- Thing thing = fl.getThing();
- Log.d(TAG, "Flattr thing: " + fl.getThingId() + " name: " + thing.getTitle() + " url: " + thing.getUrl() + " on: " + fl.getCreated());
- }
- } else {
- Log.e(TAG, "retrieveFlattrdThings was called with null access token");
- }
-
- return myFlattrs;
- }
-
- public static void handleCallback(Context context, Uri uri) {
- AndroidAuthenticator auth = createAuthenticator();
- new FlattrTokenFetcher(context, auth, uri).executeAsync();
- }
-
- public static void revokeAccessToken(Context context) {
- Log.d(TAG, "Revoking access token");
- deleteToken();
- FlattrServiceCreator.deleteFlattrService();
- showRevokeDialog(context);
- DBWriter.clearAllFlattrStatus();
- }
-
- // ------------------------------------------------ DIALOGS
-
- private static void showRevokeDialog(final Context context) {
- AlertDialog.Builder builder = new AlertDialog.Builder(context);
- builder.setTitle(R.string.access_revoked_title);
- builder.setMessage(R.string.access_revoked_info);
- builder.setNeutralButton(android.R.string.ok, (dialog, which) -> dialog.cancel());
- builder.create().show();
- }
-
- /**
- * Opens a dialog that ask the user to either connect the app with flattr or to be redirected to
- * the thing's website.
- * If no API credentials are available, the user will immediately be redirected to the thing's website.
- */
- public static void showNoTokenDialogOrRedirect(final Context context, final String url) {
- if (hasAPICredentials()) {
- AlertDialog.Builder builder = new AlertDialog.Builder(context);
- builder.setTitle(R.string.no_flattr_token_title);
- builder.setMessage(R.string.no_flattr_token_msg);
- builder.setPositiveButton(R.string.authenticate_now_label,
- (dialog, which) -> context.startActivity(
- ClientConfig.flattrCallbacks.getFlattrAuthenticationActivityIntent(context))
- );
-
- builder.setNegativeButton(R.string.visit_website_label,
- (dialog, which) -> {
- Uri uri = Uri.parse(url);
- context.startActivity(new Intent(Intent.ACTION_VIEW,
- uri));
- }
- );
- builder.create().show();
- } else {
- Uri uri = Uri.parse(url);
- context.startActivity(new Intent(Intent.ACTION_VIEW, uri));
- }
- }
-
- public static void showErrorDialog(final Context context, final String msg) {
- AlertDialog.Builder builder = new AlertDialog.Builder(context);
- builder.setTitle(R.string.error_label);
- builder.setMessage(msg);
- builder.setNeutralButton(android.R.string.ok, (dialog, which) -> dialog.cancel());
- builder.create().show();
- }
-
-} \ No newline at end of file
diff --git a/core/src/main/java/de/danoeh/antennapod/core/util/flattr/SimpleFlattrThing.java b/core/src/main/java/de/danoeh/antennapod/core/util/flattr/SimpleFlattrThing.java
deleted file mode 100644
index 43cd5f170..000000000
--- a/core/src/main/java/de/danoeh/antennapod/core/util/flattr/SimpleFlattrThing.java
+++ /dev/null
@@ -1,30 +0,0 @@
-package de.danoeh.antennapod.core.util.flattr;
-
-/* SimpleFlattrThing is a trivial implementation of the FlattrThing interface */
-public class SimpleFlattrThing implements FlattrThing {
- public SimpleFlattrThing(String title, String url, FlattrStatus status)
- {
- this.title = title;
- this.url = url;
- this.status = status;
- }
-
- public String getTitle()
- {
- return this.title;
- }
-
- public String getPaymentLink()
- {
- return this.url;
- }
-
- public FlattrStatus getFlattrStatus()
- {
- return this.status;
- }
-
- private final String title;
- private final String url;
- private final FlattrStatus status;
-}