Merge pull request #3266 from ByteHamster/remove-flattr

Removed Flattr support
This commit is contained in:
H. Lehmann 2019-07-13 15:04:05 +02:00 committed by GitHub
commit ed338edea4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
54 changed files with 13 additions and 1737 deletions

1
.gitignore vendored
View File

@ -39,7 +39,6 @@ contributers.py
proguard
libs
*.DS_Store
src/de/danoeh/antennapod/util/flattr/FlattrConfig.java
gradle.properties
*.keystore
*.p12

View File

@ -59,16 +59,10 @@ android {
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"
resValue "string", "provider_authority", "de.danoeh.antennapod.debug.provider"
buildConfigField STRING, FLATTR_APP_KEY, mFlattrAppKey
buildConfigField STRING, FLATTR_APP_SECRET, mFlattrAppSecret
dexcount {
if (project.hasProperty("enableDexcountInDebug")) {
runOnEachPackage enableDexcountInDebug.toBoolean()
@ -82,8 +76,6 @@ android {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), "proguard.cfg"
signingConfig signingConfigs.releaseConfig
buildConfigField STRING, FLATTR_APP_KEY, mFlattrAppKey
buildConfigField STRING, FLATTR_APP_SECRET, mFlattrAppSecret
}
}
@ -145,9 +137,6 @@ dependencies {
annotationProcessor "android.arch.lifecycle:compiler:$lifecycle_version"
implementation "org.apache.commons:commons-lang3:$commonslangVersion"
implementation("org.shredzone.flattr4j:flattr4j-core:$flattr4jVersion") {
exclude group: "org.json", module: "json"
}
implementation "commons-io:commons-io:$commonsioVersion"
implementation "org.jsoup:jsoup:$jsoupVersion"
implementation "com.github.bumptech.glide:glide:$glideVersion"

View File

@ -75,9 +75,6 @@
-dontwarn android.support.v7.**
-dontwarn com.google.android.wearable.**
-keep class org.shredzone.flattr4j.** { *; }
-dontwarn org.shredzone.flattr4j.**
-keep class org.apache.commons.** { *; }
-dontskipnonpubliclibraryclassmembers

View File

@ -14,7 +14,6 @@ import de.danoeh.antennapod.core.feed.FeedMedia;
import de.danoeh.antennapod.core.feed.SimpleChapter;
import de.danoeh.antennapod.core.storage.PodDBAdapter;
import de.danoeh.antennapod.core.util.comparator.FeedItemPubdateComparator;
import de.danoeh.antennapod.core.util.flattr.FlattrStatus;
/**
* Utility methods for DB* tests.
@ -46,7 +45,7 @@ class DBTestUtils {
adapter.open();
for (int i = 0; i < numFeeds; i++) {
Feed f = new Feed(0, null, "feed " + i, null, "link" + i, "descr", null, null,
null, null, "id" + i, null, null, "url" + i, false, new FlattrStatus(), false, null, null, false);
null, null, "id" + i, null, null, "url" + i, false, false, null, null, false);
f.setItems(new ArrayList<>());
for (int j = 0; j < numItems; j++) {
FeedItem item = new FeedItem(0, "item " + j, "id" + j, "link" + j, new Date(),

View File

@ -14,7 +14,6 @@ class GeneratorUtil {
String ns = (withNamespace) ? "http://www.w3.org/2005/Atom" : null;
xml.startTag(ns, "link");
xml.attribute(null, "rel", "payment");
xml.attribute(null, "title", "Flattr this!");
xml.attribute(null, "href", paymentLink);
xml.attribute(null, "type", "text/html");
xml.endTag(ns, "link");

View File

@ -141,25 +141,6 @@
<activity android:name=".activity.StorageErrorActivity">
</activity>
<activity
android:name=".activity.FlattrAuthActivity"
android:label="@string/flattr_auth_label">
<intent-filter>
<action android:name=".activities.FlattrAuthActivity"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
<data
android:host="de.danoeh.antennapod"
android:scheme="flattr4j"/>
</intent-filter>
</activity>
<activity
android:name=".activity.AboutActivity"
android:configChanges="keyboardHidden|orientation|screenSize"

View File

@ -199,8 +199,6 @@ public class FeedInfoActivity extends AppCompatActivity {
@Override
public boolean onPrepareOptionsMenu(Menu menu) {
super.onPrepareOptionsMenu(menu);
menu.findItem(R.id.support_item).setVisible(
feed != null && feed.getPaymentLink() != null);
menu.findItem(R.id.share_link_item).setVisible(feed != null && feed.getLink() != null);
menu.findItem(R.id.visit_website_item).setVisible(feed != null && feed.getLink() != null &&
IntentUtils.isCallable(this, new Intent(Intent.ACTION_VIEW, Uri.parse(feed.getLink()))));

View File

@ -1,120 +0,0 @@
package de.danoeh.antennapod.activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import org.shredzone.flattr4j.exception.FlattrException;
import de.danoeh.antennapod.BuildConfig;
import de.danoeh.antennapod.R;
import de.danoeh.antennapod.core.preferences.UserPreferences;
import de.danoeh.antennapod.core.util.flattr.FlattrUtils;
/** Guides the user through the authentication process */
public class FlattrAuthActivity extends AppCompatActivity {
private static final String TAG = "FlattrAuthActivity";
private TextView txtvExplanation;
private Button butAuthenticate;
private Button butReturn;
private boolean authSuccessful;
private static FlattrAuthActivity singleton;
@Override
protected void onCreate(Bundle savedInstanceState) {
setTheme(UserPreferences.getTheme());
super.onCreate(savedInstanceState);
singleton = this;
authSuccessful = false;
if (BuildConfig.DEBUG) Log.d(TAG, "Activity created");
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
setContentView(R.layout.flattr_auth);
txtvExplanation = findViewById(R.id.txtvExplanation);
butAuthenticate = findViewById(R.id.but_authenticate);
butReturn = findViewById(R.id.but_return_home);
butReturn.setOnClickListener(v -> {
Intent intent = new Intent(FlattrAuthActivity.this, MainActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
});
butAuthenticate.setOnClickListener(v -> {
try {
FlattrUtils.startAuthProcess(FlattrAuthActivity.this);
} catch (FlattrException e) {
e.printStackTrace();
}
});
}
public static FlattrAuthActivity getInstance() {
return singleton;
}
@Override
protected void onResume() {
super.onResume();
if (BuildConfig.DEBUG) Log.d(TAG, "Activity resumed");
Uri uri = getIntent().getData();
if (uri != null) {
if (BuildConfig.DEBUG) Log.d(TAG, "Received uri");
FlattrUtils.handleCallback(this, uri);
}
}
public void handleAuthenticationSuccess() {
authSuccessful = true;
txtvExplanation.setText(R.string.flattr_auth_success);
butAuthenticate.setEnabled(false);
butReturn.setVisibility(View.VISIBLE);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
super.onCreateOptionsMenu(menu);
return true;
}
@Override
protected void onPause() {
super.onPause();
if (authSuccessful) {
finish();
}
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
if (authSuccessful) {
Intent intent = new Intent(this, PreferenceActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
} else {
finish();
}
break;
default:
return false;
}
return true;
}
}

View File

@ -330,11 +330,6 @@ public abstract class MediaplayerActivity extends CastEnabledActivity implements
Playable media = controller.getMedia();
boolean isFeedMedia = media != null && (media instanceof FeedMedia);
menu.findItem(R.id.support_item).setVisible(isFeedMedia && media.getPaymentLink() != null &&
((FeedMedia) media).getItem() != null &&
((FeedMedia) media).getItem().getFlattrStatus().flattrable()
);
boolean hasWebsiteLink = ( getWebsiteLinkWithFallback(media) != null );
menu.findItem(R.id.visit_website_item).setVisible(hasWebsiteLink);
@ -603,11 +598,6 @@ public abstract class MediaplayerActivity extends CastEnabledActivity implements
Uri uri = Uri.parse(getWebsiteLinkWithFallback(media));
startActivity(new Intent(Intent.ACTION_VIEW, uri));
break;
case R.id.support_item:
if (media instanceof FeedMedia) {
DBTasks.flattrItemIfLoggedIn(this, ((FeedMedia) media).getItem());
}
break;
case R.id.share_link_item:
if (media instanceof FeedMedia) {
ShareUtils.shareFeedItemLink(this, ((FeedMedia) media).getItem());

View File

@ -15,7 +15,6 @@ import com.bytehamster.lib.preferencesearch.SearchPreferenceResultListener;
import de.danoeh.antennapod.R;
import de.danoeh.antennapod.core.preferences.UserPreferences;
import de.danoeh.antennapod.fragment.preferences.AutoDownloadPreferencesFragment;
import de.danoeh.antennapod.fragment.preferences.FlattrPreferencesFragment;
import de.danoeh.antennapod.fragment.preferences.GpodderPreferencesFragment;
import de.danoeh.antennapod.fragment.preferences.IntegrationsPreferencesFragment;
import de.danoeh.antennapod.fragment.preferences.MainPreferencesFragment;
@ -64,8 +63,6 @@ public class PreferenceActivity extends AppCompatActivity implements SearchPrefe
prefFragment = new AutoDownloadPreferencesFragment();
} else if (screen == R.xml.preferences_gpodder) {
prefFragment = new GpodderPreferencesFragment();
} else if (screen == R.xml.preferences_flattr) {
prefFragment = new FlattrPreferencesFragment();
} else if (screen == R.xml.preferences_playback) {
prefFragment = new PlaybackPreferencesFragment();
}
@ -86,8 +83,6 @@ public class PreferenceActivity extends AppCompatActivity implements SearchPrefe
return R.string.user_interface_label;
case R.xml.preferences_integrations:
return R.string.integrations_label;
case R.xml.preferences_flattr:
return R.string.flattr_label;
case R.xml.preferences_gpodder:
return R.string.gpodnet_main_label;
default:

View File

@ -16,7 +16,6 @@ class ClientConfigurator {
ClientConfig.downloadServiceCallbacks = new DownloadServiceCallbacksImpl();
ClientConfig.gpodnetCallbacks = new GpodnetCallbacksImpl();
ClientConfig.playbackServiceCallbacks = new PlaybackServiceCallbacksImpl();
ClientConfig.flattrCallbacks = new FlattrCallbacksImpl();
ClientConfig.dbTasksCallbacks = new DBTasksCallbacksImpl();
ClientConfig.castCallbacks = new CastCallbackImpl();
}

View File

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

@ -1,97 +0,0 @@
package de.danoeh.antennapod.dialog;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Context;
import android.support.v7.app.AlertDialog;
import android.view.View;
import android.widget.CheckBox;
import android.widget.SeekBar;
import android.widget.TextView;
import org.apache.commons.lang3.Validate;
import de.danoeh.antennapod.R;
import de.danoeh.antennapod.core.preferences.UserPreferences;
/**
* Creates a new AlertDialog that displays preferences for auto-flattring to the user.
*/
public class AutoFlattrPreferenceDialog {
private AutoFlattrPreferenceDialog() {
}
public static void newAutoFlattrPreferenceDialog(final Activity activity, final AutoFlattrPreferenceDialogInterface callback) {
Validate.notNull(activity);
Validate.notNull(callback);
AlertDialog.Builder builder = new AlertDialog.Builder(activity);
@SuppressLint("InflateParams") View view = activity.getLayoutInflater().inflate(R.layout.autoflattr_preference_dialog, null);
final CheckBox chkAutoFlattr = view.findViewById(R.id.chkAutoFlattr);
final SeekBar skbPercent = view.findViewById(R.id.skbPercent);
final TextView txtvStatus = view.findViewById(R.id.txtvStatus);
chkAutoFlattr.setChecked(UserPreferences.isAutoFlattr());
skbPercent.setEnabled(chkAutoFlattr.isChecked());
txtvStatus.setEnabled(chkAutoFlattr.isChecked());
final int initialValue = (int) (UserPreferences.getAutoFlattrPlayedDurationThreshold() * 100.0f);
setStatusMsgText(activity, txtvStatus, initialValue);
skbPercent.setProgress(initialValue);
chkAutoFlattr.setOnClickListener(v -> {
skbPercent.setEnabled(chkAutoFlattr.isChecked());
txtvStatus.setEnabled(chkAutoFlattr.isChecked());
});
skbPercent.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
setStatusMsgText(activity, txtvStatus, progress);
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
}
});
builder.setTitle(R.string.pref_auto_flattr_title)
.setView(view)
.setPositiveButton(R.string.confirm_label, (dialog, which) -> {
float progDouble = ((float) skbPercent.getProgress()) / 100.0f;
callback.onConfirmed(chkAutoFlattr.isChecked(), progDouble);
dialog.dismiss();
})
.setNegativeButton(R.string.cancel_label, (dialog, which) -> {
callback.onCancelled();
dialog.dismiss();
})
.setCancelable(false).show();
}
private static void setStatusMsgText(Context context, TextView txtvStatus, int progress) {
if (progress == 0) {
txtvStatus.setText(R.string.auto_flattr_ater_beginning);
} else if (progress == 100) {
txtvStatus.setText(R.string.auto_flattr_ater_end);
} else {
txtvStatus.setText(context.getString(R.string.auto_flattr_after_percent, progress));
}
}
public interface AutoFlattrPreferenceDialogInterface {
void onCancelled();
void onConfirmed(boolean autoFlattrEnabled, float autoFlattrValue);
}
}

