Moved core classes into subproject

This commit is contained in:
daniel oeh 2014-10-11 17:43:07 +02:00
parent 21b5b835e3
commit 658559699f
493 changed files with 2293 additions and 2071 deletions

View File

@ -15,7 +15,7 @@ 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') {
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'
@ -23,9 +23,8 @@ dependencies {
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") {
compile('com.doomonafireball.betterpickers:library:1.5.2') {
exclude group: 'com.android.support', module: 'support-v4'
}
compile 'org.jsoup:jsoup:1.7.3'
@ -33,6 +32,7 @@ dependencies {
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'
compile project(':core')
}
android {

View File

@ -1,83 +0,0 @@
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

@ -112,12 +112,12 @@
</activity>
<service
android:name=".core.service.playback.PlayerWidgetService"
android:name=".service.PlayerWidgetService"
android:enabled="true"
android:exported="false">
</service>
<receiver android:name=".core.receiver.PlayerWidget">
<receiver android:name=".receiver.PlayerWidget">
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE"/>
</intent-filter>

File diff suppressed because it is too large Load Diff

View File

@ -12,7 +12,6 @@ import de.danoeh.antennapod.spa.SPAUtil;
public class PodcastApp extends Application {
private static final String TAG = "PodcastApp";
public static final String EXPORT_DIR = "export/";
private static float LOGICAL_DENSITY;

View File

@ -43,8 +43,8 @@ import de.danoeh.antennapod.fragment.ItemDescriptionFragment;
import de.danoeh.antennapod.core.preferences.UserPreferences;
import de.danoeh.antennapod.core.service.playback.PlaybackService;
import de.danoeh.antennapod.core.storage.DBReader;
import de.danoeh.antennapod.core.util.menuhandler.MenuItemUtils;
import de.danoeh.antennapod.core.util.menuhandler.NavDrawerActivity;
import de.danoeh.antennapod.menuhandler.MenuItemUtils;
import de.danoeh.antennapod.menuhandler.NavDrawerActivity;
import de.danoeh.antennapod.core.util.playback.ExternalMedia;
import de.danoeh.antennapod.core.util.playback.Playable;
import de.danoeh.antennapod.core.util.playback.PlaybackController;

View File

@ -21,7 +21,7 @@ import de.danoeh.antennapod.core.storage.DBReader;
import de.danoeh.antennapod.core.storage.DBWriter;
import de.danoeh.antennapod.core.storage.DownloadRequestException;
import de.danoeh.antennapod.core.util.LangUtils;
import de.danoeh.antennapod.core.util.menuhandler.FeedMenuHandler;
import de.danoeh.antennapod.menuhandler.FeedMenuHandler;
/**
* Displays information about a feed.

View File

@ -31,7 +31,7 @@ import de.danoeh.antennapod.fragment.*;
import de.danoeh.antennapod.core.preferences.UserPreferences;
import de.danoeh.antennapod.core.storage.DBReader;
import de.danoeh.antennapod.core.util.StorageUtils;
import de.danoeh.antennapod.core.util.menuhandler.NavDrawerActivity;
import de.danoeh.antennapod.menuhandler.NavDrawerActivity;
import java.util.List;

View File

@ -22,7 +22,7 @@ import com.doomonafireball.betterpickers.hmspicker.HmsPickerBuilder;
import com.doomonafireball.betterpickers.hmspicker.HmsPickerDialogFragment;
import de.danoeh.antennapod.BuildConfig;
import de.danoeh.antennapod.R;
import de.danoeh.antennapod.core.dialog.TimeDialog;
import de.danoeh.antennapod.dialog.TimeDialog;
import de.danoeh.antennapod.core.feed.FeedItem;
import de.danoeh.antennapod.core.feed.FeedMedia;
import de.danoeh.antennapod.core.preferences.UserPreferences;

View File

@ -4,8 +4,8 @@ import android.content.Intent;
import android.support.v7.app.ActionBarActivity;
import android.util.Log;
import de.danoeh.antennapod.BuildConfig;
import de.danoeh.antennapod.core.asynctask.OpmlFeedQueuer;
import de.danoeh.antennapod.core.asynctask.OpmlImportWorker;
import de.danoeh.antennapod.asynctask.OpmlFeedQueuer;
import de.danoeh.antennapod.asynctask.OpmlImportWorker;
import de.danoeh.antennapod.core.opml.OpmlElement;
import java.io.Reader;

View File

@ -22,7 +22,7 @@ import android.widget.Toast;
import de.danoeh.antennapod.BuildConfig;
import de.danoeh.antennapod.R;
import de.danoeh.antennapod.core.asynctask.FlattrClickWorker;
import de.danoeh.antennapod.core.asynctask.OpmlExportWorker;
import de.danoeh.antennapod.asynctask.OpmlExportWorker;
import de.danoeh.antennapod.dialog.AuthenticationDialog;
import de.danoeh.antennapod.dialog.AutoFlattrPreferenceDialog;
import de.danoeh.antennapod.dialog.GpodnetSetHostnameDialog;

View File

@ -0,0 +1,118 @@
package de.danoeh.antennapod.asynctask;
import android.annotation.SuppressLint;
import android.app.AlertDialog;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.os.AsyncTask;
import android.util.Log;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import de.danoeh.antennapod.core.R;
import de.danoeh.antennapod.core.opml.OpmlWriter;
import de.danoeh.antennapod.core.preferences.UserPreferences;
import de.danoeh.antennapod.core.storage.DBReader;
import de.danoeh.antennapod.core.util.LangUtils;
/**
* Writes an OPML file into the export directory in the background.
*/
public class OpmlExportWorker extends AsyncTask<Void, Void, Void> {
private static final String TAG = "OpmlExportWorker";
private static final String DEFAULT_OUTPUT_NAME = "antennapod-feeds.opml";
public static final String EXPORT_DIR = "export/";
private Context context;
private File output;
private ProgressDialog progDialog;
private Exception exception;
public OpmlExportWorker(Context context, File output) {
this.context = context;
this.output = output;
}
public OpmlExportWorker(Context context) {
this.context = context;
}
@Override
protected Void doInBackground(Void... params) {
OpmlWriter opmlWriter = new OpmlWriter();
if (output == null) {
output = new File(
UserPreferences.getDataFolder(context, EXPORT_DIR),
DEFAULT_OUTPUT_NAME);
if (output.exists()) {
Log.w(TAG, "Overwriting previously exported file.");
output.delete();
}
}
OutputStreamWriter writer = null;
try {
writer = new OutputStreamWriter(new FileOutputStream(output), LangUtils.UTF_8);
opmlWriter.writeDocument(DBReader.getFeedList(context), writer);
} catch (IOException e) {
e.printStackTrace();
exception = e;
} finally {
if (writer != null) {
try {
writer.close();
} catch (IOException ioe) {
exception = ioe;
}
}
}
return null;
}
@Override
protected void onPostExecute(Void result) {
progDialog.dismiss();
AlertDialog.Builder alert = new AlertDialog.Builder(context)
.setNeutralButton(android.R.string.ok,
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog,
int which) {
dialog.dismiss();
}
});
if (exception != null) {
alert.setTitle(R.string.export_error_label);
alert.setMessage(exception.getMessage());
} else {
alert.setTitle(R.string.opml_export_success_title);
alert.setMessage(context
.getString(R.string.opml_export_success_sum)
+ output.toString());
}
alert.create().show();
}
@Override
protected void onPreExecute() {
progDialog = new ProgressDialog(context);
progDialog.setMessage(context.getString(R.string.exporting_label));
progDialog.setIndeterminate(true);
progDialog.show();
}
@SuppressLint("NewApi")
public void executeAsync() {
if (android.os.Build.VERSION.SDK_INT > android.os.Build.VERSION_CODES.GINGERBREAD_MR1) {
executeOnExecutor(THREAD_POOL_EXECUTOR);
} else {
execute();
}
}
}

View File

@ -1,10 +1,10 @@
package de.danoeh.antennapod.core.asynctask;
package de.danoeh.antennapod.asynctask;
import android.annotation.SuppressLint;
import android.app.ProgressDialog;
import android.content.Context;
import android.os.AsyncTask;
import de.danoeh.antennapod.R;
import de.danoeh.antennapod.core.R;
import de.danoeh.antennapod.activity.OpmlImportHolder;
import de.danoeh.antennapod.core.feed.Feed;
import de.danoeh.antennapod.core.opml.OpmlElement;

View File

@ -1,4 +1,4 @@
package de.danoeh.antennapod.core.asynctask;
package de.danoeh.antennapod.asynctask;
import android.annotation.SuppressLint;
import android.app.AlertDialog;
@ -8,8 +8,8 @@ import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.os.AsyncTask;
import android.util.Log;
import de.danoeh.antennapod.BuildConfig;
import de.danoeh.antennapod.R;
import de.danoeh.antennapod.core.BuildConfig;
import de.danoeh.antennapod.core.R;
import de.danoeh.antennapod.core.opml.OpmlElement;
import de.danoeh.antennapod.core.opml.OpmlReader;
import org.xmlpull.v1.XmlPullParserException;

View File

@ -0,0 +1,23 @@
package de.danoeh.antennapod.config;
import android.app.Application;
import android.content.Context;
import android.content.Intent;
import de.danoeh.antennapod.PodcastApp;
import de.danoeh.antennapod.activity.StorageErrorActivity;
import de.danoeh.antennapod.core.ApplicationCallbacks;
public class ApplicationCallbacksImpl implements ApplicationCallbacks {
@Override
public Application getApplicationInstance() {
return PodcastApp.getInstance();
}
@Override
public Intent getStorageErrorActivity(Context context) {
return new Intent(context, StorageErrorActivity.class);
}
}

View File

@ -0,0 +1,19 @@
package de.danoeh.antennapod.config;
import de.danoeh.antennapod.core.ClientConfig;
/**
* Configures the ClientConfig class of the core package.
*/
public class ClientConfigurator {
static {
ClientConfig.USER_AGENT = "AntennaPod/0.9.9.3";
ClientConfig.applicationCallbacks = new ApplicationCallbacksImpl();
ClientConfig.downloadServiceCallbacks = new DownloadServiceCallbacksImpl();
ClientConfig.gpodnetCallbacks = new GpodnetCallbacksImpl();
ClientConfig.playbackServiceCallbacks = new PlaybackServiceCallbacksImpl();
ClientConfig.storageCallbacks = new StorageCallbacksImpl();
ClientConfig.flattrCallbacks = new FlattrCallbacksImpl();
}
}

View File

@ -0,0 +1,49 @@
package de.danoeh.antennapod.config;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import de.danoeh.antennapod.activity.DownloadAuthenticationActivity;
import de.danoeh.antennapod.activity.MainActivity;
import de.danoeh.antennapod.adapter.NavListAdapter;
import de.danoeh.antennapod.core.DownloadServiceCallbacks;
import de.danoeh.antennapod.core.service.download.DownloadRequest;
import de.danoeh.antennapod.fragment.DownloadsFragment;
public class DownloadServiceCallbacksImpl implements DownloadServiceCallbacks {
@Override
public PendingIntent getNotificationContentIntent(Context context) {
Intent intent = new Intent(context, MainActivity.class);
intent.putExtra(MainActivity.EXTRA_NAV_TYPE, NavListAdapter.VIEW_TYPE_NAV);
intent.putExtra(MainActivity.EXTRA_NAV_INDEX, MainActivity.POS_DOWNLOADS);
Bundle args = new Bundle();
args.putInt(DownloadsFragment.ARG_SELECTED_TAB, DownloadsFragment.POS_RUNNING);
intent.putExtra(MainActivity.EXTRA_FRAGMENT_ARGS, args);
return PendingIntent.getActivity(context, 0, intent,
PendingIntent.FLAG_UPDATE_CURRENT);
}
@Override
public PendingIntent getAuthentificationNotificationContentIntent(Context context, DownloadRequest request) {
final Intent activityIntent = new Intent(context.getApplicationContext(), DownloadAuthenticationActivity.class);
activityIntent.putExtra(DownloadAuthenticationActivity.ARG_DOWNLOAD_REQUEST, request);
activityIntent.putExtra(DownloadAuthenticationActivity.ARG_SEND_TO_DOWNLOAD_REQUESTER_BOOL, true);
return PendingIntent.getActivity(context.getApplicationContext(), 0, activityIntent, PendingIntent.FLAG_ONE_SHOT);
}
@Override
public PendingIntent getReportNotificationContentIntent(Context context) {
Intent intent = new Intent(context, MainActivity.class);
intent.putExtra(MainActivity.EXTRA_NAV_TYPE, NavListAdapter.VIEW_TYPE_NAV);
intent.putExtra(MainActivity.EXTRA_NAV_INDEX, MainActivity.POS_DOWNLOADS);
Bundle args = new Bundle();
args.putInt(DownloadsFragment.ARG_SELECTED_TAB, DownloadsFragment.POS_LOG);
intent.putExtra(MainActivity.EXTRA_FRAGMENT_ARGS, args);
return PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
}
}

View File

@ -0,0 +1,53 @@
package de.danoeh.antennapod.config;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.util.Log;
import org.shredzone.flattr4j.oauth.AccessToken;
import de.danoeh.antennapod.BuildConfig;
import de.danoeh.antennapod.activity.FlattrAuthActivity;
import de.danoeh.antennapod.activity.MainActivity;
import de.danoeh.antennapod.core.FlattrCallbacks;
public class FlattrCallbacksImpl implements FlattrCallbacks {
private static final String TAG = "FlattrCallbacksImpl";
@Override
public boolean flattrEnabled() {
return true;
}
@Override
public Intent getFlattrAuthenticationActivityIntent(Context context) {
return new Intent(context, FlattrAuthActivity.class);
}
@Override
public PendingIntent getFlattrFailedNotificationContentIntent(Context context) {
return PendingIntent.getActivity(context, 0, new Intent(context, MainActivity.class), 0);
}
@Override
public String getFlattrAppKey() {
return BuildConfig.FLATTR_APP_KEY;
}
@Override
public String getFlattrAppSecret() {
return BuildConfig.FLATTR_APP_SECRET;
}
@Override
public void handleFlattrAuthenticationSuccess(AccessToken token) {
FlattrAuthActivity instance = FlattrAuthActivity.getInstance();
if (instance != null) {
instance.handleAuthenticationSuccess();
} else {
Log.e(TAG, "FlattrAuthActivity instance was null");
}
}
}

View File

@ -0,0 +1,22 @@
package de.danoeh.antennapod.config;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import de.danoeh.antennapod.activity.MainActivity;
import de.danoeh.antennapod.core.GpodnetCallbacks;
public class GpodnetCallbacksImpl implements GpodnetCallbacks {
@Override
public boolean gpodnetEnabled() {
return true;
}
@Override
public PendingIntent getGpodnetSyncServiceErrorNotificationPendingIntent(Context context) {
return PendingIntent.getActivity(context, 0, new Intent(context, MainActivity.class),
PendingIntent.FLAG_UPDATE_CURRENT);
}
}

View File

@ -0,0 +1,21 @@
package de.danoeh.antennapod.config;
import android.content.Context;
import android.content.Intent;
import de.danoeh.antennapod.activity.AudioplayerActivity;
import de.danoeh.antennapod.activity.VideoplayerActivity;
import de.danoeh.antennapod.core.PlaybackServiceCallbacks;
import de.danoeh.antennapod.core.feed.MediaType;
public class PlaybackServiceCallbacksImpl implements PlaybackServiceCallbacks {
@Override
public Intent getPlayerActivityIntent(Context context, MediaType mediaType) {
if (mediaType == MediaType.VIDEO) {
return new Intent(context, VideoplayerActivity.class);
} else {
return new Intent(context, AudioplayerActivity.class);
}
}
}

View File

@ -0,0 +1,107 @@
package de.danoeh.antennapod.config;
import android.content.ContentValues;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.util.Log;
import de.danoeh.antennapod.core.StorageCallbacks;
import de.danoeh.antennapod.core.storage.PodDBAdapter;
public class StorageCallbacksImpl implements StorageCallbacks {
@Override
public int getDatabaseVersion() {
return 12;
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
Log.w("DBAdapter", "Upgrading from version " + oldVersion + " to "
+ newVersion + ".");
if (oldVersion <= 1) {
db.execSQL("ALTER TABLE " + PodDBAdapter.TABLE_NAME_FEEDS + " ADD COLUMN "
+ PodDBAdapter.KEY_TYPE + " TEXT");
}
if (oldVersion <= 2) {
db.execSQL("ALTER TABLE " + PodDBAdapter.TABLE_NAME_SIMPLECHAPTERS
+ " ADD COLUMN " + PodDBAdapter.KEY_LINK + " TEXT");
}
if (oldVersion <= 3) {
db.execSQL("ALTER TABLE " + PodDBAdapter.TABLE_NAME_FEED_ITEMS
+ " ADD COLUMN " + PodDBAdapter.KEY_ITEM_IDENTIFIER + " TEXT");
}
if (oldVersion <= 4) {
db.execSQL("ALTER TABLE " + PodDBAdapter.TABLE_NAME_FEEDS + " ADD COLUMN "
+ PodDBAdapter.KEY_FEED_IDENTIFIER + " TEXT");
}
if (oldVersion <= 5) {
db.execSQL("ALTER TABLE " + PodDBAdapter.TABLE_NAME_DOWNLOAD_LOG
+ " ADD COLUMN " + PodDBAdapter.KEY_REASON_DETAILED + " TEXT");
db.execSQL("ALTER TABLE " + PodDBAdapter.TABLE_NAME_DOWNLOAD_LOG
+ " ADD COLUMN " + PodDBAdapter.KEY_DOWNLOADSTATUS_TITLE + " TEXT");
}
if (oldVersion <= 6) {
db.execSQL("ALTER TABLE " + PodDBAdapter.TABLE_NAME_SIMPLECHAPTERS
+ " ADD COLUMN " + PodDBAdapter.KEY_CHAPTER_TYPE + " INTEGER");
}
if (oldVersion <= 7) {
db.execSQL("ALTER TABLE " + PodDBAdapter.TABLE_NAME_FEED_MEDIA
+ " ADD COLUMN " + PodDBAdapter.KEY_PLAYBACK_COMPLETION_DATE
+ " INTEGER");
}
if (oldVersion <= 8) {
final int KEY_ID_POSITION = 0;
final int KEY_MEDIA_POSITION = 1;
// Add feeditem column to feedmedia table
db.execSQL("ALTER TABLE " + PodDBAdapter.TABLE_NAME_FEED_MEDIA
+ " ADD COLUMN " + PodDBAdapter.KEY_FEEDITEM
+ " INTEGER");
Cursor feeditemCursor = db.query(PodDBAdapter.TABLE_NAME_FEED_ITEMS,
new String[]{PodDBAdapter.KEY_ID, PodDBAdapter.KEY_MEDIA}, "? > 0",
new String[]{PodDBAdapter.KEY_MEDIA}, null, null, null);
if (feeditemCursor.moveToFirst()) {
db.beginTransaction();
ContentValues contentValues = new ContentValues();
do {
long mediaId = feeditemCursor.getLong(KEY_MEDIA_POSITION);
contentValues.put(PodDBAdapter.KEY_FEEDITEM, feeditemCursor.getLong(KEY_ID_POSITION));
db.update(PodDBAdapter.TABLE_NAME_FEED_MEDIA, contentValues, PodDBAdapter.KEY_ID + "=?", new String[]{String.valueOf(mediaId)});
contentValues.clear();
} while (feeditemCursor.moveToNext());
db.setTransactionSuccessful();
db.endTransaction();
}
feeditemCursor.close();
}
if (oldVersion <= 9) {
db.execSQL("ALTER TABLE " + PodDBAdapter.TABLE_NAME_FEEDS
+ " ADD COLUMN " + PodDBAdapter.KEY_AUTO_DOWNLOAD
+ " INTEGER DEFAULT 1");
}
if (oldVersion <= 10) {
db.execSQL("ALTER TABLE " + PodDBAdapter.TABLE_NAME_FEEDS
+ " ADD COLUMN " + PodDBAdapter.KEY_FLATTR_STATUS
+ " INTEGER");
db.execSQL("ALTER TABLE " + PodDBAdapter.TABLE_NAME_FEED_ITEMS
+ " ADD COLUMN " + PodDBAdapter.KEY_FLATTR_STATUS
+ " INTEGER");
db.execSQL("ALTER TABLE " + PodDBAdapter.TABLE_NAME_FEED_MEDIA
+ " ADD COLUMN " + PodDBAdapter.KEY_PLAYED_DURATION
+ " INTEGER");
}
if (oldVersion <= 11) {
db.execSQL("ALTER TABLE " + PodDBAdapter.TABLE_NAME_FEEDS
+ " ADD COLUMN " + PodDBAdapter.KEY_USERNAME
+ " TEXT");
db.execSQL("ALTER TABLE " + PodDBAdapter.TABLE_NAME_FEEDS
+ " ADD COLUMN " + PodDBAdapter.KEY_PASSWORD
+ " TEXT");
db.execSQL("ALTER TABLE " + PodDBAdapter.TABLE_NAME_FEED_ITEMS
+ " ADD COLUMN " + PodDBAdapter.KEY_IMAGE
+ " INTEGER");
}
}
}

View File

@ -1,95 +0,0 @@
package de.danoeh.antennapod.core.asynctask;
import android.annotation.SuppressLint;
import android.app.ProgressDialog;
import android.content.Context;
import android.net.Uri;
import android.os.AsyncTask;
import android.util.Log;
import de.danoeh.antennapod.BuildConfig;
import de.danoeh.antennapod.R;
import de.danoeh.antennapod.activity.FlattrAuthActivity;
import de.danoeh.antennapod.core.util.flattr.FlattrUtils;
import org.shredzone.flattr4j.exception.FlattrException;
import org.shredzone.flattr4j.oauth.AccessToken;
import org.shredzone.flattr4j.oauth.AndroidAuthenticator;
/** 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";
Context context;
AndroidAuthenticator auth;
AccessToken token;
Uri uri;
ProgressDialog dialog;
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) {
FlattrAuthActivity instance = FlattrAuthActivity.getInstance();
if (instance != null) {
instance.handleAuthenticationSuccess();
} else {
Log.e(TAG, "FlattrAuthActivity instance was null");
}
} 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;
}
}
@SuppressLint("NewApi")
public void executeAsync() {
if (android.os.Build.VERSION.SDK_INT > android.os.Build.VERSION_CODES.GINGERBREAD_MR1) {
executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
} else {
execute();
}
}
}

View File

@ -1,114 +0,0 @@
package de.danoeh.antennapod.core.asynctask;
import android.annotation.SuppressLint;
import android.app.AlertDialog;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.os.AsyncTask;
import android.util.Log;
import de.danoeh.antennapod.PodcastApp;
import de.danoeh.antennapod.R;
import de.danoeh.antennapod.core.opml.OpmlWriter;
import de.danoeh.antennapod.core.preferences.UserPreferences;
import de.danoeh.antennapod.core.storage.DBReader;
import de.danoeh.antennapod.core.util.LangUtils;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
/** Writes an OPML file into the export directory in the background. */
public class OpmlExportWorker extends AsyncTask<Void, Void, Void> {
private static final String TAG = "OpmlExportWorker";
private static final String DEFAULT_OUTPUT_NAME = "antennapod-feeds.opml";
private Context context;
private File output;
private ProgressDialog progDialog;
private Exception exception;
public OpmlExportWorker(Context context, File output) {
this.context = context;
this.output = output;
}
public OpmlExportWorker(Context context) {
this.context = context;
}
@Override
protected Void doInBackground(Void... params) {
OpmlWriter opmlWriter = new OpmlWriter();
if (output == null) {
output = new File(
UserPreferences.getDataFolder(context, PodcastApp.EXPORT_DIR),
DEFAULT_OUTPUT_NAME);
if (output.exists()) {
Log.w(TAG, "Overwriting previously exported file.");
output.delete();
}
}
OutputStreamWriter writer = null;
try {
writer = new OutputStreamWriter(new FileOutputStream(output), LangUtils.UTF_8);
opmlWriter.writeDocument(DBReader.getFeedList(context), writer);
} catch (IOException e) {
e.printStackTrace();
exception = e;
} finally {
if (writer != null) {
try {
writer.close();
} catch (IOException ioe) {
exception = ioe;
}
}
}
return null;
}
@Override
protected void onPostExecute(Void result) {
progDialog.dismiss();
AlertDialog.Builder alert = new AlertDialog.Builder(context)
.setNeutralButton(android.R.string.ok,
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog,
int which) {
dialog.dismiss();
}
});
if (exception != null) {
alert.setTitle(R.string.export_error_label);
alert.setMessage(exception.getMessage());
} else {
alert.setTitle(R.string.opml_export_success_title);
alert.setMessage(context
.getString(R.string.opml_export_success_sum)
+ output.toString());
}
alert.create().show();
}
@Override
protected void onPreExecute() {
progDialog = new ProgressDialog(context);
progDialog.setMessage(context.getString(R.string.exporting_label));
progDialog.setIndeterminate(true);
progDialog.show();
}
@SuppressLint("NewApi")
public void executeAsync() {
if (android.os.Build.VERSION.SDK_INT > android.os.Build.VERSION_CODES.GINGERBREAD_MR1) {
executeOnExecutor(THREAD_POOL_EXECUTOR);
} else {
execute();
}
}
}

