-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add menu to select encryption method
- Loading branch information
twisted_pear
committed
Jul 28, 2023
1 parent
0f9eebd
commit 4927e68
Showing
7 changed files
with
183 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
#include "../esubghz_chat_i.h" | ||
|
||
typedef enum { | ||
ESubGhzChatKeyMenuItems_NoEncryption, | ||
ESubGhzChatKeyMenuItems_Password, | ||
} 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; | ||
|
||
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 | ||
); | ||
|
||
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; | ||
} | ||
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); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
ADD_SCENE(esubghz_chat, freq_input, FreqInput) | ||
ADD_SCENE(esubghz_chat, key_menu, KeyMenu) | ||
ADD_SCENE(esubghz_chat, pass_input, PassInput) | ||
ADD_SCENE(esubghz_chat, chat_input, ChatInput) | ||
ADD_SCENE(esubghz_chat, chat_box, ChatBox) |