Exemplo n.º 1
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;
 }
Exemplo n.º 2
0
	@Override
	public boolean onPrepareOptionsMenu(Menu menu)
	{
		super.onPrepareOptionsMenu(menu);
		//Log.e("Navit","onPrepareOptionsMenu");
		// this gets called every time the menu is opened!!
		// change menu items here!
		menu.clear();

		// group-id,item-id,sort order number
		//menu.add(1, 1, 100, getString(R.string.optionsmenu_zoom_in)); //TRANS
		//menu.add(1, 2, 200, getString(R.string.optionsmenu_zoom_out)); //TRANS

		menu.add(1, 3, 300, getString(R.string.optionsmenu_download_maps)); //TRANS
		menu.add(1, 5, 400, getString(R.string.optionsmenu_toggle_poi)); //TRANS

		menu.add(1, 6, 500, getString(R.string.optionsmenu_address_search)); //TRANS
		menu.add(1, 10, 600, getString(R.string.optionsmenu_set_map_location));

		menu.add(1, 99, 900, getString(R.string.optionsmenu_exit_navit)); //TRANS
		
		/* Only show the Backup to SD-Card Option if we really have one */
		if(Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED))
		    menu.add(1, 7, 700, getString(R.string.optionsmenu_backup_restore)); //TRANS
		
		return true;
	}
 /*
   // Don't display the share menu item if the result overlay is showing.
   @Override
   public boolean onPrepareOptionsMenu(Menu menu) {
     super.onPrepareOptionsMenu(menu);
     menu.findItem(SHARE_ID).setVisible(lastResult == null);
     return true;
   }
 */
 @Override
 public boolean onPrepareOptionsMenu(Menu menu) {
   super.onPrepareOptionsMenu(menu);
   menu.clear();
   menu.add(0, MENU_QR_HELP, Menu.NONE, "Help").setIcon(R.drawable.menu_about);
   return true;
 }
Exemplo n.º 4
0
  @Override
  /**
   * Initialize the content of the Options menu each time Menu is pressed, based on the current
   * screen.
   */
  public boolean onPrepareOptionsMenu(Menu menu) {
    super.onPrepareOptionsMenu(menu);

    // Remove all the items from the menu.
    menu.clear();

    // Get the focused screen widget.
    ScreenWidget currentScreen = mMoSyncThread.getCurrentScreen();
    if (currentScreen != null) {
      // Get the menu items for that screen.
      List<OptionsMenuItem> items = currentScreen.getMenuItems();
      // Add each menu item to the options menu.
      for (int i = 0; i < items.size(); i++) {
        MenuItem item = menu.add(0, items.get(i).getId(), 0, items.get(i).getTitle());
        if (items.get(i).hasIconFromResources()) {
          item.setIcon(items.get(i).getIconResId());
        } else {
          item.setIcon(items.get(i).getIcon());
        }
      }
      return true;
    }

    return false;
  }
Exemplo n.º 5
0
  @Override
  public boolean onPrepareOptionsMenu(Menu menu) {
    super.onPrepareOptionsMenu(menu);

    engine.toggleDebugMode();
    return true;
  }
Exemplo n.º 6
0
  @Override
  public boolean onPrepareOptionsMenu(Menu menu) {
    Activity activity = getCurrentActivity();

    if (hasContent && activity != null) {
      return activity.onPrepareOptionsMenu(menu);
    } else {
      return super.onPrepareOptionsMenu(menu);
    }
  }
Exemplo n.º 7
0
  public void internalSetProgressBarIndeterminateVisibility(boolean progressBarVisible) {
    setProgressBarIndeterminateVisibility(progressBarVisible);
    this.progressBarVisible = progressBarVisible;

    Activity activity = getCurrentActivity();

    if (activity != null) {
      activity.onPrepareOptionsMenu(null);
    }
  }
  /** Called right before your activity's option menu is displayed. */
  @Override
  public boolean onPrepareOptionsMenu(Menu menu) {
    super.onPrepareOptionsMenu(menu);

    // Before showing the menu, we need to decide whether the clear
    // item is enabled depending on whether there is text to clear.
    menu.findItem(CLEAR_ID).setVisible(mEditor.getText().length() > 0);

    return true;
  }
Exemplo n.º 9
0
  @Override
  public boolean onPrepareOptionsMenu(Menu menu) {
    super.onPrepareOptionsMenu(menu);

    MenuItem itemPause = menu.getItem(0);
    if (gameView.state == GameManager.PAUSE) {
      itemPause.setIcon(R.drawable.resume);
      itemPause.setTitle(R.string.menu_continue);
    } else {
      itemPause.setIcon(R.drawable.pause);
      itemPause.setTitle(R.string.menu_pause);
    }
    return true;
  }
