updater_scene_error.c 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. #include "updater/updater_i.h"
  2. #include "updater_scene.h"
  3. #include <update_util/update_operation.h>
  4. void updater_scene_error_callback(GuiButtonType result, InputType type, void* context) {
  5. furi_assert(context);
  6. Updater* updater = context;
  7. if(type != InputTypeShort) {
  8. return;
  9. }
  10. if(result == GuiButtonTypeLeft) {
  11. view_dispatcher_send_custom_event(
  12. updater->view_dispatcher, UpdaterCustomEventCancelUpdate);
  13. }
  14. }
  15. void updater_scene_error_on_enter(void* context) {
  16. Updater* updater = (Updater*)context;
  17. widget_add_button_element(
  18. updater->widget, GuiButtonTypeLeft, "Exit", updater_scene_error_callback, updater);
  19. widget_add_string_multiline_element(
  20. updater->widget, 64, 13, AlignCenter, AlignCenter, FontPrimary, "Error");
  21. widget_add_string_multiline_element(
  22. updater->widget,
  23. 64,
  24. 33,
  25. AlignCenter,
  26. AlignCenter,
  27. FontPrimary,
  28. update_operation_describe_preparation_result(updater->preparation_result));
  29. view_dispatcher_switch_to_view(updater->view_dispatcher, UpdaterViewWidget);
  30. }
  31. bool updater_scene_error_on_event(void* context, SceneManagerEvent event) {
  32. Updater* updater = (Updater*)context;
  33. bool consumed = false;
  34. if(event.type == SceneManagerEventTypeBack) {
  35. view_dispatcher_stop(updater->view_dispatcher);
  36. consumed = true;
  37. } else if(event.type == SceneManagerEventTypeCustom) {
  38. switch(event.event) {
  39. case UpdaterCustomEventCancelUpdate:
  40. view_dispatcher_stop(updater->view_dispatcher);
  41. consumed = true;
  42. break;
  43. default:
  44. break;
  45. }
  46. }
  47. return consumed;
  48. }
  49. void updater_scene_error_on_exit(void* context) {
  50. Updater* updater = (Updater*)context;
  51. widget_reset(updater->widget);
  52. free(updater->pending_update);
  53. }