Removed flattr integration (not working)

This commit is contained in:
daniel oeh 2012-07-22 17:05:43 +02:00
parent e5b37b463c
commit d061f86266
10 changed files with 54 additions and 76 deletions

View File

@ -52,7 +52,5 @@
<h2>Apache Commons <a href="http://commons.apache.org/">(Link)</a></h2> <h2>Apache Commons <a href="http://commons.apache.org/">(Link)</a></h2>
by The Apache Software Foundation, licensed under the Apache 2.0 license by The Apache Software Foundation, licensed under the Apache 2.0 license
<h2>flattr4j <a href="http://www.shredzone.org/projects/flattr4j/wiki">(Link)</a></h2>
licensed under the Apache 2.0 license
</body> </body>
</html> </html>

View File

@ -31,19 +31,8 @@
android:summary="@string/pref_mobileUpdate_sum" android:summary="@string/pref_mobileUpdate_sum"
android:title="@string/pref_mobileUpdate_title" /> android:title="@string/pref_mobileUpdate_title" />
</PreferenceCategory> </PreferenceCategory>
<PreferenceCategory android:title="@string/flattr_settings_label" > <PreferenceCategory android:title="@string/other_pref" ><Preference android:summary="@string/pref_flattr_this_app_sum" android:title="@string/pref_flattr_this_app_title" android:key="prefFlattrThisApp">
<PreferenceScreen
android:summary="@string/pref_flattr_auth_sum"
android:title="@string/pref_flattr_auth_title" android:key="pref_flattr_authenticate">
<intent android:action=".activities.FlattrAuthActivity" />
</PreferenceScreen><Preference android:key="prefRevokeAccess" android:title="@string/pref_revokeAccess_title" android:summary="@string/pref_revokeAccess_sum"/>
<Preference
android:summary="@string/pref_flattr_this_app_sum"
android:title="@string/pref_flattr_this_app_title" android:key="prefFlattrThisApp">
</Preference> </Preference>
</PreferenceCategory>
<PreferenceCategory android:title="@string/other_pref" >
<Preference android:title="@string/about_pref" android:key="prefAbout"/> <Preference android:title="@string/about_pref" android:key="prefAbout"/>
</PreferenceCategory> </PreferenceCategory>

View File

@ -1,6 +1,5 @@
package de.danoeh.antennapod.activity; package de.danoeh.antennapod.activity;
import org.shredzone.flattr4j.exception.FlattrException;
import android.content.Intent; import android.content.Intent;
import android.net.Uri; import android.net.Uri;
@ -20,6 +19,7 @@ import de.danoeh.antennapod.AppConfig;
import de.danoeh.antennapod.R; import de.danoeh.antennapod.R;
/** Guides the user through the authentication process */ /** Guides the user through the authentication process */
/*
public class FlattrAuthActivity extends SherlockActivity { public class FlattrAuthActivity extends SherlockActivity {
private static final String TAG = "FlattrAuthActivity"; private static final String TAG = "FlattrAuthActivity";
@ -114,5 +114,6 @@ public class FlattrAuthActivity extends SherlockActivity {
} }
return true; return true;
} }
} }*/

View File

