@Override
  public void onPrepareSubMenu(final SubMenu subMenu) {
    subMenu.clear();
    if (geocache == null) {
      return;
    }
    for (final NavigationAppsEnum app : NavigationAppFactory.getActiveNavigationApps()) {
      if (!(app.app instanceof CacheNavigationApp)) {
        continue;
      }
      final CacheNavigationApp cacheApp = (CacheNavigationApp) app.app;
      if (app.app.isEnabled(geocache)) {
        subMenu
            .add(Menu.NONE, app.id, Menu.NONE, app.app.getName())
            .setOnMenuItemClickListener(
                new OnMenuItemClickListener() {

                  @Override
                  public boolean onMenuItemClick(final MenuItem item) {
                    cacheApp.navigate(activity, geocache);
                    return true;
                  }
                });
      }
    }
  }
Example #2
0
  public static void addMapTypeMenu(IGxMapView mapView, Menu menu) {
    SubMenu subMenu = menu.addSubMenu(Menu.NONE, R.id.map_mode, 0, R.string.GXM_SelectMapType);

    MenuItem itemStandard =
        addMapTypeMenuOption(
            mapView,
            subMenu,
            GxMapViewDefinition.MAP_TYPE_STANDARD,
            MENU_TYPE_STANDARD,
            R.string.GXM_Standard);
    MenuItem itemSatellite =
        addMapTypeMenuOption(
            mapView,
            subMenu,
            GxMapViewDefinition.MAP_TYPE_SATELLITE,
            MENU_TYPE_SATELLITE,
            R.string.GXM_Satellite);
    MenuItem itemHybrid =
        addMapTypeMenuOption(
            mapView,
            subMenu,
            GxMapViewDefinition.MAP_TYPE_HYBRID,
            MENU_TYPE_HYBRID,
            R.string.GXM_Hybrid);

    subMenu.setGroupCheckable(GROUP_MAP_TYPE, true, true);

    String currentMapType = mapView.getMapType();
    if (currentMapType.equalsIgnoreCase(GxMapViewDefinition.MAP_TYPE_SATELLITE))
      itemSatellite.setChecked(true);
    else if (currentMapType.equalsIgnoreCase(GxMapViewDefinition.MAP_TYPE_HYBRID))
      itemHybrid.setChecked(true);
    else itemStandard.setChecked(true);
  }
Example #3
0
 @Override
 public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
   inflater.inflate(R.menu.sort, menu);
   SubMenu subMenu = menu.findItem(R.id.SORT_COMMAND).getSubMenu();
   subMenu.findItem(R.id.SORT_AMOUNT_COMMAND).setVisible(true);
   subMenu.findItem(R.id.SORT_NEXT_INSTANCE_COMMAND).setVisible(true);
 }
  protected void createFileMenu(final ContextMenu menu, final String path) {
    final BookSettings bs = SettingsManager.getBookSettings(path);
    final MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.book_menu, menu);
    menu.setHeaderTitle(path);
    menu.findItem(R.id.bookmenu_recentgroup).setVisible(bs != null);
    menu.findItem(R.id.bookmenu_openbookshelf).setVisible(false);
    menu.findItem(R.id.bookmenu_openbookfolder).setVisible(false);

    final MenuItem om = menu.findItem(R.id.bookmenu_open);
    final SubMenu osm = om != null ? om.getSubMenu() : null;
    if (osm == null) {
      return;
    }
    osm.clear();

    final List<Bookmark> list = new ArrayList<Bookmark>();
    list.add(new Bookmark(true, getString(R.string.bookmark_start), PageIndex.FIRST, 0, 0));
    list.add(new Bookmark(true, getString(R.string.bookmark_end), PageIndex.LAST, 0, 1));
    if (bs != null) {
      if (LengthUtils.isNotEmpty(bs.bookmarks)) {
        list.addAll(bs.bookmarks);
      }
      list.add(
          new Bookmark(
              true, getString(R.string.bookmark_current), bs.currentPage, bs.offsetX, bs.offsetY));
    }

    Collections.sort(list);
    for (final Bookmark b : list) {
      addBookmarkMenuItem(osm, b);
    }
  }
