Refresh the main menu after sync, only show featured lists when necessary

pull/14/head
Sam Bosley 14 years ago
parent 8dca9f8a0c
commit f0ff251bda

@ -842,6 +842,9 @@ public final class ActFmSyncService {
JSONObject result = actFmInvoker.invoke("featured_lists", JSONObject result = actFmInvoker.invoke("featured_lists",
"token", token, "modified_after", serverTime); "token", token, "modified_after", serverTime);
JSONArray featuredLists = result.getJSONArray("list"); JSONArray featuredLists = result.getJSONArray("list");
if (featuredLists.length() > 0)
Preferences.setBoolean(R.string.p_show_featured_lists, true);
for (int i = 0; i < featuredLists.length(); i++) { for (int i = 0; i < featuredLists.length(); i++) {
JSONObject featObject = featuredLists.getJSONObject(i); JSONObject featObject = featuredLists.getJSONObject(i);
actFmDataService.saveFeaturedList(featObject); actFmDataService.saveFeaturedList(featObject);

@ -52,6 +52,9 @@
<!-- show friends view preference --> <!-- show friends view preference -->
<string name="p_show_friends_view">show_friends_view</string> <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 --> <!-- enable third party addons preference -->
<string name="p_third_party_addons">third_party_addons</string> <string name="p_third_party_addons">third_party_addons</string>

@ -695,7 +695,7 @@ public class TaskListActivity extends AstridActivity implements MainMenuListener
getIntent().putExtra(FILTER_MODE, mode); getIntent().putExtra(FILTER_MODE, mode);
} }
private void refreshMainMenu() { public void refreshMainMenu() {
mainMenuPopover.refreshFixedItems(); mainMenuPopover.refreshFixedItems();
TypedValue tv = new TypedValue(); TypedValue tv = new TypedValue();
getTheme().resolveAttribute(filterModeSpec.getMainMenuIconAttr(), tv, false); getTheme().resolveAttribute(filterModeSpec.getMainMenuIconAttr(), tv, false);

@ -696,12 +696,14 @@ public class TaskListFragment extends ListFragment implements OnScrollListener,
|| !AstridApiConstants.BROADCAST_EVENT_REFRESH.equals(intent.getAction())) || !AstridApiConstants.BROADCAST_EVENT_REFRESH.equals(intent.getAction()))
return; return;
Activity activity = getActivity(); final Activity activity = getActivity();
if (activity != null) { if (activity != null) {
activity.runOnUiThread(new Runnable() { activity.runOnUiThread(new Runnable() {
@Override @Override
public void run() { public void run() {
refresh(); refresh();
if (activity instanceof TaskListActivity)
((TaskListActivity) activity).refreshMainMenu();
} }
}); });
} }

@ -111,9 +111,10 @@ public class MainMenuPopover extends FragmentPopover implements InterceptTouchLi
ThemeService.getDrawable(R.drawable.icn_menu_friends, themeFlags), ThemeService.getDrawable(R.drawable.icn_menu_friends, themeFlags),
MAIN_MENU_ITEM_FRIENDS, null, topFixed); MAIN_MENU_ITEM_FRIENDS, null, topFixed);
addMenuItem(R.string.TLA_menu_featured_lists, if (Preferences.getBoolean(R.string.p_show_featured_lists, false))
ThemeService.getDrawable(R.drawable.icn_featured_lists, themeFlags), addMenuItem(R.string.TLA_menu_featured_lists,
MAIN_MENU_ITEM_FEATURED_LISTS, null, topFixed); ThemeService.getDrawable(R.drawable.icn_featured_lists, themeFlags),
MAIN_MENU_ITEM_FEATURED_LISTS, null, topFixed);
addMenuItem(R.string.TLA_menu_search, addMenuItem(R.string.TLA_menu_search,
ThemeService.getDrawable(R.drawable.icn_menu_search, themeFlags), ThemeService.getDrawable(R.drawable.icn_menu_search, themeFlags),

@ -8,10 +8,12 @@ import android.content.res.Resources;
import com.timsu.astrid.R; import com.timsu.astrid.R;
import com.todoroo.andlib.data.TodorooCursor; import com.todoroo.andlib.data.TodorooCursor;
import com.todoroo.andlib.service.ContextManager; import com.todoroo.andlib.service.ContextManager;
import com.todoroo.andlib.sql.Functions;
import com.todoroo.andlib.sql.Query; import com.todoroo.andlib.sql.Query;
import com.todoroo.andlib.utility.Preferences; import com.todoroo.andlib.utility.Preferences;
import com.todoroo.astrid.api.AstridApiConstants; import com.todoroo.astrid.api.AstridApiConstants;
import com.todoroo.astrid.core.PluginServices; import com.todoroo.astrid.core.PluginServices;
import com.todoroo.astrid.data.TagData;
import com.todoroo.astrid.data.Task; import com.todoroo.astrid.data.Task;
import com.todoroo.astrid.data.User; import com.todoroo.astrid.data.User;
import com.todoroo.astrid.service.ThemeService; import com.todoroo.astrid.service.ThemeService;
@ -76,6 +78,16 @@ public class AstridPreferences {
} }
Preferences.setBoolean(R.string.p_show_friends_view, showFriends); Preferences.setBoolean(R.string.p_show_friends_view, showFriends);
boolean showFeaturedLists = false;
TodorooCursor<TagData> featLists = PluginServices.getTagDataService().query(Query.select(TagData.ID)
.where(Functions.bitwiseAnd(TagData.FLAGS, TagData.FLAG_FEATURED).gt(0)).limit(1));
try {
showFeaturedLists = featLists.getCount() > 0;
} finally {
featLists.close();
}
Preferences.setBoolean(R.string.p_show_featured_lists, showFeaturedLists);
editor.commit(); editor.commit();
} }

Loading…
Cancel
Save