From ce67472dc4a884b79648d369f266314e2f94bc2a Mon Sep 17 00:00:00 2001 From: MX <10697207+xMasterX@users.noreply.github.com> Date: Fri, 15 Mar 2024 09:33:27 +0300 Subject: [PATCH] use non prefixed names for regular files with random name --- .../main/ibutton/scenes/ibutton_scene_save_name.c | 2 +- applications/main/lfrfid/scenes/lfrfid_scene_save_name.c | 2 +- .../nfc/helpers/protocol_support/nfc_protocol_support.c | 2 +- lib/toolbox/name_generator.c | 8 ++++++++ lib/toolbox/name_generator.h | 3 +++ targets/f7/api_symbols.csv | 1 + 6 files changed, 15 insertions(+), 3 deletions(-) diff --git a/applications/main/ibutton/scenes/ibutton_scene_save_name.c b/applications/main/ibutton/scenes/ibutton_scene_save_name.c index e6236dc359..f48ae60d39 100644 --- a/applications/main/ibutton/scenes/ibutton_scene_save_name.c +++ b/applications/main/ibutton/scenes/ibutton_scene_save_name.c @@ -17,7 +17,7 @@ void ibutton_scene_save_name_on_enter(void* context) { const bool is_new_file = furi_string_empty(ibutton->file_path); if(is_new_file) { - name_generator_make_auto( + name_generator_make_auto_basic( ibutton->key_name, IBUTTON_KEY_NAME_SIZE, IBUTTON_APP_FILENAME_PREFIX); } diff --git a/applications/main/lfrfid/scenes/lfrfid_scene_save_name.c b/applications/main/lfrfid/scenes/lfrfid_scene_save_name.c index 3a38e213de..c6845b44a1 100644 --- a/applications/main/lfrfid/scenes/lfrfid_scene_save_name.c +++ b/applications/main/lfrfid/scenes/lfrfid_scene_save_name.c @@ -12,7 +12,7 @@ void lfrfid_scene_save_name_on_enter(void* context) { if(key_name_is_empty) { furi_string_set(app->file_path, LFRFID_APP_FOLDER); - name_generator_make_auto( + name_generator_make_auto_basic( app->text_store, LFRFID_TEXT_STORE_SIZE, LFRFID_APP_FILENAME_PREFIX); furi_string_set(folder_path, LFRFID_APP_FOLDER); diff --git a/applications/main/nfc/helpers/protocol_support/nfc_protocol_support.c b/applications/main/nfc/helpers/protocol_support/nfc_protocol_support.c index bf562bf587..549f1ca945 100644 --- a/applications/main/nfc/helpers/protocol_support/nfc_protocol_support.c +++ b/applications/main/nfc/helpers/protocol_support/nfc_protocol_support.c @@ -481,7 +481,7 @@ static void nfc_protocol_support_scene_save_name_on_enter(NfcApp* instance) { bool name_is_empty = furi_string_empty(instance->file_name); if(name_is_empty) { furi_string_set(instance->file_path, NFC_APP_FOLDER); - name_generator_make_auto( + name_generator_make_auto_basic( instance->text_store, NFC_TEXT_STORE_SIZE, NFC_APP_FILENAME_PREFIX); furi_string_set(folder_path, NFC_APP_FOLDER); } else { diff --git a/lib/toolbox/name_generator.c b/lib/toolbox/name_generator.c index 9748a76484..5986c0ed7a 100644 --- a/lib/toolbox/name_generator.c +++ b/lib/toolbox/name_generator.c @@ -60,6 +60,14 @@ void name_generator_make_auto(char* name, size_t max_name_size, const char* pref name_generator_make_auto_datetime(name, max_name_size, prefix, NULL); } +void name_generator_make_auto_basic(char* name, size_t max_name_size, const char* prefix) { + if(furi_hal_rtc_is_flag_set(FuriHalRtcFlagDetailedFilename)) { + name_generator_make_detailed_datetime(name, max_name_size, prefix, NULL); + } else { + name_generator_make_random(name, max_name_size); + } +} + void name_generator_make_random_prefixed(char* name, size_t max_name_size, const char* prefix) { furi_assert(name); furi_assert(max_name_size); diff --git a/lib/toolbox/name_generator.h b/lib/toolbox/name_generator.h index e6c4436881..b990381c3b 100644 --- a/lib/toolbox/name_generator.h +++ b/lib/toolbox/name_generator.h @@ -21,6 +21,9 @@ void name_generator_make_auto_datetime( const char* prefix, DateTime* custom_time); +// Generate name without prefix in random names +void name_generator_make_auto_basic(char* name, size_t max_name_size, const char* prefix); + /** Generates random name * * @param name buffer to write random name diff --git a/targets/f7/api_symbols.csv b/targets/f7/api_symbols.csv index f2e97a5e05..8ca458eed7 100644 --- a/targets/f7/api_symbols.csv +++ b/targets/f7/api_symbols.csv @@ -2645,6 +2645,7 @@ Function,-,music_worker_set_volume,void,"MusicWorker*, float" Function,-,music_worker_start,void,MusicWorker* Function,-,music_worker_stop,void,MusicWorker* Function,+,name_generator_make_auto,void,"char*, size_t, const char*" +Function,+,name_generator_make_auto_basic,void,"char*, size_t, const char*" Function,+,name_generator_make_auto_datetime,void,"char*, size_t, const char*, DateTime*" Function,+,name_generator_make_detailed,void,"char*, size_t, const char*" Function,+,name_generator_make_detailed_datetime,void,"char*, size_t, const char*, DateTime*"