Java Code Examples for android.view.Menu#removeItem()

The following examples show how to use android.view.Menu#removeItem() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SelectActionModeCallback.java    From android-chromium with BSD 2-Clause "Simplified" License 6 votes vote down vote up
private void createActionMenu(ActionMode mode, Menu menu) {
    mode.getMenuInflater().inflate(R.menu.select_action_menu, menu);
    if (!mEditable || !canPaste()) {
        menu.removeItem(R.id.select_action_menu_paste);
    }

    if (!mEditable) {
        menu.removeItem(R.id.select_action_menu_cut);
    }

    if (mEditable || !mActionHandler.isShareAvailable()) {
        menu.removeItem(R.id.select_action_menu_share);
    }

    if (mEditable || mIncognito || !mActionHandler.isWebSearchAvailable()) {
        menu.removeItem(R.id.select_action_menu_web_search);
    }
}
 
Example 2
Source File: ActivityMain.java    From NetGuard with GNU General Public License v3.0 6 votes vote down vote up
@Override
public boolean onPrepareOptionsMenu(Menu menu) {
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);

    if (prefs.getBoolean("manage_system", false)) {
        menu.findItem(R.id.menu_app_user).setChecked(prefs.getBoolean("show_user", true));
        menu.findItem(R.id.menu_app_system).setChecked(prefs.getBoolean("show_system", false));
    } else {
        Menu submenu = menu.findItem(R.id.menu_filter).getSubMenu();
        submenu.removeItem(R.id.menu_app_user);
        submenu.removeItem(R.id.menu_app_system);
    }

    menu.findItem(R.id.menu_app_nointernet).setChecked(prefs.getBoolean("show_nointernet", true));
    menu.findItem(R.id.menu_app_disabled).setChecked(prefs.getBoolean("show_disabled", true));

    String sort = prefs.getString("sort", "name");
    if ("uid".equals(sort))
        menu.findItem(R.id.menu_sort_uid).setChecked(true);
    else
        menu.findItem(R.id.menu_sort_name).setChecked(true);

    menu.findItem(R.id.menu_lockdown).setChecked(prefs.getBoolean("lockdown", false));

    return super.onPrepareOptionsMenu(menu);
}
 
Example 3
Source File: MovieActivity.java    From android with Apache License 2.0 6 votes vote down vote up
@Override
public boolean onPrepareOptionsMenu(Menu menu) {

    if (AppUtils.isFavorite(this, mTitle)) {
        menu.findItem(R.id.action_star).setIcon(R.drawable.ic_action_starred);
    } else {
        menu.findItem(R.id.action_star).setIcon(R.drawable.ic_action_unstarred);
    }
    if (AppUtils.isChromecastPluginInstalled(this)) {
        menu.removeItem(R.id.cast_upgrade);
    }
    if (!AppUtils.isChromecastPluginInstalled(this)) {
        menu.removeItem(R.id.media_route_menu_item);

    }
    if (AppUtils.isPremiumInstalled(this)) {
        menu.removeItem(R.id.action_upgrade);
    }
    return super.onPrepareOptionsMenu(menu);
}
 
Example 4
Source File: LibraryFragment.java    From Orin with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    super.onCreateOptionsMenu(menu, inflater);
    if (pager == null) return;
    inflater.inflate(R.menu.menu_main, menu);
    if (isPlaylistPage()) {
        menu.add(0, R.id.action_new_playlist, 0, R.string.new_playlist_title);
    }
    Fragment currentFragment = getCurrentFragment();
    if (currentFragment instanceof AbsLibraryPagerRecyclerViewCustomGridSizeFragment && currentFragment.isAdded()) {
        AbsLibraryPagerRecyclerViewCustomGridSizeFragment absLibraryRecyclerViewCustomGridSizeFragment = (AbsLibraryPagerRecyclerViewCustomGridSizeFragment) currentFragment;

        menu.findItem(R.id.action_colored_footers).setChecked(absLibraryRecyclerViewCustomGridSizeFragment.usePalette());
        menu.findItem(R.id.action_colored_footers).setEnabled(absLibraryRecyclerViewCustomGridSizeFragment.canUsePalette());
    } else {
        menu.removeItem(R.id.action_colored_footers);
    }
    Activity activity = getActivity();
    if (activity == null) return;
    ToolbarContentTintHelper.handleOnCreateOptionsMenu(getActivity(), toolbar, menu, ATHToolbarActivity.getToolbarBackgroundColor(toolbar));
}
 
Example 5
Source File: NotesFragment.java    From writeily-pro with MIT License 5 votes vote down vote up
private void showRenameContextButton(Menu menu, boolean show) {
    if (show) {
        menu.add(Menu.FIRST+1, RENAME_CONTEXT_BUTTON_ID,Menu.FIRST,R.string.rename)
                .setIcon(R.drawable.ic_edit_light);

    } else {
        menu.setGroupVisible(1, false);
        menu.removeItem(RENAME_CONTEXT_BUTTON_ID);
    };
}
 
