@@ -64,15 +64,15 @@ typedef struct {
64
64
static ShareBackupWidget_t g_shareBackupTile ;
65
65
static ShareBackupWidget_t g_shareConfirmTile ;
66
66
67
- static uint8_t g_phraseCnt = 20 ;
67
+ static uint8_t g_selectCnt = 20 ;
68
68
static uint8_t g_pressedBtn [SLIP39_MNEMONIC_WORDS_MAX + 1 ];
69
69
static uint8_t g_pressedBtnFlag [SLIP39_MNEMONIC_WORDS_MAX + 1 ];
70
70
static uint8_t g_currId = 0 ;
71
71
static char g_randomBuff [BUFFER_SIZE_512 ];
72
72
static lv_obj_t * g_noticeWindow = NULL ;
73
73
static uint8_t g_entropyMethod ;
74
74
static PageWidget_t * g_pageWidget ;
75
- static void SelectPhraseCntHandler (lv_event_t * e );
75
+ static void SelectParseCntHandler (lv_event_t * e );
76
76
static void SelectCheckBoxHandler (lv_event_t * e );
77
77
78
78
static void ShareUpdateTileHandler (lv_event_t * e )
@@ -97,7 +97,7 @@ static void ContinueStopCreateHandler(lv_event_t *e)
97
97
98
98
static void ResetBtnTest (void )
99
99
{
100
- for (int i = 0 ; i < g_phraseCnt ; i ++ ) {
100
+ for (int i = 0 ; i < g_selectCnt ; i ++ ) {
101
101
g_pressedBtn [i ] = 0 ;
102
102
g_pressedBtnFlag [i ] = 0 ;
103
103
}
@@ -113,12 +113,16 @@ static void ResetBtnHandler(lv_event_t * e)
113
113
114
114
void GuiCreateShareUpdateMnemonic (void * signalParam , uint16_t paramLen )
115
115
{
116
- g_shareBackupTile .keyBoard -> wordCnt = g_phraseCnt ;
116
+ g_shareBackupTile .keyBoard -> wordCnt = g_selectCnt ;
117
117
GuiUpdateMnemonicKeyBoard (g_shareBackupTile .keyBoard , SecretCacheGetSlip39Mnemonic (g_createShareTileView .currentSlice ), false);
118
- g_shareConfirmTile .keyBoard -> wordCnt = g_phraseCnt ;
119
- ArrayRandom (SecretCacheGetSlip39Mnemonic (g_createShareTileView .currentSlice ), g_randomBuff , g_phraseCnt );
118
+ g_shareConfirmTile .keyBoard -> wordCnt = g_selectCnt ;
119
+ ArrayRandom (SecretCacheGetSlip39Mnemonic (g_createShareTileView .currentSlice ), g_randomBuff , g_selectCnt );
120
120
GuiUpdateMnemonicKeyBoard (g_shareConfirmTile .keyBoard , g_randomBuff , true);
121
121
GuiStopCircleAroundAnimation ();
122
+ if (g_pageWidget != NULL ) {
123
+ SetRightBtnLabel (g_pageWidget -> navBarWidget , NVS_BAR_WORD_SELECT , g_selectCnt == 20 ? "20" : "33" );
124
+ SetRightBtnCb (g_pageWidget -> navBarWidget , SelectParseCntHandler , NULL );
125
+ }
122
126
}
123
127
124
128
static void StopCreateViewHandler (lv_event_t * e )
@@ -301,13 +305,13 @@ static void MnemonicConfirmHandler(lv_event_t * e)
301
305
g_currId ++ ;
302
306
}
303
307
304
- if (g_currId == g_phraseCnt ) {
305
- char * confirmMnemonic = SRAM_MALLOC (10 * g_phraseCnt + 1 );
308
+ if (g_currId == g_selectCnt ) {
309
+ char * confirmMnemonic = SRAM_MALLOC (10 * g_selectCnt + 1 );
306
310
confirmMnemonic [0 ] = 0 ;
307
- for (i = 0 ; i < g_phraseCnt ; i ++ ) {
311
+ for (i = 0 ; i < g_selectCnt ; i ++ ) {
308
312
j = (g_pressedBtn [i ] - 1 ) + (g_pressedBtn [i ] - 1 ) / 3 ;
309
313
strcat (confirmMnemonic , strchr (g_shareConfirmTile .keyBoard -> mnemonicWord [j ], '\n' ) + 1 );
310
- if (i < g_phraseCnt - 1 ) {
314
+ if (i < g_selectCnt - 1 ) {
311
315
strcat (confirmMnemonic , " " );
312
316
}
313
317
}
@@ -319,7 +323,7 @@ static void MnemonicConfirmHandler(lv_event_t * e)
319
323
} else {
320
324
g_noticeWindow = GuiCreateErrorCodeWindow (ERR_KEYSTORE_MNEMONIC_NOT_MATCH_WALLET , & g_noticeWindow , NULL );
321
325
}
322
- memset_s (confirmMnemonic , 10 * g_phraseCnt + 1 , 0 , 10 * g_phraseCnt + 1 );
326
+ memset_s (confirmMnemonic , 10 * g_selectCnt + 1 , 0 , 10 * g_selectCnt + 1 );
323
327
SRAM_FREE (confirmMnemonic );
324
328
}
325
329
}
@@ -339,7 +343,7 @@ static void GuiShareBackupWidget(lv_obj_t *parent)
339
343
lv_obj_refr_size (label );
340
344
height -= lv_obj_get_self_height (label );
341
345
342
- g_shareBackupTile .keyBoard = GuiCreateMnemonicKeyBoard (parent , NULL , g_phraseCnt == 20 ? KEY_STONE_MNEMONIC_20 : KEY_STONE_MNEMONIC_33 , NULL );
346
+ g_shareBackupTile .keyBoard = GuiCreateMnemonicKeyBoard (parent , NULL , g_selectCnt == 20 ? KEY_STONE_MNEMONIC_20 : KEY_STONE_MNEMONIC_33 , NULL );
343
347
lv_obj_align_to (g_shareBackupTile .keyBoard -> cont , label , LV_ALIGN_OUT_BOTTOM_LEFT , 0 , 36 );
344
348
lv_obj_set_size (g_shareBackupTile .keyBoard -> cont , 408 , height );
345
349
@@ -364,7 +368,7 @@ static void GuiShareConfirmWidget(lv_obj_t *parent)
364
368
365
369
g_shareConfirmTile .noticeLabel = label ;
366
370
367
- g_shareConfirmTile .keyBoard = GuiCreateMnemonicKeyBoard (parent , MnemonicConfirmHandler , g_phraseCnt == 20 ? KEY_STONE_MNEMONIC_20 : KEY_STONE_MNEMONIC_33 , NULL );
371
+ g_shareConfirmTile .keyBoard = GuiCreateMnemonicKeyBoard (parent , MnemonicConfirmHandler , g_selectCnt == 20 ? KEY_STONE_MNEMONIC_20 : KEY_STONE_MNEMONIC_33 , NULL );
368
372
lv_obj_align_to (g_shareConfirmTile .keyBoard -> cont , label , LV_ALIGN_OUT_BOTTOM_LEFT , 0 , 36 );
369
373
}
370
374
@@ -420,7 +424,7 @@ int8_t GuiCreateShareNextSlice(void)
420
424
GuiUpdateMnemonicKeyBoard (g_shareBackupTile .keyBoard , SecretCacheGetSlip39Mnemonic (g_createShareTileView .currentSlice ), false);
421
425
SetNavBarRightBtn (g_pageWidget -> navBarWidget , NVS_RIGHT_BUTTON_BUTT , NULL , NULL );
422
426
lv_obj_set_tile_id (g_createShareTileView .tileView , g_createShareTileView .currentTile , 0 , LV_ANIM_OFF );
423
- ArrayRandom (SecretCacheGetSlip39Mnemonic (g_createShareTileView .currentSlice ), g_randomBuff , g_phraseCnt );
427
+ ArrayRandom (SecretCacheGetSlip39Mnemonic (g_createShareTileView .currentSlice ), g_randomBuff , g_selectCnt );
424
428
GuiUpdateMnemonicKeyBoard (g_shareConfirmTile .keyBoard , g_randomBuff , true);
425
429
return SUCCESS_CODE ;
426
430
}
@@ -430,7 +434,7 @@ int8_t GuiCreateShareNextTile(void)
430
434
Slip39Data_t slip39 = {
431
435
.threShold = g_selectSliceTile .memberThreshold ,
432
436
.memberCnt = g_selectSliceTile .memberCnt ,
433
- .wordCnt = g_phraseCnt ,
437
+ .wordCnt = g_selectCnt ,
434
438
};
435
439
switch (g_createShareTileView .currentTile ) {
436
440
case CREATE_SHARE_SELECT_SLICE :
@@ -446,8 +450,8 @@ int8_t GuiCreateShareNextTile(void)
446
450
case CREATE_SHARE_CUSTODIAN :
447
451
lv_obj_clear_flag (g_shareBackupTile .nextCont , LV_OBJ_FLAG_HIDDEN );
448
452
if (g_createShareTileView .currentSlice == 0 ) {
449
- SetRightBtnLabel (g_pageWidget -> navBarWidget , NVS_BAR_WORD_SELECT , g_phraseCnt == 20 ? "20" : "33" );
450
- SetRightBtnCb (g_pageWidget -> navBarWidget , SelectPhraseCntHandler , NULL );
453
+ SetRightBtnLabel (g_pageWidget -> navBarWidget , NVS_BAR_WORD_SELECT , g_selectCnt == 20 ? "20" : "33" );
454
+ SetRightBtnCb (g_pageWidget -> navBarWidget , SelectParseCntHandler , NULL );
451
455
}
452
456
break ;
453
457
case CREATE_SHARE_BACKUPFROM :
@@ -458,7 +462,7 @@ int8_t GuiCreateShareNextTile(void)
458
462
case CREATE_SHARE_CONFIRM :
459
463
SetNavBarLeftBtn (g_pageWidget -> navBarWidget , NVS_LEFT_BUTTON_BUTT , NULL , NULL );
460
464
SetNavBarRightBtn (g_pageWidget -> navBarWidget , NVS_RIGHT_BUTTON_BUTT , NULL , NULL );
461
- GuiModelSlip39WriteSe (g_phraseCnt );
465
+ GuiModelSlip39WriteSe (g_selectCnt );
462
466
break ;
463
467
}
464
468
g_createShareTileView .currentTile ++ ;
@@ -492,7 +496,7 @@ void GuiCreateShareDeInit(void)
492
496
g_pressedBtnFlag [i ] = 0 ;
493
497
}
494
498
g_currId = 0 ;
495
- g_phraseCnt = 20 ;
499
+ g_selectCnt = 20 ;
496
500
g_selectSliceTile .memberCnt = SLIP39_DEFAULT_MEMBER_COUNT ;
497
501
g_selectSliceTile .memberThreshold = SLIP39_DEFAULT_MEMBER_THRESHOLD ;
498
502
memset_s (g_randomBuff , 512 , 0 , 512 );
@@ -514,8 +518,8 @@ void GuiCreateShareRefresh(void)
514
518
SetNavBarLeftBtn (g_pageWidget -> navBarWidget , NVS_BAR_RETURN , CloseCurrentViewHandler , NULL );
515
519
} else if (g_createShareTileView .currentTile == CREATE_SHARE_BACKUPFROM ) {
516
520
SetNavBarLeftBtn (g_pageWidget -> navBarWidget , NVS_BAR_CLOSE , StopCreateViewHandler , NULL );
517
- SetRightBtnLabel (g_pageWidget -> navBarWidget , NVS_BAR_WORD_SELECT , g_phraseCnt == 20 ? "20" : "33" );
518
- SetRightBtnCb (g_pageWidget -> navBarWidget , SelectPhraseCntHandler , NULL );
521
+ SetRightBtnLabel (g_pageWidget -> navBarWidget , NVS_BAR_WORD_SELECT , g_selectCnt == 20 ? "20" : "33" );
522
+ SetRightBtnCb (g_pageWidget -> navBarWidget , SelectParseCntHandler , NULL );
519
523
} else if (g_createShareTileView .currentTile == CREATE_SHARE_CONFIRM ) {
520
524
SetNavBarLeftBtn (g_pageWidget -> navBarWidget , NVS_BAR_CLOSE , StopCreateViewHandler , NULL );
521
525
SetNavBarRightBtn (g_pageWidget -> navBarWidget , NVS_BAR_WORD_RESET , ResetBtnHandler , NULL );
@@ -525,7 +529,7 @@ void GuiCreateShareRefresh(void)
525
529
SetNavBarMidBtn (g_pageWidget -> navBarWidget , NVS_MID_BUTTON_BUTT , NULL , NULL );
526
530
}
527
531
528
- static void SelectPhraseCntHandler (lv_event_t * e )
532
+ static void SelectParseCntHandler (lv_event_t * e )
529
533
{
530
534
static uint32_t currentIndex = 0 ;
531
535
lv_obj_t * checkBox = NULL ;
@@ -537,7 +541,7 @@ static void SelectPhraseCntHandler(lv_event_t *e)
537
541
lv_obj_t * button = GuiCreateImgButton (g_noticeWindow , & imgClose , 36 , CloseHintBoxHandler , & g_noticeWindow );
538
542
lv_obj_align (button , LV_ALIGN_DEFAULT , 407 , 550 );
539
543
540
- if (g_phraseCnt == 33 ) {
544
+ if (g_selectCnt == 33 ) {
541
545
checkBox = GuiCreateSingleCheckBox (g_noticeWindow , _ ("wallet_phrase_20words" ));
542
546
lv_obj_align (checkBox , LV_ALIGN_DEFAULT , 30 , 630 );
543
547
checkBox = GuiCreateSingleCheckBox (g_noticeWindow , _ ("wallet_phrase_33words" ));
@@ -576,10 +580,9 @@ static void SelectCheckBoxHandler(lv_event_t* e)
576
580
const char * currText = lv_checkbox_get_text (actCb );
577
581
if (!strcmp (currText , _ ("wallet_phrase_20words" ))) {
578
582
SetRightBtnLabel (g_pageWidget -> navBarWidget , NVS_BAR_WORD_SELECT , "20" );
579
- SetRightBtnCb (g_pageWidget -> navBarWidget , SelectPhraseCntHandler , NULL );
580
- if (g_phraseCnt != 20 ) {
581
- g_phraseCnt = 20 ;
582
- slip39 .wordCnt = g_phraseCnt ;
583
+ if (g_selectCnt != 20 ) {
584
+ g_selectCnt = 20 ;
585
+ slip39 .wordCnt = g_selectCnt ;
583
586
if (g_entropyMethod == 0 ) {
584
587
GuiModelSlip39UpdateMnemonic (slip39 );
585
588
} else {
@@ -588,17 +591,17 @@ static void SelectCheckBoxHandler(lv_event_t* e)
588
591
}
589
592
} else if (!strcmp (currText , _ ("wallet_phrase_33words" ))) {
590
593
SetRightBtnLabel (g_pageWidget -> navBarWidget , NVS_BAR_WORD_SELECT , "33" );
591
- SetRightBtnCb (g_pageWidget -> navBarWidget , SelectPhraseCntHandler , NULL );
592
- if (g_phraseCnt != 33 ) {
593
- g_phraseCnt = 33 ;
594
- slip39 .wordCnt = g_phraseCnt ;
594
+ if (g_selectCnt != 33 ) {
595
+ g_selectCnt = 33 ;
596
+ slip39 .wordCnt = g_selectCnt ;
595
597
if (g_entropyMethod == 0 ) {
596
598
GuiModelSlip39UpdateMnemonic (slip39 );
597
599
} else {
598
600
GuiModelSlip39UpdateMnemonicWithDiceRolls (slip39 );
599
601
}
600
602
}
601
603
}
604
+ lv_obj_clear_flag (g_pageWidget -> navBarWidget -> rightBtn , LV_OBJ_FLAG_CLICKABLE );
602
605
lv_obj_scroll_to_y (g_shareBackupTile .keyBoard -> cont , 0 , LV_ANIM_ON );
603
606
GUI_DEL_OBJ (g_noticeWindow )
604
607
}
0 commit comments