Skip to content

Commit ada95eb

Browse files
committed
Adds view playlist content
1 parent ec33779 commit ada95eb

11 files changed

+84
-10
lines changed

README.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,13 @@ As i know these firmwares are supported and working if you know any more please
2323
- Reset settings (Puts all the settings back to the defaults)
2424
## Playlist editor:
2525
- Delete playlist (Deletes the selected playlist)
26-
- Rename playlist (Renames the selected playlist the new name provided)
26+
- Rename playlist (Renames the selected playlist to the new name provided)
27+
- View playlist content (Allows you to view the items in the playlist)
2728
## Development plans/ideas:
2829
Things i would like to add:
2930
- Ability to add cards to playlists
3031
- Ability to remove cards from the playlist
3132

33+
These features are not guaranteed to be added but are being looked at as features to add
34+
3235
Any feedback is welcome and would be very much appreciated

nfc_playlist.c

+8-3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ static void (*const nfc_playlist_scene_on_enter_handlers[])(void*) = {
88
nfc_playlist_playlist_select_scene_on_enter,
99
nfc_playlist_file_edit_scene_on_enter,
1010
nfc_playlist_file_rename_scene_on_enter,
11-
nfc_playlist_confirm_delete_scene_on_enter
11+
nfc_playlist_confirm_delete_scene_on_enter,
12+
nfc_playlist_view_playlist_content_scene_on_enter
1213
};
1314

