From 17b6bc63c5392bb488d014925e9809983282ba8e Mon Sep 17 00:00:00 2001 From: Daniel Morais Date: Thu, 25 Apr 2024 17:06:50 +0200 Subject: [PATCH] Keep pointer for nbgl_layoutAddKeypad (LNX/LNS+) --- lib_nbgl/include/nbgl_layout.h | 6 +++++- lib_nbgl/src/nbgl_layout_keypad_nanos.c | 23 +++++++++++++++-------- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/lib_nbgl/include/nbgl_layout.h b/lib_nbgl/include/nbgl_layout.h index a294f82df..8a76b05da 100644 --- a/lib_nbgl/include/nbgl_layout.h +++ b/lib_nbgl/include/nbgl_layout.h @@ -666,11 +666,15 @@ int nbgl_layoutUpdateKeypadContent(nbgl_layout_t *layout, uint8_t nbActiveDigits, const char *text); -#else // HAVE_SE_TOUCH +#else // HAVE_SE_TOUCH /* layout objects for pages with keypad (nanos) */ int nbgl_layoutAddKeypad(nbgl_layout_t *layout, keyboardCallback_t callback, +#ifdef BUILD_SCREENSHOTS UX_LOC_STRINGS_INDEX textId, +#else // BUILD_SCREENSHOTS + const char *text, +#endif // BUILD_SCREENSHOTS bool shuffled); int nbgl_layoutUpdateKeypad(nbgl_layout_t *layout, uint8_t index, diff --git a/lib_nbgl/src/nbgl_layout_keypad_nanos.c b/lib_nbgl/src/nbgl_layout_keypad_nanos.c index 0377a0e1c..20c96653e 100644 --- a/lib_nbgl/src/nbgl_layout_keypad_nanos.c +++ b/lib_nbgl/src/nbgl_layout_keypad_nanos.c @@ -41,9 +41,9 @@ * PROTOTYPES **********************/ -// #ifdef BUILD_SCREENSHOTS +#ifdef BUILD_SCREENSHOTS extern const char *get_ux_loc_string(uint32_t index); -// #endif // BUILD_SCREENSHOTS +#endif // BUILD_SCREENSHOTS /********************** * GLOBAL FUNCTIONS @@ -57,18 +57,25 @@ extern const char *get_ux_loc_string(uint32_t index); * @param layout the current layout * @param callback function called when any of the key is touched * @param textId ID of the text to use as title for the keypad + * @param text text to use as title for the keypad * @param shuffled if set to true, digits are shuffled in keypad * @return the index of keypad in layout, to use in @ref nbgl_layoutUpdateKeypad() */ -int nbgl_layoutAddKeypad(nbgl_layout_t *layout, - keyboardCallback_t callback, +int nbgl_layoutAddKeypad(nbgl_layout_t *layout, + keyboardCallback_t callback, +#ifdef BUILD_SCREENSHOTS UX_LOC_STRINGS_INDEX textId, - bool shuffled) +#else // BUILD_SCREENSHOTS + const char *text, +#endif // BUILD_SCREENSHOTS + bool shuffled) { nbgl_layoutInternal_t *layoutInt = (nbgl_layoutInternal_t *) layout; nbgl_keypad_t *keypad; nbgl_text_area_t *textArea; - const char *text = get_ux_loc_string(textId); +#ifdef BUILD_SCREENSHOTS + const char *text = get_ux_loc_string(textId); +#endif // BUILD_SCREENSHOTS LOG_DEBUG(LAYOUT_LOGGER, "nbgl_layoutAddKeypad():\n"); if (layout == NULL) { @@ -78,9 +85,9 @@ int nbgl_layoutAddKeypad(nbgl_layout_t *layout, textArea = (nbgl_text_area_t *) nbgl_objPoolGet(TEXT_AREA, layoutInt->layer); textArea->textColor = WHITE; textArea->text = PIC(text); -#if (defined(HAVE_LANGUAGE_PACK) || defined(BUILD_SCREENSHOTS)) +#ifdef BUILD_SCREENSHOTS textArea->textId = textId; -#endif //(defined(HAVE_LANGUAGE_PACK)||defined(BUILD_SCREENSHOTS)) +#endif // BUILD_SCREENSHOTS textArea->textAlignment = CENTER; textArea->fontId = BAGL_FONT_OPEN_SANS_REGULAR_11px_1bpp; textArea->obj.area.width = AVAILABLE_WIDTH;