feat: FlipBIP v1.13

This commit is contained in:
Struan Clark
2023-08-11 23:51:28 -06:00
parent 5e710916d6
commit 92a481e770
26 changed files with 127 additions and 456 deletions

View File

@@ -1,4 +1,3 @@
ADD_SCENE(flipbip, startscreen, Startscreen)
ADD_SCENE(flipbip, menu, Menu)
ADD_SCENE(flipbip, scene_1, Scene_1)
ADD_SCENE(flipbip, settings, Settings)

View File

@@ -1,13 +1,17 @@
#include "../flipbip.h"
#include "../helpers/flipbip_file.h"
#define FLIPBIP_SUBMENU_TEXT "** FlipBIP wallet " FLIPBIP_VERSION " **"
enum SubmenuIndex {
SubmenuIndexScene1BTC = 10,
SubmenuIndexScene1ETH,
SubmenuIndexScene1DOGE,
SubmenuIndexScene1ZEC,
SubmenuIndexScene1New,
SubmenuIndexScene1Import,
SubmenuIndexSettings,
SubmenuIndexNOP,
};
void flipbip_scene_menu_submenu_callback(void* context, uint32_t index) {
@@ -18,6 +22,14 @@ void flipbip_scene_menu_submenu_callback(void* context, uint32_t index) {
void flipbip_scene_menu_on_enter(void* context) {
FlipBip* app = context;
// FlipBIP header with version
submenu_add_item(
app->submenu,
FLIPBIP_SUBMENU_TEXT,
SubmenuIndexNOP,
flipbip_scene_menu_submenu_callback,
app);
if(flipbip_has_file(FlipBipFileKey, NULL, false) &&
flipbip_has_file(FlipBipFileDat, NULL, false)) {
submenu_add_item(
@@ -38,6 +50,12 @@ void flipbip_scene_menu_on_enter(void* context) {
SubmenuIndexScene1DOGE,
flipbip_scene_menu_submenu_callback,
app);
submenu_add_item(
app->submenu,
"View ZEC (t-addr) wallet",
SubmenuIndexScene1ZEC,
flipbip_scene_menu_submenu_callback,
app);
submenu_add_item(
app->submenu,
"Regenerate wallet",
@@ -54,7 +72,7 @@ void flipbip_scene_menu_on_enter(void* context) {
}
submenu_add_item(
app->submenu,
"Import from mnemonic",
app->mnemonic_menu_text,
SubmenuIndexScene1Import,
flipbip_scene_menu_submenu_callback,
app);
@@ -101,6 +119,14 @@ bool flipbip_scene_menu_on_event(void* context, SceneManagerEvent event) {
app->scene_manager, FlipBipSceneMenu, SubmenuIndexScene1DOGE);
scene_manager_next_scene(app->scene_manager, FlipBipSceneScene_1);
return true;
} else if(event.event == SubmenuIndexScene1ZEC) {
app->overwrite_saved_seed = 0;
app->import_from_mnemonic = 0;
app->bip44_coin = FlipBipCoinZEC133;
scene_manager_set_scene_state(
app->scene_manager, FlipBipSceneMenu, SubmenuIndexScene1ZEC);
scene_manager_next_scene(app->scene_manager, FlipBipSceneScene_1);
return true;
} else if(event.event == SubmenuIndexScene1New) {
app->overwrite_saved_seed = 1;
app->import_from_mnemonic = 0;
@@ -110,15 +136,17 @@ bool flipbip_scene_menu_on_event(void* context, SceneManagerEvent event) {
return true;
} else if(event.event == SubmenuIndexScene1Import) {
app->import_from_mnemonic = 1;
app->input_state = FlipBipTextInputMnemonic;
text_input_set_header_text(app->text_input, "Enter mnemonic phrase");
view_dispatcher_switch_to_view(app->view_dispatcher, FlipBipViewIdTextInput);
scene_manager_set_scene_state(
app->scene_manager, FlipBipSceneMenu, SubmenuIndexScene1Import);
scene_manager_next_scene(app->scene_manager, FlipBipSceneScene_1);
return true;
} else if(event.event == SubmenuIndexSettings) {
scene_manager_set_scene_state(
app->scene_manager, FlipBipSceneMenu, SubmenuIndexSettings);
scene_manager_next_scene(app->scene_manager, FlipBipSceneSettings);
return true;
} else if(event.event == SubmenuIndexNOP) {
return true;
}
}
return false;

View File

@@ -11,8 +11,18 @@ void flipbip_scene_1_callback(FlipBipCustomEvent event, void* context) {
void flipbip_scene_scene_1_on_enter(void* context) {
furi_assert(context);
FlipBip* app = context;
flipbip_scene_1_set_callback(app->flipbip_scene_1, flipbip_scene_1_callback, app);
view_dispatcher_switch_to_view(app->view_dispatcher, FlipBipViewIdScene1);
if(app->import_from_mnemonic == 1) {
// handle mnemonic seed import mode with text input, this only
// uses this scene to have a correct stack of scenes
app->input_state = FlipBipTextInputMnemonic;
text_input_set_header_text(app->text_input, "Enter mnemonic phrase");
view_dispatcher_switch_to_view(app->view_dispatcher, FlipBipViewIdTextInput);
} else {
// handle all other modes, these actually use this scene's logic
flipbip_scene_1_set_callback(app->flipbip_scene_1, flipbip_scene_1_callback, app);
view_dispatcher_switch_to_view(app->view_dispatcher, FlipBipViewIdScene1);
}
}
bool flipbip_scene_scene_1_on_event(void* context, SceneManagerEvent event) {
@@ -21,16 +31,16 @@ bool flipbip_scene_scene_1_on_event(void* context, SceneManagerEvent event) {
if(event.type == SceneManagerEventTypeCustom) {
switch(event.event) {
case FlipBipCustomEventScene1Left:
case FlipBipCustomEventScene1Right:
break;
case FlipBipCustomEventScene1Up:
case FlipBipCustomEventScene1Down:
break;
// case FlipBipCustomEventScene1Left:
// case FlipBipCustomEventScene1Right:
// break;
// case FlipBipCustomEventScene1Up:
// case FlipBipCustomEventScene1Down:
// break;
case FlipBipCustomEventScene1Back:
notification_message(app->notification, &sequence_reset_red);
notification_message(app->notification, &sequence_reset_green);
notification_message(app->notification, &sequence_reset_blue);
//notification_message(app->notification, &sequence_reset_red);
//notification_message(app->notification, &sequence_reset_green);
//notification_message(app->notification, &sequence_reset_blue);
if(!scene_manager_search_and_switch_to_previous_scene(
app->scene_manager, FlipBipSceneMenu)) {
scene_manager_stop(app->scene_manager);

View File

@@ -6,24 +6,6 @@
#define TEXT_LABEL_ON "ON"
#define TEXT_LABEL_OFF "OFF"
const char* const haptic_text[2] = {
TEXT_LABEL_OFF,
TEXT_LABEL_ON,
};
const uint32_t haptic_value[2] = {
FlipBipHapticOff,
FlipBipHapticOn,
};
const char* const led_text[2] = {
TEXT_LABEL_OFF,
TEXT_LABEL_ON,
};
const uint32_t led_value[2] = {
FlipBipLedOff,
FlipBipLedOn,
};
const char* const bip39_strength_text[3] = {
"12",
"18",
@@ -44,20 +26,6 @@ const uint32_t passphrase_value[2] = {
FlipBipPassphraseOn,
};
static void flipbip_scene_settings_set_haptic(VariableItem* item) {
FlipBip* app = variable_item_get_context(item);
uint8_t index = variable_item_get_current_value_index(item);
variable_item_set_current_value_text(item, haptic_text[index]);
app->haptic = haptic_value[index];
}
static void flipbip_scene_settings_set_led(VariableItem* item) {
FlipBip* app = variable_item_get_context(item);
uint8_t index = variable_item_get_current_value_index(item);
variable_item_set_current_value_text(item, led_text[index]);
app->led = led_value[index];
}
static void flipbip_scene_settings_set_bip39_strength(VariableItem* item) {
FlipBip* app = variable_item_get_context(item);
uint8_t index = variable_item_get_current_value_index(item);
@@ -108,20 +76,6 @@ void flipbip_scene_settings_on_enter(void* context) {
variable_item_set_current_value_index(item, value_index);
variable_item_set_current_value_text(item, passphrase_text[value_index]);
// Vibro on/off
item = variable_item_list_add(
app->variable_item_list, "Vibro/Haptic:", 2, flipbip_scene_settings_set_haptic, app);
value_index = value_index_uint32(app->haptic, haptic_value, 2);
variable_item_set_current_value_index(item, value_index);
variable_item_set_current_value_text(item, haptic_text[value_index]);
// LED Effects on/off
item = variable_item_list_add(
app->variable_item_list, "LED FX:", 2, flipbip_scene_settings_set_led, app);
value_index = value_index_uint32(app->led, led_value, 2);
variable_item_set_current_value_index(item, value_index);
variable_item_set_current_value_text(item, led_text[value_index]);
view_dispatcher_switch_to_view(app->view_dispatcher, FlipBipViewIdSettings);
}

View File

@@ -1,55 +0,0 @@
#include "../flipbip.h"
#include "../helpers/flipbip_custom_event.h"
#include "../views/flipbip_startscreen.h"
void flipbip_scene_startscreen_callback(FlipBipCustomEvent event, void* context) {
furi_assert(context);
FlipBip* app = context;
view_dispatcher_send_custom_event(app->view_dispatcher, event);
}
void flipbip_scene_startscreen_on_enter(void* context) {
furi_assert(context);
FlipBip* app = context;
flipbip_startscreen_set_callback(
app->flipbip_startscreen, flipbip_scene_startscreen_callback, app);
view_dispatcher_switch_to_view(app->view_dispatcher, FlipBipViewIdStartscreen);
}
bool flipbip_scene_startscreen_on_event(void* context, SceneManagerEvent event) {
FlipBip* app = context;
bool consumed = false;
if(event.type == SceneManagerEventTypeCustom) {
switch(event.event) {
case FlipBipCustomEventStartscreenLeft:
case FlipBipCustomEventStartscreenRight:
break;
case FlipBipCustomEventStartscreenUp:
case FlipBipCustomEventStartscreenDown:
break;
case FlipBipCustomEventStartscreenOk:
scene_manager_next_scene(app->scene_manager, FlipBipSceneMenu);
consumed = true;
break;
case FlipBipCustomEventStartscreenBack:
notification_message(app->notification, &sequence_reset_red);
notification_message(app->notification, &sequence_reset_green);
notification_message(app->notification, &sequence_reset_blue);
if(!scene_manager_search_and_switch_to_previous_scene(
app->scene_manager, FlipBipSceneStartscreen)) {
scene_manager_stop(app->scene_manager);
view_dispatcher_stop(app->view_dispatcher);
}
consumed = true;
break;
}
}
return consumed;
}
void flipbip_scene_startscreen_on_exit(void* context) {
FlipBip* app = context;
UNUSED(app);
}