From d06ab5fe8f551f1a1876697b59c799a764f549e6 Mon Sep 17 00:00:00 2001 From: Willy-JL <49810075+Willy-JL@users.noreply.github.com> Date: Thu, 16 May 2024 07:06:10 +0100 Subject: [PATCH] MNTM: Confirm screen for SubGHz extend --- .../scenes/momentum_app_scene_protocols.c | 45 ++++++++++++++++--- 1 file changed, 39 insertions(+), 6 deletions(-) diff --git a/applications/main/momentum_app/scenes/momentum_app_scene_protocols.c b/applications/main/momentum_app/scenes/momentum_app_scene_protocols.c index 255daaa05..fc8bb4197 100644 --- a/applications/main/momentum_app/scenes/momentum_app_scene_protocols.c +++ b/applications/main/momentum_app/scenes/momentum_app_scene_protocols.c @@ -13,7 +13,7 @@ void momentum_app_scene_protocols_var_item_list_callback(void* context, uint32_t view_dispatcher_send_custom_event(app->view_dispatcher, index); } -static void xtreme_app_scene_protocols_subghz_bypass_changed(VariableItem* item) { +static void momentum_app_scene_protocols_subghz_bypass_changed(VariableItem* item) { MomentumApp* app = variable_item_get_context(item); app->subghz_bypass = variable_item_get_current_value_index(item); variable_item_set_current_value_text(item, app->subghz_bypass ? "ON" : "OFF"); @@ -27,10 +27,7 @@ static void xtreme_app_scene_protocols_subghz_bypass_changed(VariableItem* item) static void momentum_app_scene_protocols_subghz_extend_changed(VariableItem* item) { MomentumApp* app = variable_item_get_context(item); - app->subghz_extend = variable_item_get_current_value_index(item); - variable_item_set_current_value_text(item, app->subghz_extend ? "ON" : "OFF"); - app->save_subghz = true; - app->require_reboot = true; + view_dispatcher_send_custom_event(app->view_dispatcher, VarItemListIndexSubghzExtend); } static void momentum_app_scene_protocols_file_naming_prefix_changed(VariableItem* item) { @@ -53,7 +50,7 @@ void momentum_app_scene_protocols_on_enter(void* context) { var_item_list, "SubGHz Bypass Region Lock", 2, - xtreme_app_scene_protocols_subghz_bypass_changed, + momentum_app_scene_protocols_subghz_bypass_changed, app); variable_item_set_current_value_index(item, app->subghz_bypass); variable_item_set_current_value_text(item, app->subghz_bypass ? "ON" : "OFF"); @@ -103,6 +100,42 @@ bool momentum_app_scene_protocols_on_event(void* context, SceneManagerEvent even scene_manager_set_scene_state(app->scene_manager, MomentumAppSceneProtocolsFreqs, 0); scene_manager_next_scene(app->scene_manager, MomentumAppSceneProtocolsFreqs); break; + case VarItemListIndexSubghzExtend: { + VariableItem* item = + variable_item_list_get(app->var_item_list, VarItemListIndexSubghzExtend); + bool value = variable_item_get_current_value_index(item); + if(value == app->subghz_extend) value = !value; // Invoked via click + bool change = !value; // Change without confirm if going from ON to OFF + if(value) { + DialogMessage* msg = dialog_message_alloc(); + dialog_message_set_header(msg, "Are you sure?", 64, 0, AlignCenter, AlignTop); + dialog_message_set_buttons(msg, "No", NULL, "Yes"); + dialog_message_set_text( + msg, + "Extends to: 281-361,\n" + "378-481, 749-962 MHz\n" + "Use at own risk, may\n" + "damage Flipper", + 64, + 32, + AlignCenter, + AlignCenter); + if(dialog_message_show(app->dialogs, msg) == DialogMessageButtonRight) { + change = true; + } + dialog_message_free(msg); + } + if(change) { + app->subghz_extend = value; + app->save_subghz = true; + app->require_reboot = true; + } else { + value = !value; + } + variable_item_set_current_value_index(item, value); + variable_item_set_current_value_text(item, value ? "ON" : "OFF"); + break; + } case VarItemListIndexGpioPins: scene_manager_set_scene_state(app->scene_manager, MomentumAppSceneProtocolsGpio, 0); scene_manager_next_scene(app->scene_manager, MomentumAppSceneProtocolsGpio);