View File

@ -1,61 +0,0 @@
package de.danoeh.antennapod.fragment.preferences;
import android.os.Bundle;
import android.support.v7.preference.PreferenceFragmentCompat;
import de.danoeh.antennapod.R;
import de.danoeh.antennapod.core.preferences.UserPreferences;
import de.danoeh.antennapod.core.util.flattr.FlattrUtils;
import de.danoeh.antennapod.dialog.AutoFlattrPreferenceDialog;
public class FlattrPreferencesFragment extends PreferenceFragmentCompat {
private static final String PREF_FLATTR_AUTH = "pref_flattr_authenticate";
private static final String PREF_FLATTR_REVOKE = "prefRevokeAccess";
private static final String PREF_AUTO_FLATTR_PREFS = "prefAutoFlattrPrefs";
@Override
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
addPreferencesFromResource(R.xml.preferences_flattr);
setupFlattrScreen();
}
@Override
public void onResume() {
super.onResume();
checkFlattrItemVisibility();
}
private void setupFlattrScreen() {
findPreference(PREF_FLATTR_REVOKE).setOnPreferenceClickListener(
preference -> {
FlattrUtils.revokeAccessToken(getActivity());
checkFlattrItemVisibility();
return true;
}
);
findPreference(PREF_AUTO_FLATTR_PREFS)
.setOnPreferenceClickListener(preference -> {
AutoFlattrPreferenceDialog.newAutoFlattrPreferenceDialog(getActivity(),
new AutoFlattrPreferenceDialog.AutoFlattrPreferenceDialogInterface() {
@Override
public void onCancelled() {
}
@Override
public void onConfirmed(boolean autoFlattrEnabled, float autoFlattrValue) {
UserPreferences.setAutoFlattrSettings(autoFlattrEnabled, autoFlattrValue);
checkFlattrItemVisibility();
}
});
return true;
});
}
private void checkFlattrItemVisibility() {
boolean hasFlattrToken = FlattrUtils.hasToken();
findPreference(PREF_FLATTR_AUTH).setEnabled(!hasFlattrToken);
findPreference(PREF_FLATTR_REVOKE).setEnabled(hasFlattrToken);
findPreference(PREF_AUTO_FLATTR_PREFS).setEnabled(hasFlattrToken);
}
}