View File

@ -1,69 +0,0 @@
package de.danoeh.antennapod.core.service.download;
import android.content.Context;
import android.net.wifi.WifiManager;
import de.danoeh.antennapod.PodcastApp;
import de.danoeh.antennapod.R;
import java.util.concurrent.Callable;
/** Downloads files */
public abstract class Downloader implements Callable<Downloader> {
private static final String TAG = "Downloader";
protected volatile boolean finished;
protected volatile boolean cancelled;
protected DownloadRequest request;
protected DownloadStatus result;
public Downloader(DownloadRequest request) {
super();
this.request = request;
this.request.setStatusMsg(R.string.download_pending);
this.cancelled = false;
this.result = new DownloadStatus(request, null, false, false, null);
}
protected abstract void download();
public final Downloader call() {
WifiManager wifiManager = (WifiManager) PodcastApp.getInstance().getSystemService(Context.WIFI_SERVICE);
WifiManager.WifiLock wifiLock = null;
if (wifiManager != null) {
wifiLock = wifiManager.createWifiLock(TAG);
wifiLock.acquire();
}
download();
if (wifiLock != null) {
wifiLock.release();
}
if (result == null) {
throw new IllegalStateException(
"Downloader hasn't created DownloadStatus object");
}
finished = true;
return this;
}
public DownloadRequest getDownloadRequest() {
return request;
}
public DownloadStatus getResult() {
return result;
}
public boolean isFinished() {
return finished;
}
public void cancel() {
cancelled = true;
}
}

