diff --git a/astrid/plugin-src/com/todoroo/astrid/core/LabsPreferences.java b/astrid/plugin-src/com/todoroo/astrid/core/LabsPreferences.java index 558d3ea6b..0ef3aec3c 100644 --- a/astrid/plugin-src/com/todoroo/astrid/core/LabsPreferences.java +++ b/astrid/plugin-src/com/todoroo/astrid/core/LabsPreferences.java @@ -46,23 +46,25 @@ public class LabsPreferences extends TodorooPreferenceActivity { preference.setSummary(r.getString(R.string.EPr_swipe_lists_display, name, desc)); } else if (r.getString(R.string.p_show_friends_view).equals(key)) { preference.setOnPreferenceChangeListener(settingChangedListener); - if (value != null && (Boolean) value) { - preference.setSummary(R.string.EPr_show_friends_view_desc_enabled); - } else { - preference.setSummary(R.string.EPr_show_friends_view_desc_disabled); - } + setEnabledSummary(preference, value, + R.string.EPr_show_friends_view_desc_enabled, R.string.EPr_show_friends_view_desc_disabled); } else if (r.getString(R.string.p_field_missed_calls).equals(key)) { - if (value != null && (Boolean) value) { - preference.setSummary(R.string.MCA_missed_calls_pref_desc_enabled); - } else { - preference.setSummary(R.string.MCA_missed_calls_pref_desc_disabled); - } + setEnabledSummary(preference, value, + R.string.MCA_missed_calls_pref_desc_enabled, R.string.MCA_missed_calls_pref_desc_disabled); } else if (r.getString(R.string.p_use_contact_picker).equals(key)) { - if (value != null && (Boolean) value) { - preference.setSummary(R.string.EPr_use_contact_picker_desc_enabled); - } else { - preference.setSummary(R.string.EPr_use_contact_picker_desc_disabled); - } + setEnabledSummary(preference, value, + R.string.EPr_use_contact_picker_desc_enabled, R.string.EPr_use_contact_picker_desc_disabled); + } else if (r.getString(R.string.p_third_party_addons).equals(key)) { + setEnabledSummary(preference, value, + R.string.EPr_third_party_addons_desc_enabled, R.string.EPr_third_party_addons_desc_disabled); + } + } + + private void setEnabledSummary(Preference preference, Object value, int enabledStr, int disabledStr) { + if (value != null && (Boolean) value) { + preference.setSummary(enabledStr); + } else { + preference.setSummary(disabledStr); } } diff --git a/astrid/plugin-src/com/todoroo/astrid/producteev/ProducteevUtilities.java b/astrid/plugin-src/com/todoroo/astrid/producteev/ProducteevUtilities.java index dbc2fb699..190d853e1 100644 --- a/astrid/plugin-src/com/todoroo/astrid/producteev/ProducteevUtilities.java +++ b/astrid/plugin-src/com/todoroo/astrid/producteev/ProducteevUtilities.java @@ -1,5 +1,7 @@ package com.todoroo.astrid.producteev; +import android.text.TextUtils; + import com.timsu.astrid.R; import com.todoroo.andlib.utility.Preferences; import com.todoroo.astrid.sync.SyncProviderUtilities; @@ -76,4 +78,9 @@ public class ProducteevUtilities extends SyncProviderUtilities { return Preferences.getStringValue(R.string.producteev_PPr_email); } + @Override + public boolean isLoggedIn() { + return !TextUtils.isEmpty(getLoggedInUserName()); + } + } diff --git a/astrid/res/values/keys.xml b/astrid/res/values/keys.xml index a9e2cb513..401ca902e 100644 --- a/astrid/res/values/keys.xml +++ b/astrid/res/values/keys.xml @@ -51,6 +51,9 @@ show_friends_view + + + third_party_addons diff --git a/astrid/res/values/strings-core.xml b/astrid/res/values/strings-core.xml index 2c3aebf38..0079bebd5 100644 --- a/astrid/res/values/strings-core.xml +++ b/astrid/res/values/strings-core.xml @@ -613,6 +613,11 @@ Show Friends View Friends menu item will be shown Friends menu item will be hidden + + + Enable Third Party Add-ons + Third party add-ons will be enabled + Third party add-ons will be disabled You will need to restart Astrid for this change to take effect diff --git a/astrid/res/xml/preferences_labs.xml b/astrid/res/xml/preferences_labs.xml index 3b802ecc9..4ed1d7e98 100644 --- a/astrid/res/xml/preferences_labs.xml +++ b/astrid/res/xml/preferences_labs.xml @@ -18,4 +18,7 @@ + diff --git a/astrid/src/com/todoroo/astrid/activity/EditPreferences.java b/astrid/src/com/todoroo/astrid/activity/EditPreferences.java index ab9f793c9..eb02b6f18 100644 --- a/astrid/src/com/todoroo/astrid/activity/EditPreferences.java +++ b/astrid/src/com/todoroo/astrid/activity/EditPreferences.java @@ -48,6 +48,7 @@ import com.todoroo.astrid.dao.Database; import com.todoroo.astrid.data.Task; import com.todoroo.astrid.gtasks.GtasksPreferences; import com.todoroo.astrid.helper.MetadataHelper; +import com.todoroo.astrid.producteev.ProducteevPreferences; import com.todoroo.astrid.service.AddOnService; import com.todoroo.astrid.service.MarketStrategy.AmazonMarketStrategy; import com.todoroo.astrid.service.StartupService; @@ -231,6 +232,10 @@ public class EditPreferences extends TodorooPreferenceActivity { && AmazonMarketStrategy.isKindleFire()) continue; + if (ProducteevPreferences.class.getName().equals(resolveInfo.activityInfo.name) + && !Preferences.getBoolean(R.string.p_third_party_addons, false)) + continue; + Preference preference = new Preference(this); preference.setTitle(resolveInfo.activityInfo.loadLabel(pm)); if (labsTitle.equals(preference.getTitle())) diff --git a/astrid/src/com/todoroo/astrid/service/AddOnService.java b/astrid/src/com/todoroo/astrid/service/AddOnService.java index c1b6cae0f..1496bb15c 100644 --- a/astrid/src/com/todoroo/astrid/service/AddOnService.java +++ b/astrid/src/com/todoroo/astrid/service/AddOnService.java @@ -170,10 +170,10 @@ public class AddOnService { LOCALE_PACKAGE, "http://www.weloveastrid.com/store", ((BitmapDrawable)r.getDrawable(R.drawable.icon_locale)).getBitmap())); - list.add(new AddOn(true, true, "Producteev", null, - "Synchronize with Producteev service. Also changes Astrid's importance levels to stars.", - Constants.PACKAGE, "http://www.producteev.com", - ((BitmapDrawable)r.getDrawable(R.drawable.icon_producteev)).getBitmap())); +// list.add(new AddOn(true, true, "Producteev", null, +// "Synchronize with Producteev service. Also changes Astrid's importance levels to stars.", +// Constants.PACKAGE, "http://www.producteev.com", +// ((BitmapDrawable)r.getDrawable(R.drawable.icon_producteev)).getBitmap())); return list.toArray(new AddOn[list.size()]); } diff --git a/astrid/src/com/todoroo/astrid/service/abtesting/ABTests.java b/astrid/src/com/todoroo/astrid/service/abtesting/ABTests.java index dbc45f1e8..510bd4eb4 100644 --- a/astrid/src/com/todoroo/astrid/service/abtesting/ABTests.java +++ b/astrid/src/com/todoroo/astrid/service/abtesting/ABTests.java @@ -117,8 +117,12 @@ public class ABTests { private void initialize() { // Set up addTest(AB_TEST_FRIENDS_VIEW_AVAILABLE, new int[] { 1, 1 }, new int[] { 8, 2 }, new String[] { "friends-view-disabled", "friends-view-enabled" }); //$NON-NLS-1$ //$NON-NLS-2$ + + addTest(AB_TEST_PRODUCTEEV_ENABLED, new int[] { 1, 1 }, + new int[] { 1, 0 }, new String[] { "producteev-disabled", "producteev-enabled" }); //$NON-NLS-1$ //$NON-NLS-2$ } public static final String AB_TEST_FRIENDS_VIEW_AVAILABLE = "friends-view"; //$NON-NLS-1$ + public static final String AB_TEST_PRODUCTEEV_ENABLED = "producteev"; //$NON-NLS-1$ } diff --git a/astrid/src/com/todoroo/astrid/utility/AstridPreferences.java b/astrid/src/com/todoroo/astrid/utility/AstridPreferences.java index 719500d7d..bb689d73d 100644 --- a/astrid/src/com/todoroo/astrid/utility/AstridPreferences.java +++ b/astrid/src/com/todoroo/astrid/utility/AstridPreferences.java @@ -10,6 +10,7 @@ import com.todoroo.andlib.service.ContextManager; import com.todoroo.andlib.utility.Preferences; import com.todoroo.astrid.api.AstridApiConstants; import com.todoroo.astrid.data.Task; +import com.todoroo.astrid.producteev.ProducteevUtilities; import com.todoroo.astrid.service.ThemeService; import com.todoroo.astrid.service.abtesting.ABChooser; import com.todoroo.astrid.service.abtesting.ABTests; @@ -56,6 +57,9 @@ public class AstridPreferences { boolean friendsViewEnabled = (ABChooser.readChoiceForTest(ABTests.AB_TEST_FRIENDS_VIEW_AVAILABLE) == 1); Preferences.setIfUnset(prefs, editor, r, R.string.p_show_friends_view, friendsViewEnabled); + boolean thirdPartyAddons = (ABChooser.readChoiceForTest(ABTests.AB_TEST_PRODUCTEEV_ENABLED) == 1) || ProducteevUtilities.INSTANCE.isLoggedIn(); + Preferences.setIfUnset(prefs, editor, r, R.string.p_third_party_addons, thirdPartyAddons); + if ("white-blue".equals(Preferences.getStringValue(R.string.p_theme))) { //$NON-NLS-1$ migrate from when white-blue wasn't the default Preferences.setString(R.string.p_theme, ThemeService.THEME_WHITE); }