Skip to content

Commit

Permalink
Picopass: Rename option (#25)
Browse files Browse the repository at this point in the history
Co-authored-by: hedger <hedger@users.noreply.github.com>
  • Loading branch information
bettse and hedger authored Aug 18, 2023
1 parent 8d36a99 commit 44c74e1
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
3 changes: 2 additions & 1 deletion scenes/picopass_scene_save_name.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,9 @@ bool picopass_scene_save_name_on_event(void* context, SceneManagerEvent event) {

if(event.type == SceneManagerEventTypeCustom) {
if(event.event == PicopassCustomEventTextInputDone) {
// Delete old file if renaming
if(strcmp(picopass->dev->dev_name, "") != 0) {
// picopass_device_delete(picopass->dev, true);
picopass_device_delete(picopass->dev, true);
}
strlcpy(
picopass->dev->dev_name, picopass->text_store, strlen(picopass->text_store) + 1);
Expand Down
22 changes: 16 additions & 6 deletions scenes/picopass_scene_saved_menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ enum SubmenuIndex {
SubmenuIndexInfo,
SubmenuIndexWrite,
SubmenuIndexEmulate,
SubmenuIndexRename,
};

void picopass_scene_saved_menu_submenu_callback(void* context, uint32_t index) {
Expand All @@ -17,12 +18,6 @@ void picopass_scene_saved_menu_on_enter(void* context) {
Picopass* picopass = context;
Submenu* submenu = picopass->submenu;

submenu_add_item(
submenu,
"Delete",
SubmenuIndexDelete,
picopass_scene_saved_menu_submenu_callback,
picopass);
submenu_add_item(
submenu, "Info", SubmenuIndexInfo, picopass_scene_saved_menu_submenu_callback, picopass);
submenu_add_item(
Expand All @@ -33,6 +28,18 @@ void picopass_scene_saved_menu_on_enter(void* context) {
SubmenuIndexEmulate,
picopass_scene_saved_menu_submenu_callback,
picopass);
submenu_add_item(
submenu,
"Rename",
SubmenuIndexRename,
picopass_scene_saved_menu_submenu_callback,
picopass);
submenu_add_item(
submenu,
"Delete",
SubmenuIndexDelete,
picopass_scene_saved_menu_submenu_callback,
picopass);

submenu_set_selected_item(
picopass->submenu,
Expand Down Expand Up @@ -61,6 +68,9 @@ bool picopass_scene_saved_menu_on_event(void* context, SceneManagerEvent event)
} else if(event.event == SubmenuIndexEmulate) {
scene_manager_next_scene(picopass->scene_manager, PicopassSceneEmulate);
consumed = true;
} else if(event.event == SubmenuIndexRename) {
scene_manager_next_scene(picopass->scene_manager, PicopassSceneSaveName);
consumed = true;
}
}

Expand Down

0 comments on commit 44c74e1

Please sign in to comment.