View File

@ -1,66 +0,0 @@
package de.danoeh.antennapod.core.util;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Build;
import android.os.StatFs;
import android.util.Log;
import de.danoeh.antennapod.BuildConfig;
import de.danoeh.antennapod.PodcastApp;
import de.danoeh.antennapod.activity.StorageErrorActivity;
import de.danoeh.antennapod.core.preferences.UserPreferences;
import java.io.File;
/** Utility functions for handling storage errors */
public class StorageUtils {
private static final String TAG = "StorageUtils";
public static boolean storageAvailable(Context context) {
File dir = UserPreferences.getDataFolder(context, null);
if (dir != null) {
return dir.exists() && dir.canRead() && dir.canWrite();
} else {
if (BuildConfig.DEBUG)
Log.d(TAG, "Storage not available: data folder is null");
return false;
}
}
/**
* Checks if external storage is available. If external storage isn't
* available, the current activity is finsished an an error activity is
* launched.
*
* @param activity
* the activity which would be finished if no storage is
* available
* @return true if external storage is available
*/
public static boolean checkStorageAvailability(Activity activity) {
boolean storageAvailable = storageAvailable(activity);
if (!storageAvailable) {
activity.finish();
activity.startActivity(new Intent(activity,
StorageErrorActivity.class));
}
return storageAvailable;
}
/** Get the number of free bytes that are available on the external storage. */
public static long getFreeSpaceAvailable() {
StatFs stat = new StatFs(UserPreferences.getDataFolder(
PodcastApp.getInstance(), null).getAbsolutePath());
long availableBlocks;
long blockSize;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
availableBlocks = stat.getAvailableBlocksLong();
blockSize = stat.getBlockSizeLong();
} else {
availableBlocks = stat.getAvailableBlocks();
blockSize = stat.getBlockSize();
}
return availableBlocks * blockSize;
}
}

