@Override public ContextMenuSubject getSubject(ContextMenu menu, View view, ContextMenuInfo menuInfo) { ContextMenuSubject subject = null; if (!(menuInfo instanceof AdapterView.AdapterContextMenuInfo)) { Log.e(LOGTAG, "menuInfo is not AdapterContextMenuInfo"); return subject; } ListView list = (ListView) view; AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuInfo; subject = ((AwesomeBarItem) list.getItemAtPosition(info.position)).getSubject(); if (subject == null) return subject; MenuInflater inflater = new MenuInflater(mContext); inflater.inflate(R.menu.awesomebar_contextmenu, menu); menu.findItem(R.id.remove_bookmark).setVisible(false); menu.findItem(R.id.edit_bookmark).setVisible(false); menu.findItem(R.id.open_in_reader).setVisible(subject.display == Combined.DISPLAY_READER); // Hide "Remove" item if there isn't a valid history ID if (subject.id < 0) menu.findItem(R.id.remove_history).setVisible(false); menu.setHeaderTitle(subject.title); return subject; }
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); } }
@Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { super.onCreateContextMenu(menu, v, menuInfo); MenuInflater inflater = getActivity().getMenuInflater(); inflater.inflate(R.menu.browse_context, menu); menu.findItem(R.id.browse_context_open).setVisible(isDirectory(menuInfo)); menu.findItem(R.id.browse_context_stream).setVisible(false); }
@Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { super.onCreateContextMenu(menu, v, menuInfo); activity.getMenuInflater().inflate(R.menu.recording_context_menu, menu); (menu.findItem(R.id.menu_play)).setVisible(false); (menu.findItem(R.id.menu_record_cancel)).setVisible(false); // Get the currently selected program from the list where the context // menu has been triggered AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuInfo; SeriesRecording srec = adapter.getItem(info.position); menu.setHeaderTitle(srec.title); }
@Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { AdapterView.AdapterContextMenuInfo i = (AdapterView.AdapterContextMenuInfo) menuInfo; MenuInflater inflater = getMenuInflater(); if (mMostVisited) { inflater.inflate(R.menu.historycontext, menu); } else { inflater.inflate(R.menu.bookmarkscontext, menu); } if (0 == i.position && !mMostVisited) { menu.setGroupVisible(R.id.CONTEXT_MENU, false); if (mAddHeader == null) { mAddHeader = new AddNewBookmark(BrowserBookmarksPage.this); } else if (mAddHeader.getParent() != null) { ((ViewGroup) mAddHeader.getParent()).removeView(mAddHeader); } mAddHeader.setUrl(getIntent().getStringExtra("url")); menu.setHeaderView(mAddHeader); return; } if (mMostVisited) { if ((mViewMode == BookmarkViewMode.LIST && ((HistoryItem) i.targetView).isBookmark()) || mBookmarksAdapter.getIsBookmark(i.position)) { MenuItem item = menu.findItem(R.id.save_to_bookmarks_menu_id); item.setTitle(R.string.remove_from_bookmarks); } } else { // The historycontext menu has no ADD_MENU group. menu.setGroupVisible(R.id.ADD_MENU, false); } if (mDisableNewWindow) { menu.findItem(R.id.new_window_context_menu_id).setVisible(false); } if (mContextHeader == null) { mContextHeader = new BookmarkItem(BrowserBookmarksPage.this); } else if (mContextHeader.getParent() != null) { ((ViewGroup) mContextHeader.getParent()).removeView(mContextHeader); } if (mViewMode == BookmarkViewMode.GRID) { mBookmarksAdapter.populateBookmarkItem(mContextHeader, i.position); } else { BookmarkItem b = (BookmarkItem) i.targetView; b.copyTo(mContextHeader); } menu.setHeaderView(mContextHeader); }
@Override public void onCreateContextMenu(ContextMenu menu, View view, ContextMenuInfo menuInfo) { // Inflate the menu from xml. getMenuInflater().inflate(R.menu.context_menu, menu); // Use the current item to create a custom view for the header. final AdapterContextMenuInfo info = (AdapterContextMenuInfo) menuInfo; final Cursor c = (Cursor) mAlarmsList.getAdapter().getItem(info.position); final Alarm alarm = new Alarm(c); // Construct the Calendar to compute the time. final Calendar cal = Calendar.getInstance(); cal.set(Calendar.HOUR_OF_DAY, alarm.hour); cal.set(Calendar.MINUTE, alarm.minutes); final String time = Alarms.formatTime(this, cal); // Inflate the custom view and set each TextView's text. final View v = mFactory.inflate(R.layout.context_menu_header, null); TextView textView = (TextView) v.findViewById(R.id.header_time); textView.setText(time); textView = (TextView) v.findViewById(R.id.header_label); textView.setText(alarm.label); // Set the custom view on the menu. menu.setHeaderView(v); // Change the text based on the state of the alarm. if (alarm.enabled) { menu.findItem(R.id.enable_alarm).setTitle(R.string.disable_alarm); } }
@Override public void onCreateContextMenu(ContextMenu menu, View view, ContextMenuInfo menuInfo) { // Inflate the menu from xml. getMenuInflater().inflate(R.menu.time_schedule_context_menu, menu); // Use the current item to create a custom view for the header. final AdapterContextMenuInfo info = (AdapterContextMenuInfo) menuInfo; final Cursor c = (Cursor) mScheduleList.getAdapter().getItem((int) info.position); final TimeSchedule schedule = new TimeSchedule(c); // Construct the Calendar to compute the time. final Calendar cal = Calendar.getInstance(); cal.set(Calendar.HOUR_OF_DAY, schedule.hour); cal.set(Calendar.MINUTE, schedule.minutes); final String time = TimeSchedule.formatTime(this, cal); // Inflate the custom view and set each TextView's text. final View v = mInflater.inflate(R.layout.context_menu_header, null); TextView textView = (TextView) v.findViewById(R.id.header_time); textView.setText(time); textView = (TextView) v.findViewById(R.id.header_mode); textView.setText(OBS.getInstance().getModeDbAdapter().getModeNameStr(schedule.modeId)); // Set the custom view on the menu. menu.setHeaderView(v); // Change the text based on the state of the schedule. if (schedule.enabled) { menu.findItem(R.id.enable_schedule).setTitle(R.string.disable_schedule); } }
private void populateContextMenu(ContextMenu menu) { final Message m = this.selectedMessage; if (m.getType() != Message.TYPE_STATUS) { activity.getMenuInflater().inflate(R.menu.message_context, menu); menu.setHeaderTitle(R.string.message_options); MenuItem copyText = menu.findItem(R.id.copy_text); MenuItem shareWith = menu.findItem(R.id.share_with); MenuItem sendAgain = menu.findItem(R.id.send_again); MenuItem copyUrl = menu.findItem(R.id.copy_url); MenuItem downloadFile = menu.findItem(R.id.download_file); MenuItem cancelTransmission = menu.findItem(R.id.cancel_transmission); if ((m.getType() == Message.TYPE_TEXT || m.getType() == Message.TYPE_PRIVATE) && m.getTransferable() == null && !GeoHelper.isGeoUri(m.getBody()) && m.treatAsDownloadable() != Message.Decision.MUST) { copyText.setVisible(true); } if ((m.getType() != Message.TYPE_TEXT && m.getType() != Message.TYPE_PRIVATE && m.getTransferable() == null) || (GeoHelper.isGeoUri(m.getBody()))) { shareWith.setVisible(true); } if (m.getStatus() == Message.STATUS_SEND_FAILED) { sendAgain.setVisible(true); } if (m.hasFileOnRemoteHost() || GeoHelper.isGeoUri(m.getBody()) || m.treatAsDownloadable() == Message.Decision.MUST) { copyUrl.setVisible(true); } if (m.getType() == Message.TYPE_TEXT && m.getTransferable() == null && m.treatAsDownloadable() != Message.Decision.NEVER) { downloadFile.setVisible(true); downloadFile.setTitle( activity.getString( R.string.download_x_file, UIHelper.getFileDescriptionString(activity, m))); } if ((m.getTransferable() != null && !(m.getTransferable() instanceof TransferablePlaceholder)) || (m.isFileOrImage() && (m.getStatus() == Message.STATUS_WAITING || m.getStatus() == Message.STATUS_OFFERED))) { cancelTransmission.setVisible(true); } } }
@Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) { getActivity().getMenuInflater().inflate(R.menu.menu_treeview, menu); AdapterView.AdapterContextMenuInfo adapterInfo = (AdapterView.AdapterContextMenuInfo) menuInfo; long id = adapterInfo.id; TreeNodeInfo<Long> nodeInfo = mTreeStateManager.getNodeInfo(id); if (nodeInfo.isWithChildren()) { if (nodeInfo.isExpanded()) { menu.findItem(R.id.context_menu_expand_item).setVisible(false); menu.findItem(R.id.context_menu_expand_all).setVisible(false); } else { menu.findItem(R.id.context_menu_collapse).setVisible(false); } } else { menu.findItem(R.id.context_menu_expand_item).setVisible(false); menu.findItem(R.id.context_menu_expand_all).setVisible(false); menu.findItem(R.id.context_menu_collapse).setVisible(false); } // hide delete because deleting is dangerous menu.findItem(R.id.context_menu_delete).setVisible(false); super.onCreateContextMenu(menu, v, menuInfo); }
@Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { super.onCreateContextMenu(menu, v, menuInfo); MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.bluemagicset_context, menu); BlueMagicSetView ms; boolean set; ms = (BlueMagicSetView) findViewById(R.id.Magics); set = getFFXICharacter().isBlueMagicSet(ms.getItemId(mLongClickingItemPosition)); MenuItem item; item = menu.findItem(R.id.Remove); if (item != null) item.setEnabled(set); item = menu.findItem(R.id.Set); if (item != null) item.setEnabled(!set); }
@Override public void onCreateContextMenu(ContextMenu menu, View view, ContextMenuInfo menuInfo) { super.onCreateContextMenu(menu, view, menuInfo); selectedLookData = adapter.getItem(selectedLookPosition); menu.setHeaderTitle(selectedLookData.getLookName()); getSherlockActivity().getMenuInflater().inflate(R.menu.context_menu_default, menu); menu.findItem(R.id.context_edit_in_pocket_paint).setVisible(true); }
@Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { View targetView = getTargetView(menuInfo); if (!(targetView instanceof HistoryItem)) { return; } HistoryItem historyItem = (HistoryItem) targetView; // Inflate the menu Activity parent = getActivity(); MenuInflater inflater = parent.getMenuInflater(); inflater.inflate(R.menu.historycontext, menu); // Setup the header if (mContextHeader == null) { mContextHeader = new HistoryItem(parent, false); mContextHeader.setEnableScrolling(true); } else if (mContextHeader.getParent() != null) { ((ViewGroup) mContextHeader.getParent()).removeView(mContextHeader); } historyItem.copyTo(mContextHeader); menu.setHeaderView(mContextHeader); // Only show open in new tab if it was not explicitly disabled if (mDisableNewWindow) { menu.findItem(R.id.new_window_context_menu_id).setVisible(false); } // For a bookmark, provide the option to remove it from bookmarks if (historyItem.isBookmark()) { MenuItem item = menu.findItem(R.id.save_to_bookmarks_menu_id); item.setTitle(R.string.remove_from_bookmarks); } // decide whether to show the share link option PackageManager pm = parent.getPackageManager(); Intent send = new Intent(Intent.ACTION_SEND); send.setType("text/plain"); ResolveInfo ri = pm.resolveActivity(send, PackageManager.MATCH_DEFAULT_ONLY); menu.findItem(R.id.share_link_context_menu_id).setVisible(ri != null); super.onCreateContextMenu(menu, v, menuInfo); }
public ContextMenuSubject getSubject(ContextMenu menu, View view, ContextMenuInfo menuInfo) { ContextMenuSubject subject = null; if (!(menuInfo instanceof ExpandableListView.ExpandableListContextMenuInfo)) { Log.e(LOGTAG, "menuInfo is not ExpandableListContextMenuInfo"); return subject; } ExpandableListView.ExpandableListContextMenuInfo info = (ExpandableListView.ExpandableListContextMenuInfo) menuInfo; int childPosition = ExpandableListView.getPackedPositionChild(info.packedPosition); int groupPosition = ExpandableListView.getPackedPositionGroup(info.packedPosition); // Check if long tap is on a header row if (groupPosition < 0 || childPosition < 0) return subject; ExpandableListView exList = (ExpandableListView) view; // The history list is backed by a SimpleExpandableListAdapter @SuppressWarnings("rawtypes") Map map = (Map) exList.getExpandableListAdapter().getChild(groupPosition, childPosition); subject = new AwesomeBar.ContextMenuSubject( (Integer) map.get(Combined.HISTORY_ID), (String) map.get(URLColumns.URL), (byte[]) map.get(URLColumns.FAVICON), (String) map.get(URLColumns.TITLE), null); MenuInflater inflater = new MenuInflater(mContext); inflater.inflate(R.menu.awesomebar_contextmenu, menu); menu.findItem(R.id.remove_bookmark).setVisible(false); menu.findItem(R.id.edit_bookmark).setVisible(false); menu.findItem(R.id.open_in_reader).setVisible(false); // Hide "Remove" item if there isn't a valid history ID if (subject.id < 0) menu.findItem(R.id.remove_history).setVisible(false); menu.setHeaderTitle(subject.title); return subject; }
/** Add the menu with the tools. It will be shown if the user clicks on "Tools". */ @Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { super.onCreateContextMenu(menu, v, menuInfo); MenuInflater inflater = getMenuInflater(); menu.setHeaderTitle(R.string.dialog_tools_menu_title); menu.setHeaderIcon(android.R.drawable.ic_menu_preferences); inflater.inflate(R.menu.tools, menu); // Enable/Disable tag info tool depending on NFC availability. menu.findItem(R.id.menuMainTagInfo) .setEnabled(Common.getNfcAdapter() != null && Common.getNfcAdapter().isEnabled()); }
public void initializeItem( ContextMenu menu, int id, TGActionProcessorListener actionProcessor, boolean enabled, boolean checked) { MenuItem menuItem = menu.findItem(id); menuItem.setOnMenuItemClickListener(actionProcessor); menuItem.setEnabled(enabled); menuItem.setChecked(checked); }
@Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) { super.onCreateContextMenu(menu, v, menuInfo); final AdapterContextMenuInfo info = (AdapterContextMenuInfo) menuInfo; if (networksFound == null || wifiListAdapter.getCount() <= info.position) return; final WiFiNetwork wiFiNetwork = wifiListAdapter.getItem(info.position).wifiNetwork; if (wiFiNetwork == null) // the list is unstable and it can happen return; MenuInflater inflater = getActivity().getMenuInflater(); inflater.inflate(R.menu.networks_context_menu, menu); // We are copying the values right away as the networks list is // unstable. menu.findItem(R.id.copy_ssid) .setIntent(new Intent().putExtra(MENU_VALUE, wiFiNetwork.getSsidName())); menu.findItem(R.id.copy_mac) .setIntent(new Intent().putExtra(MENU_VALUE, wiFiNetwork.getMacAddress())); menu.findItem(R.id.use_mac) .setIntent(new Intent().putExtra(MENU_VALUE, wiFiNetwork.getMacAddress())); }
@Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) { super.onCreateContextMenu(menu, v, menuInfo); View target = ((AdapterContextMenuInfo) menuInfo).targetView; TextView from = (TextView) target.findViewById(R.id.chat_from); getMenuInflater().inflate(R.menu.chat_contextmenu, menu); if (!from.getText().equals(getString(R.string.chat_from_me))) { menu.findItem(R.id.chat_contextmenu_resend).setEnabled(false); } }
@Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { // Si se ha hecho LongClick sobre la lista. if (v.getId() == R.id.lstAlumnos) { // Obtengo la posición de la lista que se ha pulsado int position = ((AdapterContextMenuInfo) menuInfo).position; // Inflo el menú. this.getMenuInflater().inflate(R.menu.lstalumnos, menu); // Cambio el título de los menús para incluir el nombre del alumno. menu.findItem(R.id.mnuEditar) .setTitle(getString(R.string.editar) + lstAlumnos.getItemAtPosition(position)); menu.findItem(R.id.mnuEliminar) .setTitle(getString(R.string.eliminar) + lstAlumnos.getItemAtPosition(position)); // Establezco el título que se muestra en el encabezado del menú. menu.setHeaderTitle(R.string.elija_una_opcion); } // Llamo al OnCreateContextMenu del padre por si quiere // añadir algún elemento. super.onCreateContextMenu(menu, v, menuInfo); }
@Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { super.onCreateContextMenu(menu, v, menuInfo); AdapterContextMenuInfo info = (AdapterContextMenuInfo) menuInfo; getMenuInflater().inflate(R.menu.folder_context, menu); FolderInfoHolder folder = (FolderInfoHolder) mAdapter.getItem(info.position); menu.setHeaderTitle(folder.displayName); if (!folder.name.equals(mAccount.getTrashFolderName())) menu.findItem(R.id.empty_trash).setVisible(false); if (folder.name.equals(mAccount.getOutboxFolderName())) { menu.findItem(R.id.check_mail).setVisible(false); } else { menu.findItem(R.id.send_messages).setVisible(false); } if (K9.ERROR_FOLDER_NAME.equals(folder.name)) { menu.findItem(R.id.expunge).setVisible(false); } menu.setHeaderTitle(folder.displayName); }
@Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { getMenuInflater().inflate(R.menu.context_bookmark, menu); android.view.MenuItem menuRenameLabel = menu.findItem(R.id.menuRenameLabel); android.view.MenuItem menuDeleteLabel = menu.findItem(R.id.menuDeleteLabel); AdapterContextMenuInfo info = (AdapterContextMenuInfo) menuInfo; if (info.position < 4) { menuRenameLabel.setEnabled(false); menuDeleteLabel.setEnabled(false); } else { menuRenameLabel.setEnabled(true); menuDeleteLabel.setEnabled(true); } }
@Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) { super.onCreateContextMenu(menu, v, menuInfo); MenuItem item = menu.findItem(menu.add(0, v.getId(), 0, "Copy").getItemId()); if (this.characterListAdapter.getCount() < MAX_CHARACTERS) { item.setEnabled(true); } else { // disabled item.setEnabled(false); item.setTitle("Copy (Too many characters)"); } menu.add(0, v.getId(), 1, "Delete"); }
/** * Builds a context menu suitable for the currently playing song. * * <p>Takes the general song context menu, and disables items that make no sense for the song that * is currently playing. * * <p>{@inheritDoc} * * @param menu * @param v * @param menuInfo */ @Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) { super.onCreateContextMenu(menu, v, menuInfo); MenuInflater inflater = getActivity().getMenuInflater(); inflater.inflate(R.menu.songcontextmenu, menu); menu.findItem(R.id.play_now).setVisible(false); menu.findItem(R.id.play_next).setVisible(false); menu.findItem(R.id.add_to_playlist).setVisible(false); menu.findItem(R.id.view_this_album).setVisible(true); menu.findItem(R.id.view_albums_by_song).setVisible(true); menu.findItem(R.id.view_songs_by_artist).setVisible(true); }
/* * (non-Javadoc) * * @see * android.support.v4.app.Fragment#onCreateContextMenu(android.view.ContextMenu * , android.view.View, android.view.ContextMenu.ContextMenuInfo) */ @Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { super.onCreateContextMenu(menu, v, menuInfo); getActivity().getMenuInflater().inflate(R.menu.context_menu_channellist, menu); menu.findItem(R.id.menuSwitch).setVisible(URLUtil.isValidUrl(ServerConsts.DVBVIEWER_URL)); }
@Override public void onCreateContextMenu(ContextMenu menu, View view, ContextMenuInfo menuInfo) { super.onCreateContextMenu(menu, view, menuInfo); ListView list = (ListView) view; mContextMenuSubject = null; if (list == findViewById(R.id.history_list)) { if (!(menuInfo instanceof ExpandableListView.ExpandableListContextMenuInfo)) { Log.e(LOGTAG, "menuInfo is not ExpandableListContextMenuInfo"); return; } ExpandableListView.ExpandableListContextMenuInfo info = (ExpandableListView.ExpandableListContextMenuInfo) menuInfo; int childPosition = ExpandableListView.getPackedPositionChild(info.packedPosition); int groupPosition = ExpandableListView.getPackedPositionGroup(info.packedPosition); // Check if long tap is on a header row if (groupPosition < 0 || childPosition < 0) return; ExpandableListView exList = (ExpandableListView) list; // The history list is backed by a SimpleExpandableListAdapter @SuppressWarnings("rawtypes") Map map = (Map) exList.getExpandableListAdapter().getChild(groupPosition, childPosition); mContextMenuSubject = new ContextMenuSubject( (Integer) map.get(Combined.HISTORY_ID), (String) map.get(URLColumns.URL), (byte[]) map.get(URLColumns.FAVICON), (String) map.get(URLColumns.TITLE), null); } else { if (!(menuInfo instanceof AdapterView.AdapterContextMenuInfo)) { Log.e(LOGTAG, "menuInfo is not AdapterContextMenuInfo"); return; } AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuInfo; Object selectedItem = list.getItemAtPosition(info.position); if (!(selectedItem instanceof Cursor)) { Log.e(LOGTAG, "item at " + info.position + " is not a Cursor"); return; } Cursor cursor = (Cursor) selectedItem; // Don't show the context menu for folders if (!(list == findViewById(R.id.bookmarks_list) && cursor.getInt(cursor.getColumnIndexOrThrow(Bookmarks.TYPE)) == Bookmarks.TYPE_FOLDER)) { String keyword = null; int keywordCol = cursor.getColumnIndex(URLColumns.KEYWORD); if (keywordCol != -1) keyword = cursor.getString(keywordCol); // Use the bookmark id for the Bookmarks tab and the history id for the Top Sites tab int id = (list == findViewById(R.id.bookmarks_list)) ? cursor.getInt(cursor.getColumnIndexOrThrow(Bookmarks._ID)) : cursor.getInt(cursor.getColumnIndexOrThrow(Combined.HISTORY_ID)); mContextMenuSubject = new ContextMenuSubject( id, cursor.getString(cursor.getColumnIndexOrThrow(URLColumns.URL)), cursor.getBlob(cursor.getColumnIndexOrThrow(URLColumns.FAVICON)), cursor.getString(cursor.getColumnIndexOrThrow(URLColumns.TITLE)), keyword); } } if (mContextMenuSubject == null) return; MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.awesomebar_contextmenu, menu); if (list != findViewById(R.id.bookmarks_list)) { menu.findItem(R.id.remove_bookmark).setVisible(false); menu.findItem(R.id.edit_bookmark).setVisible(false); // Hide "Remove" item if there isn't a valid history ID if (mContextMenuSubject.id < 0) menu.findItem(R.id.remove_history).setVisible(false); } else { menu.findItem(R.id.remove_history).setVisible(false); } menu.setHeaderTitle(mContextMenuSubject.title); }