Example #5
0
  @Override
  public boolean onCreateOptionsMenu(
      final Menu pMenu, final int pMenuIdOffset, final MapView pMapView) {
    final SubMenu mapMenu =
        pMenu
            .addSubMenu(0, MENU_MAP_MODE + pMenuIdOffset, Menu.NONE, R.string.map_mode)
            .setIcon(R.drawable.ic_menu_mapmode);

    for (int a = 0; a < TileSourceFactory.getTileSources().size(); a++) {
      final ITileSource tileSource = TileSourceFactory.getTileSources().get(a);
      mapMenu.add(
          MENU_MAP_MODE + pMenuIdOffset,
          MENU_TILE_SOURCE_STARTING_ID + a + pMenuIdOffset,
          Menu.NONE,
          tileSource.name());
    }
    mapMenu.setGroupCheckable(MENU_MAP_MODE + pMenuIdOffset, true, true);

    if (ctx != null) {
      final String title =
          ctx.getString(
              pMapView.useDataConnection() ? R.string.set_mode_offline : R.string.set_mode_online);
      final Drawable icon = ctx.getResources().getDrawable(R.drawable.ic_menu_offline);
      pMenu.add(0, MENU_OFFLINE + pMenuIdOffset, Menu.NONE, title).setIcon(icon);
    }
    return true;
  }
Example #6
0
  /** On options menu creation. */
  @Override
  public boolean onCreateOptionsMenu(Menu menu) {

    // ===

    SubMenu sortMenu = menu.addSubMenu(group2Id, MENU_ITEM_SORT, sortBtnId, R.string.logsmenu_sort);
    sortMenu.add(MENU_ITEM_SORT, MENU_ITEM_SORT_ALL, 0, R.string.logsmenu_sort_all);
    sortMenu.add(MENU_ITEM_SORT, MENU_ITEM_SORT_BY_XODIL, 1, R.string.logsmenu_sort_xodil);
    sortMenu.add(
        MENU_ITEM_SORT, MENU_ITEM_SORT_BY_PODTVERDIL, 2, R.string.logsmenu_sort_podtverdil);
    sortMenu.setIcon(android.R.drawable.ic_menu_sort_alphabetically);

    // // ===
    // MenuItem item_2 = menu.add(group2Id, MENU_ITEM_LOGSTEXT,
    // logstextBtnId, R.string.logsmenu_sort_all);
    // item_2.setIcon(android.R.drawable.ic_menu_edit);

    // // ===
    // MenuItem item_2 = menu.add(group2Id, MENU_ITEM_SORT_ALL,
    // sortAllBtnId, R.string.logsmenu_sort_all);
    // item_2.setIcon(android.R.drawable.ic_menu_edit);
    //
    // // ===
    // MenuItem item_3 = menu.add(group2Id, MENU_ITEM_SORT_BY_PODTVERDIL,
    // sortPodtverdilBtnId, R.string.logsmenu_sort_podtverdil);
    // item_3.setIcon(android.R.drawable.ic_menu_sort_by_size);

    return super.onCreateOptionsMenu(menu);
  }
  private void addWaypoints(final SubMenu subMenu) {
    subMenu.clear();
    for (final Waypoint waypoint : geocache.getWaypoints()) {
      if (waypoint.getCoords() != null) {
        subMenu
            .add(Menu.NONE, waypoint.getId(), Menu.NONE, waypoint.getName())
            .setOnMenuItemClickListener(
                new OnMenuItemClickListener() {

                  @Override
                  public boolean onMenuItemClick(final MenuItem item) {
                    callback.onWaypointSelected(waypoint);
                    return true;
                  }
                });
      }
    }
    subMenu
        .add(Menu.NONE, Menu.NONE, Menu.NONE, getContext().getString(R.string.cache))
        .setOnMenuItemClickListener(
            new OnMenuItemClickListener() {

              @Override
              public boolean onMenuItemClick(final MenuItem item) {
                callback.onGeocacheSelected(geocache);
                return true;
              }
            });
  }