View File

@ -1,22 +0,0 @@
package de.danoeh.antennapod.core.util;
import android.util.Log;
import de.danoeh.antennapod.R;
import de.danoeh.antennapod.core.preferences.UserPreferences;
public class ThemeUtils {
private static final String TAG = "ThemeUtils";
public static int getSelectionBackgroundColor() {
switch (UserPreferences.getTheme()) {
case R.style.Theme_AntennaPod_Dark:
return R.color.selection_background_color_dark;
case R.style.Theme_AntennaPod_Light:
return R.color.selection_background_color_light;
default:
Log.e(TAG,
"getSelectionBackgroundColor could not match the current theme to any color!");
return R.color.selection_background_color_light;
}
}
}

View File

@ -42,7 +42,7 @@ import de.danoeh.antennapod.core.storage.DownloadRequestException;
import de.danoeh.antennapod.core.storage.DownloadRequester;
import de.danoeh.antennapod.core.util.QueueAccess;
import de.danoeh.antennapod.core.util.ShownotesProvider;
import de.danoeh.antennapod.core.util.menuhandler.FeedItemMenuHandler;
import de.danoeh.antennapod.menuhandler.FeedItemMenuHandler;
/**
* Shows information about a specific FeedItem and provides actions like playing, downloading, etc.

View File

@ -1,4 +1,4 @@
package de.danoeh.antennapod.core.dialog;
package de.danoeh.antennapod.dialog;
import android.app.Dialog;
import android.content.Context;
@ -10,7 +10,7 @@ import android.view.View;
import android.view.Window;
import android.view.inputmethod.InputMethodManager;
import android.widget.*;
import de.danoeh.antennapod.BuildConfig;
import de.danoeh.antennapod.core.BuildConfig;
import de.danoeh.antennapod.R;
import java.util.concurrent.TimeUnit;

View File

@ -48,9 +48,9 @@ import de.danoeh.antennapod.core.storage.DBReader;
import de.danoeh.antennapod.core.storage.DownloadRequestException;
import de.danoeh.antennapod.core.storage.DownloadRequester;
import de.danoeh.antennapod.core.util.QueueAccess;
import de.danoeh.antennapod.core.util.menuhandler.FeedMenuHandler;
import de.danoeh.antennapod.core.util.menuhandler.MenuItemUtils;
import de.danoeh.antennapod.core.util.menuhandler.NavDrawerActivity;
import de.danoeh.antennapod.menuhandler.FeedMenuHandler;
import de.danoeh.antennapod.menuhandler.MenuItemUtils;
import de.danoeh.antennapod.menuhandler.NavDrawerActivity;
/**
* Displays a list of FeedItems.

View File

@ -33,8 +33,8 @@ import de.danoeh.antennapod.core.storage.DBTasks;
import de.danoeh.antennapod.core.storage.DBWriter;
import de.danoeh.antennapod.core.storage.DownloadRequester;
import de.danoeh.antennapod.core.util.QueueAccess;
import de.danoeh.antennapod.core.util.menuhandler.MenuItemUtils;
import de.danoeh.antennapod.core.util.menuhandler.NavDrawerActivity;
import de.danoeh.antennapod.menuhandler.MenuItemUtils;
import de.danoeh.antennapod.menuhandler.NavDrawerActivity;
import java.util.List;
import java.util.concurrent.atomic.AtomicReference;

View File

@ -25,8 +25,8 @@ import de.danoeh.antennapod.core.service.download.Downloader;
import de.danoeh.antennapod.core.storage.DBReader;
import de.danoeh.antennapod.core.storage.DBWriter;
import de.danoeh.antennapod.core.util.QueueAccess;
import de.danoeh.antennapod.core.util.menuhandler.MenuItemUtils;
import de.danoeh.antennapod.core.util.menuhandler.NavDrawerActivity;
import de.danoeh.antennapod.menuhandler.MenuItemUtils;
import de.danoeh.antennapod.menuhandler.NavDrawerActivity;
import java.util.List;
import java.util.concurrent.atomic.AtomicReference;

View File

@ -37,8 +37,8 @@ import de.danoeh.antennapod.core.service.download.Downloader;
import de.danoeh.antennapod.core.storage.DBReader;
import de.danoeh.antennapod.core.storage.DBWriter;
import de.danoeh.antennapod.core.util.QueueAccess;
import de.danoeh.antennapod.core.util.menuhandler.MenuItemUtils;
import de.danoeh.antennapod.core.util.menuhandler.NavDrawerActivity;
import de.danoeh.antennapod.menuhandler.MenuItemUtils;
import de.danoeh.antennapod.menuhandler.NavDrawerActivity;
/**
* Shows all items in the queue

View File

@ -20,8 +20,8 @@ import de.danoeh.antennapod.core.feed.*;
import de.danoeh.antennapod.core.storage.DBReader;
import de.danoeh.antennapod.core.storage.FeedSearcher;
import de.danoeh.antennapod.core.util.QueueAccess;
import de.danoeh.antennapod.core.util.menuhandler.MenuItemUtils;
import de.danoeh.antennapod.core.util.menuhandler.NavDrawerActivity;
import de.danoeh.antennapod.menuhandler.MenuItemUtils;
import de.danoeh.antennapod.menuhandler.NavDrawerActivity;
import java.util.List;

View File

@ -18,8 +18,8 @@ import de.danoeh.antennapod.adapter.gpodnet.PodcastListAdapter;
import de.danoeh.antennapod.core.gpoddernet.GpodnetService;
import de.danoeh.antennapod.core.gpoddernet.GpodnetServiceException;
import de.danoeh.antennapod.core.gpoddernet.model.GpodnetPodcast;
import de.danoeh.antennapod.core.util.menuhandler.MenuItemUtils;
import de.danoeh.antennapod.core.util.menuhandler.NavDrawerActivity;
import de.danoeh.antennapod.menuhandler.MenuItemUtils;
import de.danoeh.antennapod.menuhandler.NavDrawerActivity;
import java.util.List;

View File

@ -13,8 +13,8 @@ import de.danoeh.antennapod.R;
import de.danoeh.antennapod.core.gpoddernet.GpodnetService;
import de.danoeh.antennapod.core.gpoddernet.GpodnetServiceException;
import de.danoeh.antennapod.core.gpoddernet.model.GpodnetPodcast;
import de.danoeh.antennapod.core.util.menuhandler.MenuItemUtils;
import de.danoeh.antennapod.core.util.menuhandler.NavDrawerActivity;
import de.danoeh.antennapod.menuhandler.MenuItemUtils;
import de.danoeh.antennapod.menuhandler.NavDrawerActivity;
/**
* Performs a search on the gpodder.net directory and displays the results.

View File

@ -21,8 +21,8 @@ import de.danoeh.antennapod.activity.MainActivity;
import de.danoeh.antennapod.core.gpoddernet.GpodnetService;
import de.danoeh.antennapod.core.gpoddernet.GpodnetServiceException;
import de.danoeh.antennapod.core.gpoddernet.model.GpodnetTag;
import de.danoeh.antennapod.core.util.menuhandler.MenuItemUtils;
import de.danoeh.antennapod.core.util.menuhandler.NavDrawerActivity;
import de.danoeh.antennapod.menuhandler.MenuItemUtils;
import de.danoeh.antennapod.menuhandler.NavDrawerActivity;
public class TagListFragment extends ListFragment {
private static final String TAG = "TagListFragment";

View File

@ -1,10 +1,10 @@
package de.danoeh.antennapod.core.util.menuhandler;
package de.danoeh.antennapod.menuhandler;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import de.danoeh.antennapod.BuildConfig;
import de.danoeh.antennapod.core.BuildConfig;
import de.danoeh.antennapod.R;
import de.danoeh.antennapod.core.feed.FeedItem;
import de.danoeh.antennapod.core.service.playback.PlaybackService;

View File

@ -1,4 +1,4 @@
package de.danoeh.antennapod.core.util.menuhandler;
package de.danoeh.antennapod.menuhandler;
import android.content.Context;
import android.content.Intent;
@ -7,7 +7,7 @@ import android.util.Log;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import de.danoeh.antennapod.BuildConfig;
import de.danoeh.antennapod.core.BuildConfig;
import de.danoeh.antennapod.R;
import de.danoeh.antennapod.core.feed.Feed;
import de.danoeh.antennapod.core.service.download.DownloadService;

View File

@ -1,11 +1,11 @@
package de.danoeh.antennapod.core.util.menuhandler;
package de.danoeh.antennapod.menuhandler;
import android.support.v4.view.MenuItemCompat;
import android.support.v7.widget.SearchView;
import android.view.Menu;
import android.view.MenuItem;
import de.danoeh.antennapod.R;
import de.danoeh.antennapod.core.R;
/**
* Utilities for menu items

View File

@ -1,4 +1,4 @@
package de.danoeh.antennapod.core.util.menuhandler;
package de.danoeh.antennapod.menuhandler;
/**
* Defines useful methods for activities that have a navigation drawer

View File

@ -1,4 +1,4 @@
package de.danoeh.antennapod.core.receiver;
package de.danoeh.antennapod.receiver;
import android.appwidget.AppWidgetManager;
import android.appwidget.AppWidgetProvider;
@ -8,19 +8,18 @@ import android.util.Log;
import org.apache.commons.lang3.StringUtils;
import de.danoeh.antennapod.BuildConfig;
import de.danoeh.antennapod.core.service.playback.PlayerWidgetService;
import de.danoeh.antennapod.core.BuildConfig;
import de.danoeh.antennapod.core.service.playback.PlaybackService;
import de.danoeh.antennapod.service.PlayerWidgetService;
public class PlayerWidget extends AppWidgetProvider {
private static final String TAG = "PlayerWidget";
public static final String FORCE_WIDGET_UPDATE = "de.danoeh.antennapod.FORCE_WIDGET_UPDATE";
public static final String STOP_WIDGET_UPDATE = "de.danoeh.antennapod.STOP_WIDGET_UPDATE";
@Override
@Override
public void onReceive(Context context, Intent intent) {
if (StringUtils.equals(intent.getAction(), FORCE_WIDGET_UPDATE)) {
if (StringUtils.equals(intent.getAction(), PlaybackService.FORCE_WIDGET_UPDATE)) {
startUpdate(context);
} else if (StringUtils.equals(intent.getAction(), STOP_WIDGET_UPDATE)) {
} else if (StringUtils.equals(intent.getAction(), PlaybackService.STOP_WIDGET_UPDATE)) {
stopUpdate(context);
}

View File

@ -1,4 +1,4 @@
package de.danoeh.antennapod.core.service.playback;
package de.danoeh.antennapod.service;
import android.app.PendingIntent;
import android.app.Service;
@ -12,10 +12,12 @@ import android.util.Log;
import android.view.KeyEvent;
import android.view.View;
import android.widget.RemoteViews;
import de.danoeh.antennapod.BuildConfig;
import de.danoeh.antennapod.core.BuildConfig;
import de.danoeh.antennapod.R;
import de.danoeh.antennapod.core.receiver.MediaButtonReceiver;
import de.danoeh.antennapod.core.receiver.PlayerWidget;
import de.danoeh.antennapod.receiver.PlayerWidget;
import de.danoeh.antennapod.core.service.playback.PlaybackService;
import de.danoeh.antennapod.core.service.playback.PlayerStatus;
import de.danoeh.antennapod.core.util.Converter;
import de.danoeh.antennapod.core.util.playback.Playable;

1
core/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
/build

43
core/build.gradle Normal file
View File

@ -0,0 +1,43 @@
apply plugin: 'com.android.library'
android {
compileSdkVersion 20
buildToolsVersion "20.0.0"
defaultConfig {
applicationId "de.danoeh.antennapod.core"
minSdkVersion 10
targetSdkVersion 20
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:20.0.0'
compile 'com.android.support:support-v4: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 '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'
}

17
core/proguard-rules.pro vendored Normal file
View File

@ -0,0 +1,17 @@
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in /Users/daniel/bin/android-sdk/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# Add any project specific keep options here:
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

View File

@ -0,0 +1,13 @@
package de.danoeh.antennapod.core;
import android.app.Application;
import android.test.ApplicationTestCase;
/**
* <a href="http://d.android.com/tools/testing/testing_android.html">Testing Fundamentals</a>
*/
public class ApplicationTest extends ApplicationTestCase<Application> {
public ApplicationTest() {
super(Application.class);
}
}

