public static void showSelectFunctionDialog(final Context context, final TextView formulaView, final Consumer<String> newFormulaConsumer) {

        final List<FormulaFunction> functions = FormulaFunction.valuesAsUserDisplaySortedList();

        final SimpleDialog.ItemSelectModel<FormulaFunction> model = new SimpleDialog.ItemSelectModel<>();
        model
            .setItems(functions)
            .setDisplayMapper(FormulaUtils::getFunctionDisplayString)
            .setChoiceMode(SimpleItemListModel.ChoiceMode.SINGLE_PLAIN);

        model.activateGrouping(FormulaFunction::getGroup)
                .setGroupDisplayMapper(gi -> FormulaUtils.getFunctionGroupDisplayString(gi.getGroup()))
                .setGroupComparator(CommonUtils.getTextSortingComparator(FormulaFunction.FunctionGroup::getUserDisplayableString), true);

        SimpleDialog.ofContext(context).setTitle(TextParam.id(R.string.formula_choose_function))
            .selectSingle(model, f -> {
                if (formulaView != null) {
                    final String current = formulaView.getText().toString();
                    final int currentPos = formulaView.getSelectionStart();

                    final String function = f.getFunctionInsertString();
                    final int functionPos = f.getFunctionInsertCursorPosition();

                    final String newFormula = current.substring(0, currentPos) + function + current.substring(currentPos);
                    final int newPos = currentPos + functionPos;

                    formulaView.setText(newFormula);
                    if (formulaView instanceof EditText) {
                        ((EditText) formulaView).setSelection(newPos);
                    }
                    Keyboard.show(context, formulaView);
                }
            });
    }
Shows a function selection dialog, and upon user selection pastes the function into the formula field given by 'formulaView'
main/src/main/java/cgeo/geocaching/utils/formulas/FormulaUtils.java