Exemplo n.º 10
0
  @Override
  public boolean onPrepareOptionsMenu(Menu menu) {
    super.onPrepareOptionsMenu(menu);

    try {
      boolean visible = waypoint != null && waypoint.latitude != null && waypoint.longitude != null;
      menu.findItem(MENU_ID_NAVIGATION).setVisible(visible);
      menu.findItem(MENU_ID_COMPASS).setVisible(visible);
      menu.findItem(MENU_ID_CACHES_AROUND).setVisible(visible);
    } catch (Exception e) {
      // nothing
    }

    return true;
  }
Exemplo n.º 11
0
  // ---------------------------------------------------------------------------------------------
  @Override // Method that specifies whether the login or logout option is available. ------------
  public boolean onPrepareOptionsMenu(Menu menu) {
    super.onPrepareOptionsMenu(menu);

    String there_is_no_name = "none";
    SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(MainActivity.this);
    String logged_in_username = sp.getString("username", there_is_no_name);
    if (logged_in_username.equals(there_is_no_name)) {
      menu.findItem(R.id.action_login).setVisible(true);
      menu.findItem(R.id.action_logout).setVisible(false);
    } else {
      menu.findItem(R.id.action_login).setVisible(false);
      menu.findItem(R.id.action_logout).setVisible(true);
    }

    return true;
  }
  @Override
  public void showMenu(final Activity activity, View anchor, int menuResource) {
    PopupMenu popup = new PopupMenu(activity, anchor);

    popup.setOnMenuItemClickListener(
        new PopupMenu.OnMenuItemClickListener() {
          @Override
          public boolean onMenuItemClick(MenuItem menuItem) {
            return activity.onOptionsItemSelected(menuItem);
          }
        });
    MenuInflater inflater = popup.getMenuInflater();
    inflater.inflate(menuResource, popup.getMenu());

    activity.onPrepareOptionsMenu(popup.getMenu());
    popup.show();
  }
Exemplo n.º 13
0
 @Override
 public boolean onPrepareOptionsMenu(Menu m) {
   super.onPrepareOptionsMenu(m);
   boolean showMenu = false;
   if (activeView == viewCaptureNote
       || activeView == viewTagList
       || activeView == viewNoteGallery) {
     m.findItem(R.id.menu_tag_note).setVisible(false);
     m.findItem(R.id.menu_delete_note).setVisible(false);
     showMenu = true;
   } else if (activeView == viewNote) {
     m.findItem(R.id.menu_tag_note).setVisible(true);
     m.findItem(R.id.menu_delete_note).setVisible(true);
     showMenu = true;
   }
   return showMenu;
 }
Exemplo n.º 14
0
  @Override
  public boolean onPrepareOptionsMenu(Menu menu) {

    super.onPrepareOptionsMenu(menu);

    if (mListView != null) {
      final boolean haveItems = mListView.getCount() > 0;

      if (menu.findItem(MENU_ITEM_BIBLEVIEW) != null)
        menu.findItem(MENU_ITEM_BIBLEVIEW).setVisible(haveItems);
      if (menu.findItem(MENU_ITEM_EDITNOTE) != null)
        menu.findItem(MENU_ITEM_EDITNOTE).setVisible(haveItems);
      if (menu.findItem(MENU_ITEM_DELNOTE) != null)
        menu.findItem(MENU_ITEM_DELNOTE).setVisible(haveItems);
    }
    return true;
  }
  @Override
  public boolean onPrepareOptionsMenu(Menu menu) {
    super.onPrepareOptionsMenu(menu);

    String[] toList = new String[] {mAddress.getText().toString()};

    // IntentBuilder をインスタンス化
    ShareCompat.IntentBuilder builder = ShareCompat.IntentBuilder.from(CustomSendActivity.this);
    // データをセットする
    builder.setChooserTitle("Choose Send App");
    builder.setEmailTo(toList);
    builder.setSubject(mSubject.getText().toString());
    builder.setText(mMessage.getText().toString());
    builder.setType("text/plain");

    ShareCompat.configureMenuItem(menu, R.id.menu_share, builder);

    return true;
  }
Exemplo n.º 16
0
  @Override
  public boolean onPrepareOptionsMenu(Menu menu) {
    super.onPrepareOptionsMenu(menu);

    if (mSettings.isLoggedIn()) {
      menu.findItem(R.id.user_profile_menu_id).setVisible(true);
      menu.findItem(R.id.user_profile_menu_id)
          .setTitle(
              String.format(
                  getResources().getString(R.string.user_profile), mSettings.getUsername()));
    } else {
      menu.findItem(R.id.user_profile_menu_id).setVisible(false);
    }

    MenuItem src, dest;
    src =
        Util.isLightTheme(mSettings.getTheme())
            ? menu.findItem(R.id.dark_menu_id)
            : menu.findItem(R.id.light_menu_id);
    dest = menu.findItem(R.id.light_dark_menu_id);
    dest.setTitle(src.getTitle());
    return true;
  }