View File

@ -0,0 +1,11 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="de.danoeh.antennapod.core">
<application android:allowBackup="true"
android:label="@string/app_name"
android:icon="@drawable/ic_launcher"
>
</application>
</manifest>

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,22 @@
package de.danoeh.antennapod.core;
import android.app.Application;
import android.content.Context;
import android.content.Intent;
/**
* Callbacks related to the application in general
*/
public interface ApplicationCallbacks {
/**
* Returns a non-null instance of the application class
*/
public Application getApplicationInstance();
/**
* Returns a non-null intent that starts the storage error
* activity.
*/
public Intent getStorageErrorActivity(Context context);
}

View File

@ -11,11 +11,15 @@ public class ClientConfig {
*/
public static String USER_AGENT;
public static ApplicationCallbacks applicationCallbacks;
public static DownloadServiceCallbacks downloadServiceCallbacks;
public static PlaybackServiceCallbacks playbackServiceCallbacks;
public static GpodnetCallbacks gpodnetCallbacks;
public static FlattrCallbacks flattrCallbacks;
public static StorageCallbacks storageCallbacks;
}

View File

@ -1,6 +1,7 @@
package de.danoeh.antennapod.core;
import android.app.PendingIntent;
import android.content.Context;
import de.danoeh.antennapod.core.service.download.DownloadRequest;
@ -17,7 +18,7 @@ public interface DownloadServiceCallbacks {
*
* @return A non-null PendingIntent for the notification.
*/
public PendingIntent getNotificationContentIntent();
public PendingIntent getNotificationContentIntent(Context context);
/**
* Returns a PendingIntent for a notification that tells the user to enter a username
@ -28,7 +29,7 @@ public interface DownloadServiceCallbacks {
*
* @return A non-null PendingIntent for the notification.
*/
public PendingIntent getAuthentificationNotificationContentIntent(DownloadRequest request);
public PendingIntent getAuthentificationNotificationContentIntent(Context context, DownloadRequest request);
/**
* Returns a PendingIntent for notification that notifies the user about the completion of downloads
@ -38,6 +39,6 @@ public interface DownloadServiceCallbacks {
*
* @return A non-null PendingIntent for the notification.
*/
public PendingIntent getReportNotificationContentIntent();
public PendingIntent getReportNotificationContentIntent(Context context);
}

