Dynamic default nfc naming

This commit is contained in:
Willy-JL
2023-09-02 22:18:42 +02:00
parent 6caf8a6432
commit 8443fc53f2
4 changed files with 15 additions and 3 deletions

View File

@@ -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);

View File

@@ -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*"
1 entry status name type params
2196 Function + nfc_device_free void NfcDevice*
2197 Function + nfc_device_load _Bool NfcDevice*, const char*, _Bool
2198 Function + nfc_device_load_key_cache _Bool NfcDevice*
2199 Function + nfc_device_prepare_format_string void NfcDevice*, FuriString*
2200 Function + nfc_device_restore _Bool NfcDevice*, _Bool
2201 Function + nfc_device_save _Bool NfcDevice*, const char*
2202 Function + nfc_device_save_shadow _Bool NfcDevice*, const char*

View File

@@ -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) {

View File

@@ -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