Skip to content

Commit

Permalink
Merge pull request #38 from acegoal07/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
acegoal07 authored Aug 22, 2024
2 parents a32cce4 + dd6c8ca commit cb6e15d
Show file tree
Hide file tree
Showing 15 changed files with 246 additions and 79 deletions.
8 changes: 4 additions & 4 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -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**
Expand Down
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ assignees: acegoal07
---

**Describe the feature**
A indepth description of what you want
A in depth description of what you want
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ 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
- 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
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.4",
fap_version="2.5",
fap_icon_assets="assets",
fap_icon="assets/Playlist_10px.png",
fap_private_libs=[
Expand Down
12 changes: 5 additions & 7 deletions nfc_playlist.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,12 @@ 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();

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;
Expand Down Expand Up @@ -82,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) {
Expand Down
2 changes: 1 addition & 1 deletion nfc_playlist.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -45,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;
Expand Down
5 changes: 3 additions & 2 deletions scenes/nfc_playlist_scene_config.h
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
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, 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)
ADD_SCENE(nfc_playlist, settings, Settings)
ADD_SCENE(nfc_playlist, view_playlist_content, ViewPlaylistContent)
6 changes: 4 additions & 2 deletions scenes/nfc_playlist_scene_confirm_delete.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,17 @@ 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);
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;
}
}
Expand Down
29 changes: 12 additions & 17 deletions scenes/nfc_playlist_scene_main_menu.c
Original file line number Diff line number Diff line change
@@ -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) {
Expand All @@ -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));
Expand All @@ -27,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),
Expand All @@ -36,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);

Expand All @@ -62,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;
Expand Down
2 changes: 1 addition & 1 deletion scenes/nfc_playlist_scene_name_new_playlist.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
9 changes: 4 additions & 5 deletions scenes/nfc_playlist_scene_nfc_add.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -39,13 +38,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);

Expand Down
Loading

0 comments on commit cb6e15d

Please sign in to comment.