diff --git a/applications/main/nfc/scenes/nfc_scene_save_name.c b/applications/main/nfc/scenes/nfc_scene_save_name.c index eed0a58dc..06d94ebb5 100644 --- a/applications/main/nfc/scenes/nfc_scene_save_name.c +++ b/applications/main/nfc/scenes/nfc_scene_save_name.c @@ -17,7 +17,16 @@ void nfc_scene_save_name_on_enter(void* context) { TextInput* text_input = nfc->text_input; bool dev_name_empty = false; if(!strcmp(nfc->dev->dev_name, "")) { - name_generator_make_auto(nfc->text_store, NFC_DEV_NAME_MAX_LEN, NFC_APP_FILENAME_PREFIX); + FuriString* prefix = furi_string_alloc(); + nfc_device_prepare_format_string(nfc->dev, prefix); + furi_string_replace(prefix, "Mifare", "MF"); + furi_string_replace(prefix, "Ultralight", "UL"); + furi_string_replace(prefix, " Plus", "+"); + furi_string_replace_all(prefix, " ", "_"); + furi_string_left(prefix, 12); + name_generator_make_auto( + nfc->text_store, NFC_DEV_NAME_MAX_LEN, furi_string_get_cstr(prefix)); + furi_string_free(prefix); dev_name_empty = true; } else { nfc_text_store_set(nfc, nfc->dev->dev_name); diff --git a/firmware/targets/f7/api_symbols.csv b/firmware/targets/f7/api_symbols.csv index 388ebf462..f02007682 100644 --- a/firmware/targets/f7/api_symbols.csv +++ b/firmware/targets/f7/api_symbols.csv @@ -2196,6 +2196,7 @@ Function,+,nfc_device_delete,_Bool,"NfcDevice*, _Bool" Function,+,nfc_device_free,void,NfcDevice* Function,+,nfc_device_load,_Bool,"NfcDevice*, const char*, _Bool" Function,+,nfc_device_load_key_cache,_Bool,NfcDevice* +Function,+,nfc_device_prepare_format_string,void,"NfcDevice*, FuriString*" Function,+,nfc_device_restore,_Bool,"NfcDevice*, _Bool" Function,+,nfc_device_save,_Bool,"NfcDevice*, const char*" Function,+,nfc_device_save_shadow,_Bool,"NfcDevice*, const char*" diff --git a/lib/nfc/nfc_device.c b/lib/nfc/nfc_device.c index 19830cd04..a0073549a 100644 --- a/lib/nfc/nfc_device.c +++ b/lib/nfc/nfc_device.c @@ -47,7 +47,7 @@ void nfc_device_free(NfcDevice* nfc_dev) { free(nfc_dev); } -static void nfc_device_prepare_format_string(NfcDevice* dev, FuriString* format_string) { +void nfc_device_prepare_format_string(NfcDevice* dev, FuriString* format_string) { if(dev->format == NfcDeviceSaveFormatUid) { furi_string_set(format_string, "UID"); } else if(dev->format == NfcDeviceSaveFormatBankCard) { diff --git a/lib/nfc/nfc_device.h b/lib/nfc/nfc_device.h index 096225ccf..79429e7cb 100644 --- a/lib/nfc/nfc_device.h +++ b/lib/nfc/nfc_device.h @@ -17,7 +17,7 @@ extern "C" { #endif -#define NFC_DEV_NAME_MAX_LEN 22 +#define NFC_DEV_NAME_MAX_LEN 31 #define NFC_READER_DATA_MAX_SIZE 64 #define NFC_DICT_KEY_BATCH_SIZE 10 @@ -123,6 +123,8 @@ bool nfc_device_restore(NfcDevice* dev, bool use_load_path); void nfc_device_set_loading_callback(NfcDevice* dev, NfcLoadingCallback callback, void* context); +void nfc_device_prepare_format_string(NfcDevice* dev, FuriString* format_string); + #ifdef __cplusplus } #endif