From 60bce7b8d8f2712d985352d1e38795dd8f18f3a3 Mon Sep 17 00:00:00 2001 From: Astra <93453568+Astrrra@users.noreply.github.com> Date: Thu, 15 Sep 2022 18:49:10 +0300 Subject: [PATCH] [FL-2780] NFC Notifications fix (#1731) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Show error popup when NFC chip is not init/disconnected * Move to dialogs for the error message * NFC notifications fixed to match the intended design * Revert "Move to dialogs for the error message" * Revert "Show error popup when NFC chip is not init/disconnected" Co-authored-by: SG Co-authored-by: あく --- applications/main/nfc/nfc.c | 12 ++++++++++-- applications/main/nfc/nfc_i.h | 6 +++++- .../main/nfc/scenes/nfc_scene_detect_reader.c | 2 +- .../nfc/scenes/nfc_scene_emulate_apdu_sequence.c | 2 +- applications/main/nfc/scenes/nfc_scene_emulate_uid.c | 2 +- .../main/nfc/scenes/nfc_scene_emv_read_success.c | 4 ++++ .../nfc/scenes/nfc_scene_mf_classic_dict_attack.c | 2 +- .../main/nfc/scenes/nfc_scene_mf_classic_emulate.c | 2 +- .../nfc/scenes/nfc_scene_mf_classic_read_success.c | 4 ++++ .../nfc/scenes/nfc_scene_mf_desfire_read_success.c | 4 ++++ .../nfc/scenes/nfc_scene_mf_ultralight_emulate.c | 2 +- .../nfc/scenes/nfc_scene_mf_ultralight_read_auth.c | 2 +- .../scenes/nfc_scene_mf_ultralight_read_success.c | 4 ++++ .../main/nfc/scenes/nfc_scene_nfca_read_success.c | 4 ++++ applications/main/nfc/scenes/nfc_scene_read.c | 4 +++- applications/main/nfc/scenes/nfc_scene_rpc.c | 2 +- 16 files changed, 46 insertions(+), 12 deletions(-) diff --git a/applications/main/nfc/nfc.c b/applications/main/nfc/nfc.c index 57e25f81e..432630204 100644 --- a/applications/main/nfc/nfc.c +++ b/applications/main/nfc/nfc.c @@ -201,8 +201,16 @@ void nfc_text_store_clear(Nfc* nfc) { memset(nfc->text_store, 0, sizeof(nfc->text_store)); } -void nfc_blink_start(Nfc* nfc) { - notification_message(nfc->notifications, &sequence_blink_start_blue); +void nfc_blink_read_start(Nfc* nfc) { + notification_message(nfc->notifications, &sequence_blink_start_cyan); +} + +void nfc_blink_emulate_start(Nfc* nfc) { + notification_message(nfc->notifications, &sequence_blink_start_magenta); +} + +void nfc_blink_detect_start(Nfc* nfc) { + notification_message(nfc->notifications, &sequence_blink_start_yellow); } void nfc_blink_stop(Nfc* nfc) { diff --git a/applications/main/nfc/nfc_i.h b/applications/main/nfc/nfc_i.h index c9ba7fff7..b5d284d5b 100644 --- a/applications/main/nfc/nfc_i.h +++ b/applications/main/nfc/nfc_i.h @@ -98,7 +98,11 @@ void nfc_text_store_set(Nfc* nfc, const char* text, ...); void nfc_text_store_clear(Nfc* nfc); -void nfc_blink_start(Nfc* nfc); +void nfc_blink_read_start(Nfc* nfc); + +void nfc_blink_emulate_start(Nfc* nfc); + +void nfc_blink_detect_start(Nfc* nfc); void nfc_blink_stop(Nfc* nfc); diff --git a/applications/main/nfc/scenes/nfc_scene_detect_reader.c b/applications/main/nfc/scenes/nfc_scene_detect_reader.c index 8945febaf..5f4582d8e 100644 --- a/applications/main/nfc/scenes/nfc_scene_detect_reader.c +++ b/applications/main/nfc/scenes/nfc_scene_detect_reader.c @@ -29,7 +29,7 @@ void nfc_scene_detect_reader_on_enter(void* context) { view_dispatcher_switch_to_view(nfc->view_dispatcher, NfcViewDetectReader); - nfc_blink_start(nfc); + nfc_blink_read_start(nfc); } bool nfc_scene_detect_reader_on_event(void* context, SceneManagerEvent event) { diff --git a/applications/main/nfc/scenes/nfc_scene_emulate_apdu_sequence.c b/applications/main/nfc/scenes/nfc_scene_emulate_apdu_sequence.c index e6062ba49..358ad2ab6 100644 --- a/applications/main/nfc/scenes/nfc_scene_emulate_apdu_sequence.c +++ b/applications/main/nfc/scenes/nfc_scene_emulate_apdu_sequence.c @@ -12,7 +12,7 @@ void nfc_scene_emulate_apdu_sequence_on_enter(void* context) { view_dispatcher_switch_to_view(nfc->view_dispatcher, NfcViewPopup); nfc_worker_start(nfc->worker, NfcWorkerStateEmulateApdu, &nfc->dev->dev_data, NULL, nfc); - nfc_blink_start(nfc); + nfc_blink_emulate_start(nfc); } bool nfc_scene_emulate_apdu_sequence_on_event(void* context, SceneManagerEvent event) { diff --git a/applications/main/nfc/scenes/nfc_scene_emulate_uid.c b/applications/main/nfc/scenes/nfc_scene_emulate_uid.c index 0d92c9f04..f64023010 100644 --- a/applications/main/nfc/scenes/nfc_scene_emulate_uid.c +++ b/applications/main/nfc/scenes/nfc_scene_emulate_uid.c @@ -82,7 +82,7 @@ void nfc_scene_emulate_uid_on_enter(void* context) { nfc_emulate_uid_worker_callback, nfc); - nfc_blink_start(nfc); + nfc_blink_emulate_start(nfc); } bool nfc_scene_emulate_uid_on_event(void* context, SceneManagerEvent event) { diff --git a/applications/main/nfc/scenes/nfc_scene_emv_read_success.c b/applications/main/nfc/scenes/nfc_scene_emv_read_success.c index 9cf7ff9e9..a40b4c1c9 100644 --- a/applications/main/nfc/scenes/nfc_scene_emv_read_success.c +++ b/applications/main/nfc/scenes/nfc_scene_emv_read_success.c @@ -55,6 +55,8 @@ void nfc_scene_emv_read_success_on_enter(void* context) { string_clear(country_name); } + notification_message_block(nfc->notifications, &sequence_set_green_255); + widget_add_text_scroll_element(nfc->widget, 0, 0, 128, 52, string_get_cstr(temp_str)); string_clear(temp_str); @@ -83,6 +85,8 @@ bool nfc_scene_emv_read_success_on_event(void* context, SceneManagerEvent event) void nfc_scene_emv_read_success_on_exit(void* context) { Nfc* nfc = context; + notification_message_block(nfc->notifications, &sequence_reset_green); + // Clear view widget_reset(nfc->widget); } diff --git a/applications/main/nfc/scenes/nfc_scene_mf_classic_dict_attack.c b/applications/main/nfc/scenes/nfc_scene_mf_classic_dict_attack.c index d821c182d..b23f4b8f1 100644 --- a/applications/main/nfc/scenes/nfc_scene_mf_classic_dict_attack.c +++ b/applications/main/nfc/scenes/nfc_scene_mf_classic_dict_attack.c @@ -90,7 +90,7 @@ void nfc_scene_mf_classic_dict_attack_on_enter(void* context) { Nfc* nfc = context; nfc_scene_mf_classic_dict_attack_prepare_view(nfc, DictAttackStateIdle); view_dispatcher_switch_to_view(nfc->view_dispatcher, NfcViewDictAttack); - nfc_blink_start(nfc); + nfc_blink_read_start(nfc); } bool nfc_scene_mf_classic_dict_attack_on_event(void* context, SceneManagerEvent event) { diff --git a/applications/main/nfc/scenes/nfc_scene_mf_classic_emulate.c b/applications/main/nfc/scenes/nfc_scene_mf_classic_emulate.c index 044388b8b..65639b2b4 100644 --- a/applications/main/nfc/scenes/nfc_scene_mf_classic_emulate.c +++ b/applications/main/nfc/scenes/nfc_scene_mf_classic_emulate.c @@ -35,7 +35,7 @@ void nfc_scene_mf_classic_emulate_on_enter(void* context) { &nfc->dev->dev_data, nfc_mf_classic_emulate_worker_callback, nfc); - nfc_blink_start(nfc); + nfc_blink_emulate_start(nfc); } bool nfc_scene_mf_classic_emulate_on_event(void* context, SceneManagerEvent event) { diff --git a/applications/main/nfc/scenes/nfc_scene_mf_classic_read_success.c b/applications/main/nfc/scenes/nfc_scene_mf_classic_read_success.c index efe676706..3ca24416a 100644 --- a/applications/main/nfc/scenes/nfc_scene_mf_classic_read_success.c +++ b/applications/main/nfc/scenes/nfc_scene_mf_classic_read_success.c @@ -48,6 +48,8 @@ void nfc_scene_mf_classic_read_success_on_enter(void* context) { widget_add_text_scroll_element(widget, 0, 0, 128, 52, string_get_cstr(temp_str)); string_clear(temp_str); + notification_message_block(nfc->notifications, &sequence_set_green_255); + view_dispatcher_switch_to_view(nfc->view_dispatcher, NfcViewWidget); } @@ -76,6 +78,8 @@ bool nfc_scene_mf_classic_read_success_on_event(void* context, SceneManagerEvent void nfc_scene_mf_classic_read_success_on_exit(void* context) { Nfc* nfc = context; + notification_message_block(nfc->notifications, &sequence_reset_green); + // Clear view widget_reset(nfc->widget); } diff --git a/applications/main/nfc/scenes/nfc_scene_mf_desfire_read_success.c b/applications/main/nfc/scenes/nfc_scene_mf_desfire_read_success.c index 4827c2851..12047c15a 100644 --- a/applications/main/nfc/scenes/nfc_scene_mf_desfire_read_success.c +++ b/applications/main/nfc/scenes/nfc_scene_mf_desfire_read_success.c @@ -52,6 +52,8 @@ void nfc_scene_mf_desfire_read_success_on_enter(void* context) { string_push_back(temp_str, 's'); } + notification_message_block(nfc->notifications, &sequence_set_green_255); + // Add text scroll element widget_add_text_scroll_element(widget, 0, 0, 128, 52, string_get_cstr(temp_str)); string_clear(temp_str); @@ -88,6 +90,8 @@ bool nfc_scene_mf_desfire_read_success_on_event(void* context, SceneManagerEvent void nfc_scene_mf_desfire_read_success_on_exit(void* context) { Nfc* nfc = context; + notification_message_block(nfc->notifications, &sequence_reset_green); + // Clean dialog widget_reset(nfc->widget); } diff --git a/applications/main/nfc/scenes/nfc_scene_mf_ultralight_emulate.c b/applications/main/nfc/scenes/nfc_scene_mf_ultralight_emulate.c index ce3755541..712ddc077 100644 --- a/applications/main/nfc/scenes/nfc_scene_mf_ultralight_emulate.c +++ b/applications/main/nfc/scenes/nfc_scene_mf_ultralight_emulate.c @@ -35,7 +35,7 @@ void nfc_scene_mf_ultralight_emulate_on_enter(void* context) { &nfc->dev->dev_data, nfc_mf_ultralight_emulate_worker_callback, nfc); - nfc_blink_start(nfc); + nfc_blink_emulate_start(nfc); } bool nfc_scene_mf_ultralight_emulate_on_event(void* context, SceneManagerEvent event) { diff --git a/applications/main/nfc/scenes/nfc_scene_mf_ultralight_read_auth.c b/applications/main/nfc/scenes/nfc_scene_mf_ultralight_read_auth.c index 853ccb055..1a106bdb4 100644 --- a/applications/main/nfc/scenes/nfc_scene_mf_ultralight_read_auth.c +++ b/applications/main/nfc/scenes/nfc_scene_mf_ultralight_read_auth.c @@ -65,7 +65,7 @@ void nfc_scene_mf_ultralight_read_auth_on_enter(void* context) { nfc_scene_mf_ultralight_read_auth_worker_callback, nfc); - nfc_blink_start(nfc); + nfc_blink_read_start(nfc); } bool nfc_scene_mf_ultralight_read_auth_on_event(void* context, SceneManagerEvent event) { diff --git a/applications/main/nfc/scenes/nfc_scene_mf_ultralight_read_success.c b/applications/main/nfc/scenes/nfc_scene_mf_ultralight_read_success.c index d775bb71d..56fa20578 100644 --- a/applications/main/nfc/scenes/nfc_scene_mf_ultralight_read_success.c +++ b/applications/main/nfc/scenes/nfc_scene_mf_ultralight_read_success.c @@ -47,6 +47,8 @@ void nfc_scene_mf_ultralight_read_success_on_enter(void* context) { widget_add_text_scroll_element(widget, 0, 0, 128, 52, string_get_cstr(temp_str)); string_clear(temp_str); + notification_message_block(nfc->notifications, &sequence_set_green_255); + view_dispatcher_switch_to_view(nfc->view_dispatcher, NfcViewWidget); } @@ -73,6 +75,8 @@ bool nfc_scene_mf_ultralight_read_success_on_event(void* context, SceneManagerEv void nfc_scene_mf_ultralight_read_success_on_exit(void* context) { Nfc* nfc = context; + notification_message_block(nfc->notifications, &sequence_reset_green); + // Clean view widget_reset(nfc->widget); } diff --git a/applications/main/nfc/scenes/nfc_scene_nfca_read_success.c b/applications/main/nfc/scenes/nfc_scene_nfca_read_success.c index 3467a03b6..c695da247 100644 --- a/applications/main/nfc/scenes/nfc_scene_nfca_read_success.c +++ b/applications/main/nfc/scenes/nfc_scene_nfca_read_success.c @@ -25,6 +25,8 @@ void nfc_scene_nfca_read_success_on_enter(void* context) { string_t temp_str; string_init_set_str(temp_str, "\e#Unknown ISO tag\n"); + notification_message_block(nfc->notifications, &sequence_set_green_255); + char iso_type = FURI_BIT(data->sak, 5) ? '4' : '3'; string_cat_printf(temp_str, "ISO 14443-%c (NFC-A)\n", iso_type); string_cat_printf(temp_str, "UID:"); @@ -67,6 +69,8 @@ bool nfc_scene_nfca_read_success_on_event(void* context, SceneManagerEvent event void nfc_scene_nfca_read_success_on_exit(void* context) { Nfc* nfc = context; + notification_message_block(nfc->notifications, &sequence_reset_green); + // Clear view widget_reset(nfc->widget); } diff --git a/applications/main/nfc/scenes/nfc_scene_read.c b/applications/main/nfc/scenes/nfc_scene_read.c index 00b7c8fac..da21b9f3d 100644 --- a/applications/main/nfc/scenes/nfc_scene_read.c +++ b/applications/main/nfc/scenes/nfc_scene_read.c @@ -49,7 +49,7 @@ void nfc_scene_read_on_enter(void* context) { nfc_worker_start( nfc->worker, NfcWorkerStateRead, &nfc->dev->dev_data, nfc_scene_read_worker_callback, nfc); - nfc_blink_start(nfc); + nfc_blink_read_start(nfc); } bool nfc_scene_read_on_event(void* context, SceneManagerEvent event) { @@ -92,9 +92,11 @@ bool nfc_scene_read_on_event(void* context, SceneManagerEvent event) { consumed = true; } else if(event.event == NfcWorkerEventCardDetected) { nfc_scene_read_set_state(nfc, NfcSceneReadStateReading); + nfc_blink_detect_start(nfc); consumed = true; } else if(event.event == NfcWorkerEventNoCardDetected) { nfc_scene_read_set_state(nfc, NfcSceneReadStateDetecting); + nfc_blink_read_start(nfc); consumed = true; } } diff --git a/applications/main/nfc/scenes/nfc_scene_rpc.c b/applications/main/nfc/scenes/nfc_scene_rpc.c index 7a9eb4503..e5128a52f 100644 --- a/applications/main/nfc/scenes/nfc_scene_rpc.c +++ b/applications/main/nfc/scenes/nfc_scene_rpc.c @@ -62,7 +62,7 @@ bool nfc_scene_rpc_on_event(void* context, SceneManagerEvent event) { nfc->rpc_state = NfcRpcStateEmulating; result = true; - nfc_blink_start(nfc); + nfc_blink_emulate_start(nfc); nfc_text_store_set(nfc, "emulating\n%s", nfc->dev->dev_name); popup_set_text(popup, nfc->text_store, 89, 44, AlignCenter, AlignTop); }