Example 6
Source File: StoreFragment.java    From aptoide-client-v8 with GNU General Public License v3.0 5 votes vote down vote up
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
  super.onCreateOptionsMenu(menu, inflater);
  if (hasSearchFromStoreFragment()) {
    inflater.inflate(R.menu.fragment_store, menu);

    final MenuItem menuItem = menu.findItem(R.id.menu_item_search);
    if (appSearchSuggestionsView != null && menuItem != null) {
      appSearchSuggestionsView.initialize(menuItem);
    } else if (menuItem != null) {
      menuItem.setVisible(false);
    } else {
      menu.removeItem(R.id.menu_item_search);
    }
  }
}
 
Example 7
Source File: ArtistDetailActivity.java    From RetroMusicPlayer with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.menu_artist_detail, menu);
    menu.removeItem(R.id.action_sort_order);
    //setUpSortOrderMenu(sortOrder.getSubMenu());
    return true;
}
 
Example 8
Source File: LibraryFragment.java    From Phonograph with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    super.onCreateOptionsMenu(menu, inflater);
    if (pager == null) return;
    inflater.inflate(R.menu.menu_main, menu);
    if (isPlaylistPage()) {
        menu.add(0, R.id.action_new_playlist, 0, R.string.new_playlist_title);
    }
    Fragment currentFragment = getCurrentFragment();
    if (currentFragment instanceof AbsLibraryPagerRecyclerViewCustomGridSizeFragment && currentFragment.isAdded()) {
        AbsLibraryPagerRecyclerViewCustomGridSizeFragment absLibraryRecyclerViewCustomGridSizeFragment = (AbsLibraryPagerRecyclerViewCustomGridSizeFragment) currentFragment;

        MenuItem gridSizeItem = menu.findItem(R.id.action_grid_size);
        if (Util.isLandscape(getResources())) {
            gridSizeItem.setTitle(R.string.action_grid_size_land);
        }
        setUpGridSizeMenu(absLibraryRecyclerViewCustomGridSizeFragment, gridSizeItem.getSubMenu());

        menu.findItem(R.id.action_colored_footers).setChecked(absLibraryRecyclerViewCustomGridSizeFragment.usePalette());
        menu.findItem(R.id.action_colored_footers).setEnabled(absLibraryRecyclerViewCustomGridSizeFragment.canUsePalette());

        setUpSortOrderMenu(absLibraryRecyclerViewCustomGridSizeFragment, menu.findItem(R.id.action_sort_order).getSubMenu());
    } else {
        menu.removeItem(R.id.action_grid_size);
        menu.removeItem(R.id.action_colored_footers);
        menu.removeItem(R.id.action_sort_order);
    }
    Activity activity = getActivity();
    if (activity == null) return;
    ToolbarContentTintHelper.handleOnCreateOptionsMenu(getActivity(), toolbar, menu, ATHToolbarActivity.getToolbarBackgroundColor(toolbar));
}
 
Example 9
Source File: NoteEditFragment.java    From Notepad with Apache License 2.0 5 votes vote down vote up
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    inflater.inflate(R.menu.note_edit, menu);

    if(listener.isShareIntent() && Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        menu.removeItem(R.id.action_export);
        menu.removeItem(R.id.action_print);
    }
}
 
Example 10
Source File: TileOrderActivity.java    From GravityBox with Apache License 2.0 5 votes vote down vote up
private void updateMenu(Menu menu) {
    if (supportsDualMode()) {
        menu.findItem(R.id.tile_dual).setChecked(dual);
    } else {
        menu.removeItem(R.id.tile_dual);
    }
    MenuItem miLocked = menu.findItem(R.id.tile_locked);
    MenuItem miLockedOnly = menu.findItem(R.id.tile_locked_only);
    MenuItem miSecured = menu.findItem(R.id.tile_secured);
    miLocked.setChecked(!locked);
    miLockedOnly.setChecked(lockedOnly);
    miLockedOnly.setEnabled(!locked);
    miSecured.setChecked(!secured && !"gb_tile_lock_screen".equals(key));
    miSecured.setEnabled(!locked && !"gb_tile_lock_screen".equals(key));
}
 
Example 11
Source File: ChannelDetailActivity.java    From zapp with MIT License 5 votes vote down vote up
@Override
public boolean onCreateOptionsMenu(Menu menu) {
	getMenuInflater().inflate(R.menu.activity_channel_detail, menu);

	if (!MultiWindowHelper.supportsPictureInPictureMode(this)) {
		menu.removeItem(R.id.menu_pip);
	}

	return super.onCreateOptionsMenu(menu);
}
 
Example 12
Source File: MainActivity.java    From LiTr with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.main, menu);
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
        // TODO implement these for pre-Marshmallow devices, if possible
        menu.removeItem(R.id.codec_list);
        menu.removeItem(R.id.avc_encoders);
        menu.removeItem(R.id.avc_decoders);
    }
    return true;
}
 
