Implemented revoke process

This commit is contained in:
daniel oeh 2012-07-12 21:01:00 +02:00
parent 62724acef8
commit bf1d4cb248
3 changed files with 37 additions and 1 deletions

View File

@ -118,5 +118,7 @@
<string name="pref_flattr_this_app_sum">Support the development of Antennacast 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="access_revoked_title">Access revoked</string>
<string name="access_revoked_info">You have successfully revoked deleted 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>
</resources>

View File

@ -30,10 +30,20 @@ public class PreferenceActivity extends SherlockPreferenceActivity {
@Override
public boolean onPreferenceClick(Preference preference) {
Log.d(TAG, "Flattring this app");
Log.d(TAG, "Flattring this app"); // TODO implement
return true;
}
});
findPreference(PREF_FLATTR_REVOKE).setOnPreferenceClickListener(new OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
FlattrUtils.revokeAccessToken(PreferenceActivity.this);
checkItemVisibility();
return true;
}
});
}
@Override

View File

@ -10,6 +10,7 @@ import org.shredzone.flattr4j.oauth.AndroidAuthenticator;
import org.shredzone.flattr4j.oauth.Scope;
import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
import android.content.Context;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
@ -116,6 +117,29 @@ public class FlattrUtils {
}
}
public static void revokeAccessToken(Context context) {
Log.d(TAG, "Revoking access token");
deleteToken();
showRevokeDialog(context);
}
//------------------------------------------------ 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, new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.cancel();
}
});
builder.create().show();
}
private static void showNoTokenDialog(final Context context,
final String url) {
Log.d(TAG, "Creating showNoTokenDialog");