mirror of
https://github.com/DarkFlippers/unleashed-firmware
synced 2024-12-20 17:53:20 +00:00
23ff6723cf
* bt: update connection parameters * bt: set correct connection latency and timeout * gui popup: add clean method * furi_hal_bt: add connection parameters request, clear database * bt: add forget bonded devices API * bt_settings: add forget bonded devices GUI * bt: rework pin code show with view port to hide view * bt: support conn parameters for different profiles * furi_hal_bt: sync f6 target * target f6: fix build * bt: format sources * furi_hal_bt: update connection parameters * bt: update connection params, fix GUI * FuriHal: fix spelling * Refactoring: rename _clean to _reset Co-authored-by: あく <alleteam@gmail.com>
73 lines
2.5 KiB
C++
73 lines
2.5 KiB
C++
#include "ibutton_scene_saved_key_menu.h"
|
|
#include "../ibutton_app.h"
|
|
#include "../ibutton_view_manager.h"
|
|
#include "../ibutton_event.h"
|
|
#include <callback-connector.h>
|
|
|
|
typedef enum {
|
|
SubmenuIndexEmulate,
|
|
SubmenuIndexWrite,
|
|
SubmenuIndexEdit,
|
|
SubmenuIndexDelete,
|
|
SubmenuIndexInfo,
|
|
} SubmenuIndex;
|
|
|
|
void iButtonSceneSavedKeyMenu::on_enter(iButtonApp* app) {
|
|
iButtonAppViewManager* view_manager = app->get_view_manager();
|
|
Submenu* submenu = view_manager->get_submenu();
|
|
auto callback = cbc::obtain_connector(this, &iButtonSceneSavedKeyMenu::submenu_callback);
|
|
|
|
submenu_add_item(submenu, "Emulate", SubmenuIndexEmulate, callback, app);
|
|
submenu_add_item(submenu, "Write", SubmenuIndexWrite, callback, app);
|
|
submenu_add_item(submenu, "Edit", SubmenuIndexEdit, callback, app);
|
|
submenu_add_item(submenu, "Delete", SubmenuIndexDelete, callback, app);
|
|
submenu_add_item(submenu, "Info", SubmenuIndexInfo, callback, app);
|
|
submenu_set_selected_item(submenu, submenu_item_selected);
|
|
|
|
view_manager->switch_to(iButtonAppViewManager::Type::iButtonAppViewSubmenu);
|
|
}
|
|
|
|
bool iButtonSceneSavedKeyMenu::on_event(iButtonApp* app, iButtonEvent* event) {
|
|
bool consumed = false;
|
|
|
|
if(event->type == iButtonEvent::Type::EventTypeMenuSelected) {
|
|
submenu_item_selected = event->payload.menu_index;
|
|
switch(event->payload.menu_index) {
|
|
case SubmenuIndexWrite:
|
|
app->switch_to_next_scene(iButtonApp::Scene::SceneWrite);
|
|
break;
|
|
case SubmenuIndexEmulate:
|
|
app->switch_to_next_scene(iButtonApp::Scene::SceneEmulate);
|
|
break;
|
|
case SubmenuIndexEdit:
|
|
app->switch_to_next_scene(iButtonApp::Scene::SceneAddValue);
|
|
break;
|
|
case SubmenuIndexDelete:
|
|
app->switch_to_next_scene(iButtonApp::Scene::SceneDeleteConfirm);
|
|
break;
|
|
case SubmenuIndexInfo:
|
|
app->switch_to_next_scene(iButtonApp::Scene::SceneInfo);
|
|
break;
|
|
}
|
|
consumed = true;
|
|
}
|
|
|
|
return consumed;
|
|
}
|
|
|
|
void iButtonSceneSavedKeyMenu::on_exit(iButtonApp* app) {
|
|
iButtonAppViewManager* view = app->get_view_manager();
|
|
Submenu* submenu = view->get_submenu();
|
|
|
|
submenu_reset(submenu);
|
|
}
|
|
|
|
void iButtonSceneSavedKeyMenu::submenu_callback(void* context, uint32_t index) {
|
|
iButtonApp* app = static_cast<iButtonApp*>(context);
|
|
iButtonEvent event;
|
|
|
|
event.type = iButtonEvent::Type::EventTypeMenuSelected;
|
|
event.payload.menu_index = index;
|
|
|
|
app->get_view_manager()->send_event(&event);
|
|
}
|