Created core package for storing callback classes

This commit is contained in:
daniel oeh 2014-09-18 19:09:17 +02:00
parent 072639b5b2
commit 984454bf43
13 changed files with 259 additions and 9 deletions

83
app/core/build.gradle Normal file
View File

@ -0,0 +1,83 @@
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.12.2'
}
}
apply plugin: 'android-library'
repositories {
mavenCentral()
}
dependencies {
compile 'com.android.support:support-v4:20.0.0'
compile 'com.android.support:appcompat-v7:20.0.0'
compile 'org.apache.commons:commons-lang3:3.3.2'
compile ('org.shredzone.flattr4j:flattr4j-core:2.10') {
exclude group: 'org.apache.httpcomponents', module: 'httpcore'
exclude group: 'org.apache.httpcomponents', module: 'httpclient'
exclude group: 'org.json', module: 'json'
}
compile 'commons-io:commons-io:2.4'
compile 'com.nineoldandroids:library:2.4.0'
compile project('dslv:library')
compile 'com.jayway.android.robotium:robotium-solo:5.2.1'
compile ("com.doomonafireball.betterpickers:library:1.5.2") {
exclude group: 'com.android.support', module: 'support-v4'
}
compile 'org.jsoup:jsoup:1.7.3'
compile 'com.squareup.picasso:picasso:2.3.4'
compile 'com.squareup.okhttp:okhttp:2.0.0'
compile 'com.squareup.okhttp:okhttp-urlconnection:2.0.0'
compile 'com.squareup.okio:okio:1.0.0'
}
android {
compileSdkVersion 19
buildToolsVersion "20.0"
defaultConfig {
minSdkVersion 10
targetSdkVersion 19
testApplicationId "de.test.antennapod"
testInstrumentationRunner "de.test.antennapod.AntennaPodTestRunner"
}
buildTypes {
def STRING = "String"
def FLATTR_APP_KEY = "FLATTR_APP_KEY"
def FLATTR_APP_SECRET = "FLATTR_APP_SECRET"
def mFlattrAppKey = (project.hasProperty('flattrAppKey')) ? flattrAppKey : "\"\""
def mFlattrAppSecret = (project.hasProperty('flattrAppSecret')) ? flattrAppSecret : "\"\""
debug {
applicationIdSuffix ".debug"
buildConfigField STRING, FLATTR_APP_KEY, mFlattrAppKey
buildConfigField STRING, FLATTR_APP_SECRET, mFlattrAppSecret
}
release {
runProguard true
proguardFile 'proguard.cfg'
signingConfig signingConfigs.releaseConfig
buildConfigField STRING, FLATTR_APP_KEY, mFlattrAppKey
buildConfigField STRING, FLATTR_APP_SECRET, mFlattrAppSecret
}
}
packagingOptions {
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
}
lintOptions {
abortOnError false
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
}

View File

@ -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)

View File

@ -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;
}

View File

@ -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();
}

View File

@ -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();
}

View File

@ -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();
}

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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)

View File

@ -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)

View File

@ -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);

View File

@ -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 {

View File

@ -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) {