Example #8
0
 @Override
 public boolean onPrepareOptionsMenu(Menu menu) {
   super.onPrepareOptionsMenu(menu);
   hackForSubmenus = menu;
   if (progress != null && (actionBarCompat == null || actionBarCompat.hasMenuButton()))
     return false; // not safe/useful until game is loaded
   MenuItem item;
   item = menu.findItem(R.id.solve);
   item.setEnabled(solveEnabled);
   if (actionBarCompat != null) item.setVisible(solveEnabled);
   MenuItem undoItem = menu.findItem(R.id.undo), redoItem = menu.findItem(R.id.redo);
   undoItem.setEnabled(undoEnabled);
   redoItem.setEnabled(redoEnabled);
   undoItem.setIcon(
       undoEnabled ? R.drawable.sym_keyboard_undo : R.drawable.sym_keyboard_undo_disabled);
   redoItem.setIcon(
       redoEnabled ? R.drawable.sym_keyboard_redo : R.drawable.sym_keyboard_redo_disabled);
   item = menu.findItem(R.id.type);
   item.setEnabled(!gameTypes.isEmpty() || customVisible);
   if (actionBarCompat != null) item.setVisible(item.isEnabled());
   typeMenu = item.getSubMenu();
   for (Integer i : gameTypes.keySet()) {
     if (menu.findItem(i) == null) typeMenu.add(R.id.typeGroup, i, Menu.NONE, gameTypes.get(i));
   }
   MenuItem customItem = menu.findItem(R.id.custom);
   customItem.setVisible(customVisible);
   typeMenu.setGroupCheckable(R.id.typeGroup, true, true);
   if (currentType < 0) customItem.setChecked(true);
   else if (currentType < gameTypes.size())
     menu.findItem((Integer) gameTypes.keySet().toArray()[currentType]).setChecked(true);
   menu.findItem(R.id.thisgame)
       .setTitle(
           MessageFormat.format(getString(R.string.help_on_game), new Object[] {this.getTitle()}));
   return true;
 }
 public void onPrepareSubMenu(SubMenu subMenu) {
   int i;
   subMenu.clear();
   ActivityChooserModel dataModel =
       ActivityChooserModel.get(this.mContext, this.mShareHistoryFileName);
   PackageManager packageManager = this.mContext.getPackageManager();
   int expandedActivityCount = dataModel.getActivityCount();
   int collapsedActivityCount = Math.min(expandedActivityCount, this.mMaxShownActivityCount);
   for (i = 0; i < collapsedActivityCount; i++) {
     ResolveInfo activity = dataModel.getActivity(i);
     subMenu
         .add(0, i, i, activity.loadLabel(packageManager))
         .setIcon(activity.loadIcon(packageManager))
         .setOnMenuItemClickListener(this.mOnMenuItemClickListener);
   }
   if (collapsedActivityCount < expandedActivityCount) {
     SubMenu expandedSubMenu =
         subMenu.addSubMenu(
             0,
             collapsedActivityCount,
             collapsedActivityCount,
             this.mContext.getString(C0103R.string.abc_activity_chooser_view_see_all));
     for (i = 0; i < expandedActivityCount; i++) {
       activity = dataModel.getActivity(i);
       expandedSubMenu
           .add(0, i, i, activity.loadLabel(packageManager))
           .setIcon(activity.loadIcon(packageManager))
           .setOnMenuItemClickListener(this.mOnMenuItemClickListener);
     }
   }
 }
Example #10
0
  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
    if (settings.useCompass == 1) {
      menu.add(0, 1, 0, res.getString(R.string.use_gps))
          .setIcon(android.R.drawable.ic_menu_compass);
    } else {
      menu.add(0, 1, 0, res.getString(R.string.use_compass))
          .setIcon(android.R.drawable.ic_menu_compass);
    }
    menu.add(0, 0, 0, res.getString(R.string.caches_on_map))
        .setIcon(android.R.drawable.ic_menu_mapmode);
    menu.add(0, 2, 0, res.getString(R.string.destination_set))
        .setIcon(android.R.drawable.ic_menu_edit);
    if (coordinates.size() > 1) {
      SubMenu subMenu =
          menu.addSubMenu(0, 3, 0, res.getString(R.string.destination_select))
              .setIcon(android.R.drawable.ic_menu_myplaces);

      int cnt = 4;
      for (cgCoord coordinate : coordinates) {
        subMenu.add(0, cnt, 0, coordinate.name + " (" + coordinate.type + ")");
        cnt++;
      }

      return true;
    } else {
      menu.add(0, 3, 0, res.getString(R.string.destination_select))
          .setIcon(android.R.drawable.ic_menu_myplaces)
          .setEnabled(false);

      return true;
    }
  }
Example #11
0
  private void updateDrawer(boolean updateFavorites) {
    NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
    assert navigationView != null : "Navigation view is null";

    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP)
      navigationView.setItemIconTintList(null);

    MenuItem stats = navigationView.getMenu().findItem(R.id.nav_stats);
    if (ProSettings.checkEnabled(ProSettings.STATISTICS_KEY)) stats.setVisible(true);
    else stats.setVisible(false);

    MenuItem notes = navigationView.getMenu().findItem(R.id.nav_notes);
    if (ProSettings.checkEnabled(ProSettings.NOTES_KEY)) notes.setVisible(true);
    else notes.setVisible(false);

    if (updateFavorites) {
      SubMenu fab_menu = navigationView.getMenu().findItem(R.id.nav_header_favorites).getSubMenu();
      fab_menu.clear();

      Sites favorites = dataManager.getFavoriteSites();
      for (Site site : favorites) {
        MenuItem mi = fab_menu.add(2, site.code, Menu.NONE, site.name);
        configureMenuItem(mi, site);
      }
    }
    navigationView.invalidate();
  }
  public static void addMapviewMenuItems(final Menu menu) {
    final SubMenu parentMenu = menu.findItem(R.id.menu_select_mapview).getSubMenu();

    final int currentSource = Settings.getMapSource().getNumericalId();
    for (int i = 0; i < mapSources.size(); i++) {
      final MapSource mapSource = mapSources.get(i);
      final int id = mapSource.getNumericalId();
      parentMenu
          .add(R.id.menu_group_map_sources, id, i, mapSource.getName())
          .setCheckable(true)
          .setChecked(id == currentSource);
    }
    parentMenu.setGroupCheckable(R.id.menu_group_map_sources, true, true);
  }
