| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136 |
- #include "../esubghz_chat_i.h"
- typedef enum {
- ESubGhzChatKeyMenuItems_NoEncryption,
- ESubGhzChatKeyMenuItems_Password,
- ESubGhzChatKeyMenuItems_HexKey,
- } ESubGhzChatKeyMenuItems;
- static void key_menu_cb(void* context, uint32_t index)
- {
- furi_assert(context);
- ESubGhzChatState* state = context;
- switch(index) {
- case ESubGhzChatKeyMenuItems_NoEncryption:
- state->encrypted = false;
- enter_chat(state);
- scene_manager_handle_custom_event(state->scene_manager,
- ESubGhzChatEvent_KeyMenuNoEncryption);
- break;
- case ESubGhzChatKeyMenuItems_Password:
- scene_manager_handle_custom_event(state->scene_manager,
- ESubGhzChatEvent_KeyMenuPassword);
- break;
- case ESubGhzChatKeyMenuItems_HexKey:
- scene_manager_handle_custom_event(state->scene_manager,
- ESubGhzChatEvent_KeyMenuHexKey);
- break;
- default:
- break;
- }
- }
- /* Prepares the key menu scene. */
- void scene_on_enter_key_menu(void* context)
- {
- FURI_LOG_T(APPLICATION_NAME, "scene_on_enter_key_menu");
- furi_assert(context);
- ESubGhzChatState* state = context;
- menu_reset(state->menu);
- menu_add_item(
- state->menu,
- "No encryption",
- NULL,
- ESubGhzChatKeyMenuItems_NoEncryption,
- key_menu_cb,
- state
- );
- menu_add_item(
- state->menu,
- "Password",
- NULL,
- ESubGhzChatKeyMenuItems_Password,
- key_menu_cb,
- state
- );
- menu_add_item(
- state->menu,
- "Hex Key",
- NULL,
- ESubGhzChatKeyMenuItems_HexKey,
- key_menu_cb,
- state
- );
- view_dispatcher_switch_to_view(state->view_dispatcher, ESubGhzChatView_Menu);
- }
- /* Handles scene manager events for the key menu scene. */
- bool scene_on_event_key_menu(void* context, SceneManagerEvent event)
- {
- FURI_LOG_T(APPLICATION_NAME, "scene_on_event_key_menu");
- furi_assert(context);
- ESubGhzChatState* state = context;
- bool consumed = false;
- switch(event.type) {
- case SceneManagerEventTypeCustom:
- switch(event.event) {
- /* switch to message input scene */
- case ESubGhzChatEvent_KeyMenuNoEncryption:
- scene_manager_next_scene(state->scene_manager,
- ESubGhzChatScene_ChatInput);
- consumed = true;
- break;
- /* switch to password input scene */
- case ESubGhzChatEvent_KeyMenuPassword:
- scene_manager_next_scene(state->scene_manager,
- ESubGhzChatScene_PassInput);
- consumed = true;
- break;
- /* switch to hex key input scene */
- case ESubGhzChatEvent_KeyMenuHexKey:
- scene_manager_next_scene(state->scene_manager,
- ESubGhzChatScene_HexKeyInput);
- consumed = true;
- break;
- }
- break;
- case SceneManagerEventTypeBack:
- /* stop the application if the user presses back here */
- view_dispatcher_stop(state->view_dispatcher);
- consumed = true;
- break;
- default:
- consumed = false;
- break;
- }
- return consumed;
- }
- /* Cleans up the key menu scene. */
- void scene_on_exit_key_menu(void* context)
- {
- FURI_LOG_T(APPLICATION_NAME, "scene_on_exit_key_menu");
- furi_assert(context);
- ESubGhzChatState* state = context;
- menu_reset(state->menu);
- }
|