Skip to content

Commit

Permalink
Merge pull request #807 from LedgerHQ/tdj/cherry_pick_api_level_21
Browse files Browse the repository at this point in the history
cherry pick api level 21
  • Loading branch information
tdejoigny-ledger authored Oct 18, 2024
2 parents a350cec + 019b7cf commit d265a94
Show file tree
Hide file tree
Showing 4 changed files with 147 additions and 435 deletions.
14 changes: 2 additions & 12 deletions lib_nbgl/doc/nbgl_use_case.dox
Original file line number Diff line number Diff line change
Expand Up @@ -55,25 +55,15 @@ 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 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:
- @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
- 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

Expand Down
78 changes: 0 additions & 78 deletions lib_nbgl/doc/nbgl_use_case_nanos.dox
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +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)

@subsection use_case_home Home screen Use Case

Expand Down Expand Up @@ -247,79 +242,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
Expand Down
158 changes: 64 additions & 94 deletions lib_nbgl/include/nbgl_use_case.h
Original file line number Diff line number Diff line change
Expand Up @@ -365,78 +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_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,
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_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,
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_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,
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,
Expand All @@ -454,28 +446,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

Expand Down
Loading

0 comments on commit d265a94

Please sign in to comment.