diff --git a/applications/main/ibutton/scenes/ibutton_scene_delete_confirm.c b/applications/main/ibutton/scenes/ibutton_scene_delete_confirm.c index 51f1f2794..fccefe6ec 100644 --- a/applications/main/ibutton/scenes/ibutton_scene_delete_confirm.c +++ b/applications/main/ibutton/scenes/ibutton_scene_delete_confirm.c @@ -23,7 +23,7 @@ void ibutton_scene_delete_confirm_on_enter(void* context) { ibutton_text_store_set(ibutton, "\e#Delete %s?\e#", string_get_cstr(key_name)); widget_add_text_box_element( - widget, 0, 0, 128, 27, AlignCenter, AlignCenter, ibutton->text_store, false); + widget, 0, 0, 128, 27, AlignCenter, AlignCenter, ibutton->text_store, true); widget_add_button_element( widget, GuiButtonTypeLeft, "Cancel", ibutton_scene_delete_confirm_widget_callback, ibutton); widget_add_button_element( @@ -47,24 +47,24 @@ void ibutton_scene_delete_confirm_on_enter(void* context) { key_data[6], key_data[7]); widget_add_string_element( - widget, 64, 45, AlignCenter, AlignBottom, FontSecondary, "Dallas"); + widget, 64, 34, AlignCenter, AlignBottom, FontSecondary, "Dallas"); break; case iButtonKeyCyfral: ibutton_text_store_set(ibutton, "%02X %02X", key_data[0], key_data[1]); widget_add_string_element( - widget, 64, 45, AlignCenter, AlignBottom, FontSecondary, "Cyfral"); + widget, 64, 34, AlignCenter, AlignBottom, FontSecondary, "Cyfral"); break; case iButtonKeyMetakom: ibutton_text_store_set( ibutton, "%02X %02X %02X %02X", key_data[0], key_data[1], key_data[2], key_data[3]); widget_add_string_element( - widget, 64, 45, AlignCenter, AlignBottom, FontSecondary, "Metakom"); + widget, 64, 34, AlignCenter, AlignBottom, FontSecondary, "Metakom"); break; } widget_add_string_element( - widget, 64, 33, AlignCenter, AlignBottom, FontSecondary, ibutton->text_store); + widget, 64, 46, AlignCenter, AlignBottom, FontSecondary, ibutton->text_store); view_dispatcher_switch_to_view(ibutton->view_dispatcher, iButtonViewWidget); diff --git a/applications/main/ibutton/scenes/ibutton_scene_emulate.c b/applications/main/ibutton/scenes/ibutton_scene_emulate.c index 3420f8471..e6e0ec688 100644 --- a/applications/main/ibutton/scenes/ibutton_scene_emulate.c +++ b/applications/main/ibutton/scenes/ibutton_scene_emulate.c @@ -15,7 +15,7 @@ static void ibutton_scene_emulate_callback(void* context, bool emulated) { void ibutton_scene_emulate_on_enter(void* context) { iButton* ibutton = context; - Popup* popup = ibutton->popup; + Widget* widget = ibutton->widget; iButtonKey* key = ibutton->key; const uint8_t* key_data = ibutton_key_get_data_p(key); @@ -26,20 +26,18 @@ void ibutton_scene_emulate_on_enter(void* context) { path_extract_filename(ibutton->file_path, key_name, true); } - uint8_t line_count = 2; DOLPHIN_DEED(DolphinDeedIbuttonEmulate); // check that stored key has name if(!string_empty_p(key_name)) { - ibutton_text_store_set(ibutton, "emulating\n%s", string_get_cstr(key_name)); - line_count = 2; + ibutton_text_store_set(ibutton, "%s", string_get_cstr(key_name)); } else { // if not, show key data switch(ibutton_key_get_type(key)) { case iButtonKeyDS1990: ibutton_text_store_set( ibutton, - "emulating\n%02X %02X %02X %02X\n%02X %02X %02X %02X", + "%02X %02X %02X %02X\n%02X %02X %02X %02X", key_data[0], key_data[1], key_data[2], @@ -48,40 +46,24 @@ void ibutton_scene_emulate_on_enter(void* context) { key_data[5], key_data[6], key_data[7]); - line_count = 3; break; case iButtonKeyCyfral: - ibutton_text_store_set(ibutton, "emulating\n%02X %02X", key_data[0], key_data[1]); - line_count = 2; + ibutton_text_store_set(ibutton, "%02X %02X", key_data[0], key_data[1]); break; case iButtonKeyMetakom: ibutton_text_store_set( - ibutton, - "emulating\n%02X %02X %02X %02X", - key_data[0], - key_data[1], - key_data[2], - key_data[3]); - line_count = 2; + ibutton, "%02X %02X %02X %02X", key_data[0], key_data[1], key_data[2], key_data[3]); break; } } - switch(line_count) { - case 3: - popup_set_header(popup, "iButton", 82, 18, AlignCenter, AlignBottom); - popup_set_text(popup, ibutton->text_store, 82, 22, AlignCenter, AlignTop); - break; + widget_add_string_multiline_element( + widget, 90, 10, AlignCenter, AlignTop, FontPrimary, "iButton\nemulating"); + widget_add_icon_element(widget, 3, 10, &I_iButtonKey_49x44); + widget_add_text_box_element( + widget, 54, 39, 75, 22, AlignCenter, AlignCenter, ibutton->text_store, true); - default: - popup_set_header(popup, "iButton", 82, 24, AlignCenter, AlignBottom); - popup_set_text(popup, ibutton->text_store, 82, 28, AlignCenter, AlignTop); - break; - } - - popup_set_icon(popup, 2, 10, &I_iButtonKey_49x44); - - view_dispatcher_switch_to_view(ibutton->view_dispatcher, iButtonViewPopup); + view_dispatcher_switch_to_view(ibutton->view_dispatcher, iButtonViewWidget); ibutton_worker_emulate_set_callback( ibutton->key_worker, ibutton_scene_emulate_callback, ibutton); @@ -122,10 +104,7 @@ bool ibutton_scene_emulate_on_event(void* context, SceneManagerEvent event) { void ibutton_scene_emulate_on_exit(void* context) { iButton* ibutton = context; - Popup* popup = ibutton->popup; ibutton_worker_stop(ibutton->key_worker); - popup_set_header(popup, NULL, 0, 0, AlignCenter, AlignBottom); - popup_set_text(popup, NULL, 0, 0, AlignCenter, AlignTop); - popup_set_icon(popup, 0, 0, NULL); + widget_reset(ibutton->widget); ibutton_notification_message(ibutton, iButtonNotificationMessageBlinkStop); } diff --git a/applications/main/ibutton/scenes/ibutton_scene_info.c b/applications/main/ibutton/scenes/ibutton_scene_info.c index bd364ada8..9eec2bee1 100644 --- a/applications/main/ibutton/scenes/ibutton_scene_info.c +++ b/applications/main/ibutton/scenes/ibutton_scene_info.c @@ -14,7 +14,7 @@ void ibutton_scene_info_on_enter(void* context) { ibutton_text_store_set(ibutton, "%s", string_get_cstr(key_name)); widget_add_text_box_element( - widget, 0, 0, 128, 28, AlignCenter, AlignCenter, ibutton->text_store, false); + widget, 0, 0, 128, 23, AlignCenter, AlignCenter, ibutton->text_store, true); switch(ibutton_key_get_type(key)) { case iButtonKeyDS1990: @@ -29,26 +29,24 @@ void ibutton_scene_info_on_enter(void* context) { key_data[5], key_data[6], key_data[7]); - widget_add_string_element( - widget, 64, 51, AlignCenter, AlignBottom, FontSecondary, "Dallas"); + widget_add_string_element(widget, 64, 36, AlignCenter, AlignBottom, FontPrimary, "Dallas"); break; case iButtonKeyMetakom: ibutton_text_store_set( ibutton, "%02X %02X %02X %02X", key_data[0], key_data[1], key_data[2], key_data[3]); widget_add_string_element( - widget, 64, 51, AlignCenter, AlignBottom, FontSecondary, "Metakom"); + widget, 64, 36, AlignCenter, AlignBottom, FontPrimary, "Metakom"); break; case iButtonKeyCyfral: ibutton_text_store_set(ibutton, "%02X %02X", key_data[0], key_data[1]); - widget_add_string_element( - widget, 64, 51, AlignCenter, AlignBottom, FontSecondary, "Cyfral"); + widget_add_string_element(widget, 64, 36, AlignCenter, AlignBottom, FontPrimary, "Cyfral"); break; } widget_add_string_element( - widget, 64, 35, AlignCenter, AlignBottom, FontPrimary, ibutton->text_store); + widget, 64, 50, AlignCenter, AlignBottom, FontSecondary, ibutton->text_store); view_dispatcher_switch_to_view(ibutton->view_dispatcher, iButtonViewWidget); diff --git a/applications/main/ibutton/scenes/ibutton_scene_save_success.c b/applications/main/ibutton/scenes/ibutton_scene_save_success.c index 6c24a897c..43237f429 100644 --- a/applications/main/ibutton/scenes/ibutton_scene_save_success.c +++ b/applications/main/ibutton/scenes/ibutton_scene_save_success.c @@ -29,10 +29,8 @@ bool ibutton_scene_save_success_on_event(void* context, SceneManagerEvent event) if(event.type == SceneManagerEventTypeCustom) { consumed = true; if(event.event == iButtonCustomEventBack) { - const uint32_t possible_scenes[] = { - iButtonSceneReadKeyMenu, iButtonSceneSavedKeyMenu, iButtonSceneAddType}; - scene_manager_search_and_switch_to_previous_scene_one_of( - ibutton->scene_manager, possible_scenes, COUNT_OF(possible_scenes)); + scene_manager_search_and_switch_to_another_scene( + ibutton->scene_manager, iButtonSceneSelectKey); } } diff --git a/applications/main/ibutton/scenes/ibutton_scene_write.c b/applications/main/ibutton/scenes/ibutton_scene_write.c index 195758d2c..af65575c2 100644 --- a/applications/main/ibutton/scenes/ibutton_scene_write.c +++ b/applications/main/ibutton/scenes/ibutton_scene_write.c @@ -14,8 +14,8 @@ static void ibutton_scene_write_callback(void* context, iButtonWorkerWriteResult void ibutton_scene_write_on_enter(void* context) { iButton* ibutton = context; - Popup* popup = ibutton->popup; iButtonKey* key = ibutton->key; + Widget* widget = ibutton->widget; iButtonWorker* worker = ibutton->key_worker; const uint8_t* key_data = ibutton_key_get_data_p(key); @@ -26,19 +26,16 @@ void ibutton_scene_write_on_enter(void* context) { path_extract_filename(ibutton->file_path, key_name, true); } - uint8_t line_count = 2; - // check that stored key has name if(!string_empty_p(key_name)) { - ibutton_text_store_set(ibutton, "writing\n%s", string_get_cstr(key_name)); - line_count = 2; + ibutton_text_store_set(ibutton, "%s", string_get_cstr(key_name)); } else { // if not, show key data switch(ibutton_key_get_type(key)) { case iButtonKeyDS1990: ibutton_text_store_set( ibutton, - "writing\n%02X %02X %02X %02X\n%02X %02X %02X %02X", + "%02X %02X %02X %02X\n%02X %02X %02X %02X", key_data[0], key_data[1], key_data[2], @@ -47,40 +44,24 @@ void ibutton_scene_write_on_enter(void* context) { key_data[5], key_data[6], key_data[7]); - line_count = 3; break; case iButtonKeyCyfral: - ibutton_text_store_set(ibutton, "writing\n%02X %02X", key_data[0], key_data[1]); - line_count = 2; + ibutton_text_store_set(ibutton, "%02X %02X", key_data[0], key_data[1]); break; case iButtonKeyMetakom: ibutton_text_store_set( - ibutton, - "writing\n%02X %02X %02X %02X", - key_data[0], - key_data[1], - key_data[2], - key_data[3]); - line_count = 2; + ibutton, "%02X %02X %02X %02X", key_data[0], key_data[1], key_data[2], key_data[3]); break; } } - switch(line_count) { - case 3: - popup_set_header(popup, "iButton", 82, 18, AlignCenter, AlignBottom); - popup_set_text(popup, ibutton->text_store, 82, 22, AlignCenter, AlignTop); - break; + widget_add_string_multiline_element( + widget, 90, 10, AlignCenter, AlignTop, FontPrimary, "iButton\nwriting"); + widget_add_icon_element(widget, 3, 10, &I_iButtonKey_49x44); + widget_add_text_box_element( + widget, 54, 39, 75, 22, AlignCenter, AlignCenter, ibutton->text_store, true); - default: - popup_set_header(popup, "iButton", 82, 24, AlignCenter, AlignBottom); - popup_set_text(popup, ibutton->text_store, 82, 28, AlignCenter, AlignTop); - break; - } - - popup_set_icon(popup, 2, 10, &I_iButtonKey_49x44); - - view_dispatcher_switch_to_view(ibutton->view_dispatcher, iButtonViewPopup); + view_dispatcher_switch_to_view(ibutton->view_dispatcher, iButtonViewWidget); ibutton_worker_write_set_callback(worker, ibutton_scene_write_callback, ibutton); ibutton_worker_write_start(worker, key); @@ -114,11 +95,8 @@ bool ibutton_scene_write_on_event(void* context, SceneManagerEvent event) { void ibutton_scene_write_on_exit(void* context) { iButton* ibutton = context; - Popup* popup = ibutton->popup; ibutton_worker_stop(ibutton->key_worker); - popup_set_header(popup, NULL, 0, 0, AlignCenter, AlignBottom); - popup_set_text(popup, NULL, 0, 0, AlignCenter, AlignTop); - popup_set_icon(popup, 0, 0, NULL); + widget_reset(ibutton->widget); ibutton_notification_message(ibutton, iButtonNotificationMessageBlinkStop); } diff --git a/applications/main/lfrfid/scenes/lfrfid_scene_write.c b/applications/main/lfrfid/scenes/lfrfid_scene_write.c index 4b03bac15..8e791d529 100644 --- a/applications/main/lfrfid/scenes/lfrfid_scene_write.c +++ b/applications/main/lfrfid/scenes/lfrfid_scene_write.c @@ -38,7 +38,6 @@ void lfrfid_scene_write_on_enter(void* context) { view_dispatcher_switch_to_view(app->view_dispatcher, LfRfidViewPopup); size_t size = protocol_dict_get_data_size(app->dict, app->protocol_id); - app->old_key_data = (uint8_t*)malloc(size); protocol_dict_get_data(app->dict, app->protocol_id, app->old_key_data, size); lfrfid_worker_start_thread(app->lfworker); @@ -92,5 +91,4 @@ void lfrfid_scene_write_on_exit(void* context) { size_t size = protocol_dict_get_data_size(app->dict, app->protocol_id); protocol_dict_set_data(app->dict, app->protocol_id, app->old_key_data, size); - free(app->old_key_data); }