View File

@ -1,7 +1,11 @@
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.
*/
@ -20,5 +24,13 @@ public interface FlattrCallbacks {
* @return The intent that starts the authentication activity or null
* if flattr integration is disabled (i.e. flattrEnabled() == false).
*/
public Intent getFlattrAuthenticationActivityIntent();
public Intent getFlattrAuthenticationActivityIntent(Context context);
public PendingIntent getFlattrFailedNotificationContentIntent(Context context);
public String getFlattrAppKey();
public String getFlattrAppSecret();
public void handleFlattrAuthenticationSuccess(AccessToken token);
}

View File

@ -1,6 +1,7 @@
package de.danoeh.antennapod.core;
import android.app.PendingIntent;
import android.content.Context;
/**
* Callbacks related to the gpodder.net integration of the core module
@ -22,5 +23,5 @@ public interface GpodnetCallbacks {
* @return A PendingIntent for the notification or null if gpodder.net integration
* has been disabled (i.e. gpodnetEnabled() == false).
*/
public PendingIntent getGpodnetSyncServiceErrorNotificationPendingIntent();
public PendingIntent getGpodnetSyncServiceErrorNotificationPendingIntent(Context context);
}

View File

@ -1,5 +1,6 @@
package de.danoeh.antennapod.core;
import android.content.Context;
import android.content.Intent;
import de.danoeh.antennapod.core.feed.MediaType;
@ -16,5 +17,5 @@ public interface PlaybackServiceCallbacks {
* @param mediaType The type of media that is being played.
* @return A non-null activity intent.
*/
public Intent getPlayerActivityIntent(MediaType mediaType);
public Intent getPlayerActivityIntent(Context context, MediaType mediaType);
}

