Skip to content

Commit 19b7260

Browse files
committed
tweaks
1 parent c65c6e7 commit 19b7260

7 files changed

+24
-23
lines changed

scenes/nfc_playlist_scene_config.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ ADD_SCENE(nfc_playlist, playlist_edit, PlaylistEdit)
44
ADD_SCENE(nfc_playlist, playlist_rename, PlaylistRename)
55
ADD_SCENE(nfc_playlist, main_menu, MainMenu)
66
ADD_SCENE(nfc_playlist, name_new_playlist, NameNewPlaylist)
7-
ADD_SCENE(nfc_playlist, nfc_select, NfcSelect)
7+
ADD_SCENE(nfc_playlist, nfc_add, NfcAdd)
88
ADD_SCENE(nfc_playlist, nfc_remove, NfcRemove)
99
ADD_SCENE(nfc_playlist, playlist_select, PlaylistSelect)
1010
ADD_SCENE(nfc_playlist, settings, Settings)

scenes/nfc_playlist_scene_confirm_delete.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@ void nfc_playlist_confirm_delete_scene_on_enter(void* context) {
1313
FuriString* file_name = furi_string_alloc();
1414
path_extract_filename_no_ext(furi_string_get_cstr(nfc_playlist->settings.playlist_path), file_name);
1515
FuriString* temp_str = furi_string_alloc_printf("\e#Delete %s?\e#", furi_string_get_cstr(file_name));
16+
furi_string_free(file_name);
1617

1718
widget_add_text_box_element(nfc_playlist->widget, 0, 0, 128, 23, AlignCenter, AlignCenter, furi_string_get_cstr(temp_str), false);
1819
widget_add_button_element(nfc_playlist->widget, GuiButtonTypeLeft, "Cancel", nfc_playlist_confirm_delete_menu_callback, nfc_playlist);
1920
widget_add_button_element(nfc_playlist->widget, GuiButtonTypeRight, "Delete", nfc_playlist_confirm_delete_menu_callback, nfc_playlist);
2021

2122
furi_string_free(temp_str);
22-
furi_string_free(file_name);
2323

2424
view_dispatcher_switch_to_view(nfc_playlist->view_dispatcher, NfcPlaylistView_Widget);
2525
}

scenes/nfc_playlist_scene_emulation.c

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ int32_t nfc_playlist_emulation_task(void* context) {
2020

2121
view_dispatcher_switch_to_view(nfc_playlist->view_dispatcher, NfcPlaylistView_Popup);
2222

23-
if (file_stream_open(stream, furi_string_get_cstr(nfc_playlist->settings.playlist_path), FSAM_READ, FSOM_OPEN_EXISTING)) {
23+
if (nfc_playlist->settings.playlist_length == 0) {
24+
popup_set_header(nfc_playlist->popup, "The playlist you have\nselected is empty", 64, 10, AlignCenter, AlignTop);
25+
} else if (file_stream_open(stream, furi_string_get_cstr(nfc_playlist->settings.playlist_path), FSAM_READ, FSOM_OPEN_EXISTING)) {
2426
EmulationState = NfcPlaylistEmulationState_Emulating;
2527
int file_position = 0;
2628

@@ -105,30 +107,27 @@ int32_t nfc_playlist_emulation_task(void* context) {
105107
nfc_playlist_emulation_worker_clear_nfc_data(nfc_playlist->nfc_playlist_emulation_worker);
106108
}
107109
}
108-
popup_reset(nfc_playlist->popup);
109-
if (nfc_playlist->settings.playlist_length == 0) {
110-
popup_set_header(nfc_playlist->popup, "Empty playlist", 64, 10, AlignCenter, AlignTop);
111-
} else {
112-
popup_set_header(nfc_playlist->popup, EmulationState == NfcPlaylistEmulationState_Canceled ? "Emulation stopped" : "Emulation finished", 64, 10, AlignCenter, AlignTop);
113-
}
114-
popup_set_text(nfc_playlist->popup, "Press back", 64, 50, AlignCenter, AlignTop);
115110
stop_blink(nfc_playlist);
116111

117-
EmulationState = NfcPlaylistEmulationState_Stopped;
118112
furi_string_free(line);
119113
furi_string_free(tmp_header_str);
120114
furi_string_free(tmp_counter_str);
121115
furi_string_free(tmp_file_name);
122116
furi_string_free(tmp_file_ext);
117+
file_stream_close(stream);
118+
119+
popup_reset(nfc_playlist->popup);
120+
popup_set_header(nfc_playlist->popup, EmulationState == NfcPlaylistEmulationState_Canceled ? "Emulation stopped" : "Emulation finished", 64, 10, AlignCenter, AlignTop);
123121
} else {
124122
popup_set_header(nfc_playlist->popup, "Failed to open playlist", 64, 10, AlignCenter, AlignTop);
125-
popup_set_text(nfc_playlist->popup, "Press back", 64, 50, AlignCenter, AlignTop);
126123
}
124+
popup_set_text(nfc_playlist->popup, "Press back", 64, 50, AlignCenter, AlignTop);
127125

128-
file_stream_close(stream);
129126
furi_record_close(RECORD_STORAGE);
130127
stream_free(stream);
131128

129+
EmulationState = NfcPlaylistEmulationState_Stopped;
130+
132131
return 0;
133132
}
134133

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#include "../nfc_playlist.h"
22

