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>
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>
</html>

View File

@ -31,19 +31,8 @@
android:summary="@string/pref_mobileUpdate_sum"
android:title="@string/pref_mobileUpdate_title" />
</PreferenceCategory>
<PreferenceCategory android:title="@string/flattr_settings_label" >
<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">
<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">
</Preference>
</PreferenceCategory>
<PreferenceCategory android:title="@string/other_pref" >
<Preference android:title="@string/about_pref" android:key="prefAbout"/>
</PreferenceCategory>

View File

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

View File

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

View File

@ -1,7 +1,5 @@
package de.danoeh.antennapod.asynctask;
import org.shredzone.flattr4j.exception.FlattrException;
import android.annotation.SuppressLint;
import android.app.ProgressDialog;
import android.content.Context;
@ -13,6 +11,7 @@ import de.danoeh.antennapod.R;
import de.danoeh.antennapod.util.FlattrUtils;
/** Performs a click action in a background thread. */
/*
public class FlattrClickWorker extends AsyncTask<Void, Void, Void> {
protected static final String TAG = "FlattrClickWorker";
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;
import org.shredzone.flattr4j.exception.FlattrException;
import org.shredzone.flattr4j.oauth.AccessToken;
import org.shredzone.flattr4j.oauth.AndroidAuthenticator;
import android.annotation.SuppressLint;
import android.app.ProgressDialog;
@ -12,10 +9,10 @@ import android.os.AsyncTask;
import android.util.Log;
import de.danoeh.antennapod.AppConfig;
import de.danoeh.antennapod.R;
import de.danoeh.antennapod.activity.FlattrAuthActivity;
import de.danoeh.antennapod.util.FlattrUtils;
/** Fetches the access token in the background in order to avoid networkOnMainThread exception. */
/*
public class FlattrTokenFetcher extends AsyncTask<Void, Void, AccessToken> {
private static final String TAG = "FlattrTokenFetcher";
Context context;
@ -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 de.danoeh.antennapod.R;
import de.danoeh.antennapod.asynctask.FlattrClickWorker;
import de.danoeh.antennapod.feed.FeedItem;
import de.danoeh.antennapod.feed.FeedManager;
import de.danoeh.antennapod.storage.DownloadRequester;
@ -103,7 +102,8 @@ public class FeedItemMenuHandler {
context.startActivity(new Intent(Intent.ACTION_VIEW, uri));
break;
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;
case R.id.share_link_item:
ShareUtils.shareFeedItemLink(context, selectedItem);

View File

@ -11,7 +11,6 @@ import com.actionbarsherlock.view.MenuInflater;
import com.actionbarsherlock.view.MenuItem;
import de.danoeh.antennapod.activity.FeedInfoActivity;
import de.danoeh.antennapod.asynctask.FlattrClickWorker;
import de.danoeh.antennapod.feed.Feed;
import de.danoeh.antennapod.feed.FeedItem;
import de.danoeh.antennapod.feed.FeedManager;
@ -30,7 +29,8 @@ public class FeedMenuHandler {
}
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) {
menu.findItem(R.id.support_item).setVisible(true);
}
@ -42,9 +42,10 @@ public class FeedMenuHandler {
} else {
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;
}
@ -70,7 +71,8 @@ public class FeedMenuHandler {
context.startActivity(new Intent(Intent.ACTION_VIEW, uri));
break;
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;
case R.id.share_link_item:
ShareUtils.shareFeedlink(context, selectedFeed);

View File

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

View File

@ -2,14 +2,6 @@ package de.danoeh.antennapod.util;
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.Builder;
import android.app.ProgressDialog;
@ -25,11 +17,11 @@ import android.util.Log;
import android.widget.Toast;
import de.danoeh.antennapod.AppConfig;
import de.danoeh.antennapod.PodcastApp;
import de.danoeh.antennapod.activity.FlattrAuthActivity;
import de.danoeh.antennapod.asynctask.FlattrTokenFetcher;
import de.danoeh.antennapod.R;
/** Utility methods for doing something with flattr. */
public class 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";
/** Flattr URL for this app. */
// Flattr URL for this app.
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_THING_ID = "745609";
/*
private static volatile AccessToken cachedToken;
private static AndroidAuthenticator createAuthenticator() {
@ -58,10 +50,6 @@ public class FlattrUtils {
context.startActivity(intent);
}
/**
* Returns the access token from the preferences or null if no access token
* was saved before.
*/
private static AccessToken retrieveToken() {
if (cachedToken == null) {
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() {
return retrieveToken() != null;
}
/** Stores the token as a preference */
public static void storeToken(AccessToken token) {
if (AppConfig.DEBUG) Log.d(TAG, "Storing token");
SharedPreferences.Editor editor = PreferenceManager
@ -104,7 +90,6 @@ public class FlattrUtils {
storeToken(null);
}
/** Get the thing that represents this app */
public static Thing getAppThing(Context context) {
FlattrService fs = FlattrServiceCreator.getService(retrieveToken());
try {
@ -226,5 +211,7 @@ public class FlattrUtils {
});
builder.create().show();
}
*/
}
}