View File

@ -8,7 +8,7 @@ import android.util.Log;
import org.apache.commons.lang3.Validate;
import de.danoeh.antennapod.BuildConfig;
import de.danoeh.antennapod.core.BuildConfig;
import de.danoeh.antennapod.core.service.download.DownloadService;
import de.danoeh.antennapod.core.service.download.Downloader;

View File

@ -6,7 +6,7 @@ import android.content.Context;
import android.content.DialogInterface;
import android.content.DialogInterface.OnCancelListener;
import android.os.AsyncTask;
import de.danoeh.antennapod.R;
import de.danoeh.antennapod.core.R;
import de.danoeh.antennapod.core.feed.Feed;
import de.danoeh.antennapod.core.storage.DBWriter;

View File

@ -5,7 +5,6 @@ import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.os.AsyncTask;
import android.support.v4.app.NotificationCompat;
import android.util.Log;
@ -19,10 +18,9 @@ import java.util.List;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import de.danoeh.antennapod.BuildConfig;
import de.danoeh.antennapod.R;
import de.danoeh.antennapod.activity.FlattrAuthActivity;
import de.danoeh.antennapod.activity.MainActivity;
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;
@ -177,7 +175,8 @@ public class FlattrClickWorker extends AsyncTask<Void, Integer, FlattrClickWorke
}
private void postNoTokenNotification() {
PendingIntent contentIntent = PendingIntent.getActivity(context, 0, new Intent(context, FlattrAuthActivity.class), 0);
PendingIntent contentIntent = PendingIntent.getActivity(context, 0,
ClientConfig.flattrCallbacks.getFlattrAuthenticationActivityIntent(context), 0);
Notification notification = new NotificationCompat.Builder(context)
.setStyle(new NotificationCompat.BigTextStyle().bigText(context.getString(R.string.no_flattr_token_notification_msg)))
@ -196,7 +195,7 @@ public class FlattrClickWorker extends AsyncTask<Void, Integer, FlattrClickWorke
return;
}
PendingIntent contentIntent = PendingIntent.getActivity(context, 0, new Intent(context, MainActivity.class), 0);
PendingIntent contentIntent = ClientConfig.flattrCallbacks.getFlattrFailedNotificationContentIntent(context);
String title;
String subtext;

