Skip to content

IDE-28: Add "Your Functions" Button to Formula Editor Keyboard#5172

Draft
harshsomankar123-tech wants to merge 5 commits intoCatrobat:developfrom
harshsomankar123-tech:feature/IDE-28-your-functions
Draft

IDE-28: Add "Your Functions" Button to Formula Editor Keyboard#5172
harshsomankar123-tech wants to merge 5 commits intoCatrobat:developfrom
harshsomankar123-tech:feature/IDE-28-your-functions

Conversation

@harshsomankar123-tech
Copy link
Copy Markdown
Member

@harshsomankar123-tech harshsomankar123-tech commented Mar 27, 2026

Description

This PR implements a "Your functions" button within the Formula Editor's keyboard. This allows users to insert user-defined reporter functions (UserDefinedBricks containing a ReportBrick) directly into their formulas.

Scope of this initial implementation:

  • The button is only visible when FEATURE_USER_REPORTERS_ENABLED is true (currently enabled in debug builds).
  • Selecting a function inserts a call to USER_DEFINED_BRICK_FUNCTION using the brick's UUID, placing 0 as the default value for any inputs.
  • Note: Evaluation of these functions currently returns 0.0. The actual evaluation logic is out of scope for this PR and will be handled in a subsequent task (CATROID-909).

Changes

UI / UX

  • Formula Keyboard: Added formula_editor_keyboard_your_functions button in the second row of category buttons.
  • Category List: Created a new "Your functions" category in [Insert Class/View Name] that dynamically lists reporter user-defined bricks present in the current sprite.
  • Display Format: List items are formatted as label input label(0, 0, ...) where 0 placeholders represent inputs.

Formula Engine

  • Enum Extension: Added USER_DEFINED_BRICK_FUNCTION to the Functions enum.
  • Token Adaptation: Enhanced [Insert Class Name] to support building token lists for UUID-based user-defined function calls.
  • Interpretation: Updated [Insert Class Name] to recognize and interpret the new function type (temporarily hardcoded to return 0.0).

Build & Config

  • Feature Flagging: Guarded the new button and its underlying logic with BuildConfig.FEATURE_USER_REPORTERS_ENABLED.
  • String Resources: Added formula_editor_your_functions for localization.

Verification

Automated Tests

  • ParserFunctionTest.java: Added [Insert Method Name] to verify that the formula parser correctly recognizes the new user-defined function type and safely returns 0.0.

Manual Testing Steps

  1. Create a User-Defined Brick (UDB) with a "Report" brick.
  2. Open the Formula Editor.
  3. Tap "Your functions" on the keyboard.
  4. Verify the list correctly displays the UDB reporter.
  5. Verify that selecting it inserts the function call into the editor with correct formatting.
  6. Verify the "Calculate" button evaluates the formula to 0.

checklist for this pull request

Please review the contributing guidelines and wiki pages of this repository.

  • Include the name of the Jira ticket in the PR’s title
  • Include a summary of the changes plus the relevant context
  • Choose the proper base branch (develop)
  • Confirm that the changes follow the project’s coding guidelines
  • Verify that the changes generate no compiler or linter warnings
  • Perform a self-review of the changes
  • Verify to commit no other files than the intentionally changed ones
  • Include reasonable and readable tests verifying the added or changed behavior
  • Confirm that new and existing unit tests pass locally
  • Check that the commits’ message style matches the project’s guideline
  • Stick to the project’s gitflow workflow
  • Verify that your changes do not have any conflicts with the base branch
  • After the PR, verify that all CI checks have passed
  • Post a message in the catroid-stage or catroid-ide Slack channel and ask for a code reviewer

@sonarqubecloud
Copy link
Copy Markdown

import android.view.View;
import android.view.ViewGroup;

import org.catrobat.catroid.BuildConfig;
case R.id.formula_editor_keyboard_functional_button_toggle:
toggleFunctionalButtons();
return true;
case R.id.formula_editor_keyboard_your_functions:
@harshsomankar123-tech harshsomankar123-tech marked this pull request as draft April 5, 2026 21:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants