From a279beca4addaffe04c3a2094927c82a85fdd489 Mon Sep 17 00:00:00 2001 From: tdejoigny-ledger Date: Thu, 26 Sep 2024 18:29:48 +0200 Subject: [PATCH 1/4] =?UTF-8?q?nbgl=5FuseCasePlugInHome=20removed=20nbgl?= =?UTF-8?q?=5FuseCaseForwardOnlyReview=20removed=20nbgl=5FuseCaseViewDetai?= =?UTF-8?q?ls=20renamed=20=E2=86=92=20displayDetails=20and=20removed=20fro?= =?UTF-8?q?m=20API=20nbgl=5FuseCaseKeypad=20removed?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit (cherry picked from commit d993b23d35491c108ac370572a8545acaa339952) --- lib_nbgl/doc/nbgl_use_case.dox | 4 - lib_nbgl/doc/nbgl_use_case_nanos.dox | 75 ----------- lib_nbgl/include/nbgl_use_case.h | 35 ----- lib_nbgl/src/nbgl_use_case.c | 191 ++++++--------------------- 4 files changed, 43 insertions(+), 262 deletions(-) diff --git a/lib_nbgl/doc/nbgl_use_case.dox b/lib_nbgl/doc/nbgl_use_case.dox index 78391eaa0..d2a9151a7 100644 --- a/lib_nbgl/doc/nbgl_use_case.dox +++ b/lib_nbgl/doc/nbgl_use_case.dox @@ -61,7 +61,6 @@ Some APIs have also been kept for backward compatibility, and for some rare case - for Home Screen: - @ref nbgl_useCaseHome() to draw the home screen of an application. - @ref nbgl_useCaseHomeExt() to draw an extended version of home screen of an application (with action button) - - @ref nbgl_useCasePlugInHome() to draw the home screen of a Plug-In application - for Settings: - @ref nbgl_useCaseSettings() to draw a level of settings pages - for most used reviews: @@ -71,9 +70,6 @@ Some APIs have also been kept for backward compatibility, and for some rare case - for address verification: - @ref nbgl_useCaseAddressConfirmation() to draw an address confirmation page, with a possibility to see it as QR Code - @ref nbgl_useCaseAddressConfirmationExt() to draw an address confirmation page, with a possibility to see it as QR Code and some extra tag/value pairs -- for rare reviews: - - @ref nbgl_useCaseForwardOnlyReview() to draw the pages of a forward-only review (without back key) - - @ref nbgl_useCaseViewDetails() to draw the pages displaying the full value of a given long data of a review @subsection use_case_home_settings Home & Settings screen Use Case diff --git a/lib_nbgl/doc/nbgl_use_case_nanos.dox b/lib_nbgl/doc/nbgl_use_case_nanos.dox index 1ad53d45d..eff34c383 100644 --- a/lib_nbgl/doc/nbgl_use_case_nanos.dox +++ b/lib_nbgl/doc/nbgl_use_case_nanos.dox @@ -46,8 +46,6 @@ A few APIs are available to draw typical Use-Cases, such as: - for most used reviews: - @ref nbgl_useCaseStaticReview() to draw the pages of a regular review, when all info are available from the beginning (see @subpage use_case_static_review) - @ref nbgl_useCaseRegularReview() to draw the pages of a regular review (all pages but the cover one) (see @subpage use_case_regular_review) -- for rare reviews: - - @ref nbgl_useCaseForwardOnlyReview() to draw the pages of a forward-only review (without back) (see @subpage use_case_forward_only_review) - for address verification: - @ref nbgl_useCaseAddressConfirmation() to draw an address confirmation page (see @subpage use_case_addr_confirm) - @ref nbgl_useCaseAddressConfirmationExt() to draw an address confirmation page, with some extra tag/value pairs (see @subpage use_case_addr_confirm_ext) @@ -247,79 +245,6 @@ void startReview(void) { } @endcode -@subsection use_case_forward_only_review Forward only Review Use Case - -Some message/transaction reviews may be too long to be memorized, so it is only possible to move forward. - -In this case, no backward navigation is possible, and the number of pages cannot be defined at start-up. - -The API to initiate the display of the series of forward-only review pages is @ref nbgl_useCaseForwardOnlyReview(), providing: - -- a navigation callback called when to retrieve the content of the next page. It is also called to fill the initial page. - -Here is an example code: - -@code - -static uint8_t last_transaction_page; - -static void onApprove(void) { - // confirm transaction - - // and go back to main - appMain(); -} - -static void onReject(void) { - // reject transaction - - // and go back to main - appMain(); -} - -// called to get the content of the given page -static bool navCallback(uint8_t page, nbgl_pageContent_t *content) { - memset(content, 0, sizeof(nbgl_pageContent_t)); - if (page == 0) { - // the first page is used to display the title of the review - content->text = "Review\ntransaction"; - content->icon = &C_icon_eye; - } - else if (page == (last_transaction+1)) { - // try to get a new tag/value pair in this transaction - char *tag; - char *value; - if (getNextTagValuePair(&tag, &value)) { - content->text = tag; - content->subText = value; - last_transaction_page = page; - } - else { - // this page is for approval - content->text = "Approve"; - content->icon = &C_icon_validate; - content->callback = onApprove; - } - } - else if (page == (last_transaction+2)) { - // this page is for rejection - content->text = "Reject"; - content->icon = &C_icon_crossmark; - content->callback = onReject; - } - else { - return false; - } - // valid page so return true - return true; -} - -void startForwardOnlyTransaction(void) { - last_transaction_page = 0; - nbgl_useCaseForwardOnlyReview(navCallback); -} -@endcode - @subsection use_case_static_review Static Review Use Case \image{inline} html UseCase-Nano-Review1.png "caption" width=1000 diff --git a/lib_nbgl/include/nbgl_use_case.h b/lib_nbgl/include/nbgl_use_case.h index 32e0553e4..66a5cad63 100644 --- a/lib_nbgl/include/nbgl_use_case.h +++ b/lib_nbgl/include/nbgl_use_case.h @@ -379,14 +379,6 @@ void nbgl_useCaseHomeExt(const char *appName, nbgl_callback_t actionCallback, nbgl_callback_t topRightCallback, nbgl_callback_t quitCallback); -void nbgl_useCasePlugInHome(const char *plugInName, - const char *appName, - const nbgl_icon_details_t *appIcon, - const char *tagline, - const char *subTagline, - bool withSettings, - nbgl_callback_t topRightCallback, - nbgl_callback_t quitCallback); void nbgl_useCaseSettings(const char *settingsTitle, uint8_t initPage, uint8_t nbPages, @@ -416,10 +408,6 @@ void nbgl_useCaseRegularReview(uint8_t initPage, nbgl_layoutTouchCallback_t buttonCallback, nbgl_navCallback_t navCallback, nbgl_choiceCallback_t choiceCallback); -void nbgl_useCaseForwardOnlyReview(const char *rejectText, - nbgl_layoutTouchCallback_t buttonCallback, - nbgl_navCallback_t navCallback, - nbgl_choiceCallback_t choiceCallback); void nbgl_useCaseForwardOnlyReviewNoSkip(const char *rejectText, nbgl_layoutTouchCallback_t buttonCallback, nbgl_navCallback_t navCallback, @@ -432,7 +420,6 @@ void nbgl_useCaseStaticReviewLight(const nbgl_contentTagValueList_t *tagValueLis const nbgl_pageInfoLongPress_t *infoLongPress, const char *rejectText, nbgl_choiceCallback_t callback); -void nbgl_useCaseViewDetails(const char *tag, const char *value, bool wrapping); void nbgl_useCaseAddressConfirmation(const char *address, nbgl_choiceCallback_t callback); void nbgl_useCaseAddressConfirmationExt(const char *address, nbgl_choiceCallback_t callback, @@ -454,28 +441,6 @@ void nbgl_useCaseKeypadPIN(const char *title, tune_index_e tuneId, nbgl_pinValidCallback_t validatePinCallback, nbgl_layoutTouchCallback_t actionCallback); -/** - * @deprecated - * See #nbgl_useCaseKeypadPIN - */ -DEPRECATED static inline void nbgl_useCaseKeypad(const char *title, - uint8_t minDigits, - uint8_t maxDigits, - uint8_t backToken, - bool shuffled, - tune_index_e tuneId, - nbgl_pinValidCallback_t validatePinCallback, - nbgl_layoutTouchCallback_t actionCallback) -{ - nbgl_useCaseKeypadPIN(title, - minDigits, - maxDigits, - backToken, - shuffled, - tuneId, - validatePinCallback, - actionCallback); -} #endif // NBGL_KEYPAD #endif // HAVE_SE_TOUCH diff --git a/lib_nbgl/src/nbgl_use_case.c b/lib_nbgl/src/nbgl_use_case.c index b7151ddb2..6fdf763b7 100644 --- a/lib_nbgl/src/nbgl_use_case.c +++ b/lib_nbgl/src/nbgl_use_case.c @@ -180,7 +180,6 @@ typedef union { // char buffers to build some strings static char appDescription[APP_DESCRIPTION_MAX_LEN]; -static char plugInDescription[APP_DESCRIPTION_MAX_LEN]; // multi-purposes callbacks static nbgl_callback_t onQuit; @@ -297,6 +296,7 @@ static void useCaseHomeExt(const char *appName, nbgl_homeAction_t *homeAction, nbgl_callback_t topRightCallback, nbgl_callback_t quitCallback); +static void displayDetails(const char *tag, const char *value, bool wrapping); static void reset_callbacks(void) { @@ -540,9 +540,9 @@ static void pageCallback(int token, uint8_t index) } } else if (token == DETAILS_BUTTON_TOKEN) { - nbgl_useCaseViewDetails(genericContext.detailsItem, - genericContext.detailsvalue, - genericContext.detailsWrapping); + displayDetails(genericContext.detailsItem, + genericContext.detailsvalue, + genericContext.detailsWrapping); } else if (token == NAV_TOKEN) { if (index == EXIT_PAGE) { @@ -1982,6 +1982,45 @@ static void useCaseHomeExt(const char *appName, nbgl_refreshSpecial(FULL_COLOR_CLEAN_REFRESH); } +/** + * @brief Draws a flow of pages to view details on a given tag/value pair that doesn't fit in a + * single page + * + * @param tag tag name (in gray) + * @param value full value string, that will be split in multiple pages + * @param wrapping if set to true, value text is wrapped on ' ' characters + */ +static void displayDetails(const char *tag, const char *value, bool wrapping) +{ + memset(&detailsContext, 0, sizeof(detailsContext)); + + uint16_t nbLines + = nbgl_getTextNbLinesInWidth(SMALL_REGULAR_FONT, value, AVAILABLE_WIDTH, wrapping); + + // initialize context + detailsContext.tag = tag; + detailsContext.value = value; + detailsContext.nbPages = (nbLines + NB_MAX_LINES_IN_DETAILS - 1) / NB_MAX_LINES_IN_DETAILS; + detailsContext.currentPage = 0; + detailsContext.wrapping = wrapping; + // add some spare for room lost with "..." substitution + if (detailsContext.nbPages > 1) { + uint16_t nbLostChars = (detailsContext.nbPages - 1) * 3; + uint16_t nbLostLines = (nbLostChars + ((AVAILABLE_WIDTH) / 16) - 1) + / ((AVAILABLE_WIDTH) / 16); // 16 for average char width + uint8_t nbLinesInLastPage + = nbLines - ((detailsContext.nbPages - 1) * NB_MAX_LINES_IN_DETAILS); + + detailsContext.nbPages += nbLostLines / NB_MAX_LINES_IN_DETAILS; + if ((nbLinesInLastPage + (nbLostLines % NB_MAX_LINES_IN_DETAILS)) + > NB_MAX_LINES_IN_DETAILS) { + detailsContext.nbPages++; + } + } + + displayDetailsPage(0, true); +} + /********************** * GLOBAL FUNCTIONS **********************/ @@ -2380,70 +2419,6 @@ void nbgl_useCaseHomeExt(const char *appName, appName, appIcon, tagline, withSettings, &homeAction, topRightCallback, quitCallback); } -/** - * @brief draws the home page of a plug-in app (page on which we land when launching it from - * dashboard) - * - * @param plugInName plug-in app name - * @param appName master app name (app used by plug-in) - * @param appIcon master app icon - * @param tagline text under plug-in name (if NULL, it will be "This app confirms actions - * for\n.") - * @param subTagline text under master app icon (if NULL, it will be "This app relies - * on\n") - * @param withSettings if true, use a "settings" (wheel) icon in bottom button, otherwise a "info" - * (i) - * @param topRightCallback callback called when top-right button is touched - * @param quitCallback callback called when quit button is touched - */ -void nbgl_useCasePlugInHome(const char *plugInName, - const char *appName, - const nbgl_icon_details_t *appIcon, - const char *tagline, - const char *subTagline, - bool withSettings, - nbgl_callback_t topRightCallback, - nbgl_callback_t quitCallback) -{ - reset_callbacks(); - - nbgl_pageInfoDescription_t info = {.centeredInfo.icon = appIcon, - .centeredInfo.text1 = plugInName, - .centeredInfo.style = PLUGIN_INFO, - .centeredInfo.offsetY = -16, - .footerText = NULL, - .bottomButtonStyle = QUIT_APP_TEXT, - .tapActionText = NULL, - .topRightStyle = withSettings ? SETTINGS_ICON : INFO_ICON, - .topRightToken = CONTINUE_TOKEN, - .actionButtonText = NULL, - .tuneId = TUNE_TAP_CASUAL}; - info.bottomButtonsToken = QUIT_TOKEN; - onAction = NULL; - if (tagline == NULL) { - snprintf(appDescription, - APP_DESCRIPTION_MAX_LEN, - "This app confirms actions for\n%s.", - plugInName); - info.centeredInfo.text2 = appDescription; - } - else { - info.centeredInfo.text2 = tagline; - } - if (subTagline == NULL) { - snprintf(plugInDescription, APP_DESCRIPTION_MAX_LEN, "This app relies on\n%s", appName); - info.centeredInfo.text3 = plugInDescription; - } - else { - info.centeredInfo.text3 = subTagline; - } - - onContinue = topRightCallback; - onQuit = quitCallback; - pageContext = nbgl_pageDrawInfo(&pageCallback, NULL, &info); - nbgl_refresh(); -} - /** * @brief Draws the settings pages of an app with as many pages as given * For each page, the given navCallback will be called to get the content. Only 'type' and @@ -2856,47 +2831,6 @@ void nbgl_useCaseRegularReview(uint8_t initPage, displayReviewPage(initPage, true); } -/** - * @brief Draws a flow of pages of a review, without back key. - * It is possible to go to next page thanks to "tap to continue". - * For each page, the given navCallback will be called to get the content. Only 'type' and - * union has to be set in this content. - * Note that this is not a standard use case, it should only be used on very specific - * situations. - * - * @param rejectText text to use in footer - * @param buttonCallback callback called when a potential button (details or long press) in the - * content is touched - * @param navCallback callback called when navigation "tap to continue" is touched, to get the - * content of next page - * @param choiceCallback callback called when either long_press or footer is called (param is true - * for long press) - */ -void nbgl_useCaseForwardOnlyReview(const char *rejectText, - nbgl_layoutTouchCallback_t buttonCallback, - nbgl_navCallback_t navCallback, - nbgl_choiceCallback_t choiceCallback) -{ - reset_callbacks(); - - // memorize context - onChoice = choiceCallback; - onNav = navCallback; - onControls = buttonCallback; - forwardNavOnly = true; - navType = REVIEW_NAV; - - // fill navigation structure - UNUSED(rejectText); - prepareNavInfo(true, NBGL_NO_PROGRESS_INDICATOR, getRejectReviewText(TYPE_OPERATION)); - - navInfo.progressIndicator = false; - navInfo.skipText = "Skip"; - navInfo.skipToken = SKIP_TOKEN; - - displayReviewPage(0, true); -} - /** * @brief Draws a flow of pages of a review, without back key. * It is possible to go to next page thanks to "tap to continue". @@ -3400,45 +3334,6 @@ void nbgl_useCaseReviewStreamingFinish(const char *finishTitle, displayGenericContextPage(0, true); } -/** - * @brief Draws a flow of pages to view details on a given tag/value pair that doesn't fit in a - * single page - * - * @param tag tag name (in gray) - * @param value full value string, that will be split in multiple pages - * @param wrapping if set to true, value text is wrapped on ' ' characters - */ -void nbgl_useCaseViewDetails(const char *tag, const char *value, bool wrapping) -{ - memset(&detailsContext, 0, sizeof(detailsContext)); - - uint16_t nbLines - = nbgl_getTextNbLinesInWidth(SMALL_REGULAR_FONT, value, AVAILABLE_WIDTH, wrapping); - - // initialize context - detailsContext.tag = tag; - detailsContext.value = value; - detailsContext.nbPages = (nbLines + NB_MAX_LINES_IN_DETAILS - 1) / NB_MAX_LINES_IN_DETAILS; - detailsContext.currentPage = 0; - detailsContext.wrapping = wrapping; - // add some spare for room lost with "..." substitution - if (detailsContext.nbPages > 1) { - uint16_t nbLostChars = (detailsContext.nbPages - 1) * 3; - uint16_t nbLostLines = (nbLostChars + ((AVAILABLE_WIDTH) / 16) - 1) - / ((AVAILABLE_WIDTH) / 16); // 16 for average char width - uint8_t nbLinesInLastPage - = nbLines - ((detailsContext.nbPages - 1) * NB_MAX_LINES_IN_DETAILS); - - detailsContext.nbPages += nbLostLines / NB_MAX_LINES_IN_DETAILS; - if ((nbLinesInLastPage + (nbLostLines % NB_MAX_LINES_IN_DETAILS)) - > NB_MAX_LINES_IN_DETAILS) { - detailsContext.nbPages++; - } - } - - displayDetailsPage(0, true); -} - /** * @brief draws an address confirmation page. This page contains the given address in a tag/value * layout, with a button to open a modal to see address as a QR Code, and at the bottom a button to From e6d2986967bbe834e2da60936790602366441232 Mon Sep 17 00:00:00 2001 From: tdejoigny-ledger Date: Fri, 27 Sep 2024 18:32:43 +0200 Subject: [PATCH 2/4] deprecate several use cases (cherry picked from commit 93811bacda373d1466ace3e0632718660356189d) --- lib_nbgl/doc/nbgl_use_case.dox | 3 - lib_nbgl/doc/nbgl_use_case_nanos.dox | 3 - lib_nbgl/src/nbgl_use_case.c | 88 +++++++++------------------- 3 files changed, 27 insertions(+), 67 deletions(-) diff --git a/lib_nbgl/doc/nbgl_use_case.dox b/lib_nbgl/doc/nbgl_use_case.dox index d2a9151a7..8bb246692 100644 --- a/lib_nbgl/doc/nbgl_use_case.dox +++ b/lib_nbgl/doc/nbgl_use_case.dox @@ -67,9 +67,6 @@ Some APIs have also been kept for backward compatibility, and for some rare case - @ref nbgl_useCaseReviewStart() to draw the cover page of a review (initial page, without data) - @ref nbgl_useCaseStaticReview() to draw the data pages of a regular review, when all info are available from the beginning (all pages but the cover one) - @ref nbgl_useCaseRegularReview() to draw the data pages of a regular review (all pages but the cover one) -- for address verification: - - @ref nbgl_useCaseAddressConfirmation() to draw an address confirmation page, with a possibility to see it as QR Code - - @ref nbgl_useCaseAddressConfirmationExt() to draw an address confirmation page, with a possibility to see it as QR Code and some extra tag/value pairs @subsection use_case_home_settings Home & Settings screen Use Case diff --git a/lib_nbgl/doc/nbgl_use_case_nanos.dox b/lib_nbgl/doc/nbgl_use_case_nanos.dox index eff34c383..88b18a20f 100644 --- a/lib_nbgl/doc/nbgl_use_case_nanos.dox +++ b/lib_nbgl/doc/nbgl_use_case_nanos.dox @@ -46,9 +46,6 @@ A few APIs are available to draw typical Use-Cases, such as: - for most used reviews: - @ref nbgl_useCaseStaticReview() to draw the pages of a regular review, when all info are available from the beginning (see @subpage use_case_static_review) - @ref nbgl_useCaseRegularReview() to draw the pages of a regular review (all pages but the cover one) (see @subpage use_case_regular_review) -- for address verification: - - @ref nbgl_useCaseAddressConfirmation() to draw an address confirmation page (see @subpage use_case_addr_confirm) - - @ref nbgl_useCaseAddressConfirmationExt() to draw an address confirmation page, with some extra tag/value pairs (see @subpage use_case_addr_confirm_ext) @subsection use_case_home Home screen Use Case diff --git a/lib_nbgl/src/nbgl_use_case.c b/lib_nbgl/src/nbgl_use_case.c index 6fdf763b7..2a9bd8a8c 100644 --- a/lib_nbgl/src/nbgl_use_case.c +++ b/lib_nbgl/src/nbgl_use_case.c @@ -16,6 +16,7 @@ #include "os_pic.h" #include "os_print.h" #include "os_helpers.h" +#include "decorators.h" /********************* * DEFINES @@ -2361,54 +2362,32 @@ uint8_t nbgl_useCaseGetNbPagesForTagValueList(const nbgl_contentTagValueList_t * } /** - * @brief draws the home page of an app (page on which we land when launching it from dashboard) - * - * @param appName app name - * @param appIcon app icon - * @param tagline text under app name (if NULL, it will be "This app enables signing transactions on - * the network.") - * @param withSettings if true, use a "settings" (wheel) icon in bottom button, otherwise a "info" - * (i) - * @param topRightCallback callback called when top-right button is touched - * @param quitCallback callback called when quit button is touched + * @deprecated + * See #nbgl_useCaseHomeAndSettings */ -void nbgl_useCaseHome(const char *appName, - const nbgl_icon_details_t *appIcon, - const char *tagline, - bool withSettings, - nbgl_callback_t topRightCallback, - nbgl_callback_t quitCallback) +DEPRECATED void nbgl_useCaseHome(const char *appName, + const nbgl_icon_details_t *appIcon, + const char *tagline, + bool withSettings, + nbgl_callback_t topRightCallback, + nbgl_callback_t quitCallback) { nbgl_useCaseHomeExt( appName, appIcon, tagline, withSettings, NULL, NULL, topRightCallback, quitCallback); } /** - * @brief draws the extended version of home page of an app (page on which we land when launching it - * from dashboard) - * @note it enables to use an action button (black on Stax, white on Flex) - * - * @param appName app name - * @param appIcon app icon - * @param tagline text under app name (if NULL, it will be "This app enables signing transactions on - * the network.") - * @param withSettings if true, use a "settings" (wheel) icon in bottom button, otherwise a "info" - * (i) - * @param actionButtonText if not NULL, text used for an action button (on top of "Quit - * App" button/footer) - * @param actionCallback callback called when action button is touched (if actionButtonText is not - * NULL) - * @param topRightCallback callback called when top-right button is touched - * @param quitCallback callback called when quit button is touched + * @deprecated + * See #nbgl_useCaseHomeAndSettings */ -void nbgl_useCaseHomeExt(const char *appName, - const nbgl_icon_details_t *appIcon, - const char *tagline, - bool withSettings, - const char *actionButtonText, - nbgl_callback_t actionCallback, - nbgl_callback_t topRightCallback, - nbgl_callback_t quitCallback) +DEPRECATED void nbgl_useCaseHomeExt(const char *appName, + const nbgl_icon_details_t *appIcon, + const char *tagline, + bool withSettings, + const char *actionButtonText, + nbgl_callback_t actionCallback, + nbgl_callback_t topRightCallback, + nbgl_callback_t quitCallback) { nbgl_homeAction_t homeAction = {.callback = actionCallback, .icon = NULL, @@ -3335,34 +3314,21 @@ void nbgl_useCaseReviewStreamingFinish(const char *finishTitle, } /** - * @brief draws an address confirmation page. This page contains the given address in a tag/value - * layout, with a button to open a modal to see address as a QR Code, and at the bottom a button to - * confirm and a footer to cancel - * - * @param address address to confirm (NULL terminated string) - * @param callback callback called when button or footer is touched (if true, button, if false - * footer) + * @deprecated + * See #nbgl_useCaseAddressReview */ -void nbgl_useCaseAddressConfirmation(const char *address, nbgl_choiceCallback_t callback) +DEPRECATED void nbgl_useCaseAddressConfirmation(const char *address, nbgl_choiceCallback_t callback) { nbgl_useCaseAddressConfirmationExt(address, callback, NULL); } /** - * @brief draws an extended address verification page. This page contains the given address in a - * tag/value layout, with a button to open a modal to see address as a QR Code. A "tap to continue" - * enables to open a second review page to display the other given tag/value pairs, with a button to - * confirm and a footer to cancel - * - * @param address address to confirm (NULL terminated string) - * @param callback callback called when button or footer is touched (if true, button, if false - * footer) - * @param tagValueList list of tag/value pairs (must fit in a single page, and be persistent because - * no copy) + * @deprecated + * See #nbgl_useCaseAddressReview */ -void nbgl_useCaseAddressConfirmationExt(const char *address, - nbgl_choiceCallback_t callback, - const nbgl_contentTagValueList_t *tagValueList) +DEPRECATED void nbgl_useCaseAddressConfirmationExt(const char *address, + nbgl_choiceCallback_t callback, + const nbgl_contentTagValueList_t *tagValueList) { reset_callbacks(); memset(&genericContext, 0, sizeof(genericContext)); From 419095b0896c4a51274c89707df251800c26a445 Mon Sep 17 00:00:00 2001 From: tdejoigny-ledger Date: Mon, 30 Sep 2024 12:58:37 +0200 Subject: [PATCH 3/4] remove nbgl_useCaseForwardOnlyReviewNoSkip use case (cherry picked from commit cda52e5c14f09d1eaadb298360b90fe2bd842eba) --- lib_nbgl/doc/nbgl_use_case.dox | 3 --- lib_nbgl/include/nbgl_use_case.h | 4 ---- lib_nbgl/src/nbgl_use_case.c | 37 -------------------------------- 3 files changed, 44 deletions(-) diff --git a/lib_nbgl/doc/nbgl_use_case.dox b/lib_nbgl/doc/nbgl_use_case.dox index 8bb246692..5035fd80a 100644 --- a/lib_nbgl/doc/nbgl_use_case.dox +++ b/lib_nbgl/doc/nbgl_use_case.dox @@ -58,9 +58,6 @@ A few APIs are available to draw typical Use-Cases, such as: Some APIs have also been kept for backward compatibility, and for some rare cases: -- for Home Screen: - - @ref nbgl_useCaseHome() to draw the home screen of an application. - - @ref nbgl_useCaseHomeExt() to draw an extended version of home screen of an application (with action button) - for Settings: - @ref nbgl_useCaseSettings() to draw a level of settings pages - for most used reviews: diff --git a/lib_nbgl/include/nbgl_use_case.h b/lib_nbgl/include/nbgl_use_case.h index 66a5cad63..3d56a73f1 100644 --- a/lib_nbgl/include/nbgl_use_case.h +++ b/lib_nbgl/include/nbgl_use_case.h @@ -408,10 +408,6 @@ void nbgl_useCaseRegularReview(uint8_t initPage, nbgl_layoutTouchCallback_t buttonCallback, nbgl_navCallback_t navCallback, nbgl_choiceCallback_t choiceCallback); -void nbgl_useCaseForwardOnlyReviewNoSkip(const char *rejectText, - nbgl_layoutTouchCallback_t buttonCallback, - nbgl_navCallback_t navCallback, - nbgl_choiceCallback_t choiceCallback); void nbgl_useCaseStaticReview(const nbgl_contentTagValueList_t *tagValueList, const nbgl_pageInfoLongPress_t *infoLongPress, const char *rejectText, diff --git a/lib_nbgl/src/nbgl_use_case.c b/lib_nbgl/src/nbgl_use_case.c index 2a9bd8a8c..b1de18652 100644 --- a/lib_nbgl/src/nbgl_use_case.c +++ b/lib_nbgl/src/nbgl_use_case.c @@ -2810,43 +2810,6 @@ void nbgl_useCaseRegularReview(uint8_t initPage, displayReviewPage(initPage, true); } -/** - * @brief Draws a flow of pages of a review, without back key. - * It is possible to go to next page thanks to "tap to continue". - * For each page, the given navCallback will be called to get the content. Only 'type' and - * union has to be set in this content. - * Note that this is not a standard use case, it should only be used on very specific - * situations. - * - * @param rejectText text to use in footer - * @param buttonCallback callback called when a potential button (details or long press) in the - * content is touched - * @param navCallback callback called when navigation "tap to continue" is touched, to get the - * content of next page - * @param choiceCallback callback called when either long_press or footer is called (param is true - * for long press) - */ -void nbgl_useCaseForwardOnlyReviewNoSkip(const char *rejectText, - nbgl_layoutTouchCallback_t buttonCallback, - nbgl_navCallback_t navCallback, - nbgl_choiceCallback_t choiceCallback) -{ - reset_callbacks(); - - // memorize context - onChoice = choiceCallback; - onNav = navCallback; - onControls = buttonCallback; - forwardNavOnly = true; - navType = REVIEW_NAV; - - // fill navigation structure - UNUSED(rejectText); - prepareNavInfo(true, NBGL_NO_PROGRESS_INDICATOR, getRejectReviewText(TYPE_OPERATION)); - navInfo.progressIndicator = false; - displayReviewPage(0, false); -} - /** * @brief Draws a flow of pages of a review. A back key is available on top-left of the screen, * except in first page It is possible to go to next page thanks to "tap to continue". From 019b7cfc0795eaaac529f949afcb76afbf3656a2 Mon Sep 17 00:00:00 2001 From: Nicolas Roggeman Date: Tue, 1 Oct 2024 13:13:48 +0200 Subject: [PATCH 4/4] Add navigable content use case to replace settings use case (cherry picked from commit 75ecd28ccac1b3ba32c3f99a4efe130cfa27335d) --- lib_nbgl/doc/nbgl_use_case.dox | 4 +- lib_nbgl/include/nbgl_use_case.h | 119 +++++++++++++++++-------------- lib_nbgl/src/nbgl_use_case.c | 94 ++++++++++++------------ 3 files changed, 116 insertions(+), 101 deletions(-) diff --git a/lib_nbgl/doc/nbgl_use_case.dox b/lib_nbgl/doc/nbgl_use_case.dox index 5035fd80a..d92699220 100644 --- a/lib_nbgl/doc/nbgl_use_case.dox +++ b/lib_nbgl/doc/nbgl_use_case.dox @@ -55,11 +55,11 @@ A few APIs are available to draw typical Use-Cases, such as: - for keypad: - @ref nbgl_useCaseKeypadPIN() to draw a default keypad implementation with hidden digits (see @subpage use_case_keypad) - @ref nbgl_useCaseKeypadDigits() to draw a default keypad implementation, showing digits (see @subpage use_case_keypad) +- for generic navigable content: + - @ref nbgl_useCaseNavigableContent() to draw a level of generic content navigable pages Some APIs have also been kept for backward compatibility, and for some rare cases: -- for Settings: - - @ref nbgl_useCaseSettings() to draw a level of settings pages - for most used reviews: - @ref nbgl_useCaseReviewStart() to draw the cover page of a review (initial page, without data) - @ref nbgl_useCaseStaticReview() to draw the data pages of a regular review, when all info are available from the beginning (all pages but the cover one) diff --git a/lib_nbgl/include/nbgl_use_case.h b/lib_nbgl/include/nbgl_use_case.h index 3d56a73f1..e36079cae 100644 --- a/lib_nbgl/include/nbgl_use_case.h +++ b/lib_nbgl/include/nbgl_use_case.h @@ -365,61 +365,70 @@ uint8_t nbgl_useCaseGetNbChoicesInPage(uint8_t nbChoice uint8_t nbgl_useCaseGetNbPagesForTagValueList(const nbgl_contentTagValueList_t *tagValueList); // use case drawing -void nbgl_useCaseHome(const char *appName, - const nbgl_icon_details_t *appIcon, - const char *tagline, - bool withSettings, - nbgl_callback_t topRightCallback, - nbgl_callback_t quitCallback); -void nbgl_useCaseHomeExt(const char *appName, - const nbgl_icon_details_t *appIcon, - const char *tagline, - bool withSettings, - const char *actionButtonText, - nbgl_callback_t actionCallback, - nbgl_callback_t topRightCallback, - nbgl_callback_t quitCallback); -void nbgl_useCaseSettings(const char *settingsTitle, - uint8_t initPage, - uint8_t nbPages, - bool touchableTitle, - nbgl_callback_t quitCallback, - nbgl_navCallback_t navCallback, - nbgl_layoutTouchCallback_t controlsCallback); -void nbgl_useCaseGenericSettings(const char *appName, - uint8_t initPage, - const nbgl_genericContents_t *settingContents, - const nbgl_contentInfoList_t *infosList, - nbgl_callback_t quitCallback); -void nbgl_useCaseConfirm(const char *message, - const char *subMessage, - const char *confirmText, - const char *rejectText, - nbgl_callback_t callback); -void nbgl_useCaseReviewStart(const nbgl_icon_details_t *icon, - const char *reviewTitle, - const char *reviewSubTitle, - const char *rejectText, - nbgl_callback_t continueCallback, - nbgl_callback_t rejectCallback); -void nbgl_useCaseRegularReview(uint8_t initPage, - uint8_t nbPages, - const char *rejectText, - nbgl_layoutTouchCallback_t buttonCallback, - nbgl_navCallback_t navCallback, - nbgl_choiceCallback_t choiceCallback); -void nbgl_useCaseStaticReview(const nbgl_contentTagValueList_t *tagValueList, - const nbgl_pageInfoLongPress_t *infoLongPress, - const char *rejectText, - nbgl_choiceCallback_t callback); -void nbgl_useCaseStaticReviewLight(const nbgl_contentTagValueList_t *tagValueList, - const nbgl_pageInfoLongPress_t *infoLongPress, - const char *rejectText, - nbgl_choiceCallback_t callback); -void nbgl_useCaseAddressConfirmation(const char *address, nbgl_choiceCallback_t callback); -void nbgl_useCaseAddressConfirmationExt(const char *address, - nbgl_choiceCallback_t callback, - const nbgl_contentTagValueList_t *tagValueList); +DEPRECATED void nbgl_useCaseHome(const char *appName, + const nbgl_icon_details_t *appIcon, + const char *tagline, + bool withSettings, + nbgl_callback_t topRightCallback, + nbgl_callback_t quitCallback); +DEPRECATED void nbgl_useCaseHomeExt(const char *appName, + const nbgl_icon_details_t *appIcon, + const char *tagline, + bool withSettings, + const char *actionButtonText, + nbgl_callback_t actionCallback, + nbgl_callback_t topRightCallback, + nbgl_callback_t quitCallback); +void nbgl_useCaseNavigableContent(const char *title, + uint8_t initPage, + uint8_t nbPages, + nbgl_callback_t quitCallback, + nbgl_navCallback_t navCallback, + nbgl_layoutTouchCallback_t controlsCallback); +DEPRECATED void nbgl_useCaseSettings(const char *settingsTitle, + uint8_t initPage, + uint8_t nbPages, + bool touchableTitle, + nbgl_callback_t quitCallback, + nbgl_navCallback_t navCallback, + nbgl_layoutTouchCallback_t controlsCallback); +void nbgl_useCaseGenericSettings(const char *appName, + uint8_t initPage, + const nbgl_genericContents_t *settingContents, + const nbgl_contentInfoList_t *infosList, + nbgl_callback_t quitCallback); +void nbgl_useCaseConfirm(const char *message, + const char *subMessage, + const char *confirmText, + const char *rejectText, + nbgl_callback_t callback); +void nbgl_useCaseReviewStart(const nbgl_icon_details_t *icon, + const char *reviewTitle, + const char *reviewSubTitle, + const char *rejectText, + nbgl_callback_t continueCallback, + nbgl_callback_t rejectCallback); +void nbgl_useCaseRegularReview(uint8_t initPage, + uint8_t nbPages, + const char *rejectText, + nbgl_layoutTouchCallback_t buttonCallback, + nbgl_navCallback_t navCallback, + nbgl_choiceCallback_t choiceCallback); +void nbgl_useCaseStaticReview(const nbgl_contentTagValueList_t *tagValueList, + const nbgl_pageInfoLongPress_t *infoLongPress, + const char *rejectText, + nbgl_choiceCallback_t callback); +void nbgl_useCaseStaticReviewLight(const nbgl_contentTagValueList_t *tagValueList, + const nbgl_pageInfoLongPress_t *infoLongPress, + const char *rejectText, + nbgl_choiceCallback_t callback); + +DEPRECATED void nbgl_useCaseAddressConfirmationExt(const char *address, + nbgl_choiceCallback_t callback, + const nbgl_contentTagValueList_t *tagValueList); +#define nbgl_useCaseAddressConfirmation(__address, __callback) \ + nbgl_useCaseAddressConfirmationExt(__address, __callback, NULL) + #ifdef NBGL_KEYPAD void nbgl_useCaseKeypadDigits(const char *title, uint8_t minDigits, diff --git a/lib_nbgl/src/nbgl_use_case.c b/lib_nbgl/src/nbgl_use_case.c index b1de18652..33c20abe1 100644 --- a/lib_nbgl/src/nbgl_use_case.c +++ b/lib_nbgl/src/nbgl_use_case.c @@ -16,7 +16,6 @@ #include "os_pic.h" #include "os_print.h" #include "os_helpers.h" -#include "decorators.h" /********************* * DEFINES @@ -2365,29 +2364,30 @@ uint8_t nbgl_useCaseGetNbPagesForTagValueList(const nbgl_contentTagValueList_t * * @deprecated * See #nbgl_useCaseHomeAndSettings */ -DEPRECATED void nbgl_useCaseHome(const char *appName, - const nbgl_icon_details_t *appIcon, - const char *tagline, - bool withSettings, - nbgl_callback_t topRightCallback, - nbgl_callback_t quitCallback) -{ - nbgl_useCaseHomeExt( - appName, appIcon, tagline, withSettings, NULL, NULL, topRightCallback, quitCallback); +void nbgl_useCaseHome(const char *appName, + const nbgl_icon_details_t *appIcon, + const char *tagline, + bool withSettings, + nbgl_callback_t topRightCallback, + nbgl_callback_t quitCallback) +{ + nbgl_homeAction_t homeAction = {0}; + useCaseHomeExt( + appName, appIcon, tagline, withSettings, &homeAction, topRightCallback, quitCallback); } /** * @deprecated * See #nbgl_useCaseHomeAndSettings */ -DEPRECATED void nbgl_useCaseHomeExt(const char *appName, - const nbgl_icon_details_t *appIcon, - const char *tagline, - bool withSettings, - const char *actionButtonText, - nbgl_callback_t actionCallback, - nbgl_callback_t topRightCallback, - nbgl_callback_t quitCallback) +void nbgl_useCaseHomeExt(const char *appName, + const nbgl_icon_details_t *appIcon, + const char *tagline, + bool withSettings, + const char *actionButtonText, + nbgl_callback_t actionCallback, + nbgl_callback_t topRightCallback, + nbgl_callback_t quitCallback) { nbgl_homeAction_t homeAction = {.callback = actionCallback, .icon = NULL, @@ -2399,28 +2399,25 @@ DEPRECATED void nbgl_useCaseHomeExt(const char *appName, } /** - * @brief Draws the settings pages of an app with as many pages as given - * For each page, the given navCallback will be called to get the content. Only 'type' and - * union has to be set in this content + * @brief Initiates the drawing a set of pages of generic content, with a touchable header (usually + * to go back or to an upper level) For each page (including the first one), the given 'navCallback' + * will be called to get the content. Only 'type' and union has to be set in this content. * - * @param title string to set in touchable title + * @param title string to set in touchable title (header) * @param initPage page on which to start [0->(nbPages-1)] * @param nbPages number of pages - * @param touchable unused, it is always on - * @param quitCallback callback called when quit button (or title) is pressed + * @param quitCallback callback called title is pressed * @param navCallback callback called when navigation arrows are pressed * @param controlsCallback callback called when any controls in the settings (radios, switches) is * called (the tokens must be >= @ref FIRST_USER_TOKEN) */ -void nbgl_useCaseSettings(const char *title, - uint8_t initPage, - uint8_t nbPages, - bool touchable, - nbgl_callback_t quitCallback, - nbgl_navCallback_t navCallback, - nbgl_layoutTouchCallback_t controlsCallback) +void nbgl_useCaseNavigableContent(const char *title, + uint8_t initPage, + uint8_t nbPages, + nbgl_callback_t quitCallback, + nbgl_navCallback_t navCallback, + nbgl_layoutTouchCallback_t controlsCallback) { - UNUSED(touchable); reset_callbacks(); // memorize context @@ -2436,6 +2433,24 @@ void nbgl_useCaseSettings(const char *title, displaySettingsPage(initPage, true); } +/** + * @deprecated + * See #nbgl_useCaseHomeAndSettings if used in a 'Settings' context, or nbgl_useCaseNavigableContent + * otherwise + */ +void nbgl_useCaseSettings(const char *title, + uint8_t initPage, + uint8_t nbPages, + bool touchable, + nbgl_callback_t quitCallback, + nbgl_navCallback_t navCallback, + nbgl_layoutTouchCallback_t controlsCallback) +{ + UNUSED(touchable); + nbgl_useCaseNavigableContent( + title, initPage, nbPages, quitCallback, navCallback, controlsCallback); +} + /** * @brief Draws the settings pages of an app with automatic pagination depending on content * to be displayed that is passed through settingContents and infosList @@ -3280,18 +3295,9 @@ void nbgl_useCaseReviewStreamingFinish(const char *finishTitle, * @deprecated * See #nbgl_useCaseAddressReview */ -DEPRECATED void nbgl_useCaseAddressConfirmation(const char *address, nbgl_choiceCallback_t callback) -{ - nbgl_useCaseAddressConfirmationExt(address, callback, NULL); -} - -/** - * @deprecated - * See #nbgl_useCaseAddressReview - */ -DEPRECATED void nbgl_useCaseAddressConfirmationExt(const char *address, - nbgl_choiceCallback_t callback, - const nbgl_contentTagValueList_t *tagValueList) +void nbgl_useCaseAddressConfirmationExt(const char *address, + nbgl_choiceCallback_t callback, + const nbgl_contentTagValueList_t *tagValueList) { reset_callbacks(); memset(&genericContext, 0, sizeof(genericContext));