Implemented flattr into menus, finished authActivity

This commit is contained in:
daniel oeh 2012-07-12 15:04:02 +02:00
parent e5f0e81cf9
commit 85ee1272bf
3 changed files with 35 additions and 4 deletions

View File

@ -1,6 +1,9 @@
package de.podfetcher.activity;
import org.shredzone.flattr4j.exception.FlattrException;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
@ -13,6 +16,7 @@ import com.actionbarsherlock.view.Menu;
import com.actionbarsherlock.view.MenuItem;
import de.podfetcher.R;
import de.podfetcher.util.FlattrUtils;
/** Guides the user through the authentication process */
public class FlattrAuthActivity extends SherlockActivity {
@ -39,12 +43,41 @@ public class FlattrAuthActivity extends SherlockActivity {
PodfetcherActivity.class));
}
});
butAuthenticate.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
try {
FlattrUtils.startAuthProcess(FlattrAuthActivity.this);
} catch (FlattrException e) {
e.printStackTrace();
}
}
});
}
@Override
protected void onResume() {
super.onResume();
Log.d(TAG, "Activity resumed");
Uri uri = getIntent().getData();
if (uri != null) {
Log.d(TAG, "Received uri");
try {
if (FlattrUtils.handleCallback(uri) != null) {
handleAuthenticationSuccess();
Log.d(TAG, "Authentication seemed to be successful");
}
} catch (FlattrException e) {
e.printStackTrace();
}
}
}
private void handleAuthenticationSuccess() {
txtvExplanation.setText(R.string.flattr_auth_success);
butAuthenticate.setEnabled(false);
butReturn.setVisibility(View.VISIBLE);
}
@Override

View File

@ -99,8 +99,7 @@ public class FeedItemMenuHandler {
context.startActivity(new Intent(Intent.ACTION_VIEW, uri));
break;
case R.id.support_item:
Uri supportUri = Uri.parse(selectedItem.getPaymentLink());
context.startActivity(new Intent(Intent.ACTION_VIEW, supportUri));
FlattrUtils.clickUrl(context, selectedItem.getPaymentLink());
break;
case R.id.share_link_item:
ShareUtils.shareFeedItemLink(context, selectedItem);

View File

@ -68,8 +68,7 @@ public class FeedMenuHandler {
context.startActivity(new Intent(Intent.ACTION_VIEW, uri));
break;
case R.id.support_item:
Uri supportUri = Uri.parse(selectedFeed.getPaymentLink());
context.startActivity(new Intent(Intent.ACTION_VIEW, supportUri));
FlattrUtils.clickUrl(context, selectedFeed.getPaymentLink());
break;
case R.id.share_link_item:
ShareUtils.shareFeedlink(context, selectedFeed);