Exemplo n.º 17
0
 @Override
 public boolean onPrepareOptionsMenu(android.view.Menu menu) {
   super.onPrepareOptionsMenu(menu);
   processBA.runHook("onprepareoptionsmenu", this, new Object[] {menu});
   return true;
 }
Exemplo n.º 18
0
  @Override
  public boolean onPrepareOptionsMenu(Menu menu) {
    super.onPrepareOptionsMenu(menu);

    return true;
  }
Exemplo n.º 19
0
 // Don't display the share menu item if the result overlay is showing.
 @Override
 public boolean onPrepareOptionsMenu(Menu menu) {
   super.onPrepareOptionsMenu(menu);
   menu.findItem(SHARE_ID).setVisible(lastResult == null);
   return true;
 }
 /**
  * Prepare menu contents. Hide or show "Clear find results" menu item depending on whether we're
  * in find mode.
  *
  * @param menu menu that should be prepared
  */
 @Override
 public boolean onPrepareOptionsMenu(Menu menu) {
   super.onPrepareOptionsMenu(menu);
   this.clearFindTextMenuItem.setVisible(this.pagesView.getFindMode());
   return true;
 }
Exemplo n.º 21
0
  @Override
  public boolean onPrepareOptionsMenu(Menu menu) {
    super.onPrepareOptionsMenu(menu);

    final FragmentManager fm = getFragmentManager();

    final RootInfo root = getCurrentRoot();
    final DocumentInfo cwd = getCurrentDirectory();

    final MenuItem createDir = menu.findItem(R.id.menu_create_dir);
    final MenuItem search = menu.findItem(R.id.menu_search);
    final MenuItem sort = menu.findItem(R.id.menu_sort);
    final MenuItem sortSize = menu.findItem(R.id.menu_sort_size);
    final MenuItem grid = menu.findItem(R.id.menu_grid);
    final MenuItem list = menu.findItem(R.id.menu_list);
    final MenuItem advanced = menu.findItem(R.id.menu_advanced);
    final MenuItem fileSize = menu.findItem(R.id.menu_file_size);

    sort.setVisible(cwd != null);
    grid.setVisible(mState.derivedMode != MODE_GRID);
    list.setVisible(mState.derivedMode != MODE_LIST);

    if (mState.currentSearch != null) {
      // Search uses backend ranking; no sorting
      sort.setVisible(false);

      search.expandActionView();

      mSearchView.setIconified(false);
      mSearchView.clearFocus();
      mSearchView.setQuery(mState.currentSearch, false);
    } else {
      mIgnoreNextClose = true;
      mSearchView.setIconified(true);
      mSearchView.clearFocus();

      mIgnoreNextCollapse = true;
      search.collapseActionView();
    }

    // Only sort by size when visible
    sortSize.setVisible(mState.showSize);

    final boolean searchVisible;
    if (mState.action == ACTION_CREATE || mState.action == ACTION_OPEN_TREE) {
      createDir.setVisible(cwd != null && cwd.isCreateSupported());
      searchVisible = false;

      // No display options in recent directories
      if (cwd == null) {
        grid.setVisible(false);
        list.setVisible(false);
      }

      if (mState.action == ACTION_CREATE) {
        /// M: add to avoid seldom NullPointerException
        SaveFragment saveFragment = SaveFragment.get(fm);
        if (null != saveFragment) {
          saveFragment.setSaveEnabled(cwd != null && cwd.isCreateSupported());
        } else {
          Log.e(TAG, "onPrepareOptionsMenu, SaveFragment is null");
        }
      }
    } else {
      createDir.setVisible(false);

      searchVisible = root != null && ((root.flags & Root.FLAG_SUPPORTS_SEARCH) != 0);
    }

    // TODO: close any search in-progress when hiding
    search.setVisible(searchVisible);

    advanced.setTitle(
        LocalPreferences.getDisplayAdvancedDevices(this)
            ? R.string.menu_advanced_hide
            : R.string.menu_advanced_show);
    fileSize.setTitle(
        LocalPreferences.getDisplayFileSize(this)
            ? R.string.menu_file_size_hide
            : R.string.menu_file_size_show);

    /// M: If in force show advance mode, need hide advance menu
    advanced.setVisible(mState.action != ACTION_MANAGE && !mState.forceAdvanced);
    /// M: If cmd == null and mState.action == ACTION_CREATE, it means show
    /// RecentsCreateFragment, we need hide file size menu to avoid exception
    fileSize.setVisible(
        mState.action != ACTION_MANAGE && !(cwd == null && mState.action == ACTION_CREATE));

    return true;
  }