Example #13
0
  @Override
  public boolean onCreateOptionsMenu(final Menu menu) {
    getMenuInflater().inflate(R.menu.abstract_logging_activity, menu);

    final SubMenu menuLog = menu.findItem(R.id.menu_templates).getSubMenu();
    for (final LogTemplate template : LogTemplateProvider.getTemplatesWithSignature()) {
      menuLog.add(0, template.getItemId(), 0, template.getResourceId());
    }

    final SubMenu menuSmilies = menu.findItem(R.id.menu_smilies).getSubMenu();
    for (final Smiley smiley : GCSmiliesProvider.getSmilies()) {
      menuSmilies.add(0, smiley.getItemId(), 0, smiley.text);
    }

    return true;
  }
 protected void populateMenu(Menu menu) {
   LinkedHashMap<String, String> types = getDocTypesForCreation();
   if (types.size() > 0) {
     if (types.size() == 1) {
       menu.add(Menu.NONE, MNU_NEW_LISTITEM, 0, "New Item");
     } else {
       SubMenu subMenu = menu.addSubMenu(Menu.NONE, MNU_NEW_LISTITEM, 0, "New item");
       int idx = 1;
       for (String key : types.keySet()) {
         subMenu.add(Menu.NONE, MNU_NEW_LISTITEM + idx, idx, types.get(key));
         idx++;
       }
     }
   }
   // menu.add(Menu.NONE, MNU_VIEW_LIST_EXTERNAL, 1, "External View");
   menu.add(Menu.NONE, MNU_REFRESH, 2, "Refresh");
 }
Example #15
0
 @Override
 public void onPrepareSubMenu(SubMenu subMenu) {
   // TODO Auto-generated method stub
   subMenu.clear();
   buildMenuIdMaps();
   buildAddMenu(subMenu);
   super.onPrepareSubMenu(subMenu);
 }
  @Override
  public void onPrepareSubMenu(SubMenu subMenu) {
    // Clear since the order of items may change.
    subMenu.clear();

    ActivityChooserModel dataModel = ActivityChooserModel.get(mContext, mHistoryFileName);
    PackageManager packageManager = mContext.getPackageManager();

    // Populate the sub-menu with a sub set of the activities.
    final int count = dataModel.getActivityCount();
    for (int i = 0; i < count; i++) {
      ResolveInfo activity = dataModel.getActivity(i);
      subMenu
          .add(0, i, i, activity.loadLabel(packageManager))
          .setIcon(activity.loadIcon(packageManager))
          .setOnMenuItemClickListener(mCallbacks);
    }
  }
