From 733cee4578159870b08abeb146fe5b71b66dc260 Mon Sep 17 00:00:00 2001 From: acegoal07 <39467245+acegoal07@users.noreply.github.com> Date: Sun, 11 Aug 2024 18:21:03 +0100 Subject: [PATCH 01/11] Update README.md --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 58fcc2a..4593025 100644 --- a/README.md +++ b/README.md @@ -28,5 +28,7 @@ As i know these firmwares are supported and working if you know any more please - Add NFC Item (Adds the selected nfc item to the currently selected playlist) - Remove NFC Item (Opens a menu allowing you to select a line to remove from the playlist) - View playlist content (Allows you to view the contents of the playlist) - +## Feature ideas: +- A function to allow you to add multiple nfc items to a playlist at once +- A view playlist function which only shows the name of the playlist items excluding the file path Any feedback is welcome and would be very much appreciated From f985b97d98be227483fb873f72f521f97ba9b718 Mon Sep 17 00:00:00 2001 From: acegoal07 <39467245+acegoal07@users.noreply.github.com> Date: Sun, 11 Aug 2024 18:21:23 +0100 Subject: [PATCH 02/11] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 4593025..0c1b61c 100644 --- a/README.md +++ b/README.md @@ -31,4 +31,5 @@ As i know these firmwares are supported and working if you know any more please ## Feature ideas: - A function to allow you to add multiple nfc items to a playlist at once - A view playlist function which only shows the name of the playlist items excluding the file path + Any feedback is welcome and would be very much appreciated From 27d8ffb39521b61705aa01ed789387dd27b66449 Mon Sep 17 00:00:00 2001 From: acegoal07 <39467245+acegoal07@users.noreply.github.com> Date: Sat, 17 Aug 2024 17:29:27 +0100 Subject: [PATCH 03/11] Maintainability --- nfc_playlist.h | 1 + scenes/nfc_playlist_scene_confirm_delete.c | 5 ++++- scenes/nfc_playlist_scene_name_new_playlist.c | 2 +- scenes/nfc_playlist_scene_nfc_add.c | 4 ++-- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/nfc_playlist.h b/nfc_playlist.h index 41de068..6dfac4d 100644 --- a/nfc_playlist.h +++ b/nfc_playlist.h @@ -31,6 +31,7 @@ #define PLAYLIST_LOCATION "/ext/apps_data/nfc_playlist/" #define PLAYLIST_DIR "/ext/apps_data/nfc_playlist" +#define NFC_ITEM_LOCATION "/ext/nfc/" #define MAX_PLAYLIST_NAME_LEN 50 typedef enum { diff --git a/scenes/nfc_playlist_scene_confirm_delete.c b/scenes/nfc_playlist_scene_confirm_delete.c index 82dad02..7f5e4aa 100644 --- a/scenes/nfc_playlist_scene_confirm_delete.c +++ b/scenes/nfc_playlist_scene_confirm_delete.c @@ -39,8 +39,11 @@ bool nfc_playlist_confirm_delete_scene_on_event(void* context, SceneManagerEvent scene_manager_search_and_switch_to_previous_scene(nfc_playlist->scene_manager, NfcPlaylistScene_MainMenu); consumed = true; break; - default: + case GuiButtonTypeLeft: scene_manager_previous_scene(nfc_playlist->scene_manager); + consumed = true; + break; + default: break; } } diff --git a/scenes/nfc_playlist_scene_name_new_playlist.c b/scenes/nfc_playlist_scene_name_new_playlist.c index e555e54..0d72592 100644 --- a/scenes/nfc_playlist_scene_name_new_playlist.c +++ b/scenes/nfc_playlist_scene_name_new_playlist.c @@ -3,7 +3,7 @@ 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); + FuriString* file_name = furi_string_alloc_printf("%s%s.txt", PLAYLIST_LOCATION, nfc_playlist->text_input_output); char const* file_name_cstr = furi_string_get_cstr(file_name); Storage* storage = furi_record_open(RECORD_STORAGE); diff --git a/scenes/nfc_playlist_scene_nfc_add.c b/scenes/nfc_playlist_scene_nfc_add.c index 5e2b7f1..990da8a 100644 --- a/scenes/nfc_playlist_scene_nfc_add.c +++ b/scenes/nfc_playlist_scene_nfc_add.c @@ -39,13 +39,13 @@ void nfc_playlist_nfc_add_scene_on_enter(void* context) { file_browser_configure( nfc_playlist->file_browser, ".nfc", - "/ext/nfc/", + NFC_ITEM_LOCATION, true, true, &I_Nfc_10px, true); file_browser_set_callback(nfc_playlist->file_browser, nfc_playlist_nfc_add_menu_callback, nfc_playlist); - FuriString* tmp_str = furi_string_alloc_set_str("/ext/nfc/"); + FuriString* tmp_str = furi_string_alloc_set_str(NFC_ITEM_LOCATION); file_browser_start(nfc_playlist->file_browser, tmp_str); furi_string_free(tmp_str); From 0867c8b80a3bab54abfbdb68b671f3fdc66027db Mon Sep 17 00:00:00 2001 From: acegoal07 <39467245+acegoal07@users.noreply.github.com> Date: Sat, 17 Aug 2024 18:35:04 +0100 Subject: [PATCH 04/11] Updates issues --- .github/ISSUE_TEMPLATE/bug_report.md | 8 ++++---- .github/ISSUE_TEMPLATE/feature_request.md | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index 81eb1a3..466fc0d 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -10,11 +10,11 @@ assignees: acegoal07 **Describe the bug** A clear and concise description of what the bug is. -**Screenshots** -If applicable, add screenshots to help explain your problem. +**Copy of your playlist** +[Copy and paste the content of your playlist.txt file this is useful to help find any issues caused by the reading of the playlist] -**Desktop (please complete the following information):** - - Firmware [e.g. Xtreme] +**Fap information:** + - Firmware [e.g. Momentum] - Version [e.g. 1.1] **Additional context** diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md index be9709b..d967308 100644 --- a/.github/ISSUE_TEMPLATE/feature_request.md +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -8,4 +8,4 @@ assignees: acegoal07 --- **Describe the feature** -A indepth description of what you want +A in depth description of what you want From 60f8961f86f91e228b768f276377bc5e34a7d8cc Mon Sep 17 00:00:00 2001 From: acegoal07 <39467245+acegoal07@users.noreply.github.com> Date: Mon, 19 Aug 2024 17:53:19 +0100 Subject: [PATCH 05/11] Behaviour + Move nfc items - Changes how the app acts at certain points - Also starts adding move functionality --- nfc_playlist.c | 1 - nfc_playlist.h | 1 - scenes/nfc_playlist_scene_config.h | 4 +- scenes/nfc_playlist_scene_confirm_delete.c | 1 - scenes/nfc_playlist_scene_main_menu.c | 5 - scenes/nfc_playlist_scene_nfc_move_item | 159 +++++++++++++++++++++ scenes/nfc_playlist_scene_nfc_remove.c | 28 ++-- scenes/nfc_playlist_scene_playlist_edit.c | 36 ++--- 8 files changed, 193 insertions(+), 42 deletions(-) create mode 100644 scenes/nfc_playlist_scene_nfc_move_item diff --git a/nfc_playlist.c b/nfc_playlist.c index 6980bfb..1a6bdac 100644 --- a/nfc_playlist.c +++ b/nfc_playlist.c @@ -24,7 +24,6 @@ static NfcPlaylist* nfc_playlist_alloc() { nfc_playlist->settings.playlist_path = furi_string_alloc(); nfc_playlist->file_browser_output = furi_string_alloc(); - nfc_playlist->settings.playlist_selected = false; nfc_playlist->settings.emulate_timeout = default_emulate_timeout; nfc_playlist->settings.emulate_delay = default_emulate_delay; nfc_playlist->settings.emulate_led_indicator = default_emulate_led_indicator; diff --git a/nfc_playlist.h b/nfc_playlist.h index 6dfac4d..31c0401 100644 --- a/nfc_playlist.h +++ b/nfc_playlist.h @@ -46,7 +46,6 @@ typedef enum { typedef struct { FuriString* playlist_path; uint8_t playlist_length; - bool playlist_selected; uint8_t emulate_timeout; uint8_t emulate_delay; bool emulate_led_indicator; diff --git a/scenes/nfc_playlist_scene_config.h b/scenes/nfc_playlist_scene_config.h index 043dc64..b0c4c1c 100644 --- a/scenes/nfc_playlist_scene_config.h +++ b/scenes/nfc_playlist_scene_config.h @@ -1,11 +1,11 @@ ADD_SCENE(nfc_playlist, confirm_delete, ConfirmDelete) ADD_SCENE(nfc_playlist, emulation, Emulation) -ADD_SCENE(nfc_playlist, playlist_edit, PlaylistEdit) -ADD_SCENE(nfc_playlist, playlist_rename, PlaylistRename) ADD_SCENE(nfc_playlist, main_menu, MainMenu) ADD_SCENE(nfc_playlist, name_new_playlist, NameNewPlaylist) ADD_SCENE(nfc_playlist, nfc_add, NfcAdd) ADD_SCENE(nfc_playlist, nfc_remove, NfcRemove) +ADD_SCENE(nfc_playlist, playlist_edit, PlaylistEdit) +ADD_SCENE(nfc_playlist, playlist_rename, PlaylistRename) ADD_SCENE(nfc_playlist, playlist_select, PlaylistSelect) ADD_SCENE(nfc_playlist, settings, Settings) ADD_SCENE(nfc_playlist, view_playlist_content, ViewPlaylistContent) \ No newline at end of file diff --git a/scenes/nfc_playlist_scene_confirm_delete.c b/scenes/nfc_playlist_scene_confirm_delete.c index 7f5e4aa..2917214 100644 --- a/scenes/nfc_playlist_scene_confirm_delete.c +++ b/scenes/nfc_playlist_scene_confirm_delete.c @@ -32,7 +32,6 @@ bool nfc_playlist_confirm_delete_scene_on_event(void* context, SceneManagerEvent case GuiButtonTypeRight: Storage* storage = furi_record_open(RECORD_STORAGE); if (storage_simply_remove(storage, furi_string_get_cstr(nfc_playlist->settings.playlist_path))) { - nfc_playlist->settings.playlist_selected = false; furi_string_reset(nfc_playlist->settings.playlist_path); } furi_record_close(RECORD_STORAGE); diff --git a/scenes/nfc_playlist_scene_main_menu.c b/scenes/nfc_playlist_scene_main_menu.c index 3843822..010ae79 100644 --- a/scenes/nfc_playlist_scene_main_menu.c +++ b/scenes/nfc_playlist_scene_main_menu.c @@ -14,11 +14,6 @@ void nfc_playlist_main_menu_menu_callback(void* context, uint32_t index) { void nfc_playlist_main_menu_scene_on_enter(void* context) { NfcPlaylist* nfc_playlist = context; - if (!nfc_playlist->settings.playlist_selected) { - nfc_playlist->settings.playlist_selected = true; - scene_manager_next_scene(nfc_playlist->scene_manager, NfcPlaylistScene_PlaylistSelect); - return; - } FuriString* header = furi_string_alloc_printf("NFC Playlist v%s", FAP_VERSION); submenu_set_header(nfc_playlist->submenu, furi_string_get_cstr(header)); diff --git a/scenes/nfc_playlist_scene_nfc_move_item b/scenes/nfc_playlist_scene_nfc_move_item new file mode 100644 index 0000000..c30d247 --- /dev/null +++ b/scenes/nfc_playlist_scene_nfc_move_item @@ -0,0 +1,159 @@ +// This is currently not working so its not included at the moment + + +#include "../nfc_playlist.h" + +typedef enum { + NfcPlaylistNfcMoveItem_TargetSelector, + NfcPlaylistNfcMoveItem_DestinationSelector, + NfcPlaylistNfcMoveItem_MoveItem +} NfcPlaylistNfcMoveItemMenuSelection; + +uint8_t selected_target; +uint8_t selected_destination; + +void nfc_playlist_nfc_move_item_menu_callback(void* context, uint32_t index) { + NfcPlaylist* nfc_playlist = context; + scene_manager_handle_custom_event(nfc_playlist->scene_manager, index); +} + +void nfc_playlist_nfc_move_item_options_change_callback(VariableItem* item) { + NfcPlaylist* nfc_playlist = variable_item_get_context(item); + + uint8_t current_option = variable_item_list_get_selected_item_index(nfc_playlist->variable_item_list); + uint8_t option_value_index = variable_item_get_current_value_index(item); + + switch(current_option) { + case NfcPlaylistNfcMoveItem_TargetSelector: { + selected_target = option_value_index + 1; + FuriString* tmp_str = furi_string_alloc_printf("%d", selected_target); + variable_item_set_current_value_text(item, furi_string_get_cstr(tmp_str)); + furi_string_free(tmp_str); + break; + } + case NfcPlaylistNfcMoveItem_DestinationSelector: { + selected_destination = option_value_index + 1; + FuriString* tmp_str = furi_string_alloc_printf("%d", selected_destination); + variable_item_set_current_value_text(item, furi_string_get_cstr(tmp_str)); + furi_string_free(tmp_str); + break; + } + default: + break; + } + + variable_item_set_locked(variable_item_list_get(nfc_playlist->variable_item_list, NfcPlaylistNfcMoveItem_MoveItem), (selected_target == selected_destination), "Target\nand\nDestination\nare the same"); +} + +void nfc_playlist_nfc_move_item_scene_on_enter(void* context) { + NfcPlaylist* nfc_playlist = context; + + selected_target = 0; + selected_destination = 0; + + variable_item_list_set_header(nfc_playlist->variable_item_list, "Move NFC Item"); + + VariableItem* target_selector = variable_item_list_add( + nfc_playlist->variable_item_list, + "Select Target", + nfc_playlist->settings.playlist_length, + nfc_playlist_nfc_move_item_options_change_callback, + nfc_playlist); + + variable_item_set_current_value_index(target_selector, 0); + variable_item_set_current_value_text(target_selector, "1"); + + VariableItem* destination_selector = variable_item_list_add( + nfc_playlist->variable_item_list, + "Select Destination", + nfc_playlist->settings.playlist_length, + nfc_playlist_nfc_move_item_options_change_callback, + nfc_playlist); + + variable_item_set_current_value_index(destination_selector, 0); + variable_item_set_current_value_text(destination_selector, "1"); + + VariableItem* move_button = variable_item_list_add(nfc_playlist->variable_item_list, "Move Item", 0, NULL, NULL); + variable_item_set_locked(move_button, (selected_target == selected_destination), "Target\nand\nDestination\nare the same"); + + variable_item_list_set_enter_callback(nfc_playlist->variable_item_list, nfc_playlist_nfc_move_item_menu_callback, nfc_playlist); + + view_dispatcher_switch_to_view(nfc_playlist->view_dispatcher, NfcPlaylistView_VariableItemList); +} + +bool nfc_playlist_nfc_move_item_scene_on_event(void* context, SceneManagerEvent event) { + NfcPlaylist* nfc_playlist = context; + UNUSED(nfc_playlist); + + bool consumed = false; + + if(event.type == SceneManagerEventTypeCustom) { + switch(event.event) { + case NfcPlaylistNfcMoveItem_MoveItem: { + Storage* storage = furi_record_open(RECORD_STORAGE); + Stream* stream = file_stream_alloc(storage); + + if(file_stream_open(stream, furi_string_get_cstr(nfc_playlist->settings.playlist_path), FSAM_READ_WRITE, FSOM_OPEN_EXISTING)) { + int counter = 0; + FuriString* tmp_target_line = furi_string_alloc(); + FuriString* line = furi_string_alloc(); + + while(stream_read_line(stream, line)) { + counter++; + if (counter == selected_target) { + furi_string_set(tmp_target_line, line); + } + } + furi_string_reset(line); + stream_rewind(stream); + + counter = 0; + FuriString* tmp_new_playlist_order = furi_string_alloc(); + + while(stream_read_line(stream, line)) { + counter++; + + if(counter == selected_target) { + continue; + } + + furi_string_trim(line); + + if(!furi_string_empty(tmp_new_playlist_order)) { + furi_string_cat_printf(tmp_new_playlist_order, "\n"); + } + if(counter == selected_destination) { + furi_string_cat_printf(tmp_new_playlist_order, "%s\n%s", furi_string_get_cstr(tmp_target_line), furi_string_get_cstr(line)); + } else { + furi_string_cat_printf(tmp_new_playlist_order, "%s", furi_string_get_cstr(line)); + } + } + + FURI_LOG_RAW_I("New playlist order: %s\n", furi_string_get_cstr(tmp_new_playlist_order)); + + stream_clean(stream); + stream_write_string(stream, tmp_new_playlist_order); + file_stream_close(stream); + furi_string_free(tmp_new_playlist_order); + furi_string_free(tmp_target_line); + furi_string_free(line); + } + + stream_free(stream); + furi_record_close(RECORD_STORAGE); + + consumed = true; + break; + } + default: + break; + } + } + + return consumed; +} + +void nfc_playlist_nfc_move_item_scene_on_exit(void* context) { + NfcPlaylist* nfc_playlist = context; + variable_item_list_reset(nfc_playlist->variable_item_list); +} \ No newline at end of file diff --git a/scenes/nfc_playlist_scene_nfc_remove.c b/scenes/nfc_playlist_scene_nfc_remove.c index 0811086..7e215a1 100644 --- a/scenes/nfc_playlist_scene_nfc_remove.c +++ b/scenes/nfc_playlist_scene_nfc_remove.c @@ -1,9 +1,9 @@ #include "../nfc_playlist.h" typedef enum { - NfcPlaylistSettings_LineSelector, - NfcPlaylistSettings_RemoveLine -} NfcPlaylistSettingsMenuSelection; + NfcPlaylistNfcRemove_LineSelector, + NfcPlaylistNfcRemove_RemoveLine +} NfcPlaylistNfcRemoveMenuSelection; uint8_t selected_line; @@ -19,7 +19,7 @@ void nfc_playlist_nfc_remove_options_change_callback(VariableItem* item) { uint8_t option_value_index = variable_item_get_current_value_index(item); switch(current_option) { - case NfcPlaylistSettings_LineSelector: { + case NfcPlaylistNfcRemove_LineSelector: { selected_line = option_value_index + 1; FuriString* tmp_str = furi_string_alloc_printf("%d", selected_line); variable_item_set_current_value_text(item, furi_string_get_cstr(tmp_str)); @@ -36,24 +36,24 @@ void nfc_playlist_nfc_remove_scene_on_enter(void* context) { selected_line = nfc_playlist->settings.playlist_length; - variable_item_list_set_header(nfc_playlist->variable_item_list, "Settings"); + variable_item_list_set_header(nfc_playlist->variable_item_list, "Remove Nfc Item"); - VariableItem* Line_selector = variable_item_list_add( + VariableItem* line_selector = variable_item_list_add( nfc_playlist->variable_item_list, "Select Line", nfc_playlist->settings.playlist_length, nfc_playlist_nfc_remove_options_change_callback, nfc_playlist); - variable_item_set_current_value_index(Line_selector, nfc_playlist->settings.playlist_length - 1); + variable_item_set_current_value_index(line_selector, nfc_playlist->settings.playlist_length - 1); FuriString* tmp_str = furi_string_alloc_printf("%d", selected_line); - variable_item_set_current_value_text(Line_selector, furi_string_get_cstr(tmp_str)); + variable_item_set_current_value_text(line_selector, furi_string_get_cstr(tmp_str)); furi_string_free(tmp_str); - variable_item_set_locked(Line_selector, nfc_playlist->settings.playlist_length == 0 ? true : false, "Playlist\nis empty"); + variable_item_set_locked(line_selector, nfc_playlist->settings.playlist_length == 0 ? true : false, "Playlist\nis empty"); - variable_item_list_add(nfc_playlist->variable_item_list, "Remove Line", 0, NULL, NULL); - variable_item_set_locked(variable_item_list_get(nfc_playlist->variable_item_list, NfcPlaylistSettings_RemoveLine), nfc_playlist->settings.playlist_length == 0 ? true : false, "Playlist\nis empty"); + VariableItem* remove_button = variable_item_list_add(nfc_playlist->variable_item_list, "Remove Line", 0, NULL, NULL); + variable_item_set_locked(remove_button, nfc_playlist->settings.playlist_length == 0 ? true : false, "Playlist\nis empty"); variable_item_list_set_enter_callback(nfc_playlist->variable_item_list, nfc_playlist_nfc_remove_menu_callback, nfc_playlist); @@ -65,7 +65,7 @@ bool nfc_playlist_nfc_remove_scene_on_event(void* context, SceneManagerEvent eve bool consumed = false; if (event.type == SceneManagerEventTypeCustom) { switch(event.event) { - case NfcPlaylistSettings_RemoveLine: + case NfcPlaylistNfcRemove_RemoveLine: Storage* storage = furi_record_open(RECORD_STORAGE); Stream* stream = file_stream_alloc(storage); @@ -76,7 +76,7 @@ bool nfc_playlist_nfc_remove_scene_on_event(void* context, SceneManagerEvent eve while(stream_read_line(stream, line)) { current_line++; if (current_line != selected_line) { - furi_string_replace_all(line, "\n", ""); + furi_string_trim(line); if (furi_string_empty(tmp_str)) { furi_string_cat_printf(tmp_str, "%s", furi_string_get_cstr(line)); } else { @@ -99,7 +99,7 @@ bool nfc_playlist_nfc_remove_scene_on_event(void* context, SceneManagerEvent eve if (selected_line == 0) { scene_manager_previous_scene(nfc_playlist->scene_manager); } else { - VariableItem* Line_selector = variable_item_list_get(nfc_playlist->variable_item_list, NfcPlaylistSettings_LineSelector); + VariableItem* Line_selector = variable_item_list_get(nfc_playlist->variable_item_list, NfcPlaylistNfcRemove_LineSelector); variable_item_set_values_count(Line_selector, nfc_playlist->settings.playlist_length); variable_item_set_current_value_index(Line_selector, selected_line - 1); diff --git a/scenes/nfc_playlist_scene_playlist_edit.c b/scenes/nfc_playlist_scene_playlist_edit.c index 0c8dbf4..e7e5593 100644 --- a/scenes/nfc_playlist_scene_playlist_edit.c +++ b/scenes/nfc_playlist_scene_playlist_edit.c @@ -1,12 +1,12 @@ #include "../nfc_playlist.h" typedef enum { - NfcPlaylistMenuSelection_CreatePlaylist, - NfcPlaylistMenuSelection_DeletePlaylist, - NfcPlaylistMenuSelection_RenamePlaylist, - NfcPlaylistMenuSelection_AddNfcItem, - NfcPlaylistMenuSelection_RemoveNfcItem, - NfcPlaylistMenuSelection_ViewPlaylistContent + NfcPlaylistFileEdit_CreatePlaylist, + NfcPlaylistFileEdit_DeletePlaylist, + NfcPlaylistFileEdit_RenamePlaylist, + NfcPlaylistFileEdit_AddNfcItem, + NfcPlaylistFileEdit_RemoveNfcItem, + NfcPlaylistFileEdit_ViewPlaylistContent } NfcPlaylistFileEditMenuSelection; void nfc_playlist_playlist_edit_menu_callback(void* context, uint32_t index) { @@ -24,14 +24,14 @@ void nfc_playlist_playlist_edit_scene_on_enter(void* context) { submenu_add_item( nfc_playlist->submenu, "Create Playlist", - NfcPlaylistMenuSelection_CreatePlaylist, + NfcPlaylistFileEdit_CreatePlaylist, nfc_playlist_playlist_edit_menu_callback, nfc_playlist); submenu_add_lockable_item( nfc_playlist->submenu, "Delete Playlist", - NfcPlaylistMenuSelection_DeletePlaylist, + NfcPlaylistFileEdit_DeletePlaylist, nfc_playlist_playlist_edit_menu_callback, nfc_playlist, playlist_path_empty, @@ -40,7 +40,7 @@ void nfc_playlist_playlist_edit_scene_on_enter(void* context) { submenu_add_lockable_item( nfc_playlist->submenu, "Rename Playlist", - NfcPlaylistMenuSelection_RenamePlaylist, + NfcPlaylistFileEdit_RenamePlaylist, nfc_playlist_playlist_edit_menu_callback, nfc_playlist, playlist_path_empty, @@ -49,7 +49,7 @@ void nfc_playlist_playlist_edit_scene_on_enter(void* context) { submenu_add_lockable_item( nfc_playlist->submenu, "Add NFC Item", - NfcPlaylistMenuSelection_AddNfcItem, + NfcPlaylistFileEdit_AddNfcItem, nfc_playlist_playlist_edit_menu_callback, nfc_playlist, playlist_path_empty, @@ -58,7 +58,7 @@ void nfc_playlist_playlist_edit_scene_on_enter(void* context) { submenu_add_lockable_item( nfc_playlist->submenu, "Remove NFC Item", - NfcPlaylistMenuSelection_RemoveNfcItem, + NfcPlaylistFileEdit_RemoveNfcItem, nfc_playlist_playlist_edit_menu_callback, nfc_playlist, playlist_path_empty, @@ -67,7 +67,7 @@ void nfc_playlist_playlist_edit_scene_on_enter(void* context) { submenu_add_lockable_item( nfc_playlist->submenu, "View Playlist Content", - NfcPlaylistMenuSelection_ViewPlaylistContent, + NfcPlaylistFileEdit_ViewPlaylistContent, nfc_playlist_playlist_edit_menu_callback, nfc_playlist, playlist_path_empty, @@ -81,27 +81,27 @@ bool nfc_playlist_playlist_edit_scene_on_event(void* context, SceneManagerEvent bool consumed = false; if(event.type == SceneManagerEventTypeCustom) { switch(event.event) { - case NfcPlaylistMenuSelection_CreatePlaylist: + case NfcPlaylistFileEdit_CreatePlaylist: scene_manager_next_scene(nfc_playlist->scene_manager, NfcPlaylistScene_NameNewPlaylist); consumed = true; break; - case NfcPlaylistMenuSelection_DeletePlaylist: + case NfcPlaylistFileEdit_DeletePlaylist: scene_manager_next_scene(nfc_playlist->scene_manager, NfcPlaylistScene_ConfirmDelete); consumed = true; break; - case NfcPlaylistMenuSelection_RenamePlaylist: + case NfcPlaylistFileEdit_RenamePlaylist: scene_manager_next_scene(nfc_playlist->scene_manager, NfcPlaylistScene_PlaylistRename); consumed = true; break; - case NfcPlaylistMenuSelection_AddNfcItem: + case NfcPlaylistFileEdit_AddNfcItem: scene_manager_next_scene(nfc_playlist->scene_manager, NfcPlaylistScene_NfcAdd); consumed = true; break; - case NfcPlaylistMenuSelection_RemoveNfcItem: + case NfcPlaylistFileEdit_RemoveNfcItem: scene_manager_next_scene(nfc_playlist->scene_manager, NfcPlaylistScene_NfcRemove); consumed = true; break; - case NfcPlaylistMenuSelection_ViewPlaylistContent: + case NfcPlaylistFileEdit_ViewPlaylistContent: scene_manager_next_scene(nfc_playlist->scene_manager, NfcPlaylistScene_ViewPlaylistContent); consumed = true; break; From 18bd2456971bf77c67665220ead8958b24676e73 Mon Sep 17 00:00:00 2001 From: acegoal07 <39467245+acegoal07@users.noreply.github.com> Date: Tue, 20 Aug 2024 14:07:02 +0100 Subject: [PATCH 06/11] Implements move feature in editor - This adds the ability to rearrange the playlist from within the app - Updates the readme to show new feature - Bumps the app version --- README.md | 1 + application.fam | 2 +- scenes/nfc_playlist_scene_config.h | 1 + ...tem => nfc_playlist_scene_nfc_move_item.c} | 54 +++++++++---------- scenes/nfc_playlist_scene_playlist_edit.c | 14 +++++ 5 files changed, 42 insertions(+), 30 deletions(-) rename scenes/{nfc_playlist_scene_nfc_move_item => nfc_playlist_scene_nfc_move_item.c} (76%) diff --git a/README.md b/README.md index 307a707..4e2c14f 100644 --- a/README.md +++ b/README.md @@ -27,6 +27,7 @@ As i know these firmwares are supported and working if you know any more please - Rename playlist (Renames the selected playlist to the new name provided) - Add NFC Item (Adds the selected nfc item to the currently selected playlist) - Remove NFC Item (Opens a menu allowing you to select a line to remove from the playlist) +- Move NFC Item (Allows you to change the order of the NFC items in the playlist) - View playlist content (Allows you to view the contents of the playlist) ## Feature ideas: - A function to allow you to add multiple nfc items to a playlist at once diff --git a/application.fam b/application.fam index 657ae60..762d04c 100644 --- a/application.fam +++ b/application.fam @@ -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.4", + fap_version="2.5", fap_icon_assets="assets", fap_icon="assets/Playlist_10px.png", fap_private_libs=[ diff --git a/scenes/nfc_playlist_scene_config.h b/scenes/nfc_playlist_scene_config.h index b0c4c1c..287be74 100644 --- a/scenes/nfc_playlist_scene_config.h +++ b/scenes/nfc_playlist_scene_config.h @@ -4,6 +4,7 @@ ADD_SCENE(nfc_playlist, main_menu, MainMenu) ADD_SCENE(nfc_playlist, name_new_playlist, NameNewPlaylist) ADD_SCENE(nfc_playlist, nfc_add, NfcAdd) ADD_SCENE(nfc_playlist, nfc_remove, NfcRemove) +ADD_SCENE(nfc_playlist, nfc_move_item, NfcMoveItem) ADD_SCENE(nfc_playlist, playlist_edit, PlaylistEdit) ADD_SCENE(nfc_playlist, playlist_rename, PlaylistRename) ADD_SCENE(nfc_playlist, playlist_select, PlaylistSelect) diff --git a/scenes/nfc_playlist_scene_nfc_move_item b/scenes/nfc_playlist_scene_nfc_move_item.c similarity index 76% rename from scenes/nfc_playlist_scene_nfc_move_item rename to scenes/nfc_playlist_scene_nfc_move_item.c index c30d247..400a00a 100644 --- a/scenes/nfc_playlist_scene_nfc_move_item +++ b/scenes/nfc_playlist_scene_nfc_move_item.c @@ -1,6 +1,3 @@ -// This is currently not working so its not included at the moment - - #include "../nfc_playlist.h" typedef enum { @@ -48,8 +45,8 @@ void nfc_playlist_nfc_move_item_options_change_callback(VariableItem* item) { void nfc_playlist_nfc_move_item_scene_on_enter(void* context) { NfcPlaylist* nfc_playlist = context; - selected_target = 0; - selected_destination = 0; + selected_target = 1; + selected_destination = 1; variable_item_list_set_header(nfc_playlist->variable_item_list, "Move NFC Item"); @@ -83,8 +80,6 @@ void nfc_playlist_nfc_move_item_scene_on_enter(void* context) { bool nfc_playlist_nfc_move_item_scene_on_event(void* context, SceneManagerEvent event) { NfcPlaylist* nfc_playlist = context; - UNUSED(nfc_playlist); - bool consumed = false; if(event.type == SceneManagerEventTypeCustom) { @@ -94,49 +89,50 @@ bool nfc_playlist_nfc_move_item_scene_on_event(void* context, SceneManagerEvent Stream* stream = file_stream_alloc(storage); if(file_stream_open(stream, furi_string_get_cstr(nfc_playlist->settings.playlist_path), FSAM_READ_WRITE, FSOM_OPEN_EXISTING)) { - int counter = 0; - FuriString* tmp_target_line = furi_string_alloc(); + FuriString* tmp_target_str = furi_string_alloc(); FuriString* line = furi_string_alloc(); + uint8_t counter = 0; while(stream_read_line(stream, line)) { counter++; - if (counter == selected_target) { - furi_string_set(tmp_target_line, line); + if(counter == selected_target) { + furi_string_trim(line); + furi_string_cat_printf(tmp_target_str, "%s", furi_string_get_cstr(line)); + furi_string_reset(line); + stream_rewind(stream); + counter = 0; + break; } } - furi_string_reset(line); - stream_rewind(stream); - counter = 0; - FuriString* tmp_new_playlist_order = furi_string_alloc(); + FuriString* tmp_new_order_str = furi_string_alloc(); while(stream_read_line(stream, line)) { counter++; - if(counter == selected_target) { continue; } - furi_string_trim(line); - - if(!furi_string_empty(tmp_new_playlist_order)) { - furi_string_cat_printf(tmp_new_playlist_order, "\n"); + if(!furi_string_empty(tmp_new_order_str)) { + furi_string_cat_printf(tmp_new_order_str, "%s", "\n"); } - if(counter == selected_destination) { - furi_string_cat_printf(tmp_new_playlist_order, "%s\n%s", furi_string_get_cstr(tmp_target_line), furi_string_get_cstr(line)); + if(counter == selected_destination && counter == nfc_playlist->settings.playlist_length) { + furi_string_cat_printf(tmp_new_order_str, "%s\n%s", furi_string_get_cstr(line), furi_string_get_cstr(tmp_target_str)); + furi_string_free(tmp_target_str); } else { - furi_string_cat_printf(tmp_new_playlist_order, "%s", furi_string_get_cstr(line)); + if(counter == selected_destination) { + furi_string_cat_printf(tmp_new_order_str, "%s\n", furi_string_get_cstr(tmp_target_str)); + furi_string_reset(tmp_target_str); + } + furi_string_cat_printf(tmp_new_order_str, "%s", furi_string_get_cstr(line)); } } - FURI_LOG_RAW_I("New playlist order: %s\n", furi_string_get_cstr(tmp_new_playlist_order)); - + furi_string_free(line); stream_clean(stream); - stream_write_string(stream, tmp_new_playlist_order); + stream_write_string(stream, tmp_new_order_str); + furi_string_free(tmp_new_order_str); file_stream_close(stream); - furi_string_free(tmp_new_playlist_order); - furi_string_free(tmp_target_line); - furi_string_free(line); } stream_free(stream); diff --git a/scenes/nfc_playlist_scene_playlist_edit.c b/scenes/nfc_playlist_scene_playlist_edit.c index e7e5593..838b6c3 100644 --- a/scenes/nfc_playlist_scene_playlist_edit.c +++ b/scenes/nfc_playlist_scene_playlist_edit.c @@ -6,6 +6,7 @@ typedef enum { NfcPlaylistFileEdit_RenamePlaylist, NfcPlaylistFileEdit_AddNfcItem, NfcPlaylistFileEdit_RemoveNfcItem, + NfcPlaylistFileEdit_MoveNfcItem, NfcPlaylistFileEdit_ViewPlaylistContent } NfcPlaylistFileEditMenuSelection; @@ -64,6 +65,15 @@ void nfc_playlist_playlist_edit_scene_on_enter(void* context) { playlist_path_empty, "No\nplaylist\nselected"); + submenu_add_lockable_item( + nfc_playlist->submenu, + "Move NFC Item", + NfcPlaylistFileEdit_MoveNfcItem, + nfc_playlist_playlist_edit_menu_callback, + nfc_playlist, + playlist_path_empty, + "No\nplaylist\nselected"); + submenu_add_lockable_item( nfc_playlist->submenu, "View Playlist Content", @@ -101,6 +111,10 @@ bool nfc_playlist_playlist_edit_scene_on_event(void* context, SceneManagerEvent scene_manager_next_scene(nfc_playlist->scene_manager, NfcPlaylistScene_NfcRemove); consumed = true; break; + case NfcPlaylistFileEdit_MoveNfcItem: + scene_manager_next_scene(nfc_playlist->scene_manager, NfcPlaylistScene_NfcMoveItem); + consumed = true; + break; case NfcPlaylistFileEdit_ViewPlaylistContent: scene_manager_next_scene(nfc_playlist->scene_manager, NfcPlaylistScene_ViewPlaylistContent); consumed = true; From be4153b7ba5186cc7f78da88e099c759241bfcfd Mon Sep 17 00:00:00 2001 From: acegoal07 <39467245+acegoal07@users.noreply.github.com> Date: Wed, 21 Aug 2024 02:15:10 +0100 Subject: [PATCH 07/11] Update nfc_playlist_scene_nfc_move_item.c - Fixes move logic so it now acts how it should --- scenes/nfc_playlist_scene_nfc_move_item.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/scenes/nfc_playlist_scene_nfc_move_item.c b/scenes/nfc_playlist_scene_nfc_move_item.c index 400a00a..10f0d90 100644 --- a/scenes/nfc_playlist_scene_nfc_move_item.c +++ b/scenes/nfc_playlist_scene_nfc_move_item.c @@ -109,21 +109,26 @@ bool nfc_playlist_nfc_move_item_scene_on_event(void* context, SceneManagerEvent while(stream_read_line(stream, line)) { counter++; + if(counter == selected_target) { continue; } - furi_string_trim(line); + if(!furi_string_empty(tmp_new_order_str)) { furi_string_cat_printf(tmp_new_order_str, "%s", "\n"); } - if(counter == selected_destination && counter == nfc_playlist->settings.playlist_length) { - furi_string_cat_printf(tmp_new_order_str, "%s\n%s", furi_string_get_cstr(line), furi_string_get_cstr(tmp_target_str)); - furi_string_free(tmp_target_str); - } else { - if(counter == selected_destination) { - furi_string_cat_printf(tmp_new_order_str, "%s\n", furi_string_get_cstr(tmp_target_str)); + + furi_string_trim(line); + + if(counter == selected_destination) { + if(counter == 1) { + furi_string_cat_printf(tmp_new_order_str, "%s\n%s", furi_string_get_cstr(tmp_target_str), furi_string_get_cstr(line)); + furi_string_reset(tmp_target_str); + } else { + furi_string_cat_printf(tmp_new_order_str, "%s\n%s", furi_string_get_cstr(line), furi_string_get_cstr(tmp_target_str)); furi_string_reset(tmp_target_str); } + } else { furi_string_cat_printf(tmp_new_order_str, "%s", furi_string_get_cstr(line)); } } From d7571eba6a96a232e9006166f4a113f9a9a426fc Mon Sep 17 00:00:00 2001 From: acegoal07 <39467245+acegoal07@users.noreply.github.com> Date: Wed, 21 Aug 2024 02:16:57 +0100 Subject: [PATCH 08/11] Update nfc_playlist_scene_nfc_move_item.c --- scenes/nfc_playlist_scene_nfc_move_item.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scenes/nfc_playlist_scene_nfc_move_item.c b/scenes/nfc_playlist_scene_nfc_move_item.c index 10f0d90..c9003e8 100644 --- a/scenes/nfc_playlist_scene_nfc_move_item.c +++ b/scenes/nfc_playlist_scene_nfc_move_item.c @@ -117,7 +117,7 @@ bool nfc_playlist_nfc_move_item_scene_on_event(void* context, SceneManagerEvent if(!furi_string_empty(tmp_new_order_str)) { furi_string_cat_printf(tmp_new_order_str, "%s", "\n"); } - + furi_string_trim(line); if(counter == selected_destination) { From 0cc95e2e86201727a5d4c6e3c7e180015576984d Mon Sep 17 00:00:00 2001 From: acegoal07 <39467245+acegoal07@users.noreply.github.com> Date: Wed, 21 Aug 2024 02:44:32 +0100 Subject: [PATCH 09/11] Improves other playlist editor functions --- scenes/nfc_playlist_scene_nfc_add.c | 5 ++--- scenes/nfc_playlist_scene_nfc_move_item.c | 3 +-- scenes/nfc_playlist_scene_nfc_remove.c | 7 +++---- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/scenes/nfc_playlist_scene_nfc_add.c b/scenes/nfc_playlist_scene_nfc_add.c index 990da8a..e9e5676 100644 --- a/scenes/nfc_playlist_scene_nfc_add.c +++ b/scenes/nfc_playlist_scene_nfc_add.c @@ -15,10 +15,9 @@ void nfc_playlist_nfc_add_menu_callback(void* context) { furi_string_free(line); if (!furi_string_empty(tmp_str)) { - furi_string_cat_printf(tmp_str, "\n%s", furi_string_get_cstr(nfc_playlist->file_browser_output)); - } else { - furi_string_printf(tmp_str, "%s", furi_string_get_cstr(nfc_playlist->file_browser_output)); + furi_string_cat_printf(tmp_str, "\n"); } + furi_string_cat_printf(tmp_str, "%s", furi_string_get_cstr(nfc_playlist->file_browser_output)); stream_clean(stream); stream_write_string(stream, tmp_str); diff --git a/scenes/nfc_playlist_scene_nfc_move_item.c b/scenes/nfc_playlist_scene_nfc_move_item.c index c9003e8..18e79bd 100644 --- a/scenes/nfc_playlist_scene_nfc_move_item.c +++ b/scenes/nfc_playlist_scene_nfc_move_item.c @@ -123,11 +123,10 @@ bool nfc_playlist_nfc_move_item_scene_on_event(void* context, SceneManagerEvent if(counter == selected_destination) { if(counter == 1) { furi_string_cat_printf(tmp_new_order_str, "%s\n%s", furi_string_get_cstr(tmp_target_str), furi_string_get_cstr(line)); - furi_string_reset(tmp_target_str); } else { furi_string_cat_printf(tmp_new_order_str, "%s\n%s", furi_string_get_cstr(line), furi_string_get_cstr(tmp_target_str)); - furi_string_reset(tmp_target_str); } + furi_string_free(tmp_target_str); } else { furi_string_cat_printf(tmp_new_order_str, "%s", furi_string_get_cstr(line)); } diff --git a/scenes/nfc_playlist_scene_nfc_remove.c b/scenes/nfc_playlist_scene_nfc_remove.c index 7e215a1..65dde23 100644 --- a/scenes/nfc_playlist_scene_nfc_remove.c +++ b/scenes/nfc_playlist_scene_nfc_remove.c @@ -77,11 +77,10 @@ bool nfc_playlist_nfc_remove_scene_on_event(void* context, SceneManagerEvent eve current_line++; if (current_line != selected_line) { furi_string_trim(line); - if (furi_string_empty(tmp_str)) { - furi_string_cat_printf(tmp_str, "%s", furi_string_get_cstr(line)); - } else { - furi_string_cat_printf(tmp_str, "\n%s", furi_string_get_cstr(line)); + if (!furi_string_empty(tmp_str)) { + furi_string_cat_printf(tmp_str, "\n"); } + furi_string_cat_printf(tmp_str, "%s", furi_string_get_cstr(line)); } } From 0227f47716469554b8f5842ce5da1754e55d37d4 Mon Sep 17 00:00:00 2001 From: acegoal07 <39467245+acegoal07@users.noreply.github.com> Date: Wed, 21 Aug 2024 22:25:58 +0100 Subject: [PATCH 10/11] Removes deprecated function --- nfc_playlist.c | 1 - scenes/nfc_playlist_scene_playlist_rename.c | 1 - 2 files changed, 2 deletions(-) diff --git a/nfc_playlist.c b/nfc_playlist.c index 1a6bdac..f001f93 100644 --- a/nfc_playlist.c +++ b/nfc_playlist.c @@ -17,7 +17,6 @@ static NfcPlaylist* nfc_playlist_alloc() { furi_assert(nfc_playlist); nfc_playlist->scene_manager = scene_manager_alloc(&nfc_playlist_scene_handlers, nfc_playlist); nfc_playlist->view_dispatcher = view_dispatcher_alloc(); - view_dispatcher_enable_queue(nfc_playlist->view_dispatcher); nfc_playlist->variable_item_list = variable_item_list_alloc(); nfc_playlist->submenu = submenu_alloc(); nfc_playlist->widget= widget_alloc(); diff --git a/scenes/nfc_playlist_scene_playlist_rename.c b/scenes/nfc_playlist_scene_playlist_rename.c index 2787cbf..205b79a 100644 --- a/scenes/nfc_playlist_scene_playlist_rename.c +++ b/scenes/nfc_playlist_scene_playlist_rename.c @@ -19,7 +19,6 @@ int32_t nfc_playlist_playlist_rename_thread_task(void* context) { } furi_string_free(new_file_path); - furi_record_close(RECORD_STORAGE); return 0; From dd6c8ca61566c9c296b6b1e5fab01bd5a599cdd1 Mon Sep 17 00:00:00 2001 From: acegoal07 <39467245+acegoal07@users.noreply.github.com> Date: Thu, 22 Aug 2024 12:24:28 +0100 Subject: [PATCH 11/11] final tweaks --- nfc_playlist.c | 10 +++--- scenes/nfc_playlist_scene_main_menu.c | 24 ++++++------- scenes/nfc_playlist_scene_nfc_move_item.c | 3 -- scenes/nfc_playlist_scene_playlist_edit.c | 44 +++++++++++------------ 4 files changed, 39 insertions(+), 42 deletions(-) diff --git a/nfc_playlist.c b/nfc_playlist.c index f001f93..2fe76ba 100644 --- a/nfc_playlist.c +++ b/nfc_playlist.c @@ -80,11 +80,11 @@ static void nfc_playlist_free(NfcPlaylist* nfc_playlist) { } void nfc_playlist_set_log_level() { -#ifdef FURI_DEBUG - furi_log_set_level(FuriLogLevelTrace); -#else - furi_log_set_level(FuriLogLevelInfo); -#endif + #ifdef FURI_DEBUG + furi_log_set_level(FuriLogLevelTrace); + #else + furi_log_set_level(FuriLogLevelInfo); + #endif } int32_t nfc_playlist_main(void* p) { diff --git a/scenes/nfc_playlist_scene_main_menu.c b/scenes/nfc_playlist_scene_main_menu.c index 010ae79..828147c 100644 --- a/scenes/nfc_playlist_scene_main_menu.c +++ b/scenes/nfc_playlist_scene_main_menu.c @@ -1,10 +1,10 @@ #include "../nfc_playlist.h" typedef enum { - NfcPlaylistMenuSelection_Start, - NfcPlaylistMenuSelection_PlaylistSelect, - NfcPlaylistMenuSelection_FileEdit, - NfcPlaylistMenuSelection_Settings + NfcPlaylistMainMenu_Start, + NfcPlaylistMainMenu_PlaylistSelect, + NfcPlaylistMainMenu_FileEdit, + NfcPlaylistMainMenu_Settings } NfcPlaylistMainMenuMenuSelection; void nfc_playlist_main_menu_menu_callback(void* context, uint32_t index) { @@ -22,7 +22,7 @@ void nfc_playlist_main_menu_scene_on_enter(void* context) { submenu_add_lockable_item( nfc_playlist->submenu, "Start", - NfcPlaylistMenuSelection_Start, + NfcPlaylistMainMenu_Start, nfc_playlist_main_menu_menu_callback, nfc_playlist, furi_string_empty(nfc_playlist->settings.playlist_path), @@ -31,21 +31,21 @@ void nfc_playlist_main_menu_scene_on_enter(void* context) { submenu_add_item( nfc_playlist->submenu, "Select playlist", - NfcPlaylistMenuSelection_PlaylistSelect, + NfcPlaylistMainMenu_PlaylistSelect, nfc_playlist_main_menu_menu_callback, nfc_playlist); submenu_add_item( nfc_playlist->submenu, "Edit playlist", - NfcPlaylistMenuSelection_FileEdit, + NfcPlaylistMainMenu_FileEdit, nfc_playlist_main_menu_menu_callback, nfc_playlist); submenu_add_item( nfc_playlist->submenu, "Settings", - NfcPlaylistMenuSelection_Settings, + NfcPlaylistMainMenu_Settings, nfc_playlist_main_menu_menu_callback, nfc_playlist); @@ -57,19 +57,19 @@ bool nfc_playlist_main_menu_scene_on_event(void* context, SceneManagerEvent even bool consumed = false; if (event.type == SceneManagerEventTypeCustom) { switch(event.event) { - case NfcPlaylistMenuSelection_Start: + case NfcPlaylistMainMenu_Start: scene_manager_next_scene(nfc_playlist->scene_manager, NfcPlaylistScene_Emulation); consumed = true; break; - case NfcPlaylistMenuSelection_PlaylistSelect: + case NfcPlaylistMainMenu_PlaylistSelect: scene_manager_next_scene(nfc_playlist->scene_manager, NfcPlaylistScene_PlaylistSelect); consumed = true; break; - case NfcPlaylistMenuSelection_FileEdit: + case NfcPlaylistMainMenu_FileEdit: scene_manager_next_scene(nfc_playlist->scene_manager, NfcPlaylistScene_PlaylistEdit); consumed = true; break; - case NfcPlaylistMenuSelection_Settings: + case NfcPlaylistMainMenu_Settings: scene_manager_next_scene(nfc_playlist->scene_manager, NfcPlaylistScene_Settings); consumed = true; break; diff --git a/scenes/nfc_playlist_scene_nfc_move_item.c b/scenes/nfc_playlist_scene_nfc_move_item.c index 18e79bd..7c1a53d 100644 --- a/scenes/nfc_playlist_scene_nfc_move_item.c +++ b/scenes/nfc_playlist_scene_nfc_move_item.c @@ -56,7 +56,6 @@ void nfc_playlist_nfc_move_item_scene_on_enter(void* context) { nfc_playlist->settings.playlist_length, nfc_playlist_nfc_move_item_options_change_callback, nfc_playlist); - variable_item_set_current_value_index(target_selector, 0); variable_item_set_current_value_text(target_selector, "1"); @@ -66,7 +65,6 @@ void nfc_playlist_nfc_move_item_scene_on_enter(void* context) { nfc_playlist->settings.playlist_length, nfc_playlist_nfc_move_item_options_change_callback, nfc_playlist); - variable_item_set_current_value_index(destination_selector, 0); variable_item_set_current_value_text(destination_selector, "1"); @@ -98,7 +96,6 @@ bool nfc_playlist_nfc_move_item_scene_on_event(void* context, SceneManagerEvent if(counter == selected_target) { furi_string_trim(line); furi_string_cat_printf(tmp_target_str, "%s", furi_string_get_cstr(line)); - furi_string_reset(line); stream_rewind(stream); counter = 0; break; diff --git a/scenes/nfc_playlist_scene_playlist_edit.c b/scenes/nfc_playlist_scene_playlist_edit.c index 838b6c3..173a833 100644 --- a/scenes/nfc_playlist_scene_playlist_edit.c +++ b/scenes/nfc_playlist_scene_playlist_edit.c @@ -1,14 +1,14 @@ #include "../nfc_playlist.h" typedef enum { - NfcPlaylistFileEdit_CreatePlaylist, - NfcPlaylistFileEdit_DeletePlaylist, - NfcPlaylistFileEdit_RenamePlaylist, - NfcPlaylistFileEdit_AddNfcItem, - NfcPlaylistFileEdit_RemoveNfcItem, - NfcPlaylistFileEdit_MoveNfcItem, - NfcPlaylistFileEdit_ViewPlaylistContent -} NfcPlaylistFileEditMenuSelection; + NfcPlaylistPlaylistEdit_CreatePlaylist, + NfcPlaylistPlaylistEdit_DeletePlaylist, + NfcPlaylistPlaylistEdit_RenamePlaylist, + NfcPlaylistPlaylistEdit_AddNfcItem, + NfcPlaylistPlaylistEdit_RemoveNfcItem, + NfcPlaylistPlaylistEdit_MoveNfcItem, + NfcPlaylistPlaylistEdit_ViewPlaylistContent +} NfcPlaylistPlaylistEditMenuSelection; void nfc_playlist_playlist_edit_menu_callback(void* context, uint32_t index) { NfcPlaylist* nfc_playlist = context; @@ -25,14 +25,14 @@ void nfc_playlist_playlist_edit_scene_on_enter(void* context) { submenu_add_item( nfc_playlist->submenu, "Create Playlist", - NfcPlaylistFileEdit_CreatePlaylist, + NfcPlaylistPlaylistEdit_CreatePlaylist, nfc_playlist_playlist_edit_menu_callback, nfc_playlist); submenu_add_lockable_item( nfc_playlist->submenu, "Delete Playlist", - NfcPlaylistFileEdit_DeletePlaylist, + NfcPlaylistPlaylistEdit_DeletePlaylist, nfc_playlist_playlist_edit_menu_callback, nfc_playlist, playlist_path_empty, @@ -41,7 +41,7 @@ void nfc_playlist_playlist_edit_scene_on_enter(void* context) { submenu_add_lockable_item( nfc_playlist->submenu, "Rename Playlist", - NfcPlaylistFileEdit_RenamePlaylist, + NfcPlaylistPlaylistEdit_RenamePlaylist, nfc_playlist_playlist_edit_menu_callback, nfc_playlist, playlist_path_empty, @@ -50,7 +50,7 @@ void nfc_playlist_playlist_edit_scene_on_enter(void* context) { submenu_add_lockable_item( nfc_playlist->submenu, "Add NFC Item", - NfcPlaylistFileEdit_AddNfcItem, + NfcPlaylistPlaylistEdit_AddNfcItem, nfc_playlist_playlist_edit_menu_callback, nfc_playlist, playlist_path_empty, @@ -59,7 +59,7 @@ void nfc_playlist_playlist_edit_scene_on_enter(void* context) { submenu_add_lockable_item( nfc_playlist->submenu, "Remove NFC Item", - NfcPlaylistFileEdit_RemoveNfcItem, + NfcPlaylistPlaylistEdit_RemoveNfcItem, nfc_playlist_playlist_edit_menu_callback, nfc_playlist, playlist_path_empty, @@ -68,7 +68,7 @@ void nfc_playlist_playlist_edit_scene_on_enter(void* context) { submenu_add_lockable_item( nfc_playlist->submenu, "Move NFC Item", - NfcPlaylistFileEdit_MoveNfcItem, + NfcPlaylistPlaylistEdit_MoveNfcItem, nfc_playlist_playlist_edit_menu_callback, nfc_playlist, playlist_path_empty, @@ -77,7 +77,7 @@ void nfc_playlist_playlist_edit_scene_on_enter(void* context) { submenu_add_lockable_item( nfc_playlist->submenu, "View Playlist Content", - NfcPlaylistFileEdit_ViewPlaylistContent, + NfcPlaylistPlaylistEdit_ViewPlaylistContent, nfc_playlist_playlist_edit_menu_callback, nfc_playlist, playlist_path_empty, @@ -91,31 +91,31 @@ bool nfc_playlist_playlist_edit_scene_on_event(void* context, SceneManagerEvent bool consumed = false; if(event.type == SceneManagerEventTypeCustom) { switch(event.event) { - case NfcPlaylistFileEdit_CreatePlaylist: + case NfcPlaylistPlaylistEdit_CreatePlaylist: scene_manager_next_scene(nfc_playlist->scene_manager, NfcPlaylistScene_NameNewPlaylist); consumed = true; break; - case NfcPlaylistFileEdit_DeletePlaylist: + case NfcPlaylistPlaylistEdit_DeletePlaylist: scene_manager_next_scene(nfc_playlist->scene_manager, NfcPlaylistScene_ConfirmDelete); consumed = true; break; - case NfcPlaylistFileEdit_RenamePlaylist: + case NfcPlaylistPlaylistEdit_RenamePlaylist: scene_manager_next_scene(nfc_playlist->scene_manager, NfcPlaylistScene_PlaylistRename); consumed = true; break; - case NfcPlaylistFileEdit_AddNfcItem: + case NfcPlaylistPlaylistEdit_AddNfcItem: scene_manager_next_scene(nfc_playlist->scene_manager, NfcPlaylistScene_NfcAdd); consumed = true; break; - case NfcPlaylistFileEdit_RemoveNfcItem: + case NfcPlaylistPlaylistEdit_RemoveNfcItem: scene_manager_next_scene(nfc_playlist->scene_manager, NfcPlaylistScene_NfcRemove); consumed = true; break; - case NfcPlaylistFileEdit_MoveNfcItem: + case NfcPlaylistPlaylistEdit_MoveNfcItem: scene_manager_next_scene(nfc_playlist->scene_manager, NfcPlaylistScene_NfcMoveItem); consumed = true; break; - case NfcPlaylistFileEdit_ViewPlaylistContent: + case NfcPlaylistPlaylistEdit_ViewPlaylistContent: scene_manager_next_scene(nfc_playlist->scene_manager, NfcPlaylistScene_ViewPlaylistContent); consumed = true; break;