View File

@ -4,10 +4,8 @@ import android.os.Bundle;
import android.support.v7.preference.PreferenceFragmentCompat;
import de.danoeh.antennapod.R;
import de.danoeh.antennapod.activity.PreferenceActivity;
import de.danoeh.antennapod.core.util.flattr.FlattrUtils;
public class IntegrationsPreferencesFragment extends PreferenceFragmentCompat {
private static final String PREF_SCREEN_FLATTR = "prefFlattrSettings";
private static final String PREF_SCREEN_GPODDER = "prefGpodderSettings";
@Override
@ -17,19 +15,9 @@ public class IntegrationsPreferencesFragment extends PreferenceFragmentCompat {
}
private void setupIntegrationsScreen() {
findPreference(PREF_SCREEN_FLATTR).setOnPreferenceClickListener(preference -> {
((PreferenceActivity) getActivity()).openScreen(R.xml.preferences_flattr);
return true;
});
findPreference(PREF_SCREEN_GPODDER).setOnPreferenceClickListener(preference -> {
((PreferenceActivity) getActivity()).openScreen(R.xml.preferences_gpodder);
return true;
});
}
@Override
public void onResume() {
super.onResume();
findPreference(PREF_SCREEN_FLATTR).setEnabled(FlattrUtils.hasAPICredentials());
}
}