Example #17
0
  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
    SubMenu subMenu =
        menu.addSubMenu(0, 0, 0, res.getString(R.string.log_add))
            .setIcon(android.R.drawable.ic_menu_add);

    subMenu.add(0, 0x6, 0, res.getString(R.string.log_date_time));
    subMenu.add(0, 0x4, 0, res.getString(R.string.log_date));
    subMenu.add(0, 0x2, 0, res.getString(R.string.log_time));
    subMenu.add(0, 0x1, 0, res.getString(R.string.init_signature));
    subMenu.add(
        0,
        0x7,
        0,
        res.getString(R.string.log_date_time) + " & " + res.getString(R.string.init_signature));

    return true;
  }
  /** {@inheritDoc} */
  @DSSafe(DSCat.SAFE_LIST)
  @DSGenerator(
      tool_name = "Doppelganger",
      tool_version = "2.0",
      generated_on = "2014-09-18 21:46:52.211 -0400",
      hash_original_method = "5458A50E7CC261A43D8FD66D69514BF7",
      hash_generated_method = "9C9DCF571226F099D8D0DA86C844CB03")
  @Override
  public void onPrepareSubMenu(SubMenu subMenu) {
    // Clear since the order of items may change.
    subMenu.clear();

    ActivityChooserModel dataModel = ActivityChooserModel.get(mContext, mShareHistoryFileName);
    PackageManager packageManager = mContext.getPackageManager();

    final int expandedActivityCount = dataModel.getActivityCount();
    final int collapsedActivityCount = Math.min(expandedActivityCount, mMaxShownActivityCount);

    // Populate the sub-menu with a sub set of the activities.
    for (int i = 0; i < collapsedActivityCount; i++) {
      ResolveInfo activity = dataModel.getActivity(i);
      subMenu
          .add(0, i, i, activity.loadLabel(packageManager))
          .setIcon(activity.loadIcon(packageManager))
          .setOnMenuItemClickListener(mOnMenuItemClickListener);
    }

    if (collapsedActivityCount < expandedActivityCount) {
      // Add a sub-menu for showing all activities as a list item.
      SubMenu expandedSubMenu =
          subMenu.addSubMenu(
              Menu.NONE,
              collapsedActivityCount,
              collapsedActivityCount,
              mContext.getString(R.string.abc_activity_chooser_view_see_all));
      for (int i = 0; i < expandedActivityCount; i++) {
        ResolveInfo activity = dataModel.getActivity(i);
        expandedSubMenu
            .add(0, i, i, activity.loadLabel(packageManager))
            .setIcon(activity.loadIcon(packageManager))
            .setOnMenuItemClickListener(mOnMenuItemClickListener);
      }
    }
  }
  @Override
  public boolean onCreateOptionsMenu(final Menu pMenu) {
    pMenu.add(0, MENU_ZOOMIN_ID, Menu.NONE, "ZoomIn");
    pMenu.add(0, MENU_ZOOMOUT_ID, Menu.NONE, "ZoomOut");

    final SubMenu subMenu =
        pMenu.addSubMenu(0, MENU_TILE_SOURCE_ID, Menu.NONE, "Choose Tile Source");
    {
      for (final ITileSource tileSource : TileSourceFactory.getTileSources()) {
        subMenu.add(
            0, 1000 + tileSource.ordinal(), Menu.NONE, tileSource.localizedName(mResourceProxy));
      }
    }

    pMenu.add(0, MENU_ANIMATION_ID, Menu.NONE, "Run Animation");
    pMenu.add(0, MENU_MINIMAP_ID, Menu.NONE, "Toggle Minimap");

    return true;
  }
  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
    List<String> effects = mOpenCvCameraView.getEffectList();

    if (effects == null) {
      Log.e(TAG, "Color effects are not supported by device!");
      return true;
    }

    mColorEffectsMenu = menu.addSubMenu("Color Effect");
    mEffectMenuItems = new MenuItem[effects.size()];

    int idx = 0;
    ListIterator<String> effectItr = effects.listIterator();
    while (effectItr.hasNext()) {
      String element = effectItr.next();
      mEffectMenuItems[idx] = mColorEffectsMenu.add(1, idx, Menu.NONE, element);
      idx++;
    }

    mResolutionMenu = menu.addSubMenu("Resolution");
    mResolutionList = mOpenCvCameraView.getResolutionList();
    mResolutionMenuItems = new MenuItem[mResolutionList.size()];

    ListIterator<Size> resolutionItr = mResolutionList.listIterator();
    idx = 0;
    while (resolutionItr.hasNext()) {
      Size element = resolutionItr.next();
      mResolutionMenuItems[idx] =
          mResolutionMenu.add(
              2,
              idx,
              Menu.NONE,
              Integer.valueOf(element.width).toString()
                  + "x"
                  + Integer.valueOf(element.height).toString());
      idx++;
    }

    return true;
  }
 @Override
 public void onCreateOptionsMenu(Menu menu) {
   if (mActor != null || mGenre != null) {
     menu.add(0, MENU_PLAY_ALL, 0, "Play all").setIcon(R.drawable.menu_album);
   }
   SubMenu sortMenu = menu.addSubMenu(0, MENU_SORT, 0, "Sort").setIcon(R.drawable.menu_sort);
   sortMenu.add(2, MENU_SORT_BY_TITLE_ASC, 0, "by Title ascending");
   sortMenu.add(2, MENU_SORT_BY_TITLE_DESC, 0, "by Title descending");
   sortMenu.add(2, MENU_SORT_BY_YEAR_ASC, 0, "by Year ascending");
   sortMenu.add(2, MENU_SORT_BY_YEAR_DESC, 0, "by Year descending");
   sortMenu.add(2, MENU_SORT_BY_RATING_ASC, 0, "by Rating ascending");
   sortMenu.add(2, MENU_SORT_BY_RATING_DESC, 0, "by Rating descending");
   sortMenu.add(2, MENU_SORT_BY_DATE_ADDED_ASC, 0, "by Date Added ascending");
   sortMenu.add(2, MENU_SORT_BY_DATE_ADDED_DESC, 0, "by Date Added descending");
   //		menu.add(0, MENU_SWITCH_VIEW, 0, "Switch view").setIcon(R.drawable.menu_view);
   createShowHideWatchedToggle(menu);
 }
  /**
   * Prepare the Screen's standard options menu to be displayed. This is called right before the
   * menu is shown, every time it is shown. You can use this method to efficiently enable/disable
   * items or otherwise dynamically modify the contents. See {@link
   * android.app.Activity#onPrepareOptionsMenu(android.view.Menu) Activity.onPrepareOptionsMenu} for
   * more information.
   *
   * @param menu The options menu as last shown or first initialized by onCreateOptionsMenu().
   * @see #setHasOptionsMenu
   * @see #onCreateOptionsMenu
   */
  @Override
  public void onPrepareOptionsMenu(Menu menu) {

    menu.clear();

    MenuItem mItemSearch =
        menu.add(Menu.NONE, MENU_ITEM_SEARCH, Menu.NONE, getString(R.string.search));
    mItemSearch.setIcon(
        new IconDrawable(getActivity(), Iconify.IconValue.fa_search)
            .colorRes(R.color.black)
            .actionBarSize());
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
      mItemSearch.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
    }

    menu.addSubMenu(
        Menu.NONE, MENU_ITEM_DATA_TABLES, Menu.NONE, Constants.DATA_TABLE_SAVINGS_ACCOUNTS_NAME);
    menu.add(
        Menu.NONE, MENU_ITEM_DOCUMENTS, Menu.NONE, getResources().getString(R.string.documents));

    // This is the ID of Each data table which will be used in onOptionsItemSelected Method
    int SUBMENU_ITEM_ID = 0;

    // Create a Sub Menu that holds a link to all data tables
    SubMenu dataTableSubMenu = menu.getItem(1).getSubMenu();
    if (dataTableSubMenu != null
        && savingsAccountDataTables != null
        && savingsAccountDataTables.size() > 0) {
      Iterator<DataTable> dataTableIterator = savingsAccountDataTables.iterator();
      while (dataTableIterator.hasNext()) {
        dataTableSubMenu.add(
            Menu.NONE,
            SUBMENU_ITEM_ID,
            Menu.NONE,
            dataTableIterator.next().getRegisteredTableName());
        SUBMENU_ITEM_ID++;
      }
    }

    super.onPrepareOptionsMenu(menu);
  }
  // region Menu
  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.menu_uart, menu);

    // Mqtt
    mMqttMenuItem = menu.findItem(R.id.action_mqttsettings);
    mMqttMenuItemAnimationHandler = new Handler();
    mMqttMenuItemAnimationRunnable.run();

    // DisplayMode
    MenuItem displayModeMenuItem = menu.findItem(R.id.action_displaymode);
    displayModeMenuItem.setTitle(
        String.format(
            getString(R.string.uart_action_displaymode_format),
            getString(
                mIsTimestampDisplayMode
                    ? R.string.uart_displaymode_timestamp
                    : R.string.uart_displaymode_text)));
    SubMenu displayModeSubMenu = displayModeMenuItem.getSubMenu();
    if (mIsTimestampDisplayMode) {
      MenuItem displayModeTimestampMenuItem =
          displayModeSubMenu.findItem(R.id.action_displaymode_timestamp);
      displayModeTimestampMenuItem.setChecked(true);
    } else {
      MenuItem displayModeTextMenuItem = displayModeSubMenu.findItem(R.id.action_displaymode_text);
      displayModeTextMenuItem.setChecked(true);
    }

    // DataMode
    MenuItem dataModeMenuItem = menu.findItem(R.id.action_datamode);
    dataModeMenuItem.setTitle(
        String.format(
            getString(R.string.uart_action_datamode_format),
            getString(
                mShowDataInHexFormat
                    ? R.string.uart_format_hexadecimal
                    : R.string.uart_format_ascii)));
    SubMenu dataModeSubMenu = dataModeMenuItem.getSubMenu();
    if (mShowDataInHexFormat) {
      MenuItem dataModeHexMenuItem = dataModeSubMenu.findItem(R.id.action_datamode_hex);
      dataModeHexMenuItem.setChecked(true);
    } else {
      MenuItem dataModeAsciiMenuItem = dataModeSubMenu.findItem(R.id.action_datamode_ascii);
      dataModeAsciiMenuItem.setChecked(true);
    }

    // Echo
    MenuItem echoMenuItem = menu.findItem(R.id.action_echo);
    echoMenuItem.setTitle(R.string.uart_action_echo);
    echoMenuItem.setChecked(mIsEchoEnabled);

    // Eol
    MenuItem eolMenuItem = menu.findItem(R.id.action_eol);
    eolMenuItem.setTitle(R.string.uart_action_eol);
    eolMenuItem.setChecked(mIsEolEnabled);

    return true;
  }
 /**
  * @param menu
  * @param activity
  * @param res
  * @return the added menu item (also for a sub menu, then the menu item in the parent menu is
  *     returned)
  */
 public static MenuItem addMenuItems(Menu menu, Activity activity, Resources res) {
   List<CacheListApp> activeApps = new ArrayList<CacheListApp>();
   for (CacheListApp app : getMultiPointNavigationApps()) {
     if (app.isInstalled(activity)) {
       activeApps.add(app);
     }
   }
   // use a new sub menu, if more than one app is available
   if (activeApps.size() > 1) {
     SubMenu subMenu =
         menu.addSubMenu(0, 101, 0, res.getString(R.string.caches_on_map))
             .setIcon(android.R.drawable.ic_menu_mapmode);
     for (CacheListApp app : activeApps) {
       subMenu.add(0, app.getId(), 0, app.getName());
     }
     return subMenu.getItem();
   } else if (activeApps.size() == 1) {
     return menu.add(0, activeApps.get(0).getId(), 0, activeApps.get(0).getName())
         .setIcon(android.R.drawable.ic_menu_mapmode);
   }
   return null;
 }
  @Override
  public boolean onCreateOptionsMenu(Menu menu) {

    // Alternativa 1

    // getMenuInflater().inflate(R.menu.activity_main, menu);

    // Alternativa 2

    menu.add(Menu.NONE, MNU_OPC1, Menu.NONE, "Opcion1")
        .setIcon(android.R.drawable.ic_menu_preferences);

    menu.add(Menu.NONE, MNU_OPC2, Menu.NONE, "Opcion2").setIcon(android.R.drawable.ic_menu_compass);

    SubMenu smnu =
        menu.addSubMenu(Menu.NONE, MNU_OPC1, Menu.NONE, "Opcion3")
            .setIcon(android.R.drawable.ic_menu_agenda);

    smnu.add(Menu.NONE, SMNU_OPC1, Menu.NONE, "Opcion 3.1");
    smnu.add(Menu.NONE, SMNU_OPC2, Menu.NONE, "Opcion 3.2");

    return true;
  }
 /**
  * Fills out the given submenu with items for "new playlist" and any existing playlists. When the
  * user selects an item, the application will receive PLAYLIST_SELECTED with the Uri of the
  * selected playlist, NEW_PLAYLIST if a new playlist should be created, and QUEUE if the "current
  * playlist" was selected.
  *
  * @param context The context to use for creating the menu items
  * @param sub The submenu to add the items to.
  */
 public static void makePlaylistMenu(Context context, SubMenu sub) {
   String[] cols = new String[] {MediaStore.Audio.Playlists._ID, MediaStore.Audio.Playlists.NAME};
   ContentResolver resolver = context.getContentResolver();
   if (resolver == null) {
     System.out.println("resolver = null");
   } else {
     String whereclause = MediaStore.Audio.Playlists.NAME + " != ''";
     Cursor cur =
         resolver.query(
             MediaStore.Audio.Playlists.EXTERNAL_CONTENT_URI,
             cols,
             whereclause,
             null,
             MediaStore.Audio.Playlists.NAME);
     sub.clear();
     sub.add(1, Defs.QUEUE, 0, R.string.queue);
     sub.add(1, Defs.NEW_PLAYLIST, 0, R.string.new_playlist);
     if (cur != null && cur.getCount() > 0) {
       // sub.addSeparator(1, 0);
       cur.moveToFirst();
       while (!cur.isAfterLast()) {
         Intent intent = new Intent();
         intent.putExtra("playlist", cur.getLong(0));
         //                    if (cur.getInt(0) == mLastPlaylistSelected) {
         //                        sub.add(0, MusicBaseActivity.PLAYLIST_SELECTED,
         // cur.getString(1)).setIntent(intent);
         //                    } else {
         sub.add(1, Defs.PLAYLIST_SELECTED, 0, cur.getString(1)).setIntent(intent);
         //                    }
         cur.moveToNext();
       }
     }
     if (cur != null) {
       cur.close();
     }
   }
 }
 @Override
 public boolean onCreateOptionsMenu(Menu menu) {
   MenuItem item;
   item = menu.add(Menu.NONE, MENU_UNDO, Menu.NONE, R.string.undo);
   item.setIcon(R.drawable.ic_menu_revert);
   item = menu.add(Menu.NONE, MENU_REDO, Menu.NONE, R.string.redo);
   item.setIcon(R.drawable.ic_menu_redo);
   item = menu.add(Menu.NONE, MENU_ADD_FACT, Menu.NONE, R.string.add);
   item.setIcon(R.drawable.ic_menu_add);
   item =
       menu.add(
           Menu.NONE, MENU_CHANGE_ORDER, Menu.NONE, R.string.card_browser_change_display_order);
   item.setIcon(R.drawable.ic_menu_sort_by_size);
   item = menu.add(Menu.NONE, MENU_SHOW_MARKED, Menu.NONE, R.string.card_browser_show_marked);
   item.setIcon(R.drawable.ic_menu_star_on);
   SubMenu selectSubMenu =
       menu.addSubMenu(Menu.NONE, MENU_SELECT, Menu.NONE, R.string.card_browser_search);
   selectSubMenu.setIcon(R.drawable.ic_menu_search);
   selectSubMenu.add(
       Menu.NONE, MENU_SELECT_SUSPENDED, Menu.NONE, R.string.card_browser_search_suspended);
   selectSubMenu.add(Menu.NONE, MENU_SELECT_TAG, Menu.NONE, R.string.card_browser_search_by_tag);
   item.setIcon(R.drawable.ic_menu_close_clear_cancel);
   return true;
 }
    public void onPrepareSubMenu(SubMenu submenu)
    {
        submenu.clear();
        cg cg1 = cg.a(c, d);
        android.content.pm.PackageManager packagemanager = c.getPackageManager();
        int k = cg1.a();
        int l = Math.min(k, a);
        for (int i = 0; i < l; i++)
        {
            ResolveInfo resolveinfo = cg1.a(i);
            submenu.add(0, i, i, resolveinfo.loadLabel(packagemanager)).setIcon(resolveinfo.loadIcon(packagemanager)).setOnMenuItemClickListener(b);
        }

        if (l < k)
        {
            submenu = submenu.addSubMenu(0, l, l, c.getString(z.abc_activity_chooser_view_see_all));
            for (int j = 0; j < k; j++)
            {
                ResolveInfo resolveinfo1 = cg1.a(j);
                submenu.add(0, j, j, resolveinfo1.loadLabel(packagemanager)).setIcon(resolveinfo1.loadIcon(packagemanager)).setOnMenuItemClickListener(b);
            }

        }
    }
