Skip to content

Commit

Permalink
More fixes
Browse files Browse the repository at this point in the history
- Adds the fix from the renaming function to the create function
  • Loading branch information
acegoal07 committed Jun 3, 2024
1 parent 7c93057 commit c65c6e7
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 8 deletions.
2 changes: 1 addition & 1 deletion application.fam
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ App(
fap_category="NFC",
fap_author="@acegoal07",
fap_weburl="https://github.com/acegoal07/FlipperZero_NFC_Playlist/tree/main",
fap_version="2.1",
fap_version="2.2",
fap_icon="assets/icon.png",
fap_private_libs=[
Lib(
Expand Down
2 changes: 1 addition & 1 deletion lib/emulation_worker/nfc_playlist_emulation_worker.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

NfcPlaylistEmulationWorker* nfc_playlist_emulation_worker_alloc() {
NfcPlaylistEmulationWorker* nfc_playlist_emulation_worker = malloc(sizeof(NfcPlaylistEmulationWorker));
nfc_playlist_emulation_worker->thread = furi_thread_alloc_ex("NfcPlaylistEmulationWorker", 8192, nfc_playlist_emulation_worker_task, nfc_playlist_emulation_worker);
nfc_playlist_emulation_worker->thread = furi_thread_alloc_ex("NfcPlaylistEmulationWorker", 4096, nfc_playlist_emulation_worker_task, nfc_playlist_emulation_worker);
nfc_playlist_emulation_worker->state = NfcPlaylistEmulationWorkerState_Stopped;
nfc_playlist_emulation_worker->nfc = nfc_alloc();
nfc_playlist_emulation_worker->nfc_device = nfc_device_alloc();
Expand Down
2 changes: 1 addition & 1 deletion scenes/nfc_playlist_scene_emulation.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ int32_t nfc_playlist_emulation_task(void* context) {

void nfc_playlist_emulation_setup(void* context) {
NfcPlaylist* nfc_playlist = context;
nfc_playlist->thread = furi_thread_alloc_ex("NfcPlaylistEmulationWorker", 8192, nfc_playlist_emulation_task, nfc_playlist);
nfc_playlist->thread = furi_thread_alloc_ex("NfcPlaylistEmulationWorker", 4096, nfc_playlist_emulation_task, nfc_playlist);
nfc_playlist->nfc_playlist_emulation_worker = nfc_playlist_emulation_worker_alloc();
}

Expand Down
24 changes: 21 additions & 3 deletions scenes/nfc_playlist_scene_name_new_playlist.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "../nfc_playlist.h"

void nfc_playlist_name_new_playlist_menu_callback(void* context) {
int32_t nfc_playlist_name_new_playlist_thread_task(void* context) {
NfcPlaylist* nfc_playlist = context;

FuriString* file_name = furi_string_alloc_printf("/ext/apps_data/nfc_playlist/%s.txt", nfc_playlist->text_input_output);
Expand All @@ -20,7 +20,25 @@ void nfc_playlist_name_new_playlist_menu_callback(void* context) {
furi_string_free(file_name);
storage_file_free(file);
furi_record_close(RECORD_STORAGE);
scene_manager_previous_scene(nfc_playlist->scene_manager);

return 0;
}

void nfc_playlist_name_new_playlist_thread_state_callback(FuriThreadState state, void* context) {
NfcPlaylist* nfc_playlist = context;
if(state == FuriThreadStateStopped) {
furi_thread_yield();
nfc_playlist->thread = NULL;
scene_manager_search_and_switch_to_previous_scene(nfc_playlist->scene_manager, NfcPlaylistScene_MainMenu);
}
}

void nfc_playlist_name_new_playlist_menu_callback(void* context) {
NfcPlaylist* nfc_playlist = context;
nfc_playlist->thread = furi_thread_alloc_ex("NfcPlaylistCreator", 1024, nfc_playlist_name_new_playlist_thread_task, nfc_playlist);
furi_thread_set_state_context(nfc_playlist->thread, nfc_playlist);
furi_thread_set_state_callback(nfc_playlist->thread, nfc_playlist_name_new_playlist_thread_state_callback);
furi_thread_start(nfc_playlist->thread);
}

void nfc_playlist_name_new_playlist_scene_on_enter(void* context) {
Expand All @@ -29,7 +47,7 @@ void nfc_playlist_name_new_playlist_scene_on_enter(void* context) {
nfc_playlist->text_input_output = malloc(MAX_PLAYLIST_NAME_LEN + 1);
text_input_set_header_text(nfc_playlist->text_input, "Enter file name");
text_input_set_minimum_length(nfc_playlist->text_input, 1);
text_input_set_result_callback(nfc_playlist->text_input, nfc_playlist_name_new_playlist_menu_callback, nfc_playlist, nfc_playlist->text_input_output, MAX_PLAYLIST_NAME_LEN, false);
text_input_set_result_callback(nfc_playlist->text_input, nfc_playlist_name_new_playlist_menu_callback, nfc_playlist, nfc_playlist->text_input_output, MAX_PLAYLIST_NAME_LEN, true);

view_dispatcher_switch_to_view(nfc_playlist->view_dispatcher, NfcPlaylistView_TextInput);
}
Expand Down
4 changes: 2 additions & 2 deletions scenes/nfc_playlist_scene_playlist_rename.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,16 @@ int32_t nfc_playlist_playlist_rename_thread_task(void* context) {

void nfc_playlist_playlist_rename_thread_state_callback(FuriThreadState state, void* context) {
NfcPlaylist* nfc_playlist = context;
UNUSED(nfc_playlist);
if(state == FuriThreadStateStopped) {
furi_thread_yield();
nfc_playlist->thread = NULL;
scene_manager_search_and_switch_to_previous_scene(nfc_playlist->scene_manager, NfcPlaylistScene_MainMenu);
}
}

void nfc_playlist_playlist_rename_menu_callback(void* context) {
NfcPlaylist* nfc_playlist = context;
nfc_playlist->thread = furi_thread_alloc_ex("NfcPlaylistRenamer", 8192, nfc_playlist_playlist_rename_thread_task, nfc_playlist);
nfc_playlist->thread = furi_thread_alloc_ex("NfcPlaylistRenamer", 1024, nfc_playlist_playlist_rename_thread_task, nfc_playlist);
furi_thread_set_state_context(nfc_playlist->thread, nfc_playlist);
furi_thread_set_state_callback(nfc_playlist->thread, nfc_playlist_playlist_rename_thread_state_callback);
furi_thread_start(nfc_playlist->thread);
Expand Down

0 comments on commit c65c6e7

Please sign in to comment.