summaryrefslogtreecommitdiff
path: root/app/src/main/java
diff options
context:
space:
mode:
authordaniel oeh <daniel.oeh@gmail.com>2014-09-18 19:09:17 +0200
committerdaniel oeh <daniel.oeh@gmail.com>2014-09-18 19:09:17 +0200
commit984454bf4302d1432a533ff4294a52d5e73cd525 (patch)
treed20d191f0d479e70f30e59ba9785400b38a8b89b /app/src/main/java
parent072639b5b22e816df9f78b5cd8a7d4e5379b6aff (diff)
downloadAntennaPod-984454bf4302d1432a533ff4294a52d5e73cd525.zip
Created core package for storing callback classes
Diffstat (limited to 'app/src/main/java')
-rw-r--r--app/src/main/java/de/danoeh/antennapod/activity/OpmlImportFromPathActivity.java3
-rw-r--r--app/src/main/java/de/danoeh/antennapod/core/ClientConfig.java27
-rw-r--r--app/src/main/java/de/danoeh/antennapod/core/DownloadServiceCallbacks.java43
-rw-r--r--app/src/main/java/de/danoeh/antennapod/core/FlattrCallbacks.java24
-rw-r--r--app/src/main/java/de/danoeh/antennapod/core/GpodnetCallbacks.java26
-rw-r--r--app/src/main/java/de/danoeh/antennapod/core/PlaybackServiceCallbacks.java20
-rw-r--r--app/src/main/java/de/danoeh/antennapod/core/StorageCallbacks.java27
-rw-r--r--app/src/main/java/de/danoeh/antennapod/preferences/UserPreferences.java4
-rw-r--r--app/src/main/java/de/danoeh/antennapod/service/GpodnetSyncService.java2
-rw-r--r--app/src/main/java/de/danoeh/antennapod/service/download/DownloadService.java5
-rw-r--r--app/src/main/java/de/danoeh/antennapod/service/playback/PlaybackService.java2
-rw-r--r--app/src/main/java/de/danoeh/antennapod/storage/PodDBAdapter.java2
12 files changed, 176 insertions, 9 deletions
diff --git a/app/src/main/java/de/danoeh/antennapod/activity/OpmlImportFromPathActivity.java b/app/src/main/java/de/danoeh/antennapod/activity/OpmlImportFromPathActivity.java
index 94f100321..631e69f78 100644
--- a/app/src/main/java/de/danoeh/antennapod/activity/OpmlImportFromPathActivity.java
+++ b/app/src/main/java/de/danoeh/antennapod/activity/OpmlImportFromPathActivity.java
@@ -23,7 +23,6 @@ import java.io.*;
* Lets the user start the OPML-import process from a path
*/
public class OpmlImportFromPathActivity extends OpmlImportBaseActivity {
- public static final String IMPORT_DIR = "import/";
private static final String TAG = "OpmlImportFromPathActivity";
private TextView txtvPath;
private Button butStart;
@@ -61,7 +60,7 @@ public class OpmlImportFromPathActivity extends OpmlImportBaseActivity {
* directory.
*/
private void setImportPath() {
- File importDir = UserPreferences.getDataFolder(this, IMPORT_DIR);
+ File importDir = UserPreferences.getDataFolder(this, UserPreferences.IMPORT_DIR);
boolean success = true;
if (!importDir.exists()) {
if (BuildConfig.DEBUG)
diff --git a/app/src/main/java/de/danoeh/antennapod/core/ClientConfig.java b/app/src/main/java/de/danoeh/antennapod/core/ClientConfig.java
new file mode 100644
index 000000000..72ebe6347
--- /dev/null
+++ b/app/src/main/java/de/danoeh/antennapod/core/ClientConfig.java
@@ -0,0 +1,27 @@
+package de.danoeh.antennapod.core;
+
+/**
+ * Stores callbacks for core classes like Services, DB classes etc. and other configuration variables.
+ * Apps using the core module of AntennaPod should register implementations of all interfaces here.
+ */
+public class ClientConfig {
+
+ /**
+ * Package name of the client. This string is used as a prefix
+ * for internal intents.
+ */
+ public static String CLIENT_PACKAGE_NAME;
+
+ /**
+ * Should be used when setting User-Agent header for HTTP-requests.
+ */
+ public static String USER_AGENT;
+
+ public static DownloadServiceCallbacks downloadServiceCallbacks;
+
+ public static PlaybackServiceCallbacks playbackServiceCallbacks;
+
+ public static GpodnetCallbacks gpodnetCallbacks;
+
+ public static StorageCallbacks storageCallbacks;
+}
diff --git a/app/src/main/java/de/danoeh/antennapod/core/DownloadServiceCallbacks.java b/app/src/main/java/de/danoeh/antennapod/core/DownloadServiceCallbacks.java
new file mode 100644
index 000000000..1b0c4aab4
--- /dev/null
+++ b/app/src/main/java/de/danoeh/antennapod/core/DownloadServiceCallbacks.java
@@ -0,0 +1,43 @@
+package de.danoeh.antennapod.core;
+
+import android.app.PendingIntent;
+
+import de.danoeh.antennapod.service.download.DownloadRequest;
+
+/**
+ * Callbacks for the DownloadService of the core module
+ */
+public interface DownloadServiceCallbacks {
+
+ /**
+ * Returns a PendingIntent for a notification the main notification of the DownloadService.
+ * <p/>
+ * The PendingIntent takes the users to a screen where they can observe all currently running
+ * downloads.
+ *
+ * @return A non-null PendingIntent for the notification.
+ */
+ public PendingIntent getNotificationContentIntent();
+
+ /**
+ * Returns a PendingIntent for a notification that tells the user to enter a username
+ * or a password for a requested download.
+ * <p/>
+ * The PendingIntent takes users to an Activity that lets the user enter their username
+ * and password to retry the download.
+ *
+ * @return A non-null PendingIntent for the notification.
+ */
+ public PendingIntent getAuthentificationNotificationContentIntent(DownloadRequest request);
+
+ /**
+ * Returns a PendingIntent for notification that notifies the user about the completion of downloads
+ * along with information about failed and successful downloads.
+ * <p/>
+ * The PendingIntent takes users to an activity where they can look at all successful and failed downloads.
+ *
+ * @return A non-null PendingIntent for the notification.
+ */
+ public PendingIntent getReportNotificationContentIntent();
+}
+
diff --git a/app/src/main/java/de/danoeh/antennapod/core/FlattrCallbacks.java b/app/src/main/java/de/danoeh/antennapod/core/FlattrCallbacks.java
new file mode 100644
index 000000000..2dde4d8f3
--- /dev/null
+++ b/app/src/main/java/de/danoeh/antennapod/core/FlattrCallbacks.java
@@ -0,0 +1,24 @@
+package de.danoeh.antennapod.core;
+
+import android.content.Intent;
+
+/**
+ * Callbacks for the flattr integration of the app.
+ */
+public interface FlattrCallbacks {
+
+ /**
+ * Returns if true if the flattr integration should be activated,
+ * false otherwise.
+ */
+ public 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).
+ */
+ public Intent getFlattrAuthenticationActivityIntent();
+}
diff --git a/app/src/main/java/de/danoeh/antennapod/core/GpodnetCallbacks.java b/app/src/main/java/de/danoeh/antennapod/core/GpodnetCallbacks.java
new file mode 100644
index 000000000..e937bf35c
--- /dev/null
+++ b/app/src/main/java/de/danoeh/antennapod/core/GpodnetCallbacks.java
@@ -0,0 +1,26 @@
+package de.danoeh.antennapod.core;
+
+import android.app.PendingIntent;
+
+/**
+ * Callbacks related to the gpodder.net integration of the core module
+ */
+public interface GpodnetCallbacks {
+
+
+ /**
+ * Returns if true if the gpodder.net integration should be activated,
+ * false otherwise.
+ */
+ public boolean gpodnetEnabled();
+
+ /**
+ * Returns a PendingIntent for the error notification of the GpodnetSyncService.
+ * <p/>
+ * What the PendingIntent does may be implementation-specific.
+ *
+ * @return A PendingIntent for the notification or null if gpodder.net integration
+ * has been disabled (i.e. gpodnetEnabled() == false).
+ */
+ public PendingIntent getGpodnetSyncServiceErrorNotificationPendingIntent();
+}
diff --git a/app/src/main/java/de/danoeh/antennapod/core/PlaybackServiceCallbacks.java b/app/src/main/java/de/danoeh/antennapod/core/PlaybackServiceCallbacks.java
new file mode 100644
index 000000000..da64b38ad
--- /dev/null
+++ b/app/src/main/java/de/danoeh/antennapod/core/PlaybackServiceCallbacks.java
@@ -0,0 +1,20 @@
+package de.danoeh.antennapod.core;
+
+import android.content.Intent;
+
+import de.danoeh.antennapod.feed.MediaType;
+
+/**
+ * Callbacks for the PlaybackService of the core module
+ */
+public interface PlaybackServiceCallbacks {
+
+ /**
+ * Returns an intent which starts an audio- or videoplayer, depending on the
+ * type of media that is being played.
+ *
+ * @param mediaType The type of media that is being played.
+ * @return A non-null activity intent.
+ */
+ public Intent getPlayerActivityIntent(MediaType mediaType);
+}
diff --git a/app/src/main/java/de/danoeh/antennapod/core/StorageCallbacks.java b/app/src/main/java/de/danoeh/antennapod/core/StorageCallbacks.java
new file mode 100644
index 000000000..5d1a0fffc
--- /dev/null
+++ b/app/src/main/java/de/danoeh/antennapod/core/StorageCallbacks.java
@@ -0,0 +1,27 @@
+package de.danoeh.antennapod.core;
+
+import android.database.sqlite.SQLiteDatabase;
+
+/**
+ * Callbacks for the classes in the storage package of the core module.
+ */
+public interface StorageCallbacks {
+
+ /**
+ * Returns the current version of the database.
+ *
+ * @return The non-negative version number of the database.
+ */
+ public int getDatabaseVersion();
+
+ /**
+ * Upgrades the given database from an old version to a newer version.
+ *
+ * @param db The database that is supposed to be upgraded.
+ * @param oldVersion The old version of the database.
+ * @param newVersion The version that the database is supposed to be upgraded to.
+ */
+ public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion);
+
+
+}
diff --git a/app/src/main/java/de/danoeh/antennapod/preferences/UserPreferences.java b/app/src/main/java/de/danoeh/antennapod/preferences/UserPreferences.java
index 2020ddfae..d7807ddac 100644
--- a/app/src/main/java/de/danoeh/antennapod/preferences/UserPreferences.java
+++ b/app/src/main/java/de/danoeh/antennapod/preferences/UserPreferences.java
@@ -21,7 +21,6 @@ import java.util.concurrent.TimeUnit;
import de.danoeh.antennapod.BuildConfig;
import de.danoeh.antennapod.R;
-import de.danoeh.antennapod.activity.OpmlImportFromPathActivity;
import de.danoeh.antennapod.receiver.FeedUpdateReceiver;
/**
@@ -32,6 +31,7 @@ import de.danoeh.antennapod.receiver.FeedUpdateReceiver;
*/
public class UserPreferences implements
SharedPreferences.OnSharedPreferenceChangeListener {
+ public static final String IMPORT_DIR = "import/";
private static final String TAG = "UserPreferences";
public static final String PREF_PAUSE_ON_HEADSET_DISCONNECT = "prefPauseOnHeadsetDisconnect";
@@ -523,7 +523,7 @@ public class UserPreferences implements
*/
private static void createImportDirectory() {
File importDir = getDataFolder(instance.context,
- OpmlImportFromPathActivity.IMPORT_DIR);
+ IMPORT_DIR);
if (importDir != null) {
if (importDir.exists()) {
if (BuildConfig.DEBUG)
diff --git a/app/src/main/java/de/danoeh/antennapod/service/GpodnetSyncService.java b/app/src/main/java/de/danoeh/antennapod/service/GpodnetSyncService.java
index c8c9fc31e..efc44c66a 100644
--- a/app/src/main/java/de/danoeh/antennapod/service/GpodnetSyncService.java
+++ b/app/src/main/java/de/danoeh/antennapod/service/GpodnetSyncService.java
@@ -166,7 +166,7 @@ public class GpodnetSyncService extends Service {
}
PendingIntent activityIntent = PendingIntent.getActivity(this, 0, new Intent(this, MainActivity.class), PendingIntent.FLAG_UPDATE_CURRENT);
-
+// TODO getGpodnetSyncServiceErrorNotificationPendingIntent
Notification notification = builder.setContentTitle(title)
.setContentText(description)
.setContentIntent(activityIntent)
diff --git a/app/src/main/java/de/danoeh/antennapod/service/download/DownloadService.java b/app/src/main/java/de/danoeh/antennapod/service/download/DownloadService.java
index 63be91b57..d0d75d2d7 100644
--- a/app/src/main/java/de/danoeh/antennapod/service/download/DownloadService.java
+++ b/app/src/main/java/de/danoeh/antennapod/service/download/DownloadService.java
@@ -331,7 +331,7 @@ public class DownloadService extends Service {
}
@SuppressLint("NewApi")
- private void setupNotificationBuilders() {
+ private void setupNotificationBuilders() { // TODO getNotificationContentIntent
Intent intent = new Intent(this, MainActivity.class);
intent.putExtra(MainActivity.EXTRA_NAV_TYPE, NavListAdapter.VIEW_TYPE_NAV);
intent.putExtra(MainActivity.EXTRA_NAV_INDEX, MainActivity.POS_DOWNLOADS);
@@ -556,7 +556,7 @@ public class DownloadService extends Service {
}
}
- if (createReport) {
+ if (createReport) { // TODO getReportNotificationContentIntent
if (BuildConfig.DEBUG)
Log.d(TAG, "Creating report");
Intent intent = new Intent(this, MainActivity.class);
@@ -633,6 +633,7 @@ public class DownloadService extends Service {
final String resourceTitle = (downloadRequest.getTitle() != null)
? downloadRequest.getTitle() : downloadRequest.getSource();
+ // TODO getAuthentificationNotificationContentIntent
final Intent activityIntent = new Intent(getApplicationContext(), DownloadAuthenticationActivity.class);
activityIntent.putExtra(DownloadAuthenticationActivity.ARG_DOWNLOAD_REQUEST, downloadRequest);
activityIntent.putExtra(DownloadAuthenticationActivity.ARG_SEND_TO_DOWNLOAD_REQUESTER_BOOL, true);
diff --git a/app/src/main/java/de/danoeh/antennapod/service/playback/PlaybackService.java b/app/src/main/java/de/danoeh/antennapod/service/playback/PlaybackService.java
index 59d7ddbb9..96b9588c4 100644
--- a/app/src/main/java/de/danoeh/antennapod/service/playback/PlaybackService.java
+++ b/app/src/main/java/de/danoeh/antennapod/service/playback/PlaybackService.java
@@ -172,7 +172,7 @@ public class PlaybackService extends Service {
* running, the type of the last played media will be looked up.
*/
public static Intent getPlayerActivityIntent(Context context) {
- if (isRunning) {
+ if (isRunning) { // TODO getPlayerActivityIntent
if (currentMediaType == MediaType.VIDEO) {
return new Intent(context, VideoplayerActivity.class);
} else {
diff --git a/app/src/main/java/de/danoeh/antennapod/storage/PodDBAdapter.java b/app/src/main/java/de/danoeh/antennapod/storage/PodDBAdapter.java
index 671ac30d5..2a3aafe8c 100644
--- a/app/src/main/java/de/danoeh/antennapod/storage/PodDBAdapter.java
+++ b/app/src/main/java/de/danoeh/antennapod/storage/PodDBAdapter.java
@@ -1302,7 +1302,7 @@ public class PodDBAdapter {
@Override
public void onUpgrade(final SQLiteDatabase db, final int oldVersion,
- final int newVersion) {
+ final int newVersion) { // TODO onUpgrade
Log.w("DBAdapter", "Upgrading from version " + oldVersion + " to "
+ newVersion + ".");
if (oldVersion <= 1) {