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); } }
public void showVoiceInputMarketSearch(DialogInterface.OnClickListener onFail) { String packageName; if (AndroidUtilities.getSdkVersion() <= 7) { packageName = "com.google.android.voicesearch.x"; } else { packageName = "com.google.android.voicesearch"; } // User wants to install voice search, take them to the market Intent marketIntent = Constants.MARKET_STRATEGY.generateMarketLink(packageName); if (activity != null) { try { if (marketIntent == null) { throw new ActivityNotFoundException("No market link supplied"); // $NON-NLS-1$ } activity.startActivity(marketIntent); } catch (ActivityNotFoundException ane) { DialogUtilities.okDialog( activity, activity.getString(R.string.EPr_marketUnavailable_dlg), onFail); } } }