View File

@ -143,8 +143,5 @@ public class MainPreferencesFragment extends PreferenceFragmentCompat {
config.index(R.xml.preferences_gpodder)
.addBreadcrumb(PreferenceActivity.getTitleOfPage(R.xml.preferences_integrations))
.addBreadcrumb(PreferenceActivity.getTitleOfPage(R.xml.preferences_gpodder));
config.index(R.xml.preferences_flattr)
.addBreadcrumb(PreferenceActivity.getTitleOfPage(R.xml.preferences_integrations))
.addBreadcrumb(PreferenceActivity.getTitleOfPage(R.xml.preferences_flattr));
}
}

View File

@ -123,10 +123,6 @@ public class FeedItemMenuHandler {
mi.setItemVisibility(R.id.deactivate_auto_download, false);
}
if (selectedItem.getPaymentLink() == null || !selectedItem.getFlattrStatus().flattrable()) {
mi.setItemVisibility(R.id.support_item, false);
}
boolean isFavorite = selectedItem.isTagged(FeedItem.TAG_FAVORITE);
mi.setItemVisibility(R.id.add_to_favorites_item, !isFavorite);
mi.setItemVisibility(R.id.remove_from_favorites_item, isFavorite);
@ -229,9 +225,6 @@ public class FeedItemMenuHandler {
Toast.LENGTH_SHORT).show();
}
break;
case R.id.support_item:
DBTasks.flattrItemIfLoggedIn(context, selectedItem);
break;
case R.id.share_link_item:
ShareUtils.shareFeedItemLink(context, selectedItem);
break;

