Exemplo n.º 1
0
  protected void addMenuItems(Menu menu, Activity activity) {
    boolean isTablet = AstridPreferences.useTabletLayout(activity);
    TaskListActivity tla = null;
    if (activity instanceof TaskListActivity) {
      tla = (TaskListActivity) activity;
      tla.getMainMenuPopover().clear();
    }
    // --- sync
    if (tla == null || tla.getTaskEditFragment() == null)
      addSyncRefreshMenuItem(menu, isTablet ? ThemeService.FLAG_INVERT : 0);

    // --- sort
    if (allowResorting()) {
      addMenuItem(
          menu,
          R.string.TLA_menu_sort,
          ThemeService.getDrawable(
              R.drawable.icn_menu_sort_by_size, isTablet ? ThemeService.FLAG_FORCE_DARK : 0),
          MENU_SORT_ID,
          false);
    }

    // --- new filter
    if (Preferences.getBoolean(R.string.p_use_filters, true))
      addMenuItem(
          menu,
          R.string.FLA_new_filter,
          ThemeService.getDrawable(
              R.drawable.icn_menu_filters, isTablet ? ThemeService.FLAG_FORCE_DARK : 0),
          MENU_NEW_FILTER_ID,
          false);

    // --- addons
    if (Constants.MARKET_STRATEGY.showAddonMenu())
      addMenuItem(
          menu,
          R.string.TLA_menu_addons,
          ThemeService.getDrawable(
              R.drawable.icn_menu_plugins, isTablet ? ThemeService.FLAG_FORCE_DARK : 0),
          MENU_ADDONS_ID,
          false);

    // ask about plug-ins
    Intent queryIntent = new Intent(AstridApiConstants.ACTION_TASK_LIST_MENU);

    PackageManager pm = getActivity().getPackageManager();
    List<ResolveInfo> resolveInfoList = pm.queryIntentActivities(queryIntent, 0);
    int length = resolveInfoList.size();
    for (int i = 0; i < length; i++) {
      ResolveInfo resolveInfo = resolveInfoList.get(i);
      Intent intent = new Intent(AstridApiConstants.ACTION_TASK_LIST_MENU);
      intent.setClassName(resolveInfo.activityInfo.packageName, resolveInfo.activityInfo.name);
      addMenuItem(
          menu, resolveInfo.loadLabel(pm), resolveInfo.loadIcon(pm), intent, MENU_ADDON_INTENT_ID);
    }
  }
Exemplo n.º 2
0
 private void showListsHelp() {
   if (!AstridPreferences.canShowPopover()) return;
   if (!Preferences.getBoolean(R.string.p_showed_lists_help, false)) {
     AstridActivity activity = (AstridActivity) getActivity();
     if (activity != null) {
       if (AstridPreferences.useTabletLayout(activity)) {
         FilterListFragment flf = activity.getFilterListFragment();
         if (flf != null) flf.showAddListPopover();
       } else {
         ActionBar ab = activity.getSupportActionBar();
         View anchor = ab.getCustomView().findViewById(R.id.lists_nav);
         HelpInfoPopover.showPopover(activity, anchor, R.string.help_popover_switch_lists, null);
       }
       Preferences.setBoolean(R.string.p_showed_lists_help, true);
     }
   }
 }