|
@@ -1,10 +1,13 @@
|
|
|
#include "flipbip.h"
|
|
#include "flipbip.h"
|
|
|
#include "helpers/flipbip_file.h"
|
|
#include "helpers/flipbip_file.h"
|
|
|
-#include "helpers/flipbip_haptic.h"
|
|
|
|
|
// From: lib/crypto
|
|
// From: lib/crypto
|
|
|
#include <memzero.h>
|
|
#include <memzero.h>
|
|
|
#include <bip39.h>
|
|
#include <bip39.h>
|
|
|
|
|
|
|
|
|
|
+#define MNEMONIC_MENU_DEFAULT "Import mnemonic seed"
|
|
|
|
|
+#define MNEMONIC_MENU_SUCCESS "Import seed (success)"
|
|
|
|
|
+#define MNEMONIC_MENU_FAILURE "Import seed (failed!)"
|
|
|
|
|
+
|
|
|
bool flipbip_custom_event_callback(void* context, uint32_t event) {
|
|
bool flipbip_custom_event_callback(void* context, uint32_t event) {
|
|
|
furi_assert(context);
|
|
furi_assert(context);
|
|
|
FlipBip* app = context;
|
|
FlipBip* app = context;
|
|
@@ -40,6 +43,7 @@ static void text_input_callback(void* context) {
|
|
|
// reset input state
|
|
// reset input state
|
|
|
app->input_state = FlipBipTextInputDefault;
|
|
app->input_state = FlipBipTextInputDefault;
|
|
|
handled = true;
|
|
handled = true;
|
|
|
|
|
+ // switch back to settings view
|
|
|
view_dispatcher_switch_to_view(app->view_dispatcher, FlipBipViewIdSettings);
|
|
view_dispatcher_switch_to_view(app->view_dispatcher, FlipBipViewIdSettings);
|
|
|
} else if(app->input_state == FlipBipTextInputMnemonic) {
|
|
} else if(app->input_state == FlipBipTextInputMnemonic) {
|
|
|
if(app->import_from_mnemonic == 1) {
|
|
if(app->import_from_mnemonic == 1) {
|
|
@@ -54,11 +58,13 @@ static void text_input_callback(void* context) {
|
|
|
status = FlipBipStatusSaveError; // 12 = save error
|
|
status = FlipBipStatusSaveError; // 12 = save error
|
|
|
|
|
|
|
|
if(status == FlipBipStatusSuccess) {
|
|
if(status == FlipBipStatusSuccess) {
|
|
|
|
|
+ app->mnemonic_menu_text = MNEMONIC_MENU_SUCCESS;
|
|
|
//notification_message(app->notification, &sequence_blink_cyan_100);
|
|
//notification_message(app->notification, &sequence_blink_cyan_100);
|
|
|
- flipbip_play_happy_bump(app);
|
|
|
|
|
|
|
+ //flipbip_play_happy_bump(app);
|
|
|
} else {
|
|
} else {
|
|
|
|
|
+ app->mnemonic_menu_text = MNEMONIC_MENU_FAILURE;
|
|
|
//notification_message(app->notification, &sequence_blink_red_100);
|
|
//notification_message(app->notification, &sequence_blink_red_100);
|
|
|
- flipbip_play_long_bump(app);
|
|
|
|
|
|
|
+ //flipbip_play_long_bump(app);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
memzero(app->import_mnemonic_text, TEXT_BUFFER_SIZE);
|
|
memzero(app->import_mnemonic_text, TEXT_BUFFER_SIZE);
|
|
@@ -68,7 +74,9 @@ static void text_input_callback(void* context) {
|
|
|
// reset input state
|
|
// reset input state
|
|
|
app->input_state = FlipBipTextInputDefault;
|
|
app->input_state = FlipBipTextInputDefault;
|
|
|
handled = true;
|
|
handled = true;
|
|
|
- view_dispatcher_switch_to_view(app->view_dispatcher, FlipBipViewIdMenu);
|
|
|
|
|
|
|
+ // exit scene 1 instance that's being used for text input and go back to menu
|
|
|
|
|
+ scene_manager_previous_scene(app->scene_manager);
|
|
|
|
|
+ //view_dispatcher_switch_to_view(app->view_dispatcher, FlipBipViewIdMenu);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -77,6 +85,7 @@ static void text_input_callback(void* context) {
|
|
|
memzero(app->input_text, TEXT_BUFFER_SIZE);
|
|
memzero(app->input_text, TEXT_BUFFER_SIZE);
|
|
|
// reset input state
|
|
// reset input state
|
|
|
app->input_state = FlipBipTextInputDefault;
|
|
app->input_state = FlipBipTextInputDefault;
|
|
|
|
|
+ // something went wrong, switch to menu view
|
|
|
view_dispatcher_switch_to_view(app->view_dispatcher, FlipBipViewIdMenu);
|
|
view_dispatcher_switch_to_view(app->view_dispatcher, FlipBipViewIdMenu);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -84,12 +93,12 @@ static void text_input_callback(void* context) {
|
|
|
FlipBip* flipbip_app_alloc() {
|
|
FlipBip* flipbip_app_alloc() {
|
|
|
FlipBip* app = malloc(sizeof(FlipBip));
|
|
FlipBip* app = malloc(sizeof(FlipBip));
|
|
|
app->gui = furi_record_open(RECORD_GUI);
|
|
app->gui = furi_record_open(RECORD_GUI);
|
|
|
- app->notification = furi_record_open(RECORD_NOTIFICATION);
|
|
|
|
|
|
|
+ //app->notification = furi_record_open(RECORD_NOTIFICATION);
|
|
|
|
|
|
|
|
- //Turn backlight on, believe me this makes testing your app easier
|
|
|
|
|
- notification_message(app->notification, &sequence_display_backlight_on);
|
|
|
|
|
|
|
+ // Turn backlight on, believe me this makes testing your app easier
|
|
|
|
|
+ //notification_message(app->notification, &sequence_display_backlight_on);
|
|
|
|
|
|
|
|
- //Scene additions
|
|
|
|
|
|
|
+ // Scene additions
|
|
|
app->view_dispatcher = view_dispatcher_alloc();
|
|
app->view_dispatcher = view_dispatcher_alloc();
|
|
|
view_dispatcher_enable_queue(app->view_dispatcher);
|
|
view_dispatcher_enable_queue(app->view_dispatcher);
|
|
|
|
|
|
|
@@ -103,8 +112,6 @@ FlipBip* flipbip_app_alloc() {
|
|
|
app->submenu = submenu_alloc();
|
|
app->submenu = submenu_alloc();
|
|
|
|
|
|
|
|
// Settings
|
|
// Settings
|
|
|
- app->haptic = FlipBipHapticOn;
|
|
|
|
|
- app->led = FlipBipLedOn;
|
|
|
|
|
app->bip39_strength = FlipBipStrength256; // 256 bits (24 words)
|
|
app->bip39_strength = FlipBipStrength256; // 256 bits (24 words)
|
|
|
app->passphrase = FlipBipPassphraseOff;
|
|
app->passphrase = FlipBipPassphraseOff;
|
|
|
|
|
|
|
@@ -112,17 +119,13 @@ FlipBip* flipbip_app_alloc() {
|
|
|
app->bip44_coin = FlipBipCoinBTC0; // 0 (BTC)
|
|
app->bip44_coin = FlipBipCoinBTC0; // 0 (BTC)
|
|
|
app->overwrite_saved_seed = 0;
|
|
app->overwrite_saved_seed = 0;
|
|
|
app->import_from_mnemonic = 0;
|
|
app->import_from_mnemonic = 0;
|
|
|
|
|
+ app->mnemonic_menu_text = MNEMONIC_MENU_DEFAULT;
|
|
|
|
|
|
|
|
// Text input
|
|
// Text input
|
|
|
app->input_state = FlipBipTextInputDefault;
|
|
app->input_state = FlipBipTextInputDefault;
|
|
|
|
|
|
|
|
view_dispatcher_add_view(
|
|
view_dispatcher_add_view(
|
|
|
app->view_dispatcher, FlipBipViewIdMenu, submenu_get_view(app->submenu));
|
|
app->view_dispatcher, FlipBipViewIdMenu, submenu_get_view(app->submenu));
|
|
|
- app->flipbip_startscreen = flipbip_startscreen_alloc();
|
|
|
|
|
- view_dispatcher_add_view(
|
|
|
|
|
- app->view_dispatcher,
|
|
|
|
|
- FlipBipViewIdStartscreen,
|
|
|
|
|
- flipbip_startscreen_get_view(app->flipbip_startscreen));
|
|
|
|
|
app->flipbip_scene_1 = flipbip_scene_1_alloc();
|
|
app->flipbip_scene_1 = flipbip_scene_1_alloc();
|
|
|
view_dispatcher_add_view(
|
|
view_dispatcher_add_view(
|
|
|
app->view_dispatcher, FlipBipViewIdScene1, flipbip_scene_1_get_view(app->flipbip_scene_1));
|
|
app->view_dispatcher, FlipBipViewIdScene1, flipbip_scene_1_get_view(app->flipbip_scene_1));
|
|
@@ -139,13 +142,13 @@ FlipBip* flipbip_app_alloc() {
|
|
|
(void*)app,
|
|
(void*)app,
|
|
|
app->input_text,
|
|
app->input_text,
|
|
|
TEXT_BUFFER_SIZE,
|
|
TEXT_BUFFER_SIZE,
|
|
|
- //clear default text
|
|
|
|
|
|
|
+ // clear default text
|
|
|
true);
|
|
true);
|
|
|
- text_input_set_header_text(app->text_input, "Input");
|
|
|
|
|
|
|
+ //text_input_set_header_text(app->text_input, "Input");
|
|
|
view_dispatcher_add_view(
|
|
view_dispatcher_add_view(
|
|
|
app->view_dispatcher, FlipBipViewIdTextInput, text_input_get_view(app->text_input));
|
|
app->view_dispatcher, FlipBipViewIdTextInput, text_input_get_view(app->text_input));
|
|
|
|
|
|
|
|
- //End Scene Additions
|
|
|
|
|
|
|
+ // End Scene Additions
|
|
|
|
|
|
|
|
return app;
|
|
return app;
|
|
|
}
|
|
}
|
|
@@ -169,7 +172,7 @@ void flipbip_app_free(FlipBip* app) {
|
|
|
furi_record_close(RECORD_GUI);
|
|
furi_record_close(RECORD_GUI);
|
|
|
|
|
|
|
|
app->gui = NULL;
|
|
app->gui = NULL;
|
|
|
- app->notification = NULL;
|
|
|
|
|
|
|
+ //app->notification = NULL;
|
|
|
|
|
|
|
|
//Remove whatever is left
|
|
//Remove whatever is left
|
|
|
memzero(app, sizeof(FlipBip));
|
|
memzero(app, sizeof(FlipBip));
|
|
@@ -188,9 +191,7 @@ int32_t flipbip_app(void* p) {
|
|
|
|
|
|
|
|
view_dispatcher_attach_to_gui(app->view_dispatcher, app->gui, ViewDispatcherTypeFullscreen);
|
|
view_dispatcher_attach_to_gui(app->view_dispatcher, app->gui, ViewDispatcherTypeFullscreen);
|
|
|
|
|
|
|
|
- scene_manager_next_scene(
|
|
|
|
|
- app->scene_manager, FlipBipSceneStartscreen); //Start with start screen
|
|
|
|
|
- //scene_manager_next_scene(app->scene_manager, FlipBipSceneMenu); //if you want to directly start with Menu
|
|
|
|
|
|
|
+ scene_manager_next_scene(app->scene_manager, FlipBipSceneMenu); //Start with menu
|
|
|
|
|
|
|
|
furi_hal_power_suppress_charge_enter();
|
|
furi_hal_power_suppress_charge_enter();
|
|
|
|
|
|