Example #29
0
 private void buildAddMenu(SubMenu subMenu) {
   subMenu
       .add(getString(R.string.s_Folder))
       .setOnMenuItemClickListener(
           new OnMenuItemClickListener() {
             @Override
             public boolean onMenuItemClick(MenuItem item) {
               menuItemClick(MenuId.FOLDER_ADD.getId());
               return false;
             }
           });
   for (final Entry<Integer, Interpreter> entry : mAddMenuIds.entrySet()) {
     subMenu
         .add(entry.getValue().getNiceName())
         .setOnMenuItemClickListener(
             new OnMenuItemClickListener() {
               @Override
               public boolean onMenuItemClick(MenuItem item) {
                 menuItemClick(entry.getKey());
                 return false;
               }
             });
   }
 }
Example #30
0
 /**
  * Sets up the options menu when the menu button is push, dynamic population of the station select
  * menu
  */
 public boolean onPrepareOptionsMenu(Menu menu) {
   menu.clear();
   boolean result = super.onCreateOptionsMenu(menu);
   SubMenu subMenu = menu.addSubMenu(BASE_OPTION_MENU, FM_BAND, Menu.NONE, R.string.band_select);
   subMenu.setIcon(android.R.drawable.ic_menu_mapmode);
   // Populate the band selection menu
   subMenu.add(BAND_SELECTION_MENU, BAND_US, Menu.NONE, R.string.band_us);
   subMenu.add(BAND_SELECTION_MENU, BAND_EU, Menu.NONE, R.string.band_eu);
   subMenu.add(BAND_SELECTION_MENU, BAND_CHINA, Menu.NONE, R.string.band_ch);
   subMenu.add(BAND_SELECTION_MENU, BAND_JAPAN, Menu.NONE, R.string.band_ja);
   subMenu.setGroupCheckable(BAND_SELECTION_MENU, true, true);
   subMenu.getItem(mSelectedBand).setChecked(true);
   return result;
 }