View File

@ -2,7 +2,7 @@ package de.danoeh.antennapod.core.asynctask;
import android.content.Context;
import android.util.Log;
import de.danoeh.antennapod.BuildConfig;
import de.danoeh.antennapod.core.BuildConfig;
import de.danoeh.antennapod.core.storage.DBWriter;
import de.danoeh.antennapod.core.util.flattr.FlattrUtils;
import org.shredzone.flattr4j.exception.FlattrException;

View File

@ -0,0 +1,92 @@
package de.danoeh.antennapod.core.asynctask;
import android.annotation.SuppressLint;
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";
Context context;
AndroidAuthenticator auth;
AccessToken token;
Uri uri;
ProgressDialog dialog;
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;
}
}
@SuppressLint("NewApi")
public void executeAsync() {
if (android.os.Build.VERSION.SDK_INT > android.os.Build.VERSION_CODES.GINGERBREAD_MR1) {
executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
} else {
execute();
}
}
}

View File

@ -8,7 +8,7 @@ import android.content.Context;
import android.os.ParcelFileDescriptor;
import android.util.Log;
import de.danoeh.antennapod.BuildConfig;
import de.danoeh.antennapod.core.BuildConfig;
import org.xmlpull.v1.XmlPullParserException;
import java.io.ByteArrayOutputStream;

View File

@ -4,8 +4,8 @@ import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.util.Log;
import de.danoeh.antennapod.BuildConfig;
import de.danoeh.antennapod.R;
import de.danoeh.antennapod.core.BuildConfig;
import de.danoeh.antennapod.core.R;
/**
* Creates an AlertDialog which asks the user to confirm something. Other

View File

@ -3,7 +3,7 @@ package de.danoeh.antennapod.core.dialog;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import de.danoeh.antennapod.R;
import de.danoeh.antennapod.core.R;
/** Creates Alert Dialogs if a DownloadRequestException has happened. */
public class DownloadRequestErrorDialogCreator {

View File

@ -5,7 +5,7 @@ import android.util.Log;
import org.apache.commons.lang3.Validate;
import de.danoeh.antennapod.BuildConfig;
import de.danoeh.antennapod.core.BuildConfig;
import java.util.AbstractQueue;
import java.util.Observable;

View File

@ -2,17 +2,17 @@ package de.danoeh.antennapod.core.feed;
import android.net.Uri;
import de.danoeh.antennapod.PodcastApp;
import java.util.Date;
import java.util.List;
import java.util.concurrent.Callable;
import de.danoeh.antennapod.core.ClientConfig;
import de.danoeh.antennapod.core.asynctask.PicassoImageResource;
import de.danoeh.antennapod.core.storage.DBReader;
import de.danoeh.antennapod.core.util.ShownotesProvider;
import de.danoeh.antennapod.core.util.flattr.FlattrStatus;
import de.danoeh.antennapod.core.util.flattr.FlattrThing;
import java.util.Date;
import java.util.List;
import java.util.concurrent.Callable;
/**
* Data Object for a XML message
*
@ -253,7 +253,7 @@ public class FeedItem extends FeedComponent implements ShownotesProvider, Flattr
public String call() throws Exception {
if (contentEncoded == null || description == null) {
DBReader.loadExtraInformationOfFeedItem(PodcastApp.getInstance(), FeedItem.this);
DBReader.loadExtraInformationOfFeedItem(ClientConfig.applicationCallbacks.getApplicationInstance(), FeedItem.this);
}
return (contentEncoded != null) ? contentEncoded : description;

View File

@ -10,7 +10,7 @@ import java.util.Date;
import java.util.List;
import java.util.concurrent.Callable;
import de.danoeh.antennapod.PodcastApp;
import de.danoeh.antennapod.core.ClientConfig;
import de.danoeh.antennapod.core.preferences.PlaybackPreferences;
import de.danoeh.antennapod.core.storage.DBReader;
import de.danoeh.antennapod.core.storage.DBWriter;
@ -239,7 +239,7 @@ public class FeedMedia extends FeedFile implements Playable {
@Override
public void loadMetadata() throws PlayableException {
if (item == null && itemID != 0) {
item = DBReader.getFeedItem(PodcastApp.getInstance(), itemID);
item = DBReader.getFeedItem(ClientConfig.applicationCallbacks.getApplicationInstance(), itemID);
}
}
@ -248,7 +248,7 @@ public class FeedMedia extends FeedFile implements Playable {
if (getChapters() == null && !localFileAvailable()) {
ChapterUtils.loadChaptersFromStreamUrl(this);
if (getChapters() != null && item != null) {
DBWriter.setFeedItem(PodcastApp.getInstance(),
DBWriter.setFeedItem(ClientConfig.applicationCallbacks.getApplicationInstance(),
item);
}
}
@ -327,7 +327,7 @@ public class FeedMedia extends FeedFile implements Playable {
@Override
public void saveCurrentPosition(SharedPreferences pref, int newPosition) {
setPosition(newPosition);
DBWriter.setFeedMediaPlaybackInformation(PodcastApp.getInstance(), this);
DBWriter.setFeedMediaPlaybackInformation(ClientConfig.applicationCallbacks.getApplicationInstance(), this);
}
@Override
@ -355,10 +355,12 @@ public class FeedMedia extends FeedFile implements Playable {
@Override
public String call() throws Exception {
if (item == null) {
item = DBReader.getFeedItem(PodcastApp.getInstance(), itemID);
item = DBReader.getFeedItem(
ClientConfig.applicationCallbacks.getApplicationInstance(), itemID);
}
if (item.getContentEncoded() == null || item.getDescription() == null) {
DBReader.loadExtraInformationOfFeedItem(PodcastApp.getInstance(), item);
DBReader.loadExtraInformationOfFeedItem(
ClientConfig.applicationCallbacks.getApplicationInstance(), item);
}
return (item.getContentEncoded() != null) ? item.getContentEncoded() : item.getDescription();

Some files were not shown because too many files have changed in this diff Show More