@SuppressWarnings({"PMD.NPathComplexity", "PMD.ExcessiveMethodLength"})
    private void showContextOptions(final ImageGalleryEntry imgData, final ImageGalleryImageBinding binding) {
        if (activity == null || imgData == null || imgData.image == null) {
            return;
        }
        final String category = imgData.category;
        final Image img = imgData.image;

        final int intentPos = this.binding.imagegalleryList.getChildAdapterPosition(binding.getRoot());

        final ContextMenuDialog ctxMenu = new ContextMenuDialog(activity);
        ctxMenu.setTitle(LocalizationUtils.getString(R.string.cache_image));

        ctxMenu.addItem(LocalizationUtils.getString(R.string.cache_image_open), R.drawable.ic_menu_image,
                v -> openImageDetails(imgData, binding));

        ctxMenu.addItem(LocalizationUtils.getString(R.string.cache_image_open_file), R.drawable.ic_menu_image,
                v -> ImageUtils.viewImageInStandardApp(activity, img.getUri(), geocode));

        if (!UriUtils.isFileUri(img.getUri()) && !UriUtils.isContentUri(img.getUri())) {
            ctxMenu.addItem(LocalizationUtils.getString(R.string.cache_image_open_browser), R.drawable.ic_menu_open_in_browser,
                    v -> ShareUtils.openUrl(context, img.getUrl(), false));
        }
        if (img.hasDescription()) {
            ctxMenu.addItem(LocalizationUtils.getString(R.string.cache_image_show_description), R.drawable.ic_menu_hint,
                    v -> SimpleDialog.ofContext(getContext()).setTitle(R.string.log_image_description)
                            .setMessage(TextParam.text(img.getDescription()).setHtml(true)).show());
        }
        final Geopoint gp = imageCoordMap.get(img.getUrl());
        if (gp != null && geocode != null) {
            ctxMenu.addItem(LocalizationUtils.getString(R.string.cache_image_add_waypoint), R.drawable.ic_menu_myposition, v -> {
                final Geocache geocache = DataStore.loadCache(geocode, LoadFlags.LOAD_CACHE_OR_DB);
                if (geocache != null) {
                    final Waypoint waypoint = new Waypoint(img.getTitle(), WaypointType.WAYPOINT, true);
                    waypoint.setCoords(gp);
                    geocache.addOrChangeWaypoint(waypoint, true);
                    GeocacheChangedBroadcastReceiver.sendBroadcast(activity, geocode);
                }
            });
            ctxMenu.addItem(LocalizationUtils.getString(R.string.cache_menu_navigate), R.drawable.ic_menu_navigate,
                    v -> NavigationAppFactory.showNavigationMenu(activity, null, null, gp));
        }

        final EditableCategoryHandler editHandler = editableCategoryHandlerMap.get(category);
        if (editHandler != null) {

            final Image oldImg = adapter.getItem(intentPos).image;
            ctxMenu.addItem(LocalizationUtils.getString(R.string.cache_image_rename), R.drawable.ic_menu_edit, v -> SimpleDialog.ofContext(getContext()).setTitle(TextParam.id(R.string.cache_image_rename))
                    .input(new SimpleDialog.InputOptions().setInitialValue(oldImg.getTitle()), newTitle -> {
                    if (!StringUtils.isBlank(newTitle)) {
                        final Image newImg = editHandler.setTitle(oldImg, newTitle);
                        if (newImg != null) {
                            final ImageGalleryEntry oldEntry = adapter.getItem(intentPos);
                            adapter.updateItem(new ImageGalleryEntry(oldEntry.category, newImg), intentPos);
                        }
                    }
                }));

            ctxMenu.addItem(LocalizationUtils.getString(R.string.cache_image_delete), R.drawable.ic_menu_delete, v -> {
                final ImageGalleryEntry oldEntry = adapter.getItem(intentPos);
                adapter.removeItem(intentPos);
                editHandler.delete(img);
                categorizedImageListHelper.addToCount(oldEntry.category, -1);
                changeImageCount(-1);
            });
        }
        ctxMenu.show();
    }
allows the gallery to open a image detail view (again)
main/src/main/java/cgeo/geocaching/ui/ImageGalleryView.java