Skip to content

Commit 877c5c8

Browse files
nminaylovskotopes
andauthored
[FL-1962, FL-2464, FL-2465, FL-2466, FL-2560, FL-2637, FL-2595] Ibutton, Infrared, LfRFID GUI fixes (#1392)
* Ibutton, Infrared, LfRFID GUI fixes * Loading screens update Co-authored-by: あく <alleteam@gmail.com>
1 parent edc6ca0 commit 877c5c8

30 files changed

+147
-44
lines changed

applications/archive/views/archive_browser_view.c

+3-10
Original file line numberDiff line numberDiff line change
@@ -105,17 +105,10 @@ static void archive_draw_frame(Canvas* canvas, uint16_t idx, bool scrollbar, boo
105105
static void archive_draw_loading(Canvas* canvas, ArchiveBrowserViewModel* model) {
106106
furi_assert(model);
107107

108-
uint8_t width = 49;
109-
uint8_t height = 47;
110-
uint8_t x = 128 / 2 - width / 2;
111-
uint8_t y = 64 / 2 - height / 2 + 6;
108+
uint8_t x = 128 / 2 - 24 / 2;
109+
uint8_t y = 64 / 2 - 24 / 2;
112110

113-
elements_bold_rounded_frame(canvas, x, y, width, height);
114-
115-
canvas_set_font(canvas, FontSecondary);
116-
elements_multiline_text(canvas, x + 7, y + 13, "Loading...");
117-
118-
canvas_draw_icon(canvas, x + 13, y + 19, &A_Loading_24);
111+
canvas_draw_icon(canvas, x, y, &A_Loading_24);
119112
}
120113

121114
static void draw_list(Canvas* canvas, ArchiveBrowserViewModel* model) {

applications/gui/modules/file_browser.c

+3-10
Original file line numberDiff line numberDiff line change
@@ -354,19 +354,12 @@ static void browser_draw_frame(Canvas* canvas, uint16_t idx, bool scrollbar) {
354354
}
355355

356356
static void browser_draw_loading(Canvas* canvas, FileBrowserModel* model) {
357-
uint8_t width = 49;
358-
uint8_t height = 47;
359-
uint8_t x = 128 / 2 - width / 2;
360-
uint8_t y = 64 / 2 - height / 2;
361-
362357
UNUSED(model);
363358

364-
elements_bold_rounded_frame(canvas, x, y, width, height);
365-
366-
canvas_set_font(canvas, FontSecondary);
367-
elements_multiline_text(canvas, x + 7, y + 13, "Loading...");
359+
uint8_t x = 128 / 2 - 24 / 2;
360+
uint8_t y = 64 / 2 - 24 / 2;
368361

369-
canvas_draw_icon(canvas, x + 13, y + 19, &A_Loading_24);
362+
canvas_draw_icon(canvas, x, y, &A_Loading_24);
370363
}
371364

372365
static void browser_draw_list(Canvas* canvas, FileBrowserModel* model) {

applications/gui/modules/loading.c

+7-8
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,16 @@ typedef struct {
2020
static void loading_draw_callback(Canvas* canvas, void* _model) {
2121
LoadingModel* model = (LoadingModel*)_model;
2222

23-
uint8_t width = 49;
24-
uint8_t height = 47;
25-
uint8_t x = (canvas_width(canvas) - width) / 2;
26-
uint8_t y = (canvas_height(canvas) - height) / 2;
23+
canvas_set_color(canvas, ColorWhite);
24+
canvas_draw_box(canvas, 0, 0, canvas_width(canvas), canvas_height(canvas));
25+
canvas_set_color(canvas, ColorBlack);
2726

28-
elements_bold_rounded_frame(canvas, x, y, width, height);
27+
uint8_t x = canvas_width(canvas) / 2 - 24 / 2;
28+
uint8_t y = canvas_height(canvas) / 2 - 24 / 2;
2929

30-
canvas_set_font(canvas, FontSecondary);
31-
elements_multiline_text(canvas, x + 7, y + 13, "Loading...");
30+
canvas_draw_icon(canvas, x, y, &A_Loading_24);
3231

33-
canvas_draw_icon_animation(canvas, x + 13, y + 19, model->icon);
32+
canvas_draw_icon_animation(canvas, x, y, model->icon);
3433
}
3534

3635
static bool loading_input_callback(InputEvent* event, void* context) {

applications/ibutton/scenes/ibutton_scene_add_type.c

+3-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ void ibutton_scene_add_type_on_enter(void* context) {
2323
submenu_add_item(
2424
submenu, "Metakom", SubmenuIndexMetakom, ibutton_scene_add_type_submenu_callback, ibutton);
2525

26-
submenu_set_selected_item(submenu, SubmenuIndexCyfral);
26+
submenu_set_selected_item(
27+
submenu, scene_manager_get_scene_state(ibutton->scene_manager, iButtonSceneAddType));
2728

2829
view_dispatcher_switch_to_view(ibutton->view_dispatcher, iButtonViewSubmenu);
2930
}
@@ -34,6 +35,7 @@ bool ibutton_scene_add_type_on_event(void* context, SceneManagerEvent event) {
3435
bool consumed = false;
3536

3637
if(event.type == SceneManagerEventTypeCustom) {
38+
scene_manager_set_scene_state(ibutton->scene_manager, iButtonSceneAddType, event.event);
3739
consumed = true;
3840
if(event.event == SubmenuIndexCyfral) {
3941
ibutton_key_set_type(key, iButtonKeyCyfral);

applications/ibutton/scenes/ibutton_scene_exit_confirm.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ void ibutton_scene_exit_confirm_on_enter(void* context) {
1919
widget_add_button_element(
2020
widget, GuiButtonTypeRight, "Stay", ibutton_scene_exit_confirm_widget_callback, ibutton);
2121
widget_add_string_element(
22-
widget, 64, 19, AlignCenter, AlignBottom, FontPrimary, "Exit to iButton menu");
22+
widget, 64, 19, AlignCenter, AlignBottom, FontPrimary, "Exit to iButton menu?");
2323
widget_add_string_element(
24-
widget, 64, 29, AlignCenter, AlignBottom, FontSecondary, "All unsaved data will be lost");
24+
widget, 64, 31, AlignCenter, AlignBottom, FontSecondary, "All unsaved data will be lost.");
2525

2626
view_dispatcher_switch_to_view(ibutton->view_dispatcher, iButtonViewWidget);
2727
}

applications/ibutton/scenes/ibutton_scene_read_crc_error.c

+4-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,10 @@ bool ibutton_scene_read_crc_error_on_event(void* context, SceneManagerEvent even
4343
SceneManager* scene_manager = ibutton->scene_manager;
4444
bool consumed = false;
4545

46-
if(event.type == SceneManagerEventTypeCustom) {
46+
if(event.type == SceneManagerEventTypeBack) {
47+
consumed = true;
48+
scene_manager_next_scene(scene_manager, iButtonSceneExitConfirm);
49+
} else if(event.type == SceneManagerEventTypeCustom) {
4750
consumed = true;
4851
if(event.event == DialogExResultRight) {
4952
scene_manager_next_scene(scene_manager, iButtonSceneReadKeyMenu);

applications/ibutton/scenes/ibutton_scene_read_key_menu.c

+4-2
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ void ibutton_scene_read_key_menu_on_enter(void* context) {
3131
ibutton_scene_read_key_menu_submenu_callback,
3232
ibutton);
3333
}
34-
35-
submenu_set_selected_item(submenu, SubmenuIndexSave);
34+
submenu_set_selected_item(
35+
submenu, scene_manager_get_scene_state(ibutton->scene_manager, iButtonSceneReadKeyMenu));
3636

3737
view_dispatcher_switch_to_view(ibutton->view_dispatcher, iButtonViewSubmenu);
3838
}
@@ -42,6 +42,8 @@ bool ibutton_scene_read_key_menu_on_event(void* context, SceneManagerEvent event
4242
bool consumed = false;
4343

4444
if(event.type == SceneManagerEventTypeCustom) {
45+
scene_manager_set_scene_state(
46+
ibutton->scene_manager, iButtonSceneReadKeyMenu, event.event);
4547
consumed = true;
4648
if(event.event == SubmenuIndexSave) {
4749
scene_manager_next_scene(ibutton->scene_manager, iButtonSceneSaveName);

applications/ibutton/scenes/ibutton_scene_read_not_key_error.c

+4-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,10 @@ bool ibutton_scene_read_not_key_error_on_event(void* context, SceneManagerEvent
4444
SceneManager* scene_manager = ibutton->scene_manager;
4545
bool consumed = false;
4646

47-
if(event.type == SceneManagerEventTypeCustom) {
47+
if(event.type == SceneManagerEventTypeBack) {
48+
consumed = true;
49+
scene_manager_next_scene(scene_manager, iButtonSceneExitConfirm);
50+
} else if(event.type == SceneManagerEventTypeCustom) {
4851
consumed = true;
4952
if(event.event == DialogExResultRight) {
5053
scene_manager_next_scene(scene_manager, iButtonSceneReadKeyMenu);

applications/ibutton/scenes/ibutton_scene_saved_key_menu.c

+4-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ void ibutton_scene_saved_key_menu_on_enter(void* context) {
4242
submenu_add_item(
4343
submenu, "Info", SubmenuIndexInfo, ibutton_scene_saved_key_menu_submenu_callback, ibutton);
4444

45-
submenu_set_selected_item(submenu, SubmenuIndexEmulate);
45+
submenu_set_selected_item(
46+
submenu, scene_manager_get_scene_state(ibutton->scene_manager, iButtonSceneSavedKeyMenu));
4647

4748
view_dispatcher_switch_to_view(ibutton->view_dispatcher, iButtonViewSubmenu);
4849
}
@@ -52,6 +53,8 @@ bool ibutton_scene_saved_key_menu_on_event(void* context, SceneManagerEvent even
5253
bool consumed = false;
5354

5455
if(event.type == SceneManagerEventTypeCustom) {
56+
scene_manager_set_scene_state(
57+
ibutton->scene_manager, iButtonSceneSavedKeyMenu, event.event);
5558
consumed = true;
5659
if(event.event == SubmenuIndexEmulate) {
5760
scene_manager_next_scene(ibutton->scene_manager, iButtonSceneEmulate);

applications/ibutton/scenes/ibutton_scene_start.c

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include "../ibutton_i.h"
2+
#include "ibutton/scenes/ibutton_scene.h"
23

34
enum SubmenuIndex {
45
SubmenuIndexRead,
@@ -22,7 +23,8 @@ void ibutton_scene_start_on_enter(void* context) {
2223
submenu_add_item(
2324
submenu, "Add Manually", SubmenuIndexAdd, ibutton_scene_start_submenu_callback, ibutton);
2425

25-
submenu_set_selected_item(submenu, SubmenuIndexRead);
26+
submenu_set_selected_item(
27+
submenu, scene_manager_get_scene_state(ibutton->scene_manager, iButtonSceneStart));
2628

2729
view_dispatcher_switch_to_view(ibutton->view_dispatcher, iButtonViewSubmenu);
2830
}
@@ -32,6 +34,7 @@ bool ibutton_scene_start_on_event(void* context, SceneManagerEvent event) {
3234
bool consumed = false;
3335

3436
if(event.type == SceneManagerEventTypeCustom) {
37+
scene_manager_set_scene_state(ibutton->scene_manager, iButtonSceneStart, event.event);
3538
consumed = true;
3639
if(event.event == SubmenuIndexRead) {
3740
scene_manager_next_scene(ibutton->scene_manager, iButtonSceneRead);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#include "../infrared_i.h"
2+
3+
static void infrared_scene_dialog_result_callback(DialogExResult result, void* context) {
4+
Infrared* infrared = context;
5+
view_dispatcher_send_custom_event(infrared->view_dispatcher, result);
6+
}
7+
8+
void infrared_scene_ask_retry_on_enter(void* context) {
9+
Infrared* infrared = context;
10+
DialogEx* dialog_ex = infrared->dialog_ex;
11+
12+
dialog_ex_set_header(dialog_ex, "Return to reading?", 64, 0, AlignCenter, AlignTop);
13+
dialog_ex_set_text(
14+
dialog_ex, "All unsaved data\nwill be lost", 64, 31, AlignCenter, AlignCenter);
15+
dialog_ex_set_icon(dialog_ex, 0, 0, NULL);
16+
dialog_ex_set_left_button_text(dialog_ex, "Exit");
17+
dialog_ex_set_center_button_text(dialog_ex, NULL);
18+
dialog_ex_set_right_button_text(dialog_ex, "Stay");
19+
dialog_ex_set_result_callback(dialog_ex, infrared_scene_dialog_result_callback);
20+
dialog_ex_set_context(dialog_ex, context);
21+
22+
view_dispatcher_switch_to_view(infrared->view_dispatcher, InfraredViewDialogEx);
23+
}
24+
25+
bool infrared_scene_ask_retry_on_event(void* context, SceneManagerEvent event) {
26+
Infrared* infrared = context;
27+
SceneManager* scene_manager = infrared->scene_manager;
28+
bool consumed = false;
29+
30+
if(event.type == SceneManagerEventTypeBack) {
31+
consumed = true;
32+
} else if(event.type == SceneManagerEventTypeCustom) {
33+
if(event.event == DialogExResultLeft) {
34+
scene_manager_search_and_switch_to_previous_scene(scene_manager, InfraredSceneLearn);
35+
consumed = true;
36+
} else if(event.event == DialogExResultRight) {
37+
scene_manager_previous_scene(scene_manager);
38+
consumed = true;
39+
}
40+
}
41+
42+
return consumed;
43+
}
44+
45+
void infrared_scene_ask_retry_on_exit(void* context) {
46+
Infrared* infrared = context;
47+
dialog_ex_reset(infrared->dialog_ex);
48+
}

applications/infrared/scenes/infrared_scene_config.h

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
ADD_SCENE(infrared, start, Start)
22
ADD_SCENE(infrared, ask_back, AskBack)
3+
ADD_SCENE(infrared, ask_retry, AskRetry)
34
ADD_SCENE(infrared, edit, Edit)
45
ADD_SCENE(infrared, edit_delete, EditDelete)
56
ADD_SCENE(infrared, edit_delete_done, EditDeleteDone)

applications/infrared/scenes/infrared_scene_learn_success.c

+1-2
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,7 @@ bool infrared_scene_learn_success_on_event(void* context, SceneManagerEvent even
8989
} else if(event.type == SceneManagerEventTypeCustom) {
9090
if(event.event == DialogExResultLeft) {
9191
if(scene_state == InfraredSceneLearnSuccessStateIdle) {
92-
scene_manager_search_and_switch_to_previous_scene(
93-
scene_manager, InfraredSceneLearn);
92+
scene_manager_next_scene(scene_manager, InfraredSceneAskRetry);
9493
}
9594
consumed = true;
9695
} else if(event.event == DialogExResultRight) {

applications/infrared/scenes/infrared_scene_remote_list.c

+1-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ void infrared_scene_remote_list_on_enter(void* context) {
55
SceneManager* scene_manager = infrared->scene_manager;
66
ViewDispatcher* view_dispatcher = infrared->view_dispatcher;
77

8-
string_set_str(infrared->file_path, INFRARED_APP_FOLDER);
98
bool success = dialog_file_browser_show(
109
infrared->dialogs,
1110
infrared->file_path,
@@ -16,7 +15,7 @@ void infrared_scene_remote_list_on_enter(void* context) {
1615
true);
1716

1817
if(success) {
19-
view_set_orientation(view_stack_get_view(infrared->view_stack), ViewOrientationHorizontal);
18+
view_set_orientation(view_stack_get_view(infrared->view_stack), ViewOrientationVertical);
2019
view_dispatcher_switch_to_view(view_dispatcher, InfraredViewStack);
2120

2221
infrared_show_loading_popup(infrared, true);

applications/infrared/scenes/infrared_scene_start.c

+1
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ bool infrared_scene_start_on_event(void* context, SceneManagerEvent event) {
6666
scene_manager_next_scene(scene_manager, InfraredSceneLearn);
6767
consumed = true;
6868
} else if(submenu_index == SubmenuIndexSavedRemotes) {
69+
string_set_str(infrared->file_path, INFRARED_APP_FOLDER);
6970
scene_manager_next_scene(scene_manager, InfraredSceneRemoteList);
7071
consumed = true;
7172
} else if(submenu_index == SubmenuIndexDebug) {

applications/lfrfid/scene/lfrfid_app_scene_exit_confirm.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ void LfRfidAppSceneExitConfirm::on_enter(LfRfidApp* app, bool /* need_restore */
1919

2020
line_1->set_text("Exit to RFID menu?", 64, 19, 128 - 2, AlignCenter, AlignBottom, FontPrimary);
2121
line_2->set_text(
22-
"All unsaved data will be lost", 64, 29, 0, AlignCenter, AlignBottom, FontSecondary);
22+
"All unsaved data will be lost.", 64, 31, 0, AlignCenter, AlignBottom, FontSecondary);
2323

2424
app->view_controller.switch_to<ContainerVM>();
2525
}

applications/lfrfid/scene/lfrfid_app_scene_read.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ bool LfRfidAppSceneRead::on_event(LfRfidApp* app, LfRfidApp::Event* event) {
2222
app->scene_controller.switch_to_next_scene(LfRfidApp::SceneType::ReadSuccess);
2323
} else {
2424
if(app->worker.any_read()) {
25-
notification_message(app->notification, &sequence_blink_green_10);
25+
notification_message(app->notification, &sequence_blink_yellow_10);
2626
} else if(app->worker.detect()) {
27-
notification_message(app->notification, &sequence_blink_cyan_10);
27+
notification_message(app->notification, &sequence_blink_yellow_10);
2828
} else {
2929
notification_message(app->notification, &sequence_blink_cyan_10);
3030
}

applications/nfc/nfc.c

+24
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,10 @@ Nfc* nfc_alloc() {
125125
nfc->popup = popup_alloc();
126126
view_dispatcher_add_view(nfc->view_dispatcher, NfcViewPopup, popup_get_view(nfc->popup));
127127

128+
// Loading
129+
nfc->loading = loading_alloc();
130+
view_dispatcher_add_view(nfc->view_dispatcher, NfcViewLoading, loading_get_view(nfc->loading));
131+
128132
// Text Input
129133
nfc->text_input = text_input_alloc();
130134
view_dispatcher_add_view(
@@ -179,6 +183,10 @@ void nfc_free(Nfc* nfc) {
179183
view_dispatcher_remove_view(nfc->view_dispatcher, NfcViewPopup);
180184
popup_free(nfc->popup);
181185

186+
// Loading
187+
view_dispatcher_remove_view(nfc->view_dispatcher, NfcViewLoading);
188+
loading_free(nfc->loading);
189+
182190
// TextInput
183191
view_dispatcher_remove_view(nfc->view_dispatcher, NfcViewTextInput);
184192
text_input_free(nfc->text_input);
@@ -258,12 +266,27 @@ void nfc_blink_stop(Nfc* nfc) {
258266
notification_message(nfc->notifications, &sequence_blink_stop);
259267
}
260268

269+
void nfc_show_loading_popup(void* context, bool show) {
270+
Nfc* nfc = context;
271+
TaskHandle_t timer_task = xTaskGetHandle(configTIMER_SERVICE_TASK_NAME);
272+
273+
if(show) {
274+
// Raise timer priority so that animations can play
275+
vTaskPrioritySet(timer_task, configMAX_PRIORITIES - 1);
276+
view_dispatcher_switch_to_view(nfc->view_dispatcher, NfcViewLoading);
277+
} else {
278+
// Restore default timer priority
279+
vTaskPrioritySet(timer_task, configTIMER_TASK_PRIORITY);
280+
}
281+
}
282+
261283
int32_t nfc_app(void* p) {
262284
Nfc* nfc = nfc_alloc();
263285
char* args = p;
264286

265287
// Check argument and run corresponding scene
266288
if((*args != '\0')) {
289+
nfc_device_set_loading_callback(nfc->dev, nfc_show_loading_popup, nfc);
267290
uint32_t rpc_ctx = 0;
268291
if(sscanf(p, "RPC %lX", &rpc_ctx) == 1) {
269292
nfc->rpc_ctx = (void*)rpc_ctx;
@@ -281,6 +304,7 @@ int32_t nfc_app(void* p) {
281304
// Exit app
282305
view_dispatcher_stop(nfc->view_dispatcher);
283306
}
307+
nfc_device_set_loading_callback(nfc->dev, NULL, nfc);
284308
} else {
285309
scene_manager_next_scene(nfc->scene_manager, NfcSceneStart);
286310
}

applications/nfc/nfc_device.c

+15
Original file line numberDiff line numberDiff line change
@@ -846,6 +846,10 @@ static bool nfc_device_load_data(NfcDevice* dev, string_t path, bool show_dialog
846846
string_init(temp_str);
847847
bool deprecated_version = false;
848848

849+
if(dev->loading_cb) {
850+
dev->loading_cb(dev->loading_cb_ctx, true);
851+
}
852+
849853
do {
850854
// Check existance of shadow file
851855
nfc_device_get_shadow_path(path, temp_str);
@@ -887,6 +891,10 @@ static bool nfc_device_load_data(NfcDevice* dev, string_t path, bool show_dialog
887891
parsed = true;
888892
} while(false);
889893

894+
if(dev->loading_cb) {
895+
dev->loading_cb(dev->loading_cb_ctx, false);
896+
}
897+
890898
if((!parsed) && (show_dialog)) {
891899
if(deprecated_version) {
892900
dialog_message_show_storage_error(dev->dialogs, "File format deprecated");
@@ -1024,3 +1032,10 @@ bool nfc_device_restore(NfcDevice* dev, bool use_load_path) {
10241032
string_clear(path);
10251033
return restored;
10261034
}
1035+
1036+
void nfc_device_set_loading_callback(NfcDevice* dev, NfcLoadingCallback callback, void* context) {
1037+
furi_assert(dev);
1038+
1039+
dev->loading_cb = callback;
1040+
dev->loading_cb_ctx = context;
1041+
}

0 commit comments

Comments
 (0)