[FL-2220, FL-2221, FL-1883] RFID and iButton GUI update (#1107)
* RFID and iButton gui update * Grammar nazi: readed -> read * Grammar nazi pt.2: writed -> written Co-authored-by: あく <alleteam@gmail.com>
This commit is contained in:
		| @@ -9,7 +9,9 @@ | ||||
| #include "scene/ibutton_scene_read_crc_error.h" | ||||
| #include "scene/ibutton_scene_read_not_key_error.h" | ||||
| #include "scene/ibutton_scene_read_success.h" | ||||
| #include "scene/ibutton_scene_readed_key_menu.h" | ||||
| #include "scene/ibutton_scene_retry_confirm.h" | ||||
| #include "scene/ibutton_scene_exit_confirm.h" | ||||
| #include "scene/ibutton_scene_read_key_menu.h" | ||||
| #include "scene/ibutton_scene_write.h" | ||||
| #include "scene/ibutton_scene_write_success.h" | ||||
| #include "scene/ibutton_scene_saved_key_menu.h" | ||||
| @@ -42,7 +44,9 @@ public: | ||||
|         SceneReadNotKeyError, | ||||
|         SceneReadCRCError, | ||||
|         SceneReadSuccess, | ||||
|         SceneReadedKeyMenu, | ||||
|         SceneRetryConfirm, | ||||
|         SceneExitConfirm, | ||||
|         SceneReadKeyMenu, | ||||
|         SceneWrite, | ||||
|         SceneWriteSuccess, | ||||
|         SceneEmulate, | ||||
| @@ -105,7 +109,9 @@ private: | ||||
|         {Scene::SceneReadCRCError, new iButtonSceneReadCRCError()}, | ||||
|         {Scene::SceneReadNotKeyError, new iButtonSceneReadNotKeyError()}, | ||||
|         {Scene::SceneReadSuccess, new iButtonSceneReadSuccess()}, | ||||
|         {Scene::SceneReadedKeyMenu, new iButtonSceneReadedKeyMenu()}, | ||||
|         {Scene::SceneRetryConfirm, new iButtonSceneRetryConfirm()}, | ||||
|         {Scene::SceneExitConfirm, new iButtonSceneExitConfirm()}, | ||||
|         {Scene::SceneReadKeyMenu, new iButtonSceneReadKeyMenu()}, | ||||
|         {Scene::SceneWrite, new iButtonSceneWrite()}, | ||||
|         {Scene::SceneWriteSuccess, new iButtonSceneWriteSuccess()}, | ||||
|         {Scene::SceneEmulate, new iButtonSceneEmulate()}, | ||||
|   | ||||
| @@ -14,7 +14,7 @@ void iButtonSceneDeleteSuccess::on_enter(iButtonApp* app) { | ||||
|     Popup* popup = view_manager->get_popup(); | ||||
|  | ||||
|     popup_set_icon(popup, 0, 2, &I_DolphinMafia_115x62); | ||||
|     popup_set_text(popup, "Deleted", 83, 19, AlignLeft, AlignBottom); | ||||
|     popup_set_header(popup, "Deleted", 83, 19, AlignLeft, AlignBottom); | ||||
|  | ||||
|     popup_set_callback(popup, popup_callback); | ||||
|     popup_set_context(popup, app); | ||||
|   | ||||
							
								
								
									
										51
									
								
								applications/ibutton/scene/ibutton_scene_exit_confirm.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										51
									
								
								applications/ibutton/scene/ibutton_scene_exit_confirm.cpp
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,51 @@ | ||||
| #include "ibutton_scene_exit_confirm.h" | ||||
| #include "../ibutton_app.h" | ||||
|  | ||||
| static void widget_callback(GuiButtonType result, InputType type, void* context) { | ||||
|     furi_assert(context); | ||||
|     iButtonApp* app = static_cast<iButtonApp*>(context); | ||||
|     iButtonEvent event; | ||||
|  | ||||
|     if(type == InputTypeShort) { | ||||
|         event.type = iButtonEvent::Type::EventTypeWidgetButtonResult; | ||||
|         event.payload.widget_button_result = result; | ||||
|         app->get_view_manager()->send_event(&event); | ||||
|     } | ||||
| } | ||||
|  | ||||
| void iButtonSceneExitConfirm::on_enter(iButtonApp* app) { | ||||
|     iButtonAppViewManager* view_manager = app->get_view_manager(); | ||||
|     Widget* widget = view_manager->get_widget(); | ||||
|  | ||||
|     widget_add_button_element(widget, GuiButtonTypeLeft, "Exit", widget_callback, app); | ||||
|     widget_add_button_element(widget, GuiButtonTypeRight, "Stay", widget_callback, app); | ||||
|     widget_add_string_element( | ||||
|         widget, 64, 19, AlignCenter, AlignBottom, FontPrimary, "Exit to iButton menu"); | ||||
|     widget_add_string_element( | ||||
|         widget, 64, 29, AlignCenter, AlignBottom, FontSecondary, "All unsaved data will be lost"); | ||||
|  | ||||
|     view_manager->switch_to(iButtonAppViewManager::Type::iButtonAppViewWidget); | ||||
| } | ||||
|  | ||||
| bool iButtonSceneExitConfirm::on_event(iButtonApp* app, iButtonEvent* event) { | ||||
|     bool consumed = false; | ||||
|  | ||||
|     if(event->type == iButtonEvent::Type::EventTypeWidgetButtonResult) { | ||||
|         if(event->payload.widget_button_result == GuiButtonTypeLeft) { | ||||
|             app->search_and_switch_to_previous_scene({iButtonApp::Scene::SceneStart}); | ||||
|         } else if(event->payload.widget_button_result == GuiButtonTypeRight) { | ||||
|             app->switch_to_previous_scene(); | ||||
|         } | ||||
|         consumed = true; | ||||
|     } else if(event->type == iButtonEvent::Type::EventTypeBack) { | ||||
|         consumed = true; | ||||
|     } | ||||
|  | ||||
|     return consumed; | ||||
| } | ||||
|  | ||||
| void iButtonSceneExitConfirm::on_exit(iButtonApp* app) { | ||||
|     iButtonAppViewManager* view_manager = app->get_view_manager(); | ||||
|     Widget* widget = view_manager->get_widget(); | ||||
|     widget_reset(widget); | ||||
| } | ||||
							
								
								
									
										9
									
								
								applications/ibutton/scene/ibutton_scene_exit_confirm.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										9
									
								
								applications/ibutton/scene/ibutton_scene_exit_confirm.h
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,9 @@ | ||||
| #pragma once | ||||
| #include "ibutton_scene_generic.h" | ||||
|  | ||||
| class iButtonSceneExitConfirm : public iButtonScene { | ||||
| public: | ||||
|     void on_enter(iButtonApp* app) final; | ||||
|     bool on_event(iButtonApp* app, iButtonEvent* event) final; | ||||
|     void on_exit(iButtonApp* app) final; | ||||
| }; | ||||
| @@ -34,15 +34,22 @@ bool iButtonSceneRead::on_event(iButtonApp* app, iButtonEvent* event) { | ||||
|         consumed = true; | ||||
|  | ||||
|         iButtonKey* key = app->get_key(); | ||||
|         bool success = false; | ||||
|         if(ibutton_key_get_type(key) == iButtonKeyDS1990) { | ||||
|             if(!ibutton_key_dallas_crc_is_valid(key)) { | ||||
|                 app->switch_to_next_scene(iButtonApp::Scene::SceneReadCRCError); | ||||
|             } else if(!ibutton_key_dallas_is_1990_key(key)) { | ||||
|                 app->switch_to_next_scene(iButtonApp::Scene::SceneReadNotKeyError); | ||||
|             } else { | ||||
|                 app->switch_to_next_scene(iButtonApp::Scene::SceneReadSuccess); | ||||
|                 success = true; | ||||
|             } | ||||
|         } else { | ||||
|             success = true; | ||||
|         } | ||||
|         if(success) { | ||||
|             app->notify_success(); | ||||
|             app->notify_green_on(); | ||||
|             DOLPHIN_DEED(DolphinDeedIbuttonReadSuccess); | ||||
|             app->switch_to_next_scene(iButtonApp::Scene::SceneReadSuccess); | ||||
|         } | ||||
|     } else if(event->type == iButtonEvent::Type::EventTypeTick) { | ||||
|   | ||||
| @@ -47,7 +47,7 @@ bool iButtonSceneReadCRCError::on_event(iButtonApp* app, iButtonEvent* event) { | ||||
|  | ||||
|     if(event->type == iButtonEvent::Type::EventTypeDialogResult) { | ||||
|         if(event->payload.dialog_result == DialogExResultRight) { | ||||
|             app->switch_to_next_scene(iButtonApp::Scene::SceneReadedKeyMenu); | ||||
|             app->switch_to_next_scene(iButtonApp::Scene::SceneReadKeyMenu); | ||||
|         } else { | ||||
|             app->switch_to_previous_scene(); | ||||
|         } | ||||
|   | ||||
| @@ -1,11 +1,10 @@ | ||||
| #include "ibutton_scene_readed_key_menu.h" | ||||
| #include "ibutton_scene_read_key_menu.h" | ||||
| #include "../ibutton_app.h" | ||||
| 
 | ||||
| typedef enum { | ||||
|     SubmenuIndexWrite, | ||||
|     SubmenuIndexEmulate, | ||||
|     SubmenuIndexSave, | ||||
|     SubmenuIndexReadNewKey, | ||||
| } SubmenuIndex; | ||||
| 
 | ||||
| static void submenu_callback(void* context, uint32_t index) { | ||||
| @@ -19,7 +18,7 @@ static void submenu_callback(void* context, uint32_t index) { | ||||
|     app->get_view_manager()->send_event(&event); | ||||
| } | ||||
| 
 | ||||
| void iButtonSceneReadedKeyMenu::on_enter(iButtonApp* app) { | ||||
| void iButtonSceneReadKeyMenu::on_enter(iButtonApp* app) { | ||||
|     iButtonAppViewManager* view_manager = app->get_view_manager(); | ||||
|     Submenu* submenu = view_manager->get_submenu(); | ||||
| 
 | ||||
| @@ -28,13 +27,12 @@ void iButtonSceneReadedKeyMenu::on_enter(iButtonApp* app) { | ||||
|     } | ||||
|     submenu_add_item(submenu, "Save", SubmenuIndexSave, submenu_callback, app); | ||||
|     submenu_add_item(submenu, "Emulate", SubmenuIndexEmulate, submenu_callback, app); | ||||
|     submenu_add_item(submenu, "Read new key", SubmenuIndexReadNewKey, submenu_callback, app); | ||||
|     submenu_set_selected_item(submenu, submenu_item_selected); | ||||
| 
 | ||||
|     view_manager->switch_to(iButtonAppViewManager::Type::iButtonAppViewSubmenu); | ||||
| } | ||||
| 
 | ||||
| bool iButtonSceneReadedKeyMenu::on_event(iButtonApp* app, iButtonEvent* event) { | ||||
| bool iButtonSceneReadKeyMenu::on_event(iButtonApp* app, iButtonEvent* event) { | ||||
|     bool consumed = false; | ||||
| 
 | ||||
|     if(event->type == iButtonEvent::Type::EventTypeMenuSelected) { | ||||
| @@ -49,20 +47,17 @@ bool iButtonSceneReadedKeyMenu::on_event(iButtonApp* app, iButtonEvent* event) { | ||||
|         case SubmenuIndexSave: | ||||
|             app->switch_to_next_scene(iButtonApp::Scene::SceneSaveName); | ||||
|             break; | ||||
|         case SubmenuIndexReadNewKey: | ||||
|             app->search_and_switch_to_previous_scene({iButtonApp::Scene::SceneRead}); | ||||
|             break; | ||||
|         } | ||||
|         consumed = true; | ||||
|     } else if(event->type == iButtonEvent::Type::EventTypeBack) { | ||||
|         app->search_and_switch_to_previous_scene({iButtonApp::Scene::SceneStart}); | ||||
|         app->switch_to_previous_scene(); | ||||
|         consumed = true; | ||||
|     } | ||||
| 
 | ||||
|     return consumed; | ||||
| } | ||||
| 
 | ||||
| void iButtonSceneReadedKeyMenu::on_exit(iButtonApp* app) { | ||||
| void iButtonSceneReadKeyMenu::on_exit(iButtonApp* app) { | ||||
|     iButtonAppViewManager* view = app->get_view_manager(); | ||||
|     Submenu* submenu = view->get_submenu(); | ||||
| 
 | ||||
| @@ -1,7 +1,7 @@ | ||||
| #pragma once | ||||
| #include "ibutton_scene_generic.h" | ||||
| 
 | ||||
| class iButtonSceneReadedKeyMenu : public iButtonScene { | ||||
| class iButtonSceneReadKeyMenu : public iButtonScene { | ||||
| public: | ||||
|     void on_enter(iButtonApp* app) final; | ||||
|     bool on_event(iButtonApp* app, iButtonEvent* event) final; | ||||
| @@ -47,7 +47,7 @@ bool iButtonSceneReadNotKeyError::on_event(iButtonApp* app, iButtonEvent* event) | ||||
|  | ||||
|     if(event->type == iButtonEvent::Type::EventTypeDialogResult) { | ||||
|         if(event->payload.dialog_result == DialogExResultRight) { | ||||
|             app->switch_to_next_scene(iButtonApp::Scene::SceneReadedKeyMenu); | ||||
|             app->switch_to_next_scene(iButtonApp::Scene::SceneReadKeyMenu); | ||||
|         } else { | ||||
|             app->switch_to_previous_scene(); | ||||
|         } | ||||
|   | ||||
| @@ -18,7 +18,6 @@ void iButtonSceneReadSuccess::on_enter(iButtonApp* app) { | ||||
|     DialogEx* dialog_ex = view_manager->get_dialog_ex(); | ||||
|     iButtonKey* key = app->get_key(); | ||||
|     const uint8_t* key_data = ibutton_key_get_data_p(key); | ||||
|     DOLPHIN_DEED(DolphinDeedIbuttonReadSuccess); | ||||
|  | ||||
|     switch(ibutton_key_get_type(key)) { | ||||
|     case iButtonKeyDS1990: | ||||
| @@ -50,9 +49,6 @@ void iButtonSceneReadSuccess::on_enter(iButtonApp* app) { | ||||
|     dialog_ex_set_context(dialog_ex, app); | ||||
|  | ||||
|     view_manager->switch_to(iButtonAppViewManager::Type::iButtonAppViewDialogEx); | ||||
|  | ||||
|     app->notify_success(); | ||||
|     app->notify_green_on(); | ||||
| } | ||||
|  | ||||
| bool iButtonSceneReadSuccess::on_event(iButtonApp* app, iButtonEvent* event) { | ||||
| @@ -60,11 +56,13 @@ bool iButtonSceneReadSuccess::on_event(iButtonApp* app, iButtonEvent* event) { | ||||
|  | ||||
|     if(event->type == iButtonEvent::Type::EventTypeDialogResult) { | ||||
|         if(event->payload.dialog_result == DialogExResultRight) { | ||||
|             app->switch_to_next_scene(iButtonApp::Scene::SceneReadedKeyMenu); | ||||
|             app->switch_to_next_scene(iButtonApp::Scene::SceneReadKeyMenu); | ||||
|         } else { | ||||
|             app->switch_to_previous_scene(); | ||||
|             app->switch_to_next_scene(iButtonApp::Scene::SceneRetryConfirm); | ||||
|         } | ||||
|  | ||||
|         consumed = true; | ||||
|     } else if(event->type == iButtonEvent::Type::EventTypeBack) { | ||||
|         app->switch_to_next_scene(iButtonApp::Scene::SceneExitConfirm); | ||||
|         consumed = true; | ||||
|     } | ||||
|  | ||||
|   | ||||
							
								
								
									
										51
									
								
								applications/ibutton/scene/ibutton_scene_retry_confirm.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										51
									
								
								applications/ibutton/scene/ibutton_scene_retry_confirm.cpp
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,51 @@ | ||||
| #include "ibutton_scene_retry_confirm.h" | ||||
| #include "../ibutton_app.h" | ||||
|  | ||||
| static void widget_callback(GuiButtonType result, InputType type, void* context) { | ||||
|     furi_assert(context); | ||||
|     iButtonApp* app = static_cast<iButtonApp*>(context); | ||||
|     iButtonEvent event; | ||||
|  | ||||
|     if(type == InputTypeShort) { | ||||
|         event.type = iButtonEvent::Type::EventTypeWidgetButtonResult; | ||||
|         event.payload.widget_button_result = result; | ||||
|         app->get_view_manager()->send_event(&event); | ||||
|     } | ||||
| } | ||||
|  | ||||
| void iButtonSceneRetryConfirm::on_enter(iButtonApp* app) { | ||||
|     iButtonAppViewManager* view_manager = app->get_view_manager(); | ||||
|     Widget* widget = view_manager->get_widget(); | ||||
|  | ||||
|     widget_add_button_element(widget, GuiButtonTypeLeft, "Exit", widget_callback, app); | ||||
|     widget_add_button_element(widget, GuiButtonTypeRight, "Stay", widget_callback, app); | ||||
|     widget_add_string_element( | ||||
|         widget, 64, 19, AlignCenter, AlignBottom, FontPrimary, "Return to reading?"); | ||||
|     widget_add_string_element( | ||||
|         widget, 64, 29, AlignCenter, AlignBottom, FontSecondary, "All unsaved data will be lost"); | ||||
|  | ||||
|     view_manager->switch_to(iButtonAppViewManager::Type::iButtonAppViewWidget); | ||||
| } | ||||
|  | ||||
| bool iButtonSceneRetryConfirm::on_event(iButtonApp* app, iButtonEvent* event) { | ||||
|     bool consumed = false; | ||||
|  | ||||
|     if(event->type == iButtonEvent::Type::EventTypeWidgetButtonResult) { | ||||
|         if(event->payload.widget_button_result == GuiButtonTypeLeft) { | ||||
|             app->search_and_switch_to_previous_scene({iButtonApp::Scene::SceneRead}); | ||||
|         } else if(event->payload.widget_button_result == GuiButtonTypeRight) { | ||||
|             app->switch_to_previous_scene(); | ||||
|         } | ||||
|         consumed = true; | ||||
|     } else if(event->type == iButtonEvent::Type::EventTypeBack) { | ||||
|         consumed = true; | ||||
|     } | ||||
|  | ||||
|     return consumed; | ||||
| } | ||||
|  | ||||
| void iButtonSceneRetryConfirm::on_exit(iButtonApp* app) { | ||||
|     iButtonAppViewManager* view_manager = app->get_view_manager(); | ||||
|     Widget* widget = view_manager->get_widget(); | ||||
|     widget_reset(widget); | ||||
| } | ||||
							
								
								
									
										9
									
								
								applications/ibutton/scene/ibutton_scene_retry_confirm.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										9
									
								
								applications/ibutton/scene/ibutton_scene_retry_confirm.h
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,9 @@ | ||||
| #pragma once | ||||
| #include "ibutton_scene_generic.h" | ||||
|  | ||||
| class iButtonSceneRetryConfirm : public iButtonScene { | ||||
| public: | ||||
|     void on_enter(iButtonApp* app) final; | ||||
|     bool on_event(iButtonApp* app, iButtonEvent* event) final; | ||||
|     void on_exit(iButtonApp* app) final; | ||||
| }; | ||||
| @@ -49,7 +49,7 @@ bool iButtonSceneSaveName::on_event(iButtonApp* app, iButtonEvent* event) { | ||||
|             app->switch_to_next_scene(iButtonApp::Scene::SceneSaveSuccess); | ||||
|         } else { | ||||
|             app->search_and_switch_to_previous_scene( | ||||
|                 {iButtonApp::Scene::SceneReadedKeyMenu, | ||||
|                 {iButtonApp::Scene::SceneReadKeyMenu, | ||||
|                  iButtonApp::Scene::SceneSavedKeyMenu, | ||||
|                  iButtonApp::Scene::SceneAddType}); | ||||
|         } | ||||
|   | ||||
| @@ -16,7 +16,7 @@ void iButtonSceneSaveSuccess::on_enter(iButtonApp* app) { | ||||
|     DOLPHIN_DEED(DolphinDeedIbuttonSave); | ||||
|  | ||||
|     popup_set_icon(popup, 32, 5, &I_DolphinNice_96x59); | ||||
|     popup_set_text(popup, "Saved!", 13, 22, AlignLeft, AlignBottom); | ||||
|     popup_set_header(popup, "Saved!", 5, 7, AlignLeft, AlignTop); | ||||
|  | ||||
|     popup_set_callback(popup, popup_callback); | ||||
|     popup_set_context(popup, app); | ||||
| @@ -31,7 +31,7 @@ bool iButtonSceneSaveSuccess::on_event(iButtonApp* app, iButtonEvent* event) { | ||||
|  | ||||
|     if(event->type == iButtonEvent::Type::EventTypeBack) { | ||||
|         app->search_and_switch_to_previous_scene( | ||||
|             {iButtonApp::Scene::SceneReadedKeyMenu, | ||||
|             {iButtonApp::Scene::SceneReadKeyMenu, | ||||
|              iButtonApp::Scene::SceneSavedKeyMenu, | ||||
|              iButtonApp::Scene::SceneAddType}); | ||||
|         consumed = true; | ||||
|   | ||||
| @@ -33,7 +33,7 @@ bool iButtonSceneWriteSuccess::on_event(iButtonApp* app, iButtonEvent* event) { | ||||
|  | ||||
|     if(event->type == iButtonEvent::Type::EventTypeBack) { | ||||
|         app->search_and_switch_to_previous_scene( | ||||
|             {iButtonApp::Scene::SceneReadedKeyMenu, iButtonApp::Scene::SceneStart}); | ||||
|             {iButtonApp::Scene::SceneReadKeyMenu, iButtonApp::Scene::SceneStart}); | ||||
|         consumed = true; | ||||
|     } | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user