@Override
    public boolean onPrepareOptionsMenu(final Menu menu) {
        final IConnector connector = null != cache ? ConnectorFactory.getConnector(cache) : null;
        final boolean isUDC = null != connector && connector.equals(InternalConnector.getInstance());

        CacheMenuHandler.onPrepareOptionsMenu(menu, cache, false);
        LoggingUI.onPrepareOptionsMenu(menu, cache);
        MenuUtils.setVisible(menu.findItem(R.id.menu_set_coordinates), isUDC);

        if (cache != null) {
            // top level menu items

            final MenuItem ttsMenuItem = menu.findItem(R.id.menu_tts_toggle);
            ttsMenuItem.setVisible(!cache.isGotoHistoryUDC());
            ToggleItemType.TOGGLE_SPEECH.toggleMenuItem(ttsMenuItem, SpeechService.isRunning());

            if (connector instanceof PgcChallengeCheckerCapability) {
                menu.findItem(R.id.menu_challenge_checker).setVisible(((PgcChallengeCheckerCapability) connector).isChallengeCache(cache));
            }
            menu.findItem(R.id.menu_edit_fieldnote).setVisible(true);

            // submenu waypoints
            menu.findItem(R.id.menu_delete_userdefined_waypoints).setVisible(cache.isOffline() && cache.hasUserdefinedWaypoints());
            menu.findItem(R.id.menu_delete_generated_waypoints).setVisible(cache.isOffline() && cache.hasGeneratedWaypoints());
            menu.findItem(R.id.menu_extract_waypoints).setVisible(!isUDC);
            menu.findItem(R.id.menu_scan_calculated_waypoints).setVisible(!isUDC);
            menu.findItem(R.id.menu_clear_goto_history).setVisible(cache.isGotoHistoryUDC());
            menuItemToggleWaypointsFromNote = menu.findItem(R.id.menu_toggleWaypointsFromNote);
            setMenuPreventWaypointsFromNote(cache.isPreventWaypointsFromNote());
            menuItemToggleWaypointsFromNote.setVisible(!cache.isGotoHistoryUDC());
            menu.findItem(R.id.menu_waypoints).setVisible(true);

            // submenu share / export
            menu.findItem(R.id.menu_export).setVisible(true);

            // submenu advanced
            if (connector instanceof IVotingCapability) {
                final MenuItem menuItemGCVote = menu.findItem(R.id.menu_gcvote);
                menuItemGCVote.setVisible(((IVotingCapability) connector).supportsVoting(cache));
                menuItemGCVote.setEnabled(Settings.isRatingWanted() && Settings.isGCVoteLoginValid());
            }
            if (connector instanceof IIgnoreCapability) {
                menu.findItem(R.id.menu_ignore).setVisible(((IIgnoreCapability) connector).canIgnoreCache(cache));
            }
            menu.findItem(R.id.menu_set_cache_icon).setVisible(cache.isOffline());
            menu.findItem(R.id.menu_advanced).setVisible(cache.getCoords() != null);
        }

        MenuUtils.enableIconsInOverflowMenu(menu);
        MenuUtils.tintToolbarAndOverflowIcons(menu);

        return super.onPrepareOptionsMenu(menu);
    }
waypoint selected in context menu. This variable will be gone when the waypoint context menu is a fragment.
main/src/main/java/cgeo/geocaching/CacheDetailActivity.java