Skip to content

Commit

Permalink
Keep pointer for nbgl_layoutAddKeypad (LNX/LNS+)
Browse files Browse the repository at this point in the history
  • Loading branch information
dmorais-ledger committed Apr 25, 2024
1 parent a3b340f commit 17b6bc6
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 9 deletions.
6 changes: 5 additions & 1 deletion lib_nbgl/include/nbgl_layout.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
23 changes: 15 additions & 8 deletions lib_nbgl/src/nbgl_layout_keypad_nanos.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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) {
Expand All @@ -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;
Expand Down

0 comments on commit 17b6bc6

Please sign in to comment.