3-
void nfc_playlist_nfc_select_menu_callback(void* context) {
3+
void nfc_playlist_nfc_add_menu_callback(void* context) {
44
NfcPlaylist* nfc_playlist = context;
55

66
Storage* storage = furi_record_open(RECORD_STORAGE);
@@ -12,6 +12,7 @@ void nfc_playlist_nfc_select_menu_callback(void* context) {
1212
while(stream_read_line(stream, line)) {
1313
furi_string_cat_printf(tmp_str, "%s", furi_string_get_cstr(line));
1414
}
15+
furi_string_free(line);
1516

1617
if (!furi_string_empty(tmp_str)) {
1718
furi_string_cat_printf(tmp_str, "\n%s", furi_string_get_cstr(nfc_playlist->file_browser_output));
@@ -20,7 +21,6 @@ void nfc_playlist_nfc_select_menu_callback(void* context) {
2021
}
2122

2223
stream_clean(stream);
23-
furi_string_free(line);
2424
stream_write_string(stream, tmp_str);
2525
file_stream_close(stream);
2626
furi_string_free(tmp_str);
@@ -34,7 +34,7 @@ void nfc_playlist_nfc_select_menu_callback(void* context) {
3434
scene_manager_previous_scene(nfc_playlist->scene_manager);
3535
}
3636

37-
void nfc_playlist_nfc_select_scene_on_enter(void* context) {
37+
void nfc_playlist_nfc_add_scene_on_enter(void* context) {
3838
NfcPlaylist* nfc_playlist = context;
3939
file_browser_configure(
4040
nfc_playlist->file_browser,
@@ -44,21 +44,21 @@ void nfc_playlist_nfc_select_scene_on_enter(void* context) {
4444
true,
4545
&I_Nfc_10px,
4646
true);
47-
file_browser_set_callback(nfc_playlist->file_browser, nfc_playlist_nfc_select_menu_callback, nfc_playlist);
47+
file_browser_set_callback(nfc_playlist->file_browser, nfc_playlist_nfc_add_menu_callback, nfc_playlist);
4848
FuriString* tmp_str = furi_string_alloc_set_str("/ext/nfc/");
4949
file_browser_start(nfc_playlist->file_browser, tmp_str);
5050
furi_string_free(tmp_str);
5151

5252
view_dispatcher_switch_to_view(nfc_playlist->view_dispatcher, NfcPlaylistView_FileBrowser);
5353
}
5454

55-
bool nfc_playlist_nfc_select_scene_on_event(void* context, SceneManagerEvent event) {
55+
bool nfc_playlist_nfc_add_scene_on_event(void* context, SceneManagerEvent event) {
5656
UNUSED(event);
5757
UNUSED(context);
5858
return false;
5959
}
6060

61-
void nfc_playlist_nfc_select_scene_on_exit(void* context) {
61+
void nfc_playlist_nfc_add_scene_on_exit(void* context) {
6262
NfcPlaylist* nfc_playlist = context;
6363
file_browser_stop(nfc_playlist->file_browser);
6464
}

scenes/nfc_playlist_scene_nfc_remove.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,8 @@ bool nfc_playlist_nfc_remove_scene_on_event(void* context, SceneManagerEvent eve
8585
}
8686
}
8787

88-
stream_clean(stream);
8988
furi_string_free(line);
89+
stream_clean(stream);
9090
stream_write_string(stream, tmp_str);
9191
furi_string_free(tmp_str);
9292
file_stream_close(stream);

scenes/nfc_playlist_scene_playlist_edit.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ bool nfc_playlist_playlist_edit_scene_on_event(void* context, SceneManagerEvent
9494
consumed = true;
9595
break;
9696
case NfcPlaylistMenuSelection_AddNfcItem:
97-
scene_manager_next_scene(nfc_playlist->scene_manager, NfcPlaylistScene_NfcSelect);
97+
scene_manager_next_scene(nfc_playlist->scene_manager, NfcPlaylistScene_NfcAdd);
9898
consumed = true;
9999
break;
100100
case NfcPlaylistMenuSelection_RemoveNfcItem:

scenes/nfc_playlist_scene_settings.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ void nfc_playlist_settings_scene_on_enter(void* context) {
7373
furi_string_printf(tmp_str, "%ds", options_emulate_delay[nfc_playlist->settings.emulate_delay]);
7474
variable_item_set_current_value_text(emulation_delay_setting, furi_string_get_cstr(tmp_str));
7575

76+
furi_string_free(tmp_str);
77+
7678
VariableItem* emulation_led_indicator_setting = variable_item_list_add(
7779
nfc_playlist->variable_item_list,
7880
"LED Indicator",
@@ -97,7 +99,6 @@ void nfc_playlist_settings_scene_on_enter(void* context) {
9799
variable_item_set_current_value_text(credits, "Credits");
98100

99101
variable_item_list_set_enter_callback(nfc_playlist->variable_item_list, nfc_playlist_settings_menu_callback, nfc_playlist);
100-
furi_string_free(tmp_str);
101102

102103
view_dispatcher_switch_to_view(nfc_playlist->view_dispatcher, NfcPlaylistView_VariableItemList);
103104
}
@@ -121,6 +122,8 @@ bool nfc_playlist_settings_scene_on_event(void* context, SceneManagerEvent event
121122
variable_item_set_current_value_index(emulation_delay_setting, nfc_playlist->settings.emulate_delay);
122123
furi_string_printf(tmp_str, "%ds", options_emulate_delay[nfc_playlist->settings.emulate_delay]);
123124
variable_item_set_current_value_text(emulation_delay_setting, furi_string_get_cstr(tmp_str));
125+
126+
furi_string_free(tmp_str);
124127

125128
nfc_playlist->settings.emulate_led_indicator = default_emulate_led_indicator;
126129
VariableItem* emulation_led_indicator_setting = variable_item_list_get(nfc_playlist->variable_item_list, NfcPlaylistSettings_LedIndicator);
@@ -132,7 +135,6 @@ bool nfc_playlist_settings_scene_on_event(void* context, SceneManagerEvent event
132135
variable_item_set_current_value_index(emulation_skip_error_setting, nfc_playlist->settings.skip_error);
133136
variable_item_set_current_value_text(emulation_skip_error_setting, nfc_playlist->settings.skip_error ? "ON" : "OFF");
134137

135-
furi_string_free(tmp_str);
136138
consumed = true;
137139
break;
138140
default:

0 commit comments

Comments
 (0)