1415
static bool (*const nfc_playlist_scene_on_event_handlers[])(void*, SceneManagerEvent) = {
@@ -18,7 +19,8 @@ static bool (*const nfc_playlist_scene_on_event_handlers[])(void*, SceneManagerE
1819
nfc_playlist_playlist_select_scene_on_event,
1920
nfc_playlist_file_edit_scene_on_event,
2021
nfc_playlist_file_rename_scene_on_event,
21-
nfc_playlist_confirm_delete_scene_on_event
22+
nfc_playlist_confirm_delete_scene_on_event,
23+
nfc_playlist_view_playlist_content_scene_on_event
2224
};
2325

2426
static void (*const nfc_playlist_scene_on_exit_handlers[])(void*) = {
@@ -28,7 +30,8 @@ static void (*const nfc_playlist_scene_on_exit_handlers[])(void*) = {
2830
nfc_playlist_playlist_select_scene_on_exit,
2931
nfc_playlist_file_edit_scene_on_exit,
3032
nfc_playlist_file_rename_scene_on_exit,
31-
nfc_playlist_confirm_delete_scene_on_exit
33+
nfc_playlist_confirm_delete_scene_on_exit,
34+
nfc_playlist_view_playlist_content_scene_on_exit
3235
};
3336

3437
static const SceneManagerHandlers nfc_playlist_scene_manager_handlers = {
@@ -82,6 +85,7 @@ static NfcPlaylist* nfc_playlist_alloc() {
8285
view_dispatcher_add_view(nfc_playlist->view_dispatcher, NfcPlaylistView_FileEdit, submenu_get_view(nfc_playlist->submenu));
8386
view_dispatcher_add_view(nfc_playlist->view_dispatcher, NfcPlaylistView_FileRename, text_input_get_view(nfc_playlist->text_input));
8487
view_dispatcher_add_view(nfc_playlist->view_dispatcher, NfcPlaylistView_ConfirmDelete, widget_get_view(nfc_playlist->widget));
88+
view_dispatcher_add_view(nfc_playlist->view_dispatcher, NfcPlaylistView_ViewPlaylistContent, widget_get_view(nfc_playlist->widget));
8589

8690
Storage* storage = furi_record_open(RECORD_STORAGE);
8791
if (!storage_common_exists(storage, PLAYLIST_DIR)) {
@@ -102,6 +106,7 @@ static void nfc_playlist_free(NfcPlaylist* nfc_playlist) {
102106
view_dispatcher_remove_view(nfc_playlist->view_dispatcher, NfcPlaylistView_FileEdit);
103107
view_dispatcher_remove_view(nfc_playlist->view_dispatcher, NfcPlaylistView_FileRename);
104108
view_dispatcher_remove_view(nfc_playlist->view_dispatcher, NfcPlaylistView_ConfirmDelete);
109+
view_dispatcher_remove_view(nfc_playlist->view_dispatcher, NfcPlaylistView_ViewPlaylistContent);
105110

106111
scene_manager_free(nfc_playlist->scene_manager);
107112
view_dispatcher_free(nfc_playlist->view_dispatcher);

nfc_playlist.h

+3-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ typedef enum {
2323
NfcPlaylistView_PlaylistSelect,
2424
NfcPlaylistView_FileEdit,
2525
NfcPlaylistView_FileRename,
26-
NfcPlaylistView_ConfirmDelete
26+
NfcPlaylistView_ConfirmDelete,
27+
NfcPlaylistView_ViewPlaylistContent
2728
} NfcPlayScenesView;
2829

2930
typedef enum {
@@ -34,6 +35,7 @@ typedef enum {
3435
NfcPlaylistScene_FileEdit,
3536
NfcPlaylistScene_FileRename,
3637
NfcPlaylistScene_ConfirmDelete,
38+
NfcPlaylistScene_ViewPlaylistContent,
3739
NfcPlaylistScene_count
3840
} NfcPlaylistScene;
3941

nfc_playlist_i.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@
55
#include "scences/playlist_select.h"
66
#include "scences/file_edit.h"
77
#include "scences/file_rename.h"
8-
#include "scences/confirm_delete.h"
8+
#include "scences/confirm_delete.h"
9+
#include "scences/view_playlist_content.h"

scences/emulation.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ int32_t nfc_playlist_emulation_task(void* context) {
2020
FuriString* line = furi_string_alloc();
2121
FuriString* tmp_header_str = furi_string_alloc();
2222
FuriString* tmp_counter_str = furi_string_alloc();
23-
23+
2424
while(stream_read_line(stream, line) && EmulationState == NfcPlaylistEmulationState_Emulating) {
2525

2626
char* file_path = (char*)furi_string_get_cstr(line);

scences/file_edit.c

+13
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,15 @@ void nfc_playlist_file_edit_scene_on_enter(void* context) {
2929
furi_string_empty(nfc_playlist->settings.file_path),
3030
"No\nplaylist\nselected");
3131

32+
submenu_add_lockable_item(
33+
nfc_playlist->submenu,
34+
"View Playlist Content",
35+
NfcPlaylistMenuSelection_ViewPlaylistContent,
36+
nfc_playlist_file_edit_menu_callback,
37+
nfc_playlist,
38+
furi_string_empty(nfc_playlist->settings.file_path),
39+
"No\nplaylist\nselected");
40+
3241
view_dispatcher_switch_to_view(nfc_playlist->view_dispatcher, NfcPlaylistView_FileEdit);
3342
}
3443

@@ -45,6 +54,10 @@ bool nfc_playlist_file_edit_scene_on_event(void* context, SceneManagerEvent even
4554
scene_manager_next_scene(nfc_playlist->scene_manager, NfcPlaylistScene_FileRename);
4655
consumed = true;
4756
break;
57+
case NfcPlaylistMenuSelection_ViewPlaylistContent:
58+
scene_manager_next_scene(nfc_playlist->scene_manager, NfcPlaylistScene_ViewPlaylistContent);
59+
consumed = true;
60+
break;
4861
default:
4962
break;
5063
}

scences/file_edit.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,6 @@ void nfc_playlist_file_edit_scene_on_exit(void* context);
1010

1111
typedef enum {
1212
NfcPlaylistMenuSelection_DeletePlaylist,
13-
NfcPlaylistMenuSelection_RenamePlaylist
13+
NfcPlaylistMenuSelection_RenamePlaylist,
14+
NfcPlaylistMenuSelection_ViewPlaylistContent
1415
} NfcPlaylistFileEditMenuSelection;

scences/file_rename.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ void nfc_playlist_file_rename_scene_on_enter(void* context) {
3232
text_input_set_header_text(nfc_playlist->text_input, "Enter new file name");
3333
text_input_set_minimum_length(nfc_playlist->text_input, 1);
3434
text_input_set_result_callback(nfc_playlist->text_input, nfc_playlist_file_rename_menu_callback, nfc_playlist, nfc_playlist->text_input_output, 50, true);
35-
view_dispatcher_switch_to_view(nfc_playlist->view_dispatcher, NfcPlaylistView_FileRename);
35+
view_dispatcher_switch_to_view(nfc_playlist->view_dispatcher, NfcPlaylistView_FileRename);
3636
}
3737

3838
bool nfc_playlist_file_rename_scene_on_event(void* context, SceneManagerEvent event) {

scences/settings.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ void nfc_playlist_settings_scene_on_enter(void* context) {
7272

7373
VariableItem* credits = variable_item_list_add(nfc_playlist->variable_item_list, "acegoal07", 1, NULL, NULL);
7474
variable_item_set_current_value_text(credits, "Credits");
75-
75+
7676
variable_item_list_set_enter_callback(nfc_playlist->variable_item_list, nfc_playlist_settings_menu_callback, nfc_playlist);
7777
view_dispatcher_switch_to_view(nfc_playlist->view_dispatcher, NfcPlaylistView_Settings);
7878
furi_string_free(tmp_str);

scences/view_playlist_content.c

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#include "nfc_playlist.h"
2+
#include "scences/view_playlist_content.h"
3+
4+
void nfc_playlist_view_playlist_content_scene_on_enter(void* context) {
5+
NfcPlaylist* nfc_playlist = context;
6+
7+
Storage* storage = furi_record_open(RECORD_STORAGE);
8+
File* file = storage_file_alloc(storage);
9+
uint8_t buffer[8000];
10+
FuriString* playlist_content = furi_string_alloc();
11+
12+
storage_file_open(file, furi_string_get_cstr(nfc_playlist->settings.file_path), FSAM_READ, FSOM_OPEN_EXISTING);
13+
uint16_t read_count = storage_file_read(file, buffer, 8000);
14+
15+
for(uint16_t i = 0; i < read_count; i++) {
16+
furi_string_push_back(playlist_content, buffer[i]);
17+
}
18+
19+
widget_add_text_scroll_element(nfc_playlist->widget, 4, 4, 124, 60, furi_string_get_cstr(playlist_content));
20+
widget_add_frame_element(nfc_playlist->widget, 0, 0, 128, 64, 0);
21+
22+
furi_string_free(playlist_content);
23+
storage_file_close(file);
24+
storage_file_free(file);
25+
furi_record_close(RECORD_STORAGE);
26+
27+
view_dispatcher_switch_to_view(nfc_playlist->view_dispatcher, NfcPlaylistView_ViewPlaylistContent);
28+
}
29+
30+
bool nfc_playlist_view_playlist_content_scene_on_event(void* context, SceneManagerEvent event) {
31+
UNUSED(context);
32+
UNUSED(event);
33+
return false;
34+
}
35+
36+
void nfc_playlist_view_playlist_content_scene_on_exit(void* context) {
37+
NfcPlaylist* nfc_playlist = context;
38+
widget_reset(nfc_playlist->widget);
39+
}

scences/view_playlist_content.h

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#pragma once
2+
#include <furi.h>
3+
#include <gui/view_dispatcher.h>
4+
#include <gui/scene_manager.h>
5+
#include <gui/modules/widget.h>
6+
#include <storage/storage.h>
7+
8+
void nfc_playlist_view_playlist_content_scene_on_enter(void* context);
9+
bool nfc_playlist_view_playlist_content_scene_on_event(void* context, SceneManagerEvent event);
10+
void nfc_playlist_view_playlist_content_scene_on_exit(void* context);

0 commit comments

Comments
 (0)