@ -1,20 +1,17 @@
package de.danoeh.antennapod.activity; package de.danoeh.antennapod.activity;
import org.shredzone.flattr4j.model.Thing;
import android.content.Intent; import android.content.Intent;
import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
import android.preference.Preference; import android.preference.Preference;
import android.preference.Preference.OnPreferenceClickListener; import android.preference.Preference.OnPreferenceClickListener;
import android.util.Log;
import com.actionbarsherlock.app.SherlockPreferenceActivity; import com.actionbarsherlock.app.SherlockPreferenceActivity;
import com.actionbarsherlock.view.Menu; import com.actionbarsherlock.view.Menu;
import com.actionbarsherlock.view.MenuItem; import com.actionbarsherlock.view.MenuItem;
import de.danoeh.antennapod.asynctask.FlattrClickWorker;
import de.danoeh.antennapod.util.FlattrUtils;
import de.danoeh.antennapod.R; import de.danoeh.antennapod.R;
import de.danoeh.antennapod.util.FlattrUtils;
public class PreferenceActivity extends SherlockPreferenceActivity { public class PreferenceActivity extends SherlockPreferenceActivity {
private static final String TAG = "PreferenceActivity"; private static final String TAG = "PreferenceActivity";
@ -35,24 +32,24 @@ public class PreferenceActivity extends SherlockPreferenceActivity {
@Override @Override
public boolean onPreferenceClick(Preference preference) { public boolean onPreferenceClick(Preference preference) {
new FlattrClickWorker(PreferenceActivity.this, Uri supportUri = Uri.parse(FlattrUtils.APP_LINK);
FlattrUtils.APP_URL).execute(); startActivity(new Intent(Intent.ACTION_VIEW, supportUri));
return true; return true;
} }
}); });
findPreference(PREF_FLATTR_REVOKE).setOnPreferenceClickListener(
new OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
FlattrUtils.revokeAccessToken(PreferenceActivity.this);
checkItemVisibility();
return true;
}
});
/*
* Disabled until it works
* findPreference(PREF_FLATTR_REVOKE).setOnPreferenceClickListener( new
* OnPreferenceClickListener() {
*
* @Override public boolean onPreferenceClick(Preference preference) {
* FlattrUtils.revokeAccessToken(PreferenceActivity.this);
* checkItemVisibility(); return true; }
*
* });
*/
findPreference(PREF_ABOUT).setOnPreferenceClickListener( findPreference(PREF_ABOUT).setOnPreferenceClickListener(
new OnPreferenceClickListener() { new OnPreferenceClickListener() {
@ -64,6 +61,7 @@ public class PreferenceActivity extends SherlockPreferenceActivity {
} }
}); });
} }
@Override @Override
@ -74,10 +72,12 @@ public class PreferenceActivity extends SherlockPreferenceActivity {
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
private void checkItemVisibility() { private void checkItemVisibility() {
boolean hasFlattrToken = FlattrUtils.hasToken(); /*
findPreference(PREF_FLATTR_AUTH).setEnabled(!hasFlattrToken); * boolean hasFlattrToken = FlattrUtils.hasToken();
findPreference(PREF_FLATTR_REVOKE).setEnabled(hasFlattrToken); *
* findPreference(PREF_FLATTR_AUTH).setEnabled(!hasFlattrToken);
* findPreference(PREF_FLATTR_REVOKE).setEnabled(hasFlattrToken);
*/
} }
@Override @Override

View File

@ -1,7 +1,5 @@
package de.danoeh.antennapod.asynctask; package de.danoeh.antennapod.asynctask;
import org.shredzone.flattr4j.exception.FlattrException;
import android.annotation.SuppressLint; import android.annotation.SuppressLint;
import android.app.ProgressDialog; import android.app.ProgressDialog;
import android.content.Context; import android.content.Context;
@ -13,6 +11,7 @@ import de.danoeh.antennapod.R;
import de.danoeh.antennapod.util.FlattrUtils; import de.danoeh.antennapod.util.FlattrUtils;
/** Performs a click action in a background thread. */ /** Performs a click action in a background thread. */
/*
public class FlattrClickWorker extends AsyncTask<Void, Void, Void> { public class FlattrClickWorker extends AsyncTask<Void, Void, Void> {
protected static final String TAG = "FlattrClickWorker"; protected static final String TAG = "FlattrClickWorker";
protected Context context; protected Context context;
@ -111,4 +110,4 @@ public class FlattrClickWorker extends AsyncTask<Void, Void, Void> {
} }
} }
} }*/

View File

@ -1,8 +1,5 @@
package de.danoeh.antennapod.asynctask; package de.danoeh.antennapod.asynctask;
import org.shredzone.flattr4j.exception.FlattrException;
import org.shredzone.flattr4j.oauth.AccessToken;
import org.shredzone.flattr4j.oauth.AndroidAuthenticator;
import android.annotation.SuppressLint; import android.annotation.SuppressLint;
import android.app.ProgressDialog; import android.app.ProgressDialog;
@ -12,10 +9,10 @@ import android.os.AsyncTask;
import android.util.Log; import android.util.Log;
import de.danoeh.antennapod.AppConfig; import de.danoeh.antennapod.AppConfig;
import de.danoeh.antennapod.R; import de.danoeh.antennapod.R;
import de.danoeh.antennapod.activity.FlattrAuthActivity;
import de.danoeh.antennapod.util.FlattrUtils; import de.danoeh.antennapod.util.FlattrUtils;
/** Fetches the access token in the background in order to avoid networkOnMainThread exception. */ /** Fetches the access token in the background in order to avoid networkOnMainThread exception. */
/*
public class FlattrTokenFetcher extends AsyncTask<Void, Void, AccessToken> { public class FlattrTokenFetcher extends AsyncTask<Void, Void, AccessToken> {
private static final String TAG = "FlattrTokenFetcher"; private static final String TAG = "FlattrTokenFetcher";
Context context; Context context;
@ -91,4 +88,5 @@ public class FlattrTokenFetcher extends AsyncTask<Void, Void, AccessToken> {
} }
} }
} }
*/

View File

@ -9,7 +9,6 @@ import com.actionbarsherlock.view.MenuInflater;
import com.actionbarsherlock.view.MenuItem; import com.actionbarsherlock.view.MenuItem;
import de.danoeh.antennapod.R; import de.danoeh.antennapod.R;
import de.danoeh.antennapod.asynctask.FlattrClickWorker;
import de.danoeh.antennapod.feed.FeedItem; import de.danoeh.antennapod.feed.FeedItem;
import de.danoeh.antennapod.feed.FeedManager; import de.danoeh.antennapod.feed.FeedManager;
import de.danoeh.antennapod.storage.DownloadRequester; import de.danoeh.antennapod.storage.DownloadRequester;
@ -103,7 +102,8 @@ public class FeedItemMenuHandler {
context.startActivity(new Intent(Intent.ACTION_VIEW, uri)); context.startActivity(new Intent(Intent.ACTION_VIEW, uri));
break; break;
case R.id.support_item: case R.id.support_item:
new FlattrClickWorker(context, selectedItem.getPaymentLink()).executeAsync(); Uri supportUri = Uri.parse(selectedItem.getPaymentLink());
context.startActivity(new Intent(Intent.ACTION_VIEW, supportUri));
break; break;
case R.id.share_link_item: case R.id.share_link_item:
ShareUtils.shareFeedItemLink(context, selectedItem); ShareUtils.shareFeedItemLink(context, selectedItem);

View File

@ -11,7 +11,6 @@ import com.actionbarsherlock.view.MenuInflater;
import com.actionbarsherlock.view.MenuItem; import com.actionbarsherlock.view.MenuItem;
import de.danoeh.antennapod.activity.FeedInfoActivity; import de.danoeh.antennapod.activity.FeedInfoActivity;
import de.danoeh.antennapod.asynctask.FlattrClickWorker;
import de.danoeh.antennapod.feed.Feed; import de.danoeh.antennapod.feed.Feed;
import de.danoeh.antennapod.feed.FeedItem; import de.danoeh.antennapod.feed.FeedItem;
import de.danoeh.antennapod.feed.FeedManager; import de.danoeh.antennapod.feed.FeedManager;
@ -30,7 +29,8 @@ public class FeedMenuHandler {
} }
public static boolean onPrepareOptionsMenu(Menu menu, Feed selectedFeed) { public static boolean onPrepareOptionsMenu(Menu menu, Feed selectedFeed) {
if (AppConfig.DEBUG) Log.d(TAG, "Preparing options menu"); if (AppConfig.DEBUG)
Log.d(TAG, "Preparing options menu");
if (selectedFeed.getPaymentLink() != null) { if (selectedFeed.getPaymentLink() != null) {
menu.findItem(R.id.support_item).setVisible(true); menu.findItem(R.id.support_item).setVisible(true);
} }
@ -42,9 +42,10 @@ public class FeedMenuHandler {
} else { } else {
refresh.setVisible(true); refresh.setVisible(true);
} }
menu.findItem(R.id.share_link_item).setVisible(selectedFeed.getLink() != null); menu.findItem(R.id.share_link_item).setVisible(
selectedFeed.getLink() != null);
return true; return true;
} }
@ -70,7 +71,8 @@ public class FeedMenuHandler {
context.startActivity(new Intent(Intent.ACTION_VIEW, uri)); context.startActivity(new Intent(Intent.ACTION_VIEW, uri));
break; break;
case R.id.support_item: case R.id.support_item:
new FlattrClickWorker(context, selectedFeed.getPaymentLink()).executeAsync(); Uri supportUri = Uri.parse(selectedFeed.getPaymentLink());
context.startActivity(new Intent(Intent.ACTION_VIEW, supportUri));
break; break;
case R.id.share_link_item: case R.id.share_link_item:
ShareUtils.shareFeedlink(context, selectedFeed); ShareUtils.shareFeedlink(context, selectedFeed);

View File

@ -1,3 +1,4 @@
/*
package de.danoeh.antennapod.util; package de.danoeh.antennapod.util;
import org.shredzone.flattr4j.FlattrFactory; import org.shredzone.flattr4j.FlattrFactory;
@ -7,8 +8,9 @@ import org.shredzone.flattr4j.oauth.AccessToken;
import de.danoeh.antennapod.AppConfig; import de.danoeh.antennapod.AppConfig;
import android.util.Log; import android.util.Log;
*/
/** Ensures that only one instance of the FlattrService class exists at a time */ /** Ensures that only one instance of the FlattrService class exists at a time */
/*
public class FlattrServiceCreator { public class FlattrServiceCreator {
public static final String TAG = "FlattrServiceCreator"; public static final String TAG = "FlattrServiceCreator";
@ -23,3 +25,5 @@ public class FlattrServiceCreator {
flattrService = null; flattrService = null;
} }
} }
*/

View File

@ -2,14 +2,6 @@ package de.danoeh.antennapod.util;
import java.util.EnumSet; import java.util.EnumSet;
import org.shredzone.flattr4j.FlattrFactory;
import org.shredzone.flattr4j.FlattrService;
import org.shredzone.flattr4j.exception.FlattrException;
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 android.app.AlertDialog; import android.app.AlertDialog;
import android.app.AlertDialog.Builder; import android.app.AlertDialog.Builder;
import android.app.ProgressDialog; import android.app.ProgressDialog;
@ -25,11 +17,11 @@ import android.util.Log;
import android.widget.Toast; import android.widget.Toast;
import de.danoeh.antennapod.AppConfig; import de.danoeh.antennapod.AppConfig;
import de.danoeh.antennapod.PodcastApp; import de.danoeh.antennapod.PodcastApp;
import de.danoeh.antennapod.activity.FlattrAuthActivity;
import de.danoeh.antennapod.asynctask.FlattrTokenFetcher;
import de.danoeh.antennapod.R; import de.danoeh.antennapod.R;
/** Utility methods for doing something with flattr. */ /** Utility methods for doing something with flattr. */
public class FlattrUtils { public class FlattrUtils {
private static final String TAG = "FlattrUtils"; private static final String TAG = "FlattrUtils";
@ -39,12 +31,12 @@ public class FlattrUtils {
private static final String PREF_ACCESS_TOKEN = "de.danoeh.antennapod.preference.flattrAccessToken"; private static final String PREF_ACCESS_TOKEN = "de.danoeh.antennapod.preference.flattrAccessToken";
/** Flattr URL for this app. */ // Flattr URL for this app.
public static final String APP_URL = "http://antennapod.com"; public static final String APP_URL = "http://antennapod.com";
/** Human-readable flattr-page. */ // Human-readable flattr-page.
public static final String APP_LINK = "https://flattr.com/thing/745609/"; public static final String APP_LINK = "https://flattr.com/thing/745609/";
public static final String APP_THING_ID = "745609"; public static final String APP_THING_ID = "745609";
/*
private static volatile AccessToken cachedToken; private static volatile AccessToken cachedToken;
private static AndroidAuthenticator createAuthenticator() { private static AndroidAuthenticator createAuthenticator() {
@ -58,10 +50,6 @@ public class FlattrUtils {
context.startActivity(intent); context.startActivity(intent);
} }
/**
* Returns the access token from the preferences or null if no access token
* was saved before.
*/
private static AccessToken retrieveToken() { private static AccessToken retrieveToken() {
if (cachedToken == null) { if (cachedToken == null) {
if (AppConfig.DEBUG) Log.d(TAG, "Retrieving access token"); if (AppConfig.DEBUG) Log.d(TAG, "Retrieving access token");
@ -80,12 +68,10 @@ public class FlattrUtils {
} }
/** Returns true if the application has saved an access token */
public static boolean hasToken() { public static boolean hasToken() {
return retrieveToken() != null; return retrieveToken() != null;
} }
/** Stores the token as a preference */
public static void storeToken(AccessToken token) { public static void storeToken(AccessToken token) {
if (AppConfig.DEBUG) Log.d(TAG, "Storing token"); if (AppConfig.DEBUG) Log.d(TAG, "Storing token");
SharedPreferences.Editor editor = PreferenceManager SharedPreferences.Editor editor = PreferenceManager
@ -104,7 +90,6 @@ public class FlattrUtils {
storeToken(null); storeToken(null);
} }
/** Get the thing that represents this app */
public static Thing getAppThing(Context context) { public static Thing getAppThing(Context context) {
FlattrService fs = FlattrServiceCreator.getService(retrieveToken()); FlattrService fs = FlattrServiceCreator.getService(retrieveToken());
try { try {
@ -226,5 +211,7 @@ public class FlattrUtils {
}); });
builder.create().show(); builder.create().show();
} }
*/
}
}