diff --git a/astrid/plugin-src/com/todoroo/astrid/actfm/ActFmPreferences.java b/astrid/plugin-src/com/todoroo/astrid/actfm/ActFmPreferences.java index 6437b5bb3..3eec741e2 100644 --- a/astrid/plugin-src/com/todoroo/astrid/actfm/ActFmPreferences.java +++ b/astrid/plugin-src/com/todoroo/astrid/actfm/ActFmPreferences.java @@ -5,20 +5,27 @@ */ package com.todoroo.astrid.actfm; +import android.content.ActivityNotFoundException; import android.content.DialogInterface; import android.content.Intent; import android.content.res.Resources; +import android.net.Uri; +import android.os.Bundle; import android.preference.Preference; +import android.preference.Preference.OnPreferenceClickListener; import android.preference.PreferenceCategory; +import android.widget.Toast; import com.timsu.astrid.R; import com.todoroo.andlib.service.Autowired; import com.todoroo.andlib.utility.DialogUtilities; import com.todoroo.astrid.actfm.sync.ActFmPreferenceService; import com.todoroo.astrid.actfm.sync.ActFmSyncV2Provider; +import com.todoroo.astrid.billing.BillingActivity; import com.todoroo.astrid.gtasks.GtasksPreferenceService; import com.todoroo.astrid.sync.SyncProviderPreferences; import com.todoroo.astrid.sync.SyncProviderUtilities; +import com.todoroo.astrid.utility.Constants; /** * Displays synchronization preferences and an action panel so users can @@ -57,6 +64,19 @@ public class ActFmPreferences extends SyncProviderPreferences { } } + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + findPreference(getString(R.string.actfm_inapp_billing)).setOnPreferenceClickListener(new OnPreferenceClickListener() { + @Override + public boolean onPreferenceClick(Preference preference) { + handleInAppBillingClicked(); + return true; + } + }); + } + private void startLogin() { Intent intent = new Intent(this, ActFmLoginActivity.class); startActivityForResult(intent, REQUEST_LOGIN); @@ -95,9 +115,26 @@ public class ActFmPreferences extends SyncProviderPreferences { preference.setSummary(R.string.actfm_https_enabled); else preference.setSummary(R.string.actfm_https_disabled); + } else if (r.getString(R.string.actfm_inapp_billing).equals(preference.getKey())) { + // } else { super.updatePreferences(preference, value); } } + private void handleInAppBillingClicked() { + if (ActFmPreferenceService.isPremiumUser()) { + Intent intent = new Intent(Intent.ACTION_VIEW); + intent.setData(Uri.parse("market://details?id=" + Constants.PACKAGE)); //$NON-NLS-1$ + try { + startActivity(intent); + } catch (ActivityNotFoundException e) { + Toast.makeText(this, R.string.market_unavailable, Toast.LENGTH_LONG).show(); + } + } else { + Intent intent = new Intent(this, BillingActivity.class); + startActivity(intent); + } + } + } diff --git a/astrid/plugin-src/com/todoroo/astrid/files/FilesControlSet.java b/astrid/plugin-src/com/todoroo/astrid/files/FilesControlSet.java index 401bfe69c..a97490893 100644 --- a/astrid/plugin-src/com/todoroo/astrid/files/FilesControlSet.java +++ b/astrid/plugin-src/com/todoroo/astrid/files/FilesControlSet.java @@ -303,7 +303,7 @@ public class FilesControlSet extends PopupControlSet { activity.startActivity(marketIntent); } catch (ActivityNotFoundException anf) { DialogUtilities.okDialog(activity, - activity.getString(R.string.EPr_marketUnavailable_dlg), + activity.getString(R.string.market_unavailable), null); } } diff --git a/astrid/res/values/strings-actfm.xml b/astrid/res/values/strings-actfm.xml index b7e3bfce7..3eb9a0052 100644 --- a/astrid/res/values/strings-actfm.xml +++ b/astrid/res/values/strings-actfm.xml @@ -312,5 +312,7 @@ Basic None + In App Billing + diff --git a/astrid/res/values/strings-core.xml b/astrid/res/values/strings-core.xml index 5affa1ab9..317848ff4 100644 --- a/astrid/res/values/strings-core.xml +++ b/astrid/res/values/strings-core.xml @@ -846,5 +846,7 @@ you get stuff done. It features reminders, tags, sync, Locale plug-in, a widget If you see this error regularly, we suggest you clear all data (Settings->Manage All Tasks->Clear all data) and restore your tasks from a backup (Settings->Backup->Import Tasks) in Astrid. + + Unfortunately the market is not available for your system. diff --git a/astrid/res/xml/preferences_actfm.xml b/astrid/res/xml/preferences_actfm.xml index ecd5f0680..4316e8b5a 100644 --- a/astrid/res/xml/preferences_actfm.xml +++ b/astrid/res/xml/preferences_actfm.xml @@ -23,7 +23,11 @@ android:gravity="center"/> - + + + diff --git a/astrid/src/com/todoroo/astrid/billing/BillingActivity.java b/astrid/src/com/todoroo/astrid/billing/BillingActivity.java index 41444bdd9..7b94c5f90 100644 --- a/astrid/src/com/todoroo/astrid/billing/BillingActivity.java +++ b/astrid/src/com/todoroo/astrid/billing/BillingActivity.java @@ -20,7 +20,6 @@ import com.todoroo.andlib.service.Autowired; import com.todoroo.andlib.service.DependencyInjectionService; import com.todoroo.andlib.utility.DialogUtilities; import com.todoroo.andlib.utility.Preferences; -import com.todoroo.astrid.actfm.ActFmLoginActivity; import com.todoroo.astrid.actfm.sync.ActFmPreferenceService; import com.todoroo.astrid.utility.Constants; @@ -77,19 +76,13 @@ public class BillingActivity extends Activity { super.onResume(); 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) { - Intent login = new Intent(BillingActivity.this, ActFmLoginActivity.class); - startActivity(login); - } - }, - new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int which) { - finish(); - } - }); + DialogUtilities.okDialog(this, getString(R.string.premium_login_prompt), + 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()) {