View File

@ -46,11 +46,6 @@ public class FeedMenuHandler {
}
Log.d(TAG, "Preparing options menu");
if (selectedFeed.getPaymentLink() != null && selectedFeed.getFlattrStatus().flattrable()) {
menu.findItem(R.id.support_item).setVisible(true);
} else {
menu.findItem(R.id.support_item).setVisible(false);
}
menu.findItem(R.id.refresh_complete_item).setVisible(selectedFeed.isPaged());
@ -98,9 +93,6 @@ public class FeedMenuHandler {
Toast.LENGTH_SHORT).show();
}
break;
case R.id.support_item:
DBTasks.flattrFeedIfLoggedIn(context, selectedFeed);
break;
case R.id.share_link_item:
ShareUtils.shareFeedlink(context, selectedFeed);
break;

View File

@ -1,5 +1,5 @@
AntennaPod is a podcast manager and player that gives you instant access to millions of free and paid podcasts, from independent podcasters to large publishing houses such as the BBC, NPR and CNN. Add, import and export their feeds hassle-free using the iTunes podcast database, OPML files or simple RSS URLs. Save effort, battery power and mobile data usage with powerful automation controls for downloading episodes (specify times, intervals and WiFi networks) and deleting episodes (based on your favourites and delay settings).<br>
But most importantly: Download, stream or queue episodes and enjoy them the way you like with adjustable playback speeds, chapter support and a sleep timer. You can even show your love to the content creators with our Flattr integration.
But most importantly: Download, stream or queue episodes and enjoy them the way you like with adjustable playback speeds, chapter support and a sleep timer.
Made by podcast-enthousiast, AntennaPod is free in all senses of the word: open source, no costs, no ads.
@ -15,7 +15,6 @@ KEEP TRACK, SHARE & APPRECIATE<br>
&#8226; Keep track of the best of the best by marking episodes as favourites<br>
&#8226; Find that one episode through the playback history or by searching (titles and shownotes)<br>
&#8226; Share episodes and feeds through advanced social media and email options, the gPodder.net services and via OPML export<br>
&#8226; Support content creators with Flattr integration including automatic flattring
CONTROL THE SYSTEM<br>
&#8226; Take control over automated downloading: choose feeds, exclude mobile networks, select specific WiFi networks, require the phone to be charging and set times or intervals<br>

View File