Example 13
Source File: MessageInfoFragment.java    From Applozic-Android-SDK with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    super.onCreateOptionsMenu(menu, inflater);
    menu.findItem(R.id.dial).setVisible(false);
    menu.removeItem(R.id.start_new);
    menu.removeItem(R.id.conversations);
    menu.removeItem(R.id.deleteConversation);
    menu.removeItem(R.id.refresh);

}
 
Example 14
Source File: LibraryFragment.java    From Music-Player with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    super.onCreateOptionsMenu(menu, inflater);
    if (pager == null) return;
    inflater.inflate(R.menu.menu_main, menu);
    if (isPlaylistPage()) {
        menu.add(0, R.id.action_new_playlist, 0, R.string.new_playlist_title);
    }
    Fragment currentFragment = getCurrentFragment();
    if (currentFragment instanceof AbsLibraryPagerRecyclerViewCustomGridSizeFragment && currentFragment.isAdded()) {
        AbsLibraryPagerRecyclerViewCustomGridSizeFragment absLibraryRecyclerViewCustomGridSizeFragment = (AbsLibraryPagerRecyclerViewCustomGridSizeFragment) currentFragment;

        MenuItem gridSizeItem = menu.findItem(R.id.action_grid_size);
        if (Util.isLandscape(getResources())) {
            gridSizeItem.setTitle(R.string.action_grid_size_land);
        }
        setUpGridSizeMenu(absLibraryRecyclerViewCustomGridSizeFragment, gridSizeItem.getSubMenu());

        menu.findItem(R.id.action_colored_footers).setChecked(absLibraryRecyclerViewCustomGridSizeFragment.usePalette());
        menu.findItem(R.id.action_colored_footers).setEnabled(absLibraryRecyclerViewCustomGridSizeFragment.canUsePalette());

        setUpSortOrderMenu(absLibraryRecyclerViewCustomGridSizeFragment, menu.findItem(R.id.action_sort_order).getSubMenu());
    } else {
        menu.removeItem(R.id.action_grid_size);
        menu.removeItem(R.id.action_colored_footers);
        menu.removeItem(R.id.action_sort_order);
    }
    Activity activity = getActivity();
    if (activity == null) return;
    ToolbarContentTintHelper.handleOnCreateOptionsMenu(getActivity(), toolbar, menu, ATHToolbarActivity.getToolbarBackgroundColor(toolbar));
}
 
Example 15
Source File: ComposeActivity.java    From bitseal with GNU General Public License v3.0 5 votes vote down vote up
@Override
  public boolean onPrepareOptionsMenu(Menu menu)
  {
  	SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
  	if (prefs.getBoolean(KEY_DATABASE_PASSPHRASE_SAVED, false) == false)
{
	menu.removeItem(R.id.menu_item_lock);
}
      return super.onPrepareOptionsMenu(menu);
  }
 
Example 16
Source File: MenuDescriptor.java    From 365browser with Apache License 2.0 5 votes vote down vote up
public void apply(Menu menu) {
    for (int id : mRemoved) {
        menu.removeItem(id);
    }

    for (Map.Entry<Integer, ItemDescriptor> entry : mAdded.entrySet()) {
        ItemDescriptor descr = entry.getValue();
        MenuItem item = menu.add(descr.mGroupId, descr.mItemId, descr.mOrder, descr.mTitle);
        if (descr.mIcon != null) item.setIcon(descr.mIcon);
    }
}
 
Example 17
Source File: EntryGridAdapter.java    From Audinaut with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onCreateActionModeMenu(Menu menu, MenuInflater menuInflater) {
    if (Util.isOffline(context)) {
        menuInflater.inflate(R.menu.multiselect_media_offline, menu);
    } else {
        menuInflater.inflate(R.menu.multiselect_media, menu);
    }

    if (!removeFromPlaylist) {
        menu.removeItem(R.id.menu_remove_playlist);
    }
}
 
Example 18
Source File: ColorDetailActivityFlavor.java    From CameraColorPicker with Apache License 2.0 5 votes vote down vote up
/**
 * Called when {@link ColorDetailActivity#onCreateOptionsMenu(Menu)} is called.
 *
 * @param menu the {@link Menu} created.
 */
/* package */
static void onCreateOptionsMenu(Menu menu) {
    // For the kid version, hide the edit and share menu items.
    menu.removeItem(R.id.menu_color_detail_action_edit);
    menu.removeItem(R.id.menu_color_detail_action_share);
}
 
Example 19
Source File: SelectDirectoryFragment.java    From Audinaut with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onCreateContextMenu(Menu menu, MenuInflater menuInflater, UpdateView updateView, Entry entry) {
    onCreateContextMenuSupport(menu, menuInflater, updateView, entry);
    if (!Util.isOffline(context) && (playlistId == null || !playlistOwner)) {
        menu.removeItem(R.id.song_menu_remove_playlist);
    }

    recreateContextMenu(menu);
}
 
Example 20
Source File: PostFragment.java    From SmileEssence with MIT License 4 votes vote down vote up
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    super.onCreateOptionsMenu(menu, inflater);
    menu.removeItem(R.id.actionbar_post);
    showIME();
}