From e9d1f1391e177cd018a47f4e0532f8c975b400be Mon Sep 17 00:00:00 2001 From: Sam Bosley Date: Mon, 16 Jul 2012 15:07:34 -0700 Subject: [PATCH] Prompt for login at in app billing page, direct users to astrid.com if billing not supported --- astrid/res/values/strings-premium.xml | 2 +- .../astrid/billing/BillingActivity.java | 20 ++++++++++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/astrid/res/values/strings-premium.xml b/astrid/res/values/strings-premium.xml index 426ca0234..34f4a6b05 100644 --- a/astrid/res/values/strings-premium.xml +++ b/astrid/res/values/strings-premium.xml @@ -52,7 +52,7 @@ won\'t be able to make purchases. Can\'t purchase subscriptions The Market billing - service on this device does not support subscriptions at this time. + service on this device does not support subscriptions at this time. You can subscribe to Astrid Premium at http://astrid.com/premium. Can\'t connect to Market This app cannot connect to Market. Your version of Market may be out of date. diff --git a/astrid/src/com/todoroo/astrid/billing/BillingActivity.java b/astrid/src/com/todoroo/astrid/billing/BillingActivity.java index 6e03f35d2..3e3fab906 100644 --- a/astrid/src/com/todoroo/astrid/billing/BillingActivity.java +++ b/astrid/src/com/todoroo/astrid/billing/BillingActivity.java @@ -44,6 +44,8 @@ public class BillingActivity extends Activity { private Button buyYear; @Autowired private ActFmSyncService actFmSyncService; + @Autowired private ActFmPreferenceService actFmPreferenceService; + @Override protected void onCreate(Bundle savedInstanceState) { @@ -60,7 +62,23 @@ public class BillingActivity extends Activity { ResponseHandler.register(purchaseObserver); - if (!billingService.checkBillingSupported(BillingConstants.ITEM_TYPE_SUBSCRIPTION)) { + // Enforce logged in here? If so, barrier to subscribing, if not, has the possibility of double subscribing. + if (!actFmPreferenceService.isLoggedIn()) { + // Prompt to log in + DialogUtilities.okCancelDialog(this, getString(R.string.premium_login_prompt), new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + // Set result, finish, use callback to prompt for login + } + }, + new DialogInterface.OnClickListener() { + + @Override + public void onClick(DialogInterface dialog, int which) { + finish(); + } + }); + } else if (!billingService.checkBillingSupported(BillingConstants.ITEM_TYPE_SUBSCRIPTION)) { showDialog(DIALOG_SUBSCRIPTIONS_NOT_SUPPORTED_ID); } else if (ActFmPreferenceService.isPremiumUser()) { DialogUtilities.okDialog(this, getString(R.string.premium_already_subscribed), new DialogInterface.OnClickListener() {