@ -1,35 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<CheckBox
android:id="@+id/chkAutoFlattr"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="4dp"
android:text="@string/auto_flattr_enable"
android:textColor="?android:attr/textColorPrimary"
android:textSize="@dimen/text_size_small" />
<SeekBar
android:id="@+id/skbPercent"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="8dp"
android:max="100" />
<TextView
android:id="@+id/txtvStatus"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="8dp"
android:ellipsize="end"
android:lines="2"
android:text="@string/auto_flattr_after_percent"
android:textColor="?android:attr/textColorPrimary"
android:textSize="@dimen/text_size_small" />
</LinearLayout>

View File

@ -1,30 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView
android:id="@+id/txtvExplanation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="8dp"
android:text="@string/flattr_auth_explanation" />
<Button
android:id="@+id/but_authenticate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_margin="8dp"
android:text="@string/authenticate_label" />
<Button
android:id="@+id/but_return_home"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:text="@string/return_home_label"
android:visibility="gone" />
</LinearLayout>

View File

@ -83,10 +83,4 @@
android:title="@string/share_file_label" />
</menu>
</item>
<item
android:id="@+id/support_item"
android:menuCategory="container"
android:title="@string/support_label" />
</menu>

View File

@ -8,12 +8,6 @@
android:title="@string/visit_website_label"
android:visible="true">
</item>
<item
android:id="@+id/support_item"
custom:showAsAction="ifRoom|collapseActionView"
android:title="@string/support_label"
android:visible="false">
</item>
<item
android:id="@+id/share_link_item"
custom:showAsAction="collapseActionView"

View File

@ -91,12 +91,6 @@
</menu>
</item>
<item
android:id="@+id/support_item"
custom:showAsAction="collapseActionView"
android:title="@string/support_label">
</item>
<item
android:id="@+id/open_podcast"
custom:showAsAction="collapseActionView"

View File

@ -83,11 +83,4 @@
android:title="@string/share_file_label" />
</menu>
</item>
<item
android:id="@+id/support_item"
android:menuCategory="container"
android:title="@string/support_label" />
</menu>

View File

@ -37,14 +37,6 @@
custom:actionViewClass="android.support.v7.widget.SearchView"
android:title="@string/search_label"/>
<item
android:id="@+id/support_item"
android:menuCategory="container"
android:title="@string/support_label"
android:visible="false"
custom:showAsAction="collapseActionView">
</item>
<item
android:id="@+id/visit_website_item"
android:icon="?attr/location_web_site"

View File

@ -78,11 +78,4 @@
android:title="@string/share_file_label" />
</menu>
</item>
<item
android:id="@+id/support_item"
custom:showAsAction="collapseActionView"
android:title="@string/support_label"
android:visible="false">
</item>
</menu>

View File

@ -84,10 +84,4 @@
android:title="@string/share_file_label" />
</menu>
</item>
<item
android:id="@+id/support_item"
android:menuCategory="container"
android:title="@string/support_label" />
</menu>

View File

@ -1,21 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android">
<PreferenceScreen
android:key="pref_flattr_authenticate"
android:summary="@string/pref_flattr_auth_sum"
android:title="@string/pref_flattr_auth_title">
<intent android:action=".activities.FlattrAuthActivity"/>
</PreferenceScreen>
<Preference
android:key="prefAutoFlattrPrefs"
android:summary="@string/pref_auto_flattr_sum"
android:title="@string/pref_auto_flattr_title"/>
<Preference
android:key="prefRevokeAccess"
android:summary="@string/pref_revokeAccess_sum"
android:title="@string/pref_revokeAccess_title"/>
</PreferenceScreen>

View File

@ -1,12 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<Preference
android:key="prefFlattrSettings"
android:title="@string/flattr_label"
android:summary="@string/flattr_summary" />
xmlns:android="http://schemas.android.com/apk/res/android">
<Preference
android:key="prefGpodderSettings"

View File

@ -103,11 +103,6 @@ by greenrobot, licensed under the Apache 2.0 license <a href="LICENSE_APACHE-2.0
by Google, licensed under the Apache 2.0 license <a href="LICENSE_APACHE-2.0.txt">(View)</a>
</div>
<div class="card">
<h2>flattr4j <a href="http://www.shredzone.org/projects/flattr4j/wiki">(Link)</a></h2>
licensed under the Apache 2.0 license <a href="LICENSE_APACHE-2.0.txt">(View)</a>
</div>
<div class="card">
<h2>Glide <a href="https://github.com/bumptech/glide/">(Link)</a></h2>
licensed under the Simplified BSD license <a href="LICENSE_GLIDE.txt">(View)</a>

