Skip to content

Commit 39c8dfe

Browse files
committed
fix: remove haptic, add mnemonic import status text
1 parent 2e4023b commit 39c8dfe

7 files changed

+58
-74
lines changed

flipbip.c

+18-9
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
#include "flipbip.h"
22
#include "helpers/flipbip_file.h"
3-
#include "helpers/flipbip_haptic.h"
3+
//#include "helpers/flipbip_haptic.h"
44
// From: lib/crypto
55
#include <memzero.h>
66
#include <bip39.h>
77

8+
#define MNEMONIC_MENU_DEFAULT "Import mnemonic seed"
9+
#define MNEMONIC_MENU_SUCCESS "Import seed (success)"
10+
#define MNEMONIC_MENU_FAILURE "Import seed (failure)"
11+
812
bool flipbip_custom_event_callback(void* context, uint32_t event) {
913
furi_assert(context);
1014
FlipBip* app = context;
@@ -40,7 +44,7 @@ static void text_input_callback(void* context) {
4044
// reset input state
4145
app->input_state = FlipBipTextInputDefault;
4246
handled = true;
43-
view_dispatcher_switch_to_view(app->view_dispatcher, FlipBipViewIdSettings);
47+
//view_dispatcher_switch_to_view(app->view_dispatcher, FlipBipViewIdSettings);
4448
} else if(app->input_state == FlipBipTextInputMnemonic) {
4549
if(app->import_from_mnemonic == 1) {
4650
strcpy(app->import_mnemonic_text, app->input_text);
@@ -54,11 +58,13 @@ static void text_input_callback(void* context) {
5458
status = FlipBipStatusSaveError; // 12 = save error
5559

5660
if(status == FlipBipStatusSuccess) {
61+
app->mnemonic_menu_text = MNEMONIC_MENU_SUCCESS;
5762
//notification_message(app->notification, &sequence_blink_cyan_100);
58-
flipbip_play_happy_bump(app);
63+
//flipbip_play_happy_bump(app);
5964
} else {
65+
app->mnemonic_menu_text = MNEMONIC_MENU_FAILURE;
6066
//notification_message(app->notification, &sequence_blink_red_100);
61-
flipbip_play_long_bump(app);
67+
//flipbip_play_long_bump(app);
6268
}
6369

6470
memzero(app->import_mnemonic_text, TEXT_BUFFER_SIZE);
@@ -68,7 +74,9 @@ static void text_input_callback(void* context) {
6874
// reset input state
6975
app->input_state = FlipBipTextInputDefault;
7076
handled = true;
71-
view_dispatcher_switch_to_view(app->view_dispatcher, FlipBipViewIdMenu);
77+
// exit scene 1 instance that's being used for text input and go back to menu
78+
scene_manager_previous_scene(app->scene_manager);
79+
//view_dispatcher_switch_to_view(app->view_dispatcher, FlipBipViewIdMenu);
7280
}
7381
}
7482

@@ -77,17 +85,17 @@ static void text_input_callback(void* context) {
7785
memzero(app->input_text, TEXT_BUFFER_SIZE);
7886
// reset input state
7987
app->input_state = FlipBipTextInputDefault;
80-
view_dispatcher_switch_to_view(app->view_dispatcher, FlipBipViewIdMenu);
88+
//view_dispatcher_switch_to_view(app->view_dispatcher, FlipBipViewIdMenu);
8189
}
8290
}
8391

8492
FlipBip* flipbip_app_alloc() {
8593
FlipBip* app = malloc(sizeof(FlipBip));
8694
app->gui = furi_record_open(RECORD_GUI);
87-
app->notification = furi_record_open(RECORD_NOTIFICATION);
95+
//app->notification = furi_record_open(RECORD_NOTIFICATION);
8896

8997
//Turn backlight on, believe me this makes testing your app easier
90-
notification_message(app->notification, &sequence_display_backlight_on);
98+
//notification_message(app->notification, &sequence_display_backlight_on);
9199

92100
//Scene additions
93101
app->view_dispatcher = view_dispatcher_alloc();
@@ -111,6 +119,7 @@ FlipBip* flipbip_app_alloc() {
111119
app->bip44_coin = FlipBipCoinBTC0; // 0 (BTC)
112120
app->overwrite_saved_seed = 0;
113121
app->import_from_mnemonic = 0;
122+
app->mnemonic_menu_text = MNEMONIC_MENU_DEFAULT;
114123

115124
// Text input
116125
app->input_state = FlipBipTextInputDefault;
@@ -163,7 +172,7 @@ void flipbip_app_free(FlipBip* app) {
163172
furi_record_close(RECORD_GUI);
164173

165174
app->gui = NULL;
166-
app->notification = NULL;
175+
//app->notification = NULL;
167176

168177
//Remove whatever is left
169178
memzero(app, sizeof(FlipBip));

flipbip.h

+3-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#include <gui/gui.h>
66
#include <input/input.h>
77
#include <stdlib.h>
8-
#include <notification/notification_messages.h>
8+
//#include <notification/notification_messages.h>
99
#include <gui/view_dispatcher.h>
1010
#include <gui/modules/submenu.h>
1111
#include <gui/scene_manager.h>
@@ -25,13 +25,14 @@
2525

2626
typedef struct {
2727
Gui* gui;
28-
NotificationApp* notification;
28+
// NotificationApp* notification;
2929
ViewDispatcher* view_dispatcher;
3030
Submenu* submenu;
3131
SceneManager* scene_manager;
3232
VariableItemList* variable_item_list;
3333
TextInput* text_input;
3434
FlipBipScene1* flipbip_scene_1;
35+
char* mnemonic_menu_text;
3536
// Settings options
3637
int haptic;
3738
int bip39_strength;

helpers/flipbip_haptic.c

-35
This file was deleted.

helpers/flipbip_haptic.h

-7
This file was deleted.

scenes/flipbip_scene_menu.c

+6-3
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ void flipbip_scene_menu_on_enter(void* context) {
7272
}
7373
submenu_add_item(
7474
app->submenu,
75-
"Import from mnemonic",
75+
app->mnemonic_menu_text,
7676
SubmenuIndexScene1Import,
7777
flipbip_scene_menu_submenu_callback,
7878
app);
@@ -137,8 +137,11 @@ bool flipbip_scene_menu_on_event(void* context, SceneManagerEvent event) {
137137
} else if(event.event == SubmenuIndexScene1Import) {
138138
app->import_from_mnemonic = 1;
139139
app->input_state = FlipBipTextInputMnemonic;
140-
text_input_set_header_text(app->text_input, "Enter mnemonic phrase");
141-
view_dispatcher_switch_to_view(app->view_dispatcher, FlipBipViewIdTextInput);
140+
141+
scene_manager_set_scene_state(
142+
app->scene_manager, FlipBipSceneMenu, SubmenuIndexScene1Import);
143+
scene_manager_next_scene(app->scene_manager, FlipBipSceneScene_1);
144+
142145
return true;
143146
} else if(event.event == SubmenuIndexSettings) {
144147
scene_manager_set_scene_state(

scenes/flipbip_scene_scene_1.c

+20-11
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,17 @@ void flipbip_scene_1_callback(FlipBipCustomEvent event, void* context) {
1111
void flipbip_scene_scene_1_on_enter(void* context) {
1212
furi_assert(context);
1313
FlipBip* app = context;
14-
flipbip_scene_1_set_callback(app->flipbip_scene_1, flipbip_scene_1_callback, app);
15-
view_dispatcher_switch_to_view(app->view_dispatcher, FlipBipViewIdScene1);
14+
15+
if(app->import_from_mnemonic == 1) {
16+
// handle mnemonic seed import mode with text input, this only
17+
// uses this scene to have a correct stack os scenes
18+
text_input_set_header_text(app->text_input, "Enter mnemonic phrase");
19+
view_dispatcher_switch_to_view(app->view_dispatcher, FlipBipViewIdTextInput);
20+
} else {
21+
// handle all other modes, these actually use this scene's logic
22+
flipbip_scene_1_set_callback(app->flipbip_scene_1, flipbip_scene_1_callback, app);
23+
view_dispatcher_switch_to_view(app->view_dispatcher, FlipBipViewIdScene1);
24+
}
1625
}
1726

1827
bool flipbip_scene_scene_1_on_event(void* context, SceneManagerEvent event) {
@@ -21,16 +30,16 @@ bool flipbip_scene_scene_1_on_event(void* context, SceneManagerEvent event) {
2130

2231
if(event.type == SceneManagerEventTypeCustom) {
2332
switch(event.event) {
24-
case FlipBipCustomEventScene1Left:
25-
case FlipBipCustomEventScene1Right:
26-
break;
27-
case FlipBipCustomEventScene1Up:
28-
case FlipBipCustomEventScene1Down:
29-
break;
33+
// case FlipBipCustomEventScene1Left:
34+
// case FlipBipCustomEventScene1Right:
35+
// break;
36+
// case FlipBipCustomEventScene1Up:
37+
// case FlipBipCustomEventScene1Down:
38+
// break;
3039
case FlipBipCustomEventScene1Back:
31-
notification_message(app->notification, &sequence_reset_red);
32-
notification_message(app->notification, &sequence_reset_green);
33-
notification_message(app->notification, &sequence_reset_blue);
40+
//notification_message(app->notification, &sequence_reset_red);
41+
//notification_message(app->notification, &sequence_reset_green);
42+
//notification_message(app->notification, &sequence_reset_blue);
3443
if(!scene_manager_search_and_switch_to_previous_scene(
3544
app->scene_manager, FlipBipSceneMenu)) {
3645
scene_manager_stop(app->scene_manager);

views/flipbip_scene_1.c

+11-7
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
//#include <dolphin/dolphin.h>
77
#include <storage/storage.h>
88
#include <string.h>
9-
// #include "flipbip_icons.h"
10-
#include "../helpers/flipbip_haptic.h"
9+
//#include "flipbip_icons.h"
10+
//#include "../helpers/flipbip_haptic.h"
1111
#include "../helpers/flipbip_string.h"
1212
#include "../helpers/flipbip_file.h"
1313
// From: /lib/crypto
@@ -663,7 +663,10 @@ void flipbip_scene_1_enter(void* context) {
663663
s_derivation_text = TEXT_NEW_WALLET;
664664
}
665665

666-
flipbip_play_happy_bump(app);
666+
// Wait a beat to allow the display time to update to the loading screen
667+
furi_thread_flags_wait(0, FuriFlagWaitAny, 20);
668+
669+
//flipbip_play_happy_bump(app);
667670
//notification_message(app->notification, &sequence_blink_cyan_100);
668671
//flipbip_led_set_rgb(app, 255, 0, 0);
669672

@@ -678,23 +681,24 @@ void flipbip_scene_1_enter(void* context) {
678681

679682
// nonzero status, free the mnemonic
680683
if(status != FlipBipStatusSuccess) {
681-
memzero((void*)model->mnemonic, strlen(model->mnemonic));
684+
// calling strlen on mnemonic here can cause a crash, don't.
685+
// it wasn't loaded properly anyways, no need to zero the memory
682686
free((void*)model->mnemonic);
683687
}
684688

685689
// if error, set the error message
686690
if(status == FlipBipStatusSaveError) {
687691
model->mnemonic = "ERROR:,Save error";
688692
model->page = PAGE_MNEMONIC;
689-
flipbip_play_long_bump(app);
693+
//flipbip_play_long_bump(app);
690694
} else if(status == FlipBipStatusLoadError) {
691695
model->mnemonic = "ERROR:,Load error";
692696
model->page = PAGE_MNEMONIC;
693-
flipbip_play_long_bump(app);
697+
//flipbip_play_long_bump(app);
694698
} else if(status == FlipBipStatusMnemonicCheckError) {
695699
model->mnemonic = "ERROR:,Mnemonic check error";
696700
model->page = PAGE_MNEMONIC;
697-
flipbip_play_long_bump(app);
701+
//flipbip_play_long_bump(app);
698702
}
699703

700704
// s_busy = false;

0 commit comments

Comments
 (0)