Refactored featured list preference code to be easier to read, introduce an ab test for the presence of featured lists

pull/14/head
Sam Bosley 13 years ago
parent 2978c9dad1
commit 696bf298db

@ -77,6 +77,7 @@ import com.todoroo.astrid.service.TaskService;
import com.todoroo.astrid.service.abtesting.ABTestEventReportingService;
import com.todoroo.astrid.sync.SyncV2Provider.SyncExceptionHandler;
import com.todoroo.astrid.tags.TagService;
import com.todoroo.astrid.tags.reusable.FeaturedListFilterExposer;
import com.todoroo.astrid.utility.Flags;
/**
@ -859,7 +860,7 @@ public final class ActFmSyncService {
"token", token, "modified_after", serverTime);
JSONArray featuredLists = result.getJSONArray("list");
if (featuredLists.length() > 0)
Preferences.setBoolean(R.string.p_show_featured_lists, true);
Preferences.setBoolean(FeaturedListFilterExposer.PREF_SHOULD_SHOW_FEATURED_LISTS, true);
for (int i = 0; i < featuredLists.length(); i++) {
JSONObject featObject = featuredLists.getJSONObject(i);

@ -295,7 +295,7 @@ public class ActFmSyncV2Provider extends SyncV2Provider {
public void run() {
int time = Preferences.getInt(LAST_FEATURED_TAG_FETCH_TIME, 0);
try {
if (Preferences.getBoolean(R.string.p_show_featured_lists_labs, false)) {
if (Preferences.getBoolean(R.string.p_show_featured_lists, false)) {
time = actFmSyncService.fetchFeaturedLists(time);
Preferences.setInt(LAST_FEATURED_TAG_FETCH_TIME, time);
}

@ -31,6 +31,8 @@ import com.todoroo.astrid.tags.TagService.Tag;
public class FeaturedListFilterExposer extends TagFilterExposer {
public static final String PREF_SHOULD_SHOW_FEATURED_LISTS = "show_featured_lists"; //$NON-NLS-1$
@Override
public void onReceive(Context context, Intent intent) {
addUntaggedFilter = false;

@ -55,9 +55,6 @@
<!-- show friends view preference -->
<string name="p_show_friends_view">show_friends_view</string>
<!-- show featured lists preference -->
<string name="p_show_featured_lists">show_featured_lists</string>
<!-- enable third party addons preference -->
<string name="p_third_party_addons">third_party_addons</string>
@ -68,7 +65,7 @@
<string name="p_force_phone_layout">force_phone_layout</string>
<!-- show featured lists -->
<string name="p_show_featured_lists_labs">show_featured_lists_labs</string>
<string name="p_show_featured_lists">show_featured_lists_labs</string>
<!-- account status section key -->
<string name="p_account">account</string>

@ -90,7 +90,7 @@
<CheckBoxPreference
android:title="@string/EPr_show_featured_lists"
android:key="@string/p_show_featured_lists_labs"
android:key="@string/p_show_featured_lists"
android:defaultValue="false"/>
<CheckBoxPreference

@ -13,7 +13,7 @@ public class DefaultFilterMode implements FilterModeSpec {
@Override
public int[] getForbiddenMenuItems() {
if (Preferences.getBoolean(R.string.p_show_featured_lists_labs, false))
if (Preferences.getBoolean(R.string.p_show_featured_lists, false))
return new int[0];
else
return new int[] { MainMenuPopover.MAIN_MENU_ITEM_FEATURED_LISTS };

@ -574,7 +574,7 @@ public class EditPreferences extends TodorooPreferenceActivity {
return super.onPreferenceChange(p, newValue);
}
});
} else if (r.getString(R.string.p_show_featured_lists_labs).equals(preference.getKey())) {
} else if (r.getString(R.string.p_show_featured_lists).equals(preference.getKey())) {
preference.setOnPreferenceChangeListener(new SetResultOnPreferenceChangeListener(SyncProviderPreferences.RESULT_CODE_SYNCHRONIZE) {
@Override
public boolean onPreferenceChange(Preference p, Object newValue) {

@ -123,8 +123,13 @@ public class ABTests {
public static final String AB_CALENDAR_REMINDERS = "android_cal_reminders"; //$NON-NLS-1$
public static final String AB_FEATURED_LISTS = "android_featured_lists"; //$NON-NLS-1$
private void initialize() {
addTest(AB_FEATURED_LISTS, new int[] { 1, 1 },
new int[] { 1, 1 }, new String[] { "featured-lists-disabled", "featured-lists-enabled" }); //$NON-NLS-1$ //$NON-NLS-2$
addTest(AB_SIMPLE_TASK_ROW, new int[] { 1, 1 },
new int[] { 1, 0 }, new String[] { "original-row-style", "simple-row-style" }); //$NON-NLS-1$ //$NON-NLS-2$

@ -22,6 +22,7 @@ import android.widget.TextView;
import com.timsu.astrid.R;
import com.todoroo.andlib.utility.Preferences;
import com.todoroo.astrid.service.ThemeService;
import com.todoroo.astrid.tags.reusable.FeaturedListFilterExposer;
import com.todoroo.astrid.ui.TouchInterceptingFrameLayout.InterceptTouchListener;
import com.todoroo.astrid.utility.AstridPreferences;
@ -120,7 +121,7 @@ public class MainMenuPopover extends FragmentPopover implements InterceptTouchLi
ThemeService.getDrawable(R.drawable.icn_menu_friends, themeFlags),
MAIN_MENU_ITEM_FRIENDS, null, topFixed);
if (Preferences.getBoolean(R.string.p_show_featured_lists, false))
if (Preferences.getBoolean(FeaturedListFilterExposer.PREF_SHOULD_SHOW_FEATURED_LISTS, false))
addMenuItem(R.string.TLA_menu_featured_lists,
ThemeService.getDrawable(R.drawable.icn_featured_lists, themeFlags),
MAIN_MENU_ITEM_FEATURED_LISTS, null, topFixed);

@ -25,6 +25,7 @@ import com.todoroo.astrid.data.User;
import com.todoroo.astrid.service.ThemeService;
import com.todoroo.astrid.service.abtesting.ABChooser;
import com.todoroo.astrid.service.abtesting.ABTests;
import com.todoroo.astrid.tags.reusable.FeaturedListFilterExposer;
public class AstridPreferences {
@ -71,6 +72,9 @@ public class AstridPreferences {
Preferences.setIfUnset(prefs, editor, r, R.string.p_ideas_tab_enabled, true);
Preferences.setIfUnset(prefs, editor, r, R.string.p_show_featured_lists,
ABChooser.readChoiceForTest(ABTests.AB_FEATURED_LISTS) != 0);
Preferences.setIfUnset(prefs, editor, r, R.string.p_taskRowStyle,
ABChooser.readChoiceForTest(ABTests.AB_SIMPLE_TASK_ROW) != 0);
@ -114,7 +118,7 @@ public class AstridPreferences {
} finally {
featLists.close();
}
Preferences.setBoolean(R.string.p_show_featured_lists, showFeaturedLists);
Preferences.setBoolean(FeaturedListFilterExposer.PREF_SHOULD_SHOW_FEATURED_LISTS, showFeaturedLists);
}
/* ======================================================================

Loading…
Cancel
Save