View File

@ -52,7 +52,6 @@ project.ext {
commonslangVersion = "3.6"
commonstextVersion = "1.3"
eventbusVersion = "3.1.1"
flattr4jVersion = "2.14"
glideVersion = "4.8.0"
glideOkhttpIntegrationVersion = "4.8.0"
iconifyVersion = "2.2.2"

View File

@ -54,9 +54,6 @@ dependencies {
implementation "org.apache.commons:commons-lang3:$commonslangVersion"
implementation "org.apache.commons:commons-text:$commonstextVersion"
implementation ("org.shredzone.flattr4j:flattr4j-core:$flattr4jVersion") {
exclude group: "org.json", module: "json"
}
implementation "commons-io:commons-io:$commonsioVersion"
implementation "com.jayway.android.robotium:robotium-solo:$robotiumSoloVersion"
implementation "org.jsoup:jsoup:$jsoupVersion"

View File

@ -27,8 +27,6 @@ public class ClientConfig {
public static GpodnetCallbacks gpodnetCallbacks;
public static FlattrCallbacks flattrCallbacks;
public static DBTasksCallbacks dbTasksCallbacks;
public static CastCallbacks castCallbacks;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -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);
}
@ -330,10 +321,6 @@ public class FeedItem extends FeedComponent implements ShownotesProvider, Flattr
this.contentEncoded = contentEncoded;
}
public FlattrStatus getFlattrStatus() {
return flattrStatus;
}
public String getPaymentLink() {
return paymentLink;
}

View File

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

View File

@ -94,8 +94,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
@ -317,10 +315,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");
}
@ -452,15 +446,6 @@ public class UserPreferences {
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);
}
public static String[] getAutodownloadSelectedNetworks() {
String selectedNetWorks = prefs.getString(PREF_AUTODL_SELECTED_NETWORKS, "");
return TextUtils.split(selectedNetWorks, ",");
@ -586,23 +571,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);
}

View File

@ -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.
@ -1003,36 +1002,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

View File

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

View File

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

View File

