MNTM: Confirm screen for SubGHz extend

This commit is contained in:
Willy-JL
2024-05-16 07:06:10 +01:00
parent c39629ade6
commit d06ab5fe8f

View File

@@ -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);