[FL-1849] NFC and iButton gui fixes (#943)
* nfc: fix spaces between lines in delete and info scenes * gui widget: add extern c * ibutton: rework gui in info and delete scenes * Loader, Desktop: fix debug apps and plugins start from cli, fix deadlock in archive Co-authored-by: あく <alleteam@gmail.com>
This commit is contained in:
		
							parent
							
								
									7e2f0fcc22
								
							
						
					
					
						commit
						c98e54da10
					
				| @ -63,8 +63,6 @@ static void desktop_switch_to_app(Desktop* desktop, const FlipperApplication* fl | |||||||
|     furi_thread_set_callback(desktop->scene_thread, flipper_app->app); |     furi_thread_set_callback(desktop->scene_thread, flipper_app->app); | ||||||
| 
 | 
 | ||||||
|     furi_thread_start(desktop->scene_thread); |     furi_thread_start(desktop->scene_thread); | ||||||
| 
 |  | ||||||
|     furi_thread_join(desktop->scene_thread); |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void desktop_scene_main_callback(DesktopEvent event, void* context) { | void desktop_scene_main_callback(DesktopEvent event, void* context) { | ||||||
|  | |||||||
| @ -7,6 +7,10 @@ | |||||||
| 
 | 
 | ||||||
| #include "widget_elements/widget_element_i.h" | #include "widget_elements/widget_element_i.h" | ||||||
| 
 | 
 | ||||||
|  | #ifdef __cplusplus | ||||||
|  | extern "C" { | ||||||
|  | #endif | ||||||
|  | 
 | ||||||
| typedef struct Widget Widget; | typedef struct Widget Widget; | ||||||
| typedef struct WidgetElement WidgetElement; | typedef struct WidgetElement WidgetElement; | ||||||
| 
 | 
 | ||||||
| @ -139,3 +143,7 @@ void widget_add_frame_element( | |||||||
|     uint8_t width, |     uint8_t width, | ||||||
|     uint8_t height, |     uint8_t height, | ||||||
|     uint8_t radius); |     uint8_t radius); | ||||||
|  | 
 | ||||||
|  | #ifdef __cplusplus | ||||||
|  | } | ||||||
|  | #endif | ||||||
|  | |||||||
| @ -1,6 +1,7 @@ | |||||||
| #pragma once | #pragma once | ||||||
| #include <stdint.h> | #include <stdint.h> | ||||||
| #include <gui/modules/dialog_ex.h> | #include <gui/modules/dialog_ex.h> | ||||||
|  | #include <gui/modules/widget.h> | ||||||
| 
 | 
 | ||||||
| class iButtonApp; | class iButtonApp; | ||||||
| 
 | 
 | ||||||
| @ -14,12 +15,14 @@ public: | |||||||
|         EventTypeDialogResult, |         EventTypeDialogResult, | ||||||
|         EventTypeTextEditResult, |         EventTypeTextEditResult, | ||||||
|         EventTypeByteEditResult, |         EventTypeByteEditResult, | ||||||
|  |         EventTypeWidgetButtonResult, | ||||||
|     }; |     }; | ||||||
| 
 | 
 | ||||||
|     // payload
 |     // payload
 | ||||||
|     union { |     union { | ||||||
|         uint32_t menu_index; |         uint32_t menu_index; | ||||||
|         DialogExResult dialog_result; |         DialogExResult dialog_result; | ||||||
|  |         GuiButtonType widget_button_result; | ||||||
|     } payload; |     } payload; | ||||||
| 
 | 
 | ||||||
|     // event type
 |     // event type
 | ||||||
|  | |||||||
							
								
								
									
										14
									
								
								applications/ibutton/ibutton-view-manager.cpp
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						
									
										14
									
								
								applications/ibutton/ibutton-view-manager.cpp
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							| @ -38,6 +38,12 @@ iButtonAppViewManager::iButtonAppViewManager() { | |||||||
|         static_cast<uint32_t>(iButtonAppViewManager::Type::iButtonAppViewPopup), |         static_cast<uint32_t>(iButtonAppViewManager::Type::iButtonAppViewPopup), | ||||||
|         popup_get_view(popup)); |         popup_get_view(popup)); | ||||||
| 
 | 
 | ||||||
|  |     widget = widget_alloc(); | ||||||
|  |     view_dispatcher_add_view( | ||||||
|  |         view_dispatcher, | ||||||
|  |         static_cast<uint32_t>(iButtonAppViewManager::Type::iButtonAppViewWidget), | ||||||
|  |         widget_get_view(widget)); | ||||||
|  | 
 | ||||||
