[FL-2780] NFC Notifications fix (#1731)

* 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 <who.just.the.doctor@gmail.com>
Co-authored-by: あく <alleteam@gmail.com>
This commit is contained in:
Astra 2022-09-15 18:49:10 +03:00 committed by GitHub
parent 8b05bd1106
commit 60bce7b8d8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 46 additions and 12 deletions

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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