mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-05-14 16:28:36 -07:00
NFC: FeliCa menu select uses new submenu ownership model
This commit is contained in:
@@ -43,15 +43,12 @@
|
|||||||
#include <m-array.h>
|
#include <m-array.h>
|
||||||
|
|
||||||
ARRAY_DEF(FelicaAreaPath, FelicaArea*, M_PTR_OPLIST)
|
ARRAY_DEF(FelicaAreaPath, FelicaArea*, M_PTR_OPLIST)
|
||||||
LIST_DEF(FuriStringStack, FuriString*, FURI_STRING_OPLIST)
|
|
||||||
ARRAY_DEF(MfClassicUserKeys, char*, M_PTR_OPLIST)
|
ARRAY_DEF(MfClassicUserKeys, char*, M_PTR_OPLIST)
|
||||||
|
|
||||||
#define NFC_TEXT_STORE_SIZE 128
|
#define NFC_TEXT_STORE_SIZE 128
|
||||||
#define NFC_APP_FOLDER ANY_PATH("nfc")
|
#define NFC_APP_FOLDER ANY_PATH("nfc")
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
FuriStringStack_t strings;
|
|
||||||
|
|
||||||
FelicaSystem* selected_system;
|
FelicaSystem* selected_system;
|
||||||
|
|
||||||
FelicaAreaPath_t selected_areas;
|
FelicaAreaPath_t selected_areas;
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ void nfc_scene_felica_info_select_on_enter(void* context) {
|
|||||||
FelicaData* data = &nfc->dev->dev_data.felica_data;
|
FelicaData* data = &nfc->dev->dev_data.felica_data;
|
||||||
FelicaSelectState* state = &nfc->felica_select;
|
FelicaSelectState* state = &nfc->felica_select;
|
||||||
|
|
||||||
FuriStringStack_init(nfc->felica_select.strings);
|
|
||||||
FelicaAreaPath_init(nfc->felica_select.selected_areas);
|
FelicaAreaPath_init(nfc->felica_select.selected_areas);
|
||||||
|
|
||||||
submenu_add_item(submenu, "[Actions]", 0, nfc_scene_felica_info_select_submenu_callback, nfc);
|
submenu_add_item(submenu, "[Actions]", 0, nfc_scene_felica_info_select_submenu_callback, nfc);
|
||||||
@@ -31,7 +30,7 @@ void nfc_scene_felica_info_select_on_enter(void* context) {
|
|||||||
i++,
|
i++,
|
||||||
nfc_scene_felica_info_select_submenu_callback,
|
nfc_scene_felica_info_select_submenu_callback,
|
||||||
nfc);
|
nfc);
|
||||||
FuriStringStack_push_back(state->strings, system_name);
|
furi_string_free(system_name);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
FelicaSystem* system = state->selected_system;
|
FelicaSystem* system = state->selected_system;
|
||||||
@@ -50,32 +49,33 @@ void nfc_scene_felica_info_select_on_enter(void* context) {
|
|||||||
furi_string_cat(header, "Areas");
|
furi_string_cat(header, "Areas");
|
||||||
|
|
||||||
submenu_set_header(submenu, furi_string_get_cstr(header));
|
submenu_set_header(submenu, furi_string_get_cstr(header));
|
||||||
FuriStringStack_push_back(state->strings, header);
|
furi_string_free(header);
|
||||||
|
|
||||||
FelicaNodeList_it_t it;
|
FelicaNodeList_it_t it;
|
||||||
for(FelicaNodeList_it(it, area->nodes); !FelicaNodeList_end_p(it);
|
for(FelicaNodeList_it(it, area->nodes); !FelicaNodeList_end_p(it);
|
||||||
FelicaNodeList_next(it)) {
|
FelicaNodeList_next(it)) {
|
||||||
FelicaNode* node = *FelicaNodeList_ref(it);
|
FelicaNode* node = *FelicaNodeList_ref(it);
|
||||||
|
FuriString* node_name = furi_string_alloc();
|
||||||
if(node->type == FelicaNodeTypeArea) {
|
if(node->type == FelicaNodeTypeArea) {
|
||||||
FuriString* area_name = furi_string_alloc_printf("Area %d", node->area->number);
|
furi_string_printf(node_name, "Area %d", node->area->number);
|
||||||
submenu_add_item(
|
submenu_add_item(
|
||||||
submenu,
|
submenu,
|
||||||
furi_string_get_cstr(area_name),
|
furi_string_get_cstr(node_name),
|
||||||
i++,
|
i++,
|
||||||
nfc_scene_felica_info_select_submenu_callback,
|
nfc_scene_felica_info_select_submenu_callback,
|
||||||
nfc);
|
nfc);
|
||||||
FuriStringStack_push_back(state->strings, area_name);
|
|
||||||
} else {
|
} else {
|
||||||
uint16_t service_code = node->service->number << 6;
|
uint16_t service_code = node->service->number << 6;
|
||||||
FuriString* service_name = furi_string_alloc_printf("Service %04X", service_code);
|
furi_string_printf(node_name, "Service %04X", service_code);
|
||||||
submenu_add_item(
|
submenu_add_item(
|
||||||
submenu,
|
submenu,
|
||||||
furi_string_get_cstr(service_name),
|
furi_string_get_cstr(node_name),
|
||||||
i++,
|
i++,
|
||||||
nfc_scene_felica_info_select_submenu_callback,
|
nfc_scene_felica_info_select_submenu_callback,
|
||||||
nfc);
|
nfc);
|
||||||
FuriStringStack_push_back(state->strings, service_name);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
furi_string_free(node_name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -147,6 +147,5 @@ void nfc_scene_felica_info_select_on_exit(void* context) {
|
|||||||
|
|
||||||
// Clear view
|
// Clear view
|
||||||
FelicaAreaPath_clear(nfc->felica_select.selected_areas);
|
FelicaAreaPath_clear(nfc->felica_select.selected_areas);
|
||||||
FuriStringStack_clear(nfc->felica_select.strings);
|
|
||||||
submenu_reset(nfc->submenu);
|
submenu_reset(nfc->submenu);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user