mirror of
https://protopirate.net/ProtoPirate/ProtoPirate.git
synced 2026-03-29 11:00:40 +00:00
Confirm Exit Receiver if we have signals.
This commit is contained in:
@@ -288,12 +288,43 @@ bool protopirate_scene_receiver_on_event(void* context, SceneManagerEvent event)
|
||||
break;
|
||||
|
||||
case ProtoPirateCustomEventViewReceiverBack:
|
||||
if(app->txrx->txrx_state == ProtoPirateTxRxStateRx) {
|
||||
protopirate_rx_end(app);
|
||||
bool confirmed_exit = false;
|
||||
|
||||
if(protopirate_history_get_item(app->txrx->history)) {
|
||||
scene_manager_set_scene_state(app->scene_manager, ProtoPirateSceneReceiver, 1);
|
||||
//app->option_flags += FLAG_RECEIVER_DIRTY_DIALOG;
|
||||
app->dialogs = furi_record_open(RECORD_DIALOGS);
|
||||
DialogMessage* message = dialog_message_alloc();
|
||||
dialog_message_set_buttons(message, "Back", NULL, "Continue");
|
||||
dialog_message_set_icon(message, &I_WarningDolphin_45x42, 0, 12);
|
||||
dialog_message_set_header(
|
||||
message, "Exit Confirmation", 64, 0, AlignCenter, AlignTop);
|
||||
dialog_message_set_text(
|
||||
message, "You will lose\nany unsaved\nsignals.", 50, 14, AlignLeft, AlignTop);
|
||||
DialogMessageButton dialog_result = dialog_message_show(app->dialogs, message);
|
||||
dialog_message_free(message);
|
||||
furi_record_close(RECORD_DIALOGS);
|
||||
app->dialogs = NULL;
|
||||
|
||||
//Exit if the user said yes.
|
||||
if(dialog_result == DialogMessageButtonRight) {
|
||||
confirmed_exit = true;
|
||||
scene_manager_set_scene_state(app->scene_manager, ProtoPirateSceneReceiver, 0);
|
||||
}
|
||||
} else {
|
||||
//Dont need to confirm.
|
||||
confirmed_exit = true;
|
||||
}
|
||||
|
||||
//If the user confirmed, or we arent dirty we can exit now.
|
||||
if(confirmed_exit) {
|
||||
if(app->txrx->txrx_state == ProtoPirateTxRxStateRx) {
|
||||
protopirate_rx_end(app);
|
||||
}
|
||||
protopirate_sleep(app);
|
||||
scene_manager_search_and_switch_to_previous_scene(
|
||||
app->scene_manager, ProtoPirateSceneStart);
|
||||
}
|
||||
protopirate_sleep(app);
|
||||
scene_manager_search_and_switch_to_previous_scene(
|
||||
app->scene_manager, ProtoPirateSceneStart);
|
||||
consumed = true;
|
||||
break;
|
||||
|
||||
|
||||
@@ -510,6 +510,13 @@ bool protopirate_view_receiver_input(InputEvent* event, void* context) {
|
||||
receiver->callback(ProtoPirateCustomEventViewReceiverOK, receiver->context);
|
||||
}
|
||||
|
||||
consumed = true;
|
||||
break;
|
||||
case InputKeyBack:
|
||||
//We need the back event for dirty exit confirmation.
|
||||
if(receiver->callback) {
|
||||
receiver->callback(ProtoPirateCustomEventViewReceiverBack, receiver->context);
|
||||
}
|
||||
consumed = true;
|
||||
break;
|
||||
default:
|
||||
|
||||
Reference in New Issue
Block a user