|     gui = static_cast<Gui*>(furi_record_open("gui")); |     gui = static_cast<Gui*>(furi_record_open("gui")); | ||||||
|     view_dispatcher_attach_to_gui(view_dispatcher, gui, ViewDispatcherTypeFullscreen); |     view_dispatcher_attach_to_gui(view_dispatcher, gui, ViewDispatcherTypeFullscreen); | ||||||
| 
 | 
 | ||||||
| @ -47,6 +53,7 @@ iButtonAppViewManager::iButtonAppViewManager() { | |||||||
|     view_set_previous_callback(text_input_get_view(text_input), callback); |     view_set_previous_callback(text_input_get_view(text_input), callback); | ||||||
|     view_set_previous_callback(byte_input_get_view(byte_input), callback); |     view_set_previous_callback(byte_input_get_view(byte_input), callback); | ||||||
|     view_set_previous_callback(popup_get_view(popup), callback); |     view_set_previous_callback(popup_get_view(popup), callback); | ||||||
|  |     view_set_previous_callback(widget_get_view(widget), callback); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| iButtonAppViewManager::~iButtonAppViewManager() { | iButtonAppViewManager::~iButtonAppViewManager() { | ||||||
| @ -65,6 +72,8 @@ iButtonAppViewManager::~iButtonAppViewManager() { | |||||||
|     view_dispatcher_remove_view( |     view_dispatcher_remove_view( | ||||||
|         view_dispatcher, |         view_dispatcher, | ||||||
|         static_cast<uint32_t>(iButtonAppViewManager::Type::iButtonAppViewByteInput)); |         static_cast<uint32_t>(iButtonAppViewManager::Type::iButtonAppViewByteInput)); | ||||||
|  |     view_dispatcher_remove_view( | ||||||
|  |         view_dispatcher, static_cast<uint32_t>(iButtonAppViewManager::Type::iButtonAppViewWidget)); | ||||||
| 
 | 
 | ||||||
|     // free view modules
 |     // free view modules
 | ||||||
|     popup_free(popup); |     popup_free(popup); | ||||||
| @ -72,6 +81,7 @@ iButtonAppViewManager::~iButtonAppViewManager() { | |||||||
|     byte_input_free(byte_input); |     byte_input_free(byte_input); | ||||||
|     submenu_free(submenu); |     submenu_free(submenu); | ||||||
|     dialog_ex_free(dialog_ex); |     dialog_ex_free(dialog_ex); | ||||||
|  |     widget_free(widget); | ||||||
| 
 | 
 | ||||||
|     // free dispatcher
 |     // free dispatcher
 | ||||||
|     view_dispatcher_free(view_dispatcher); |     view_dispatcher_free(view_dispatcher); | ||||||
| @ -104,6 +114,10 @@ ByteInput* iButtonAppViewManager::get_byte_input() { | |||||||
|     return byte_input; |     return byte_input; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | Widget* iButtonAppViewManager::get_widget() { | ||||||
|  |     return widget; | ||||||
|  | } | ||||||
|  | 
 | ||||||
| void iButtonAppViewManager::receive_event(iButtonEvent* event) { | void iButtonAppViewManager::receive_event(iButtonEvent* event) { | ||||||
|     if(osMessageQueueGet(event_queue, event, NULL, 100) != osOK) { |     if(osMessageQueueGet(event_queue, event, NULL, 100) != osOK) { | ||||||
|         event->type = iButtonEvent::Type::EventTypeTick; |         event->type = iButtonEvent::Type::EventTypeTick; | ||||||
|  | |||||||
| @ -6,6 +6,7 @@ | |||||||
| #include <gui/modules/text_input.h> | #include <gui/modules/text_input.h> | ||||||
| #include <gui/modules/byte_input.h> | #include <gui/modules/byte_input.h> | ||||||
| #include <gui/modules/popup.h> | #include <gui/modules/popup.h> | ||||||
|  | #include <gui/modules/widget.h> | ||||||
| #include "ibutton-event.h" | #include "ibutton-event.h" | ||||||
| 
 | 
 | ||||||
| class iButtonAppViewManager { | class iButtonAppViewManager { | ||||||
| @ -16,6 +17,7 @@ public: | |||||||
|         iButtonAppViewSubmenu, |         iButtonAppViewSubmenu, | ||||||
|         iButtonAppViewDialogEx, |         iButtonAppViewDialogEx, | ||||||
|         iButtonAppViewPopup, |         iButtonAppViewPopup, | ||||||
|  |         iButtonAppViewWidget, | ||||||
|     }; |     }; | ||||||
| 
 | 
 | ||||||
|     osMessageQueueId_t event_queue; |     osMessageQueueId_t event_queue; | ||||||
| @ -30,6 +32,7 @@ public: | |||||||
|     DialogEx* get_dialog_ex(); |     DialogEx* get_dialog_ex(); | ||||||
|     TextInput* get_text_input(); |     TextInput* get_text_input(); | ||||||
|     ByteInput* get_byte_input(); |     ByteInput* get_byte_input(); | ||||||
|  |     Widget* get_widget(); | ||||||
| 
 | 
 | ||||||
|     void receive_event(iButtonEvent* event); |     void receive_event(iButtonEvent* event); | ||||||
|     void send_event(iButtonEvent* event); |     void send_event(iButtonEvent* event); | ||||||
| @ -41,6 +44,7 @@ private: | |||||||
|     TextInput* text_input; |     TextInput* text_input; | ||||||
|     ByteInput* byte_input; |     ByteInput* byte_input; | ||||||
|     Popup* popup; |     Popup* popup; | ||||||
|  |     Widget* widget; | ||||||
|     Gui* gui; |     Gui* gui; | ||||||
| 
 | 
 | ||||||
|     uint32_t previous_view_callback(void* context); |     uint32_t previous_view_callback(void* context); | ||||||
|  | |||||||
							
								
								
									
										56
									
								
								applications/ibutton/scene/ibutton-scene-delete-confirm.cpp
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						
									
										56
									
								
								applications/ibutton/scene/ibutton-scene-delete-confirm.cpp
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							| @ -6,17 +6,22 @@ | |||||||
| 
 | 
 | ||||||
| void iButtonSceneDeleteConfirm::on_enter(iButtonApp* app) { | void iButtonSceneDeleteConfirm::on_enter(iButtonApp* app) { | ||||||
|     iButtonAppViewManager* view_manager = app->get_view_manager(); |     iButtonAppViewManager* view_manager = app->get_view_manager(); | ||||||
|     DialogEx* dialog_ex = view_manager->get_dialog_ex(); |     Widget* widget = view_manager->get_widget(); | ||||||
|     auto callback = cbc::obtain_connector(this, &iButtonSceneDeleteConfirm::dialog_ex_callback); |     auto callback = cbc::obtain_connector(this, &iButtonSceneDeleteConfirm::widget_callback); | ||||||
| 
 | 
 | ||||||
|     iButtonKey* key = app->get_key(); |     iButtonKey* key = app->get_key(); | ||||||
|     uint8_t* key_data = key->get_data(); |     uint8_t* key_data = key->get_data(); | ||||||
| 
 | 
 | ||||||
|  |     app->set_text_store("\e#Delete %s?\e#", key->get_name()); | ||||||
|  |     widget_add_text_box_element( | ||||||
|  |         widget, 0, 0, 128, 23, AlignCenter, AlignCenter, app->get_text_store()); | ||||||
|  |     widget_add_button_element(widget, GuiButtonTypeLeft, "Back", callback, app); | ||||||
|  |     widget_add_button_element(widget, GuiButtonTypeRight, "Delete", callback, app); | ||||||
|  | 
 | ||||||
|     switch(key->get_key_type()) { |     switch(key->get_key_type()) { | ||||||
|     case iButtonKeyType::KeyDallas: |     case iButtonKeyType::KeyDallas: | ||||||
|         app->set_text_store( |         app->set_text_store( | ||||||
|             "Delete %s?\nID: %02X %02X %02X %02X %02X %02X %02X %02X\nType: Dallas", |             "%02X %02X %02X %02X %02X %02X %02X %02X\nDallas", | ||||||
|             key->get_name(), |  | ||||||
|             key_data[0], |             key_data[0], | ||||||
|             key_data[1], |             key_data[1], | ||||||
|             key_data[2], |             key_data[2], | ||||||
| @ -27,34 +32,24 @@ void iButtonSceneDeleteConfirm::on_enter(iButtonApp* app) { | |||||||
|             key_data[7]); |             key_data[7]); | ||||||
|         break; |         break; | ||||||
|     case iButtonKeyType::KeyCyfral: |     case iButtonKeyType::KeyCyfral: | ||||||
|         app->set_text_store( |         app->set_text_store("%02X %02X\nCyfral", key_data[0], key_data[1]); | ||||||
|             "Delete %s?\nID: %02X %02X\nType: Cyfral", key->get_name(), key_data[0], key_data[1]); |  | ||||||
|         break; |         break; | ||||||
|     case iButtonKeyType::KeyMetakom: |     case iButtonKeyType::KeyMetakom: | ||||||
|         app->set_text_store( |         app->set_text_store( | ||||||
|             "Delete %s?\nID: %02X %02X %02X %02X\nType: Metakom", |             "%02X %02X %02X %02X\nMetakom", key_data[0], key_data[1], key_data[2], key_data[3]); | ||||||
|             key->get_name(), |  | ||||||
|             key_data[0], |  | ||||||
|             key_data[1], |  | ||||||
|             key_data[2], |  | ||||||
|             key_data[3]); |  | ||||||
|         break; |         break; | ||||||
|     } |     } | ||||||
|  |     widget_add_string_multiline_element( | ||||||
|  |         widget, 64, 23, AlignCenter, AlignTop, FontSecondary, app->get_text_store()); | ||||||
| 
 | 
 | ||||||
|     dialog_ex_set_text(dialog_ex, app->get_text_store(), 64, 20, AlignCenter, AlignCenter); |     view_manager->switch_to(iButtonAppViewManager::Type::iButtonAppViewWidget); | ||||||
|     dialog_ex_set_left_button_text(dialog_ex, "Back"); |  | ||||||
|     dialog_ex_set_right_button_text(dialog_ex, "Delete"); |  | ||||||
|     dialog_ex_set_result_callback(dialog_ex, callback); |  | ||||||
|     dialog_ex_set_context(dialog_ex, app); |  | ||||||
| 
 |  | ||||||
|     view_manager->switch_to(iButtonAppViewManager::Type::iButtonAppViewDialogEx); |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| bool iButtonSceneDeleteConfirm::on_event(iButtonApp* app, iButtonEvent* event) { | bool iButtonSceneDeleteConfirm::on_event(iButtonApp* app, iButtonEvent* event) { | ||||||
|     bool consumed = false; |     bool consumed = false; | ||||||
| 
 | 
 | ||||||
|     if(event->type == iButtonEvent::Type::EventTypeDialogResult) { |     if(event->type == iButtonEvent::Type::EventTypeWidgetButtonResult) { | ||||||
|         if(event->payload.dialog_result == DialogExResultRight) { |         if(event->payload.widget_button_result == GuiButtonTypeRight) { | ||||||
|             if(app->delete_key()) { |             if(app->delete_key()) { | ||||||
|                 app->switch_to_next_scene(iButtonApp::Scene::SceneDeleteSuccess); |                 app->switch_to_next_scene(iButtonApp::Scene::SceneDeleteSuccess); | ||||||
|             } |             } | ||||||
| @ -70,23 +65,24 @@ bool iButtonSceneDeleteConfirm::on_event(iButtonApp* app, iButtonEvent* event) { | |||||||
| 
 | 
 | ||||||
| void iButtonSceneDeleteConfirm::on_exit(iButtonApp* app) { | void iButtonSceneDeleteConfirm::on_exit(iButtonApp* app) { | ||||||
|     iButtonAppViewManager* view_manager = app->get_view_manager(); |     iButtonAppViewManager* view_manager = app->get_view_manager(); | ||||||
|     DialogEx* dialog_ex = view_manager->get_dialog_ex(); |     Widget* widget = view_manager->get_widget(); | ||||||
| 
 | 
 | ||||||
|     app->set_text_store(""); |     app->set_text_store(""); | ||||||
| 
 | 
 | ||||||
|     dialog_ex_set_text(dialog_ex, NULL, 0, 0, AlignCenter, AlignTop); |     widget_clear(widget); | ||||||
|     dialog_ex_set_left_button_text(dialog_ex, NULL); |  | ||||||
|     dialog_ex_set_right_button_text(dialog_ex, NULL); |  | ||||||
|     dialog_ex_set_result_callback(dialog_ex, NULL); |  | ||||||
|     dialog_ex_set_context(dialog_ex, NULL); |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void iButtonSceneDeleteConfirm::dialog_ex_callback(DialogExResult result, void* context) { | void iButtonSceneDeleteConfirm::widget_callback( | ||||||
|  |     GuiButtonType result, | ||||||
|  |     InputType type, | ||||||
|  |     void* context) { | ||||||
|     iButtonApp* app = static_cast<iButtonApp*>(context); |     iButtonApp* app = static_cast<iButtonApp*>(context); | ||||||
|     iButtonEvent event; |     iButtonEvent event; | ||||||
| 
 | 
 | ||||||
|     event.type = iButtonEvent::Type::EventTypeDialogResult; |     if(type == InputTypeShort) { | ||||||
|     event.payload.dialog_result = result; |         event.type = iButtonEvent::Type::EventTypeWidgetButtonResult; | ||||||
|  |         event.payload.widget_button_result = result; | ||||||
|  |     } | ||||||
| 
 | 
 | ||||||
|     app->get_view_manager()->send_event(&event); |     app->get_view_manager()->send_event(&event); | ||||||
| } | } | ||||||
| @ -1,6 +1,5 @@ | |||||||
| #pragma once | #pragma once | ||||||
| #include "ibutton-scene-generic.h" | #include "ibutton-scene-generic.h" | ||||||
| #include <gui/modules/dialog_ex.h> |  | ||||||
| 
 | 
 | ||||||
| class iButtonSceneDeleteConfirm : public iButtonScene { | class iButtonSceneDeleteConfirm : public iButtonScene { | ||||||
| public: | public: | ||||||
| @ -9,5 +8,5 @@ public: | |||||||
|     void on_exit(iButtonApp* app) final; |     void on_exit(iButtonApp* app) final; | ||||||
| 
 | 
 | ||||||
| private: | private: | ||||||
|     void dialog_ex_callback(DialogExResult result, void* context); |     void widget_callback(GuiButtonType result, InputType type, void* context); | ||||||
| }; | }; | ||||||
							
								
								
									
										49
									
								
								applications/ibutton/scene/ibutton-scene-info.cpp
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						
									
										49
									
								
								applications/ibutton/scene/ibutton-scene-info.cpp
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							| @ -6,17 +6,21 @@ | |||||||
| 
 | 
 | ||||||
| void iButtonSceneInfo::on_enter(iButtonApp* app) { | void iButtonSceneInfo::on_enter(iButtonApp* app) { | ||||||
|     iButtonAppViewManager* view_manager = app->get_view_manager(); |     iButtonAppViewManager* view_manager = app->get_view_manager(); | ||||||
|     DialogEx* dialog_ex = view_manager->get_dialog_ex(); |     Widget* widget = view_manager->get_widget(); | ||||||
|     auto callback = cbc::obtain_connector(this, &iButtonSceneInfo::dialog_ex_callback); |     auto callback = cbc::obtain_connector(this, &iButtonSceneInfo::widget_callback); | ||||||
| 
 | 
 | ||||||
|     iButtonKey* key = app->get_key(); |     iButtonKey* key = app->get_key(); | ||||||
|     uint8_t* key_data = key->get_data(); |     uint8_t* key_data = key->get_data(); | ||||||
| 
 | 
 | ||||||
|  |     app->set_text_store("%s", key->get_name()); | ||||||
|  |     widget_add_text_box_element( | ||||||
|  |         widget, 0, 0, 128, 23, AlignCenter, AlignCenter, app->get_text_store()); | ||||||
|  |     widget_add_button_element(widget, GuiButtonTypeLeft, "Back", callback, app); | ||||||
|  | 
 | ||||||
|     switch(key->get_key_type()) { |     switch(key->get_key_type()) { | ||||||
|     case iButtonKeyType::KeyDallas: |     case iButtonKeyType::KeyDallas: | ||||||
|         app->set_text_store( |         app->set_text_store( | ||||||
|             "%s\n%02X %02X %02X %02X %02X %02X %02X %02X\nDallas", |             "\e#%02X %02X %02X %02X %02X %02X %02X %02X\e#\nDallas", | ||||||
|             key->get_name(), |  | ||||||
|             key_data[0], |             key_data[0], | ||||||
|             key_data[1], |             key_data[1], | ||||||
|             key_data[2], |             key_data[2], | ||||||
| @ -28,32 +32,30 @@ void iButtonSceneInfo::on_enter(iButtonApp* app) { | |||||||
|         break; |         break; | ||||||
|     case iButtonKeyType::KeyMetakom: |     case iButtonKeyType::KeyMetakom: | ||||||
|         app->set_text_store( |         app->set_text_store( | ||||||
|             "%s\n%02X %02X %02X %02X\nMetakom", |             "\e#%02X %02X %02X %02X\e#\nMetakom", | ||||||
|             key->get_name(), |  | ||||||
|             key_data[0], |             key_data[0], | ||||||
|             key_data[1], |             key_data[1], | ||||||
|             key_data[2], |             key_data[2], | ||||||
|             key_data[3]); |             key_data[3]); | ||||||
|         break; |         break; | ||||||
|     case iButtonKeyType::KeyCyfral: |     case iButtonKeyType::KeyCyfral: | ||||||
|         app->set_text_store("%s\n%02X %02X\nCyfral", key->get_name(), key_data[0], key_data[1]); |         app->set_text_store("\e#%02X %02X\e#\nCyfral", key_data[0], key_data[1]); | ||||||
|         break; |         break; | ||||||
|     } |     } | ||||||
|  |     widget_add_text_box_element( | ||||||
|  |         widget, 0, 23, 128, 40, AlignCenter, AlignTop, app->get_text_store()); | ||||||
| 
 | 
 | ||||||
|     dialog_ex_set_text(dialog_ex, app->get_text_store(), 64, 26, AlignCenter, AlignCenter); |     view_manager->switch_to(iButtonAppViewManager::Type::iButtonAppViewWidget); | ||||||
|     dialog_ex_set_left_button_text(dialog_ex, "Back"); |  | ||||||
|     dialog_ex_set_result_callback(dialog_ex, callback); |  | ||||||
|     dialog_ex_set_context(dialog_ex, app); |  | ||||||
| 
 |  | ||||||
|     view_manager->switch_to(iButtonAppViewManager::Type::iButtonAppViewDialogEx); |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| bool iButtonSceneInfo::on_event(iButtonApp* app, iButtonEvent* event) { | bool iButtonSceneInfo::on_event(iButtonApp* app, iButtonEvent* event) { | ||||||
|     bool consumed = false; |     bool consumed = false; | ||||||
| 
 | 
 | ||||||
|     if(event->type == iButtonEvent::Type::EventTypeDialogResult) { |     if(event->type == iButtonEvent::Type::EventTypeWidgetButtonResult) { | ||||||
|         app->switch_to_previous_scene(); |         if(event->payload.widget_button_result == GuiButtonTypeLeft) { | ||||||
|         consumed = true; |             app->switch_to_previous_scene(); | ||||||
|  |             consumed = true; | ||||||
|  |         } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     return consumed; |     return consumed; | ||||||
| @ -61,22 +63,21 @@ bool iButtonSceneInfo::on_event(iButtonApp* app, iButtonEvent* event) { | |||||||
| 
 | 
 | ||||||
| void iButtonSceneInfo::on_exit(iButtonApp* app) { | void iButtonSceneInfo::on_exit(iButtonApp* app) { | ||||||
|     iButtonAppViewManager* view_manager = app->get_view_manager(); |     iButtonAppViewManager* view_manager = app->get_view_manager(); | ||||||
|     DialogEx* dialog_ex = view_manager->get_dialog_ex(); |     Widget* widget = view_manager->get_widget(); | ||||||
| 
 | 
 | ||||||
|     app->set_text_store(""); |     app->set_text_store(""); | ||||||
| 
 | 
 | ||||||
|     dialog_ex_set_text(dialog_ex, NULL, 0, 0, AlignCenter, AlignTop); |     widget_clear(widget); | ||||||
|     dialog_ex_set_left_button_text(dialog_ex, NULL); |  | ||||||
|     dialog_ex_set_result_callback(dialog_ex, NULL); |  | ||||||
|     dialog_ex_set_context(dialog_ex, NULL); |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void iButtonSceneInfo::dialog_ex_callback(DialogExResult result, void* context) { | void iButtonSceneInfo::widget_callback(GuiButtonType result, InputType type, void* context) { | ||||||
|     iButtonApp* app = static_cast<iButtonApp*>(context); |     iButtonApp* app = static_cast<iButtonApp*>(context); | ||||||
|     iButtonEvent event; |     iButtonEvent event; | ||||||
| 
 | 
 | ||||||
|     event.type = iButtonEvent::Type::EventTypeDialogResult; |     if(type == InputTypeShort) { | ||||||
|     event.payload.dialog_result = result; |         event.type = iButtonEvent::Type::EventTypeWidgetButtonResult; | ||||||
|  |         event.payload.widget_button_result = result; | ||||||
|  |     } | ||||||
| 
 | 
 | ||||||
|     app->get_view_manager()->send_event(&event); |     app->get_view_manager()->send_event(&event); | ||||||
| } | } | ||||||
| @ -1,6 +1,5 @@ | |||||||
| #pragma once | #pragma once | ||||||
| #include "ibutton-scene-generic.h" | #include "ibutton-scene-generic.h" | ||||||
| #include <gui/modules/dialog_ex.h> |  | ||||||
| 
 | 
 | ||||||
| class iButtonSceneInfo : public iButtonScene { | class iButtonSceneInfo : public iButtonScene { | ||||||
| public: | public: | ||||||
| @ -9,5 +8,5 @@ public: | |||||||
|     void on_exit(iButtonApp* app) final; |     void on_exit(iButtonApp* app) final; | ||||||
| 
 | 
 | ||||||
| private: | private: | ||||||
|     void dialog_ex_callback(DialogExResult result, void* context); |     void widget_callback(GuiButtonType result, InputType type, void* context); | ||||||
| }; | }; | ||||||
| @ -46,25 +46,25 @@ static void loader_cli_print_usage() { | |||||||
|     printf("\topen <Application Name:string>\t - Open application by name\r\n"); |     printf("\topen <Application Name:string>\t - Open application by name\r\n"); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| const FlipperApplication* loader_find_application_by_name(string_t name) { | const FlipperApplication* loader_find_application_by_name(const char* name) { | ||||||
|     const FlipperApplication* application = NULL; |     const FlipperApplication* application = NULL; | ||||||
| 
 | 
 | ||||||
|     for(size_t i = 0; i < FLIPPER_APPS_COUNT; i++) { |     for(size_t i = 0; i < FLIPPER_APPS_COUNT; i++) { | ||||||
|         if(string_cmp_str(name, FLIPPER_APPS[i].name) == 0) { |         if(strcmp(name, FLIPPER_APPS[i].name) == 0) { | ||||||
|             application = &FLIPPER_APPS[i]; |             application = &FLIPPER_APPS[i]; | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     for(size_t i = 0; i < FLIPPER_PLUGINS_COUNT; i++) { |     for(size_t i = 0; i < FLIPPER_PLUGINS_COUNT; i++) { | ||||||
|         if(string_cmp_str(name, FLIPPER_APPS[i].name) == 0) { |         if(strcmp(name, FLIPPER_PLUGINS[i].name) == 0) { | ||||||
|             application = &FLIPPER_APPS[i]; |             application = &FLIPPER_PLUGINS[i]; | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     if(furi_hal_rtc_is_flag_set(FuriHalRtcFlagDebug)) { |     if(furi_hal_rtc_is_flag_set(FuriHalRtcFlagDebug)) { | ||||||
|         for(size_t i = 0; i < FLIPPER_DEBUG_APPS_COUNT; i++) { |         for(size_t i = 0; i < FLIPPER_DEBUG_APPS_COUNT; i++) { | ||||||
|             if(string_cmp_str(name, FLIPPER_APPS[i].name) == 0) { |             if(strcmp(name, FLIPPER_DEBUG_APPS[i].name) == 0) { | ||||||
|                 application = &FLIPPER_APPS[i]; |                 application = &FLIPPER_DEBUG_APPS[i]; | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| @ -80,7 +80,7 @@ void loader_cli_open(Cli* cli, string_t args, Loader* instance) { | |||||||
|         return; |         return; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     const FlipperApplication* application = loader_find_application_by_name(args); |     const FlipperApplication* application = loader_find_application_by_name(string_get_cstr(args)); | ||||||
|     if(!application) { |     if(!application) { | ||||||
|         printf("%s doesn't exists\r\n", string_get_cstr(args)); |         printf("%s doesn't exists\r\n", string_get_cstr(args)); | ||||||
|         return; |         return; | ||||||
| @ -152,23 +152,7 @@ void loader_cli(Cli* cli, string_t args, void* _ctx) { | |||||||
| LoaderStatus loader_start(Loader* instance, const char* name, const char* args) { | LoaderStatus loader_start(Loader* instance, const char* name, const char* args) { | ||||||
|     furi_assert(name); |     furi_assert(name); | ||||||
| 
 | 
 | ||||||
|     const FlipperApplication* flipper_app = NULL; |     const FlipperApplication* flipper_app = loader_find_application_by_name(name); | ||||||
|     // Search for application
 |  | ||||||
|     for(size_t i = 0; i < FLIPPER_APPS_COUNT; i++) { |  | ||||||
|         if(strcmp(FLIPPER_APPS[i].name, name) == 0) { |  | ||||||
|             flipper_app = &FLIPPER_APPS[i]; |  | ||||||
|             break; |  | ||||||
|         } |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     if(!flipper_app) { |  | ||||||
|         for(size_t i = 0; i < FLIPPER_DEBUG_APPS_COUNT; i++) { |  | ||||||
|             if(strcmp(FLIPPER_DEBUG_APPS[i].name, name) == 0) { |  | ||||||
|                 flipper_app = &FLIPPER_DEBUG_APPS[i]; |  | ||||||
|                 break; |  | ||||||
|             } |  | ||||||
|         } |  | ||||||
|     } |  | ||||||
| 
 | 
 | ||||||
|     if(!flipper_app) { |     if(!flipper_app) { | ||||||
|         FURI_LOG_E(TAG, "Can't find application with name %s", name); |         FURI_LOG_E(TAG, "Can't find application with name %s", name); | ||||||
|  | |||||||
| @ -12,8 +12,8 @@ void nfc_scene_delete_on_enter(void* context) { | |||||||
| 
 | 
 | ||||||
|     // Setup Custom Widget view
 |     // Setup Custom Widget view
 | ||||||
|     char delete_str[64]; |     char delete_str[64]; | ||||||
|     snprintf(delete_str, sizeof(delete_str), "\e#Delete %s\e#", nfc->dev->dev_name); |     snprintf(delete_str, sizeof(delete_str), "\e#Delete %s?\e#", nfc->dev->dev_name); | ||||||
|     widget_add_text_box_element(nfc->widget, 0, 0, 128, 24, AlignCenter, AlignCenter, delete_str); |     widget_add_text_box_element(nfc->widget, 0, 0, 128, 23, AlignCenter, AlignCenter, delete_str); | ||||||
|     widget_add_button_element( |     widget_add_button_element( | ||||||
|         nfc->widget, GuiButtonTypeLeft, "Back", nfc_scene_delete_widget_callback, nfc); |         nfc->widget, GuiButtonTypeLeft, "Back", nfc_scene_delete_widget_callback, nfc); | ||||||
|     widget_add_button_element( |     widget_add_button_element( | ||||||
| @ -42,7 +42,7 @@ void nfc_scene_delete_on_enter(void* context) { | |||||||
|             data->uid[5], |             data->uid[5], | ||||||
|             data->uid[6]); |             data->uid[6]); | ||||||
|     } |     } | ||||||
|     widget_add_string_element(nfc->widget, 64, 21, AlignCenter, AlignTop, FontSecondary, uid_str); |     widget_add_string_element(nfc->widget, 64, 23, AlignCenter, AlignTop, FontSecondary, uid_str); | ||||||
| 
 | 
 | ||||||
|     const char* protocol_name = NULL; |     const char* protocol_name = NULL; | ||||||
|     if(data->protocol == NfcDeviceProtocolEMV) { |     if(data->protocol == NfcDeviceProtocolEMV) { | ||||||
| @ -52,16 +52,16 @@ void nfc_scene_delete_on_enter(void* context) { | |||||||
|     } |     } | ||||||
|     if(protocol_name) { |     if(protocol_name) { | ||||||
|         widget_add_string_element( |         widget_add_string_element( | ||||||
|             nfc->widget, 10, 32, AlignLeft, AlignTop, FontSecondary, protocol_name); |             nfc->widget, 10, 33, AlignLeft, AlignTop, FontSecondary, protocol_name); | ||||||
|     } |     } | ||||||
|     // TODO change dinamically
 |     // TODO change dinamically
 | ||||||
|     widget_add_string_element(nfc->widget, 118, 32, AlignRight, AlignTop, FontSecondary, "NFC-A"); |     widget_add_string_element(nfc->widget, 118, 33, AlignRight, AlignTop, FontSecondary, "NFC-A"); | ||||||
|     char sak_str[16]; |     char sak_str[16]; | ||||||
|     snprintf(sak_str, sizeof(sak_str), "SAK: %02X", data->sak); |     snprintf(sak_str, sizeof(sak_str), "SAK: %02X", data->sak); | ||||||
|     widget_add_string_element(nfc->widget, 10, 42, AlignLeft, AlignTop, FontSecondary, sak_str); |     widget_add_string_element(nfc->widget, 10, 43, AlignLeft, AlignTop, FontSecondary, sak_str); | ||||||
|     char atqa_str[16]; |     char atqa_str[16]; | ||||||
|     snprintf(atqa_str, sizeof(atqa_str), "ATQA: %02X%02X", data->atqa[0], data->atqa[1]); |     snprintf(atqa_str, sizeof(atqa_str), "ATQA: %02X%02X", data->atqa[0], data->atqa[1]); | ||||||
|     widget_add_string_element(nfc->widget, 118, 42, AlignRight, AlignTop, FontSecondary, atqa_str); |     widget_add_string_element(nfc->widget, 118, 43, AlignRight, AlignTop, FontSecondary, atqa_str); | ||||||
| 
 | 
 | ||||||
|     view_dispatcher_switch_to_view(nfc->view_dispatcher, NfcViewWidget); |     view_dispatcher_switch_to_view(nfc->view_dispatcher, NfcViewWidget); | ||||||
| } | } | ||||||
|  | |||||||
| @ -37,7 +37,7 @@ void nfc_scene_device_info_on_enter(void* context) { | |||||||
| 
 | 
 | ||||||
|     // Setup Custom Widget view
 |     // Setup Custom Widget view
 | ||||||
|     widget_add_text_box_element( |     widget_add_text_box_element( | ||||||
|         nfc->widget, 0, 0, 128, 24, AlignCenter, AlignCenter, nfc->dev->dev_name); |         nfc->widget, 0, 0, 128, 22, AlignCenter, AlignCenter, nfc->dev->dev_name); | ||||||
|     widget_add_button_element( |     widget_add_button_element( | ||||||
|         nfc->widget, GuiButtonTypeLeft, "Back", nfc_scene_device_info_widget_callback, nfc); |         nfc->widget, GuiButtonTypeLeft, "Back", nfc_scene_device_info_widget_callback, nfc); | ||||||
|     widget_add_button_element( |     widget_add_button_element( | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 gornekich
						gornekich