1
1
#include "flipbip.h"
2
2
#include "helpers/flipbip_file.h"
3
- #include "helpers/flipbip_haptic.h"
4
3
// From: lib/crypto
5
4
#include <memzero.h>
6
5
#include <bip39.h>
7
6
7
+ #define MNEMONIC_MENU_DEFAULT "Import mnemonic seed"
8
+ #define MNEMONIC_MENU_SUCCESS "Import seed (success)"
9
+ #define MNEMONIC_MENU_FAILURE "Import seed (failed!)"
10
+
8
11
bool flipbip_custom_event_callback (void * context , uint32_t event ) {
9
12
furi_assert (context );
10
13
FlipBip * app = context ;
@@ -40,6 +43,7 @@ static void text_input_callback(void* context) {
40
43
// reset input state
41
44
app -> input_state = FlipBipTextInputDefault ;
42
45
handled = true;
46
+ // switch back to settings view
43
47
view_dispatcher_switch_to_view (app -> view_dispatcher , FlipBipViewIdSettings );
44
48
} else if (app -> input_state == FlipBipTextInputMnemonic ) {
45
49
if (app -> import_from_mnemonic == 1 ) {
@@ -54,11 +58,13 @@ static void text_input_callback(void* context) {
54
58
status = FlipBipStatusSaveError ; // 12 = save error
55
59
56
60
if (status == FlipBipStatusSuccess ) {
61
+ app -> mnemonic_menu_text = MNEMONIC_MENU_SUCCESS ;
57
62
//notification_message(app->notification, &sequence_blink_cyan_100);
58
- flipbip_play_happy_bump (app );
63
+ // flipbip_play_happy_bump(app);
59
64
} else {
65
+ app -> mnemonic_menu_text = MNEMONIC_MENU_FAILURE ;
60
66
//notification_message(app->notification, &sequence_blink_red_100);
61
- flipbip_play_long_bump (app );
67
+ // flipbip_play_long_bump(app);
62
68
}
63
69
64
70
memzero (app -> import_mnemonic_text , TEXT_BUFFER_SIZE );
@@ -68,7 +74,9 @@ static void text_input_callback(void* context) {
68
74
// reset input state
69
75
app -> input_state = FlipBipTextInputDefault ;
70
76
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);
72
80
}
73
81
}
74
82
@@ -77,19 +85,20 @@ static void text_input_callback(void* context) {
77
85
memzero (app -> input_text , TEXT_BUFFER_SIZE );
78
86
// reset input state
79
87
app -> input_state = FlipBipTextInputDefault ;
88
+ // something went wrong, switch to menu view
80
89
view_dispatcher_switch_to_view (app -> view_dispatcher , FlipBipViewIdMenu );
81
90
}
82
91
}
83
92
84
93
FlipBip * flipbip_app_alloc () {
85
94
FlipBip * app = malloc (sizeof (FlipBip ));
86
95
app -> gui = furi_record_open (RECORD_GUI );
87
- app -> notification = furi_record_open (RECORD_NOTIFICATION );
96
+ // app->notification = furi_record_open(RECORD_NOTIFICATION);
88
97
89
- //Turn backlight on, believe me this makes testing your app easier
90
- notification_message (app -> notification , & sequence_display_backlight_on );
98
+ // Turn backlight on, believe me this makes testing your app easier
99
+ // notification_message(app->notification, &sequence_display_backlight_on);
91
100
92
- //Scene additions
101
+ // Scene additions
93
102
app -> view_dispatcher = view_dispatcher_alloc ();
94
103
view_dispatcher_enable_queue (app -> view_dispatcher );
95
104
@@ -103,26 +112,20 @@ FlipBip* flipbip_app_alloc() {
103
112
app -> submenu = submenu_alloc ();
104
113
105
114
// Settings
106
- app -> haptic = FlipBipHapticOn ;
107
- app -> led = FlipBipLedOn ;
108
115
app -> bip39_strength = FlipBipStrength256 ; // 256 bits (24 words)
109
116
app -> passphrase = FlipBipPassphraseOff ;
110
117
111
118
// Main menu
112
119
app -> bip44_coin = FlipBipCoinBTC0 ; // 0 (BTC)
113
120
app -> overwrite_saved_seed = 0 ;
114
121
app -> import_from_mnemonic = 0 ;
122
+ app -> mnemonic_menu_text = MNEMONIC_MENU_DEFAULT ;
115
123
116
124
// Text input
117
125
app -> input_state = FlipBipTextInputDefault ;
118
126
119
127
view_dispatcher_add_view (
120
128
app -> view_dispatcher , FlipBipViewIdMenu , submenu_get_view (app -> submenu ));
121
- app -> flipbip_startscreen = flipbip_startscreen_alloc ();
122
- view_dispatcher_add_view (
123
- app -> view_dispatcher ,
124
- FlipBipViewIdStartscreen ,
125
- flipbip_startscreen_get_view (app -> flipbip_startscreen ));
126
129
app -> flipbip_scene_1 = flipbip_scene_1_alloc ();
127
130
view_dispatcher_add_view (
128
131
app -> view_dispatcher , FlipBipViewIdScene1 , flipbip_scene_1_get_view (app -> flipbip_scene_1 ));
@@ -139,13 +142,13 @@ FlipBip* flipbip_app_alloc() {
139
142
(void * )app ,
140
143
app -> input_text ,
141
144
TEXT_BUFFER_SIZE ,
142
- //clear default text
145
+ // clear default text
143
146
true);
144
- text_input_set_header_text (app -> text_input , "Input" );
147
+ // text_input_set_header_text(app->text_input, "Input");
145
148
view_dispatcher_add_view (
146
149
app -> view_dispatcher , FlipBipViewIdTextInput , text_input_get_view (app -> text_input ));
147
150
148
- //End Scene Additions
151
+ // End Scene Additions
149
152
150
153
return app ;
151
154
}
@@ -169,7 +172,7 @@ void flipbip_app_free(FlipBip* app) {
169
172
furi_record_close (RECORD_GUI );
170
173
171
174
app -> gui = NULL ;
172
- app -> notification = NULL ;
175
+ // app->notification = NULL;
173
176
174
177
//Remove whatever is left
175
178
memzero (app , sizeof (FlipBip ));
@@ -188,9 +191,7 @@ int32_t flipbip_app(void* p) {
188
191
189
192
view_dispatcher_attach_to_gui (app -> view_dispatcher , app -> gui , ViewDispatcherTypeFullscreen );
190
193
191
- scene_manager_next_scene (
192
- app -> scene_manager , FlipBipSceneStartscreen ); //Start with start screen
193
- //scene_manager_next_scene(app->scene_manager, FlipBipSceneMenu); //if you want to directly start with Menu
194
+ scene_manager_next_scene (app -> scene_manager , FlipBipSceneMenu ); //Start with menu
194
195
195
196
furi_hal_power_suppress_charge_enter ();
196
197
0 commit comments