diff --git a/astrid/plugin-src/com/todoroo/astrid/actfm/sync/ActFmSyncService.java b/astrid/plugin-src/com/todoroo/astrid/actfm/sync/ActFmSyncService.java index 2f894de98..96c2e2299 100644 --- a/astrid/plugin-src/com/todoroo/astrid/actfm/sync/ActFmSyncService.java +++ b/astrid/plugin-src/com/todoroo/astrid/actfm/sync/ActFmSyncService.java @@ -26,6 +26,7 @@ import android.os.ConditionVariable; import android.text.TextUtils; import android.util.Log; +import com.timsu.astrid.R; import com.todoroo.andlib.data.AbstractModel; import com.todoroo.andlib.data.DatabaseDao; import com.todoroo.andlib.data.DatabaseDao.ModelUpdateListener; @@ -702,6 +703,9 @@ public final class ActFmSyncService { "token", token, "modified_after", serverTime); JSONArray users = result.getJSONArray("list"); HashSet ids = new HashSet(); + if (users.length() > 0) + Preferences.setBoolean(R.string.p_show_friends_view, true); + for (int i = 0; i < users.length(); i++) { JSONObject userObject = users.getJSONObject(i); ids.add(userObject.optLong("id")); diff --git a/astrid/plugin-src/com/todoroo/astrid/core/LabsPreferences.java b/astrid/plugin-src/com/todoroo/astrid/core/LabsPreferences.java index 0ef3aec3c..85cc51af9 100644 --- a/astrid/plugin-src/com/todoroo/astrid/core/LabsPreferences.java +++ b/astrid/plugin-src/com/todoroo/astrid/core/LabsPreferences.java @@ -44,10 +44,6 @@ public class LabsPreferences extends TodorooPreferenceActivity { String name = r.getStringArray(R.array.EPr_swipe_lists_performance_mode)[index]; String desc = r.getStringArray(R.array.EPr_swipe_lists_performance_desc)[index]; 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); - 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)) { setEnabledSummary(preference, value, R.string.MCA_missed_calls_pref_desc_enabled, R.string.MCA_missed_calls_pref_desc_disabled); diff --git a/astrid/res/values/strings-core.xml b/astrid/res/values/strings-core.xml index 0079bebd5..de7323815 100644 --- a/astrid/res/values/strings-core.xml +++ b/astrid/res/values/strings-core.xml @@ -609,11 +609,6 @@ The system contact picker option will be displayed in the task assignment window The system contact picker option will not be displayed - - 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 diff --git a/astrid/res/xml/preferences_labs.xml b/astrid/res/xml/preferences_labs.xml index 4ed1d7e98..781241633 100644 --- a/astrid/res/xml/preferences_labs.xml +++ b/astrid/res/xml/preferences_labs.xml @@ -15,9 +15,6 @@ - diff --git a/astrid/src/com/todoroo/astrid/service/abtesting/ABTests.java b/astrid/src/com/todoroo/astrid/service/abtesting/ABTests.java index 510bd4eb4..a7386418c 100644 --- a/astrid/src/com/todoroo/astrid/service/abtesting/ABTests.java +++ b/astrid/src/com/todoroo/astrid/service/abtesting/ABTests.java @@ -115,14 +115,11 @@ 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 bb689d73d..5e3e56478 100644 --- a/astrid/src/com/todoroo/astrid/utility/AstridPreferences.java +++ b/astrid/src/com/todoroo/astrid/utility/AstridPreferences.java @@ -6,10 +6,14 @@ import android.content.SharedPreferences.Editor; import android.content.res.Resources; import com.timsu.astrid.R; +import com.todoroo.andlib.data.TodorooCursor; import com.todoroo.andlib.service.ContextManager; +import com.todoroo.andlib.sql.Query; import com.todoroo.andlib.utility.Preferences; import com.todoroo.astrid.api.AstridApiConstants; +import com.todoroo.astrid.core.PluginServices; import com.todoroo.astrid.data.Task; +import com.todoroo.astrid.data.User; import com.todoroo.astrid.producteev.ProducteevUtilities; import com.todoroo.astrid.service.ThemeService; import com.todoroo.astrid.service.abtesting.ABChooser; @@ -54,9 +58,6 @@ public class AstridPreferences { Preferences.setIfUnset(prefs, editor, r, R.string.p_use_contact_picker, true); Preferences.setIfUnset(prefs, editor, r, R.string.p_field_missed_calls, true); - 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); @@ -64,6 +65,16 @@ public class AstridPreferences { Preferences.setString(R.string.p_theme, ThemeService.THEME_WHITE); } + // Show friends view if necessary + boolean showFriends = false; + TodorooCursor users = PluginServices.getUserDao().query(Query.select(User.ID).limit(1)); + try { + showFriends = users.getCount() > 0; + } finally { + users.close(); + } + Preferences.setBoolean(R.string.p_show_friends_view, showFriends); + editor.commit(); }