@ -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;
@ -46,9 +44,6 @@ import de.danoeh.antennapod.core.service.playback.PlaybackService;
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.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.
@ -829,44 +824,6 @@ public class DBWriter {
return -1;
}
/**
* 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
*
@ -892,77 +849,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 Comparator.
* @param comparator FeedItem comparator

View File

@ -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) {
@ -515,31 +506,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.
*/
@ -577,61 +543,6 @@ public class PodDBAdapter {
return result;
}
/**
* 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
*
@ -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());

View File

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

View File

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

View File

@ -1,7 +0,0 @@
package de.danoeh.antennapod.core.util.flattr;
public interface FlattrThing {
String getTitle();
String getPaymentLink();
FlattrStatus getFlattrStatus();
}

View File

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

View File

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

View File

@ -211,7 +211,6 @@
<string name="remove_from_favorite_label">Remove from Favorites</string>
<string name="removed_from_favorites">Removed from Favorites</string>
<string name="visit_website_label">Visit Website</string>
<string name="support_label">Flattr this</string>
<string name="skip_episode_label">Skip episode</string>
<string name="activate_auto_download">Activate Auto Download</string>
<string name="deactivate_auto_download">Deactivate Auto Download</string>
@ -305,34 +304,6 @@
<string name="sort_old_to_new">Old to new</string>
<string name="sort_new_to_old">New to old</string>
<!-- Flattr -->
<string name="flattr_auth_label">Flattr sign-in</string>
<string name="flattr_auth_explanation">Press the button below to start the authentication process. You will be forwarded to the flattr login screen in your browser and be asked to give AntennaPod the permission to flattr things. After you have given permission, you will return to this screen automatically.</string>
<string name="authenticate_label">Authenticate</string>
<string name="return_home_label">Return to home</string>
<string name="flattr_auth_success">Authentication was successful! You can now flattr things within the app.</string>
<string name="no_flattr_token_title">No Flattr token found</string>
<string name="no_flattr_token_notification_msg">Your flattr account does not seem to be connected to AntennaPod. Tap here to authenticate.</string>
<string name="no_flattr_token_msg">Your flattr account does not seem to be connected to AntennaPod. You can either connect your account to AntennaPod to flattr things within the app or you can visit the website of the thing to flattr it there.</string>
<string name="authenticate_now_label">Authenticate</string>
<string name="action_forbidden_title">Action forbidden</string>
<string name="action_forbidden_msg">AntennaPod has no permission for this action. The reason for this could be that the access token of AntennaPod to your account has been revoked. You can either re-reauthenticate or visit the website of the thing instead.</string>
<string name="access_revoked_title">Access revoked</string>
<string name="access_revoked_info">You have successfully revoked AntennaPod\'s access token to your account. In order to complete the process, you have to remove this app from the list of approved applications in your account settings on the flattr website.</string>
<!-- Flattr -->
<string name="flattr_click_success">Flattr\'ed one thing!</string>
<string name="flattr_click_success_count">Flattr\'ed %d things!</string>
<string name="flattr_click_success_queue">Flattr\'ed: %s.</string>
<string name="flattr_click_failure_count">Failed to flattr %d things!</string>
<string name="flattr_click_failure">Not flattr\'ed: %s.</string>
<string name="flattr_click_enqueued">Thing will be flattr\'ed later</string>
<string name="flattring_thing">Flattring %s</string>
<string name="flattring_label">AntennaPod is flattring</string>
<string name="flattrd_label">AntennaPod has flattr\'ed</string>
<string name="flattrd_failed_label">AntennaPod flattr failed</string>
<string name="flattr_retrieving_status">Retrieving flattr\'ed things</string>
<!-- Variable Speed -->
<string name="download_plugin_label">Download Plugin</string>
<string name="no_playback_plugin_title">Plugin Not Installed</string>
@ -368,8 +339,6 @@
<string name="about_pref">About</string>
<string name="queue_label">Queue</string>
<string name="integrations_label">Integrations</string>
<string name="flattr_label">Flattr</string>
<string name="flattr_summary">Micropayment service</string>
<string name="automation">Automation</string>
<string name="download_pref_details">Details</string>
<string name="import_export_pref">Import/Export</string>
@ -419,15 +388,6 @@
<string name="pref_mobileUpdate_images">Images only</string>
<string name="pref_mobileUpdate_everything">Everything</string>
<string name="refreshing_label">Refreshing</string>
<string name="flattr_settings_label">Flattr settings</string>
<string name="pref_flattr_auth_title">Flattr sign-in</string>
<string name="pref_flattr_auth_sum">Sign in to your flattr account to flattr things directly from the app.</string>
<string name="pref_flattr_this_app_title">Flattr this App</string>
<string name="pref_flattr_this_app_sum">Support the development of AntennaPod by flattring it. Thanks!</string>
<string name="pref_revokeAccess_title">Revoke access</string>
<string name="pref_revokeAccess_sum">Revoke the access permission to your flattr account for this app.</string>
<string name="pref_auto_flattr_title">Automatic Flattr</string>
<string name="pref_auto_flattr_sum">Configure automatic flattring</string>
<string name="user_interface_label">User Interface</string>
<string name="pref_set_theme_title">Select Theme</string>
<string name="pref_nav_drawer_title">Customize Navigation Drawer</string>
@ -539,12 +499,6 @@
<string name="pref_delete_removes_from_queue_title">Delete removes from Queue</string>
<string name="pref_delete_removes_from_queue_sum">Automatically remove an episode from the queue when it is deleted.</string>
<!-- Auto-Flattr dialog -->
<string name="auto_flattr_enable">Enable automatic flattring</string>
<string name="auto_flattr_after_percent">Flattr episode as soon as %d percent have been played</string>
<string name="auto_flattr_ater_beginning">Flattr episode when playback starts</string>
<string name="auto_flattr_ater_end">Flattr episode when playback ends</string>
<!-- Search -->
<string name="search_hint">Search for episodes</string>
<string name="found_in_shownotes_label">Found in show notes</string>

View File

@ -29,8 +29,6 @@ public class ClientConfig {
public static GpodnetCallbacks gpodnetCallbacks;
public static FlattrCallbacks flattrCallbacks;
public static DBTasksCallbacks dbTasksCallbacks;
public static CastCallbacks castCallbacks;