diff --git a/astrid/plugin-src/com/todoroo/astrid/actfm/ActFmPreferences.java b/astrid/plugin-src/com/todoroo/astrid/actfm/ActFmPreferences.java index 46d325a4e..54bf6da23 100644 --- a/astrid/plugin-src/com/todoroo/astrid/actfm/ActFmPreferences.java +++ b/astrid/plugin-src/com/todoroo/astrid/actfm/ActFmPreferences.java @@ -27,6 +27,7 @@ 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.service.PremiumUnlockService; import com.todoroo.astrid.service.StatisticsConstants; import com.todoroo.astrid.service.StatisticsService; import com.todoroo.astrid.sync.SyncProviderPreferences; @@ -76,7 +77,7 @@ public class ActFmPreferences extends SyncProviderPreferences { PreferenceScreen screen = getPreferenceScreen(); Preference inAppBilling = findPreference(getString(R.string.actfm_inapp_billing)); - if (Constants.ASTRID_LITE) + if (Constants.ASTRID_LITE || Preferences.getBoolean(PremiumUnlockService.PREF_KILL_SWITCH, false)) screen.removePreference(inAppBilling); else inAppBilling.setOnPreferenceClickListener(new OnPreferenceClickListener() { diff --git a/astrid/plugin-src/com/todoroo/astrid/actfm/sync/ActFmPreferenceService.java b/astrid/plugin-src/com/todoroo/astrid/actfm/sync/ActFmPreferenceService.java index 10da26b16..6772b08af 100644 --- a/astrid/plugin-src/com/todoroo/astrid/actfm/sync/ActFmPreferenceService.java +++ b/astrid/plugin-src/com/todoroo/astrid/actfm/sync/ActFmPreferenceService.java @@ -15,6 +15,7 @@ import com.todoroo.andlib.utility.Preferences; import com.todoroo.astrid.billing.BillingConstants; import com.todoroo.astrid.dao.RemoteModelDao; import com.todoroo.astrid.data.RemoteModel; +import com.todoroo.astrid.service.PremiumUnlockService; import com.todoroo.astrid.service.StatisticsConstants; import com.todoroo.astrid.service.StatisticsService; import com.todoroo.astrid.sync.SyncProviderUtilities; @@ -150,6 +151,9 @@ public class ActFmPreferenceService extends SyncProviderUtilities { } public static boolean isPremiumUser() { + if (Preferences.getBoolean(PremiumUnlockService.PREF_KILL_SWITCH, false)) + return true; + if (Preferences.getBoolean(BillingConstants.PREF_NEEDS_SERVER_UPDATE, false)) { return Preferences.getBoolean(PREF_LOCAL_PREMIUM, false); } diff --git a/astrid/src/com/todoroo/astrid/service/PremiumUnlockService.java b/astrid/src/com/todoroo/astrid/service/PremiumUnlockService.java new file mode 100644 index 000000000..4d6e5645f --- /dev/null +++ b/astrid/src/com/todoroo/astrid/service/PremiumUnlockService.java @@ -0,0 +1,34 @@ +package com.todoroo.astrid.service; + +import com.todoroo.andlib.service.Autowired; +import com.todoroo.andlib.service.DependencyInjectionService; +import com.todoroo.andlib.service.RestClient; +import com.todoroo.andlib.utility.Preferences; + +public class PremiumUnlockService { + + public static final String PREF_KILL_SWITCH = "p_premium_kill_switch"; //$NON-NLS-1$ + + private static final String PREM_SWITCH_URL = "http://astrid.com/home/premium_check"; //$NON-NLS-1$ + + @Autowired + private RestClient restClient; + + public PremiumUnlockService() { + DependencyInjectionService.getInstance().inject(this); + } + + public void checkForPremium() { + if (Preferences.getBoolean(PREF_KILL_SWITCH, false)) + return; + + try { + String response = restClient.get(PREM_SWITCH_URL).trim(); + if ("OFF".equals(response)) //$NON-NLS-1$ + Preferences.setBoolean(PREF_KILL_SWITCH, true); + } catch (Exception e) { + e.printStackTrace(); + } + } + +} diff --git a/astrid/src/com/todoroo/astrid/service/StartupService.java b/astrid/src/com/todoroo/astrid/service/StartupService.java index 27180c5eb..13ab318a9 100644 --- a/astrid/src/com/todoroo/astrid/service/StartupService.java +++ b/astrid/src/com/todoroo/astrid/service/StartupService.java @@ -256,6 +256,8 @@ public class StartupService { if (finalLatestVersion != 0) new UpdateMessageService(context).processUpdates(); + new PremiumUnlockService().checkForPremium(); + checkForSubtasksUse(); checkForSwipeListsUse(); checkForVoiceRemindersUse();