[FL-2491] File browser GUI module (#1237)
* File browser module and test app * nfc: Add support for saved files in subdirectories * nfc: Use helper function to get shadow path when loading data * File browser dialog integration pt.1 * File browser dialog integration pt.2 * Gui,Dialogs: drop file select * Correct use of dynamic string_t(string_ptr) Co-authored-by: Yukai Li <yukaili.geek@gmail.com> Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
This commit is contained in:
@@ -49,7 +49,7 @@ bool subghz_scene_delete_on_event(void* context, SceneManagerEvent event) {
|
||||
SubGhz* subghz = context;
|
||||
if(event.type == SceneManagerEventTypeCustom) {
|
||||
if(event.event == SubGhzCustomEventSceneDelete) {
|
||||
strncpy(subghz->file_path_tmp, subghz->file_path, SUBGHZ_MAX_LEN_NAME);
|
||||
string_set(subghz->file_path_tmp, subghz->file_path);
|
||||
if(subghz_delete_file(subghz)) {
|
||||
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneDeleteSuccess);
|
||||
} else {
|
||||
|
||||
@@ -24,7 +24,7 @@ void subghz_scene_delete_raw_on_enter(void* context) {
|
||||
char delete_str[SUBGHZ_MAX_LEN_NAME + 16];
|
||||
string_t file_name;
|
||||
string_init(file_name);
|
||||
path_extract_filename_no_ext(subghz->file_path, file_name);
|
||||
path_extract_filename(subghz->file_path, file_name, true);
|
||||
snprintf(delete_str, sizeof(delete_str), "\e#Delete %s?\e#", string_get_cstr(file_name));
|
||||
string_clear(file_name);
|
||||
|
||||
@@ -61,7 +61,7 @@ bool subghz_scene_delete_raw_on_event(void* context, SceneManagerEvent event) {
|
||||
SubGhz* subghz = context;
|
||||
if(event.type == SceneManagerEventTypeCustom) {
|
||||
if(event.event == SubGhzCustomEventSceneDeleteRAW) {
|
||||
strncpy(subghz->file_path_tmp, subghz->file_path, SUBGHZ_MAX_LEN_NAME);
|
||||
string_set(subghz->file_path_tmp, subghz->file_path);
|
||||
if(subghz_delete_file(subghz)) {
|
||||
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneDeleteSuccess);
|
||||
} else {
|
||||
|
||||
@@ -45,7 +45,7 @@ bool subghz_scene_more_raw_on_event(void* context, SceneManagerEvent event) {
|
||||
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneDeleteRAW);
|
||||
return true;
|
||||
} else if(event.event == SubmenuIndexEdit) {
|
||||
memset(subghz->file_path_tmp, 0, sizeof(subghz->file_path_tmp));
|
||||
string_reset(subghz->file_path_tmp);
|
||||
scene_manager_set_scene_state(
|
||||
subghz->scene_manager, SubGhzSceneMoreRAW, SubmenuIndexEdit);
|
||||
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneSaveName);
|
||||
|
||||
@@ -23,7 +23,7 @@ bool subghz_scene_read_raw_update_filename(SubGhz* subghz) {
|
||||
break;
|
||||
}
|
||||
|
||||
strncpy(subghz->file_path, string_get_cstr(temp_str), SUBGHZ_MAX_LEN_NAME);
|
||||
string_set(subghz->file_path, temp_str);
|
||||
|
||||
ret = true;
|
||||
} while(false);
|
||||
@@ -73,13 +73,13 @@ void subghz_scene_read_raw_on_enter(void* context) {
|
||||
subghz_read_raw_set_status(subghz->subghz_read_raw, SubGhzReadRAWStatusIDLE, "");
|
||||
break;
|
||||
case SubGhzRxKeyStateRAWLoad:
|
||||
path_extract_filename_no_ext(subghz->file_path, file_name);
|
||||
path_extract_filename(subghz->file_path, file_name, true);
|
||||
subghz_read_raw_set_status(
|
||||
subghz->subghz_read_raw, SubGhzReadRAWStatusLoadKeyTX, string_get_cstr(file_name));
|
||||
subghz->txrx->rx_key_state = SubGhzRxKeyStateIDLE;
|
||||
break;
|
||||
case SubGhzRxKeyStateRAWSave:
|
||||
path_extract_filename_no_ext(subghz->file_path, file_name);
|
||||
path_extract_filename(subghz->file_path, file_name, true);
|
||||
subghz_read_raw_set_status(
|
||||
subghz->subghz_read_raw, SubGhzReadRAWStatusSaveKey, string_get_cstr(file_name));
|
||||
subghz->txrx->rx_key_state = SubGhzRxKeyStateIDLE;
|
||||
@@ -273,7 +273,7 @@ bool subghz_scene_read_raw_on_event(void* context, SceneManagerEvent event) {
|
||||
subghz->state_notifications = SubGhzNotificationStateRx;
|
||||
subghz->txrx->rx_key_state = SubGhzRxKeyStateAddKey;
|
||||
} else {
|
||||
string_set(subghz->error_str, "Function requires\nan SD card.");
|
||||
string_set_str(subghz->error_str, "Function requires\nan SD card.");
|
||||
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneShowError);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
#include "../subghz_i.h"
|
||||
#include "m-string.h"
|
||||
#include "subghz/types.h"
|
||||
#include <lib/toolbox/random_name.h>
|
||||
#include "../helpers/subghz_custom_event.h"
|
||||
#include <lib/subghz/protocols/raw.h>
|
||||
@@ -20,45 +22,49 @@ void subghz_scene_save_name_on_enter(void* context) {
|
||||
bool dev_name_empty = false;
|
||||
|
||||
string_t file_name;
|
||||
string_t dir_name;
|
||||
string_init(file_name);
|
||||
string_init(dir_name);
|
||||
|
||||
if(!strcmp(subghz->file_path, "")) {
|
||||
if(!subghz_path_is_file(subghz->file_path)) {
|
||||
char file_name_buf[SUBGHZ_MAX_LEN_NAME] = {0};
|
||||
set_random_name(file_name_buf, SUBGHZ_MAX_LEN_NAME);
|
||||
string_set(file_name, file_name_buf);
|
||||
strncpy(subghz->file_dir, SUBGHZ_APP_FOLDER, SUBGHZ_MAX_LEN_NAME);
|
||||
string_set_str(file_name, file_name_buf);
|
||||
string_set_str(subghz->file_path, SUBGHZ_APP_FOLDER);
|
||||
//highlighting the entire filename by default
|
||||
dev_name_empty = true;
|
||||
} else {
|
||||
strncpy(subghz->file_path_tmp, subghz->file_path, SUBGHZ_MAX_LEN_NAME);
|
||||
path_extract_dirname(subghz->file_path, file_name);
|
||||
strncpy(subghz->file_dir, string_get_cstr(file_name), SUBGHZ_MAX_LEN_NAME);
|
||||
path_extract_filename_no_ext(subghz->file_path, file_name);
|
||||
string_set(subghz->file_path_tmp, subghz->file_path);
|
||||
path_extract_dirname(string_get_cstr(subghz->file_path), dir_name);
|
||||
path_extract_filename(subghz->file_path, file_name, true);
|
||||
if(scene_manager_get_scene_state(subghz->scene_manager, SubGhzSceneReadRAW) !=
|
||||
SubGhzCustomEventManagerNoSet) {
|
||||
subghz_get_next_name_file(subghz, SUBGHZ_MAX_LEN_NAME);
|
||||
path_extract_filename_no_ext(subghz->file_path, file_name);
|
||||
path_extract_filename(subghz->file_path, file_name, true);
|
||||
if(scene_manager_get_scene_state(subghz->scene_manager, SubGhzSceneReadRAW) ==
|
||||
SubGhzCustomEventManagerSetRAW) {
|
||||
dev_name_empty = true;
|
||||
}
|
||||
}
|
||||
string_set(subghz->file_path, dir_name);
|
||||
}
|
||||
strncpy(subghz->file_path, string_get_cstr(file_name), SUBGHZ_MAX_LEN_NAME);
|
||||
|
||||
strncpy(subghz->file_name_tmp, string_get_cstr(file_name), SUBGHZ_MAX_LEN_NAME);
|
||||
text_input_set_header_text(text_input, "Name signal");
|
||||
text_input_set_result_callback(
|
||||
text_input,
|
||||
subghz_scene_save_name_text_input_callback,
|
||||
subghz,
|
||||
subghz->file_path,
|
||||
subghz->file_name_tmp,
|
||||
MAX_TEXT_INPUT_LEN, // buffer size
|
||||
dev_name_empty);
|
||||
|
||||
ValidatorIsFile* validator_is_file =
|
||||
validator_is_file_alloc_init(subghz->file_dir, SUBGHZ_APP_EXTENSION, NULL);
|
||||
ValidatorIsFile* validator_is_file = validator_is_file_alloc_init(
|
||||
string_get_cstr(subghz->file_path), SUBGHZ_APP_EXTENSION, NULL);
|
||||
text_input_set_validator(text_input, validator_is_file_callback, validator_is_file);
|
||||
|
||||
string_clear(file_name);
|
||||
string_clear(dir_name);
|
||||
|
||||
view_dispatcher_switch_to_view(subghz->view_dispatcher, SubGhzViewIdTextInput);
|
||||
}
|
||||
@@ -66,18 +72,15 @@ void subghz_scene_save_name_on_enter(void* context) {
|
||||
bool subghz_scene_save_name_on_event(void* context, SceneManagerEvent event) {
|
||||
SubGhz* subghz = context;
|
||||
if(event.type == SceneManagerEventTypeBack) {
|
||||
strncpy(subghz->file_path, subghz->file_path_tmp, SUBGHZ_MAX_LEN_NAME);
|
||||
string_set(subghz->file_path, subghz->file_path_tmp);
|
||||
scene_manager_previous_scene(subghz->scene_manager);
|
||||
return true;
|
||||
} else if(event.type == SceneManagerEventTypeCustom) {
|
||||
if(event.event == SubGhzCustomEventSceneSaveName) {
|
||||
if(strcmp(subghz->file_path, "")) {
|
||||
string_t temp_str;
|
||||
string_init_printf(
|
||||
temp_str, "%s/%s%s", subghz->file_dir, subghz->file_path, SUBGHZ_APP_EXTENSION);
|
||||
strncpy(subghz->file_path, string_get_cstr(temp_str), SUBGHZ_MAX_LEN_NAME);
|
||||
string_clear(temp_str);
|
||||
if(strcmp(subghz->file_path_tmp, "")) {
|
||||
if(strcmp(subghz->file_name_tmp, "")) {
|
||||
string_cat_printf(
|
||||
subghz->file_path, "/%s%s", subghz->file_name_tmp, SUBGHZ_APP_EXTENSION);
|
||||
if(subghz_path_is_file(subghz->file_path_tmp)) {
|
||||
if(!subghz_rename_file(subghz)) {
|
||||
return false;
|
||||
}
|
||||
@@ -85,7 +88,7 @@ bool subghz_scene_save_name_on_event(void* context, SceneManagerEvent event) {
|
||||
if(scene_manager_get_scene_state(subghz->scene_manager, SubGhzSceneSetType) !=
|
||||
SubGhzCustomEventManagerNoSet) {
|
||||
subghz_save_protocol_to_file(
|
||||
subghz, subghz->txrx->fff_data, subghz->file_path);
|
||||
subghz, subghz->txrx->fff_data, string_get_cstr(subghz->file_path));
|
||||
scene_manager_set_scene_state(
|
||||
subghz->scene_manager,
|
||||
SubGhzSceneSetType,
|
||||
@@ -95,13 +98,14 @@ bool subghz_scene_save_name_on_event(void* context, SceneManagerEvent event) {
|
||||
subghz,
|
||||
subghz_history_get_raw_data(
|
||||
subghz->txrx->history, subghz->txrx->idx_menu_chosen),
|
||||
subghz->file_path);
|
||||
string_get_cstr(subghz->file_path));
|
||||
}
|
||||
}
|
||||
|
||||
if(scene_manager_get_scene_state(subghz->scene_manager, SubGhzSceneReadRAW) !=
|
||||
SubGhzCustomEventManagerNoSet) {
|
||||
subghz_protocol_raw_gen_fff_data(subghz->txrx->fff_data, subghz->file_path);
|
||||
subghz_protocol_raw_gen_fff_data(
|
||||
subghz->txrx->fff_data, string_get_cstr(subghz->file_path));
|
||||
scene_manager_set_scene_state(
|
||||
subghz->scene_manager, SubGhzSceneReadRAW, SubGhzCustomEventManagerNoSet);
|
||||
} else {
|
||||
@@ -111,7 +115,7 @@ bool subghz_scene_save_name_on_event(void* context, SceneManagerEvent event) {
|
||||
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneSaveSuccess);
|
||||
return true;
|
||||
} else {
|
||||
string_set(subghz->error_str, "No name file");
|
||||
string_set_str(subghz->error_str, "No name file");
|
||||
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneShowErrorSub);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ bool subghz_scene_set_type_submenu_gen_data_protocol(
|
||||
subghz_receiver_search_decoder_base_by_name(subghz->txrx->receiver, protocol_name);
|
||||
|
||||
if(subghz->txrx->decoder_result == NULL) {
|
||||
string_set(subghz->error_str, "Protocol not found");
|
||||
string_set_str(subghz->error_str, "Protocol not found");
|
||||
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneShowErrorSub);
|
||||
return false;
|
||||
}
|
||||
@@ -282,7 +282,7 @@ bool subghz_scene_set_type_on_event(void* context, SceneManagerEvent event) {
|
||||
}
|
||||
subghz_transmitter_free(subghz->txrx->transmitter);
|
||||
if(!generated_protocol) {
|
||||
string_set(
|
||||
string_set_str(
|
||||
subghz->error_str, "Function requires\nan SD card with\nfresh databases.");
|
||||
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneShowError);
|
||||
}
|
||||
@@ -306,7 +306,7 @@ bool subghz_scene_set_type_on_event(void* context, SceneManagerEvent event) {
|
||||
}
|
||||
subghz_transmitter_free(subghz->txrx->transmitter);
|
||||
if(!generated_protocol) {
|
||||
string_set(
|
||||
string_set_str(
|
||||
subghz->error_str, "Function requires\nan SD card with\nfresh databases.");
|
||||
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneShowError);
|
||||
}
|
||||
|
||||
@@ -94,7 +94,7 @@ bool subghz_scene_transmitter_on_event(void* context, SceneManagerEvent event) {
|
||||
subghz->scene_manager, SubGhzSceneStart);
|
||||
return true;
|
||||
} else if(event.event == SubGhzCustomEventViewTransmitterError) {
|
||||
string_set(subghz->error_str, "Protocol not found");
|
||||
string_set_str(subghz->error_str, "Protocol not found");
|
||||
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneShowErrorSub);
|
||||
}
|
||||
} else if(event.type == SceneManagerEventTypeTick) {
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
/* Abandon hope, all ye who enter here. */
|
||||
|
||||
#include "m-string.h"
|
||||
#include "subghz/types.h"
|
||||
#include "subghz_i.h"
|
||||
#include <lib/toolbox/path.h>
|
||||
|
||||
@@ -24,6 +26,9 @@ void subghz_tick_event_callback(void* context) {
|
||||
SubGhz* subghz_alloc() {
|
||||
SubGhz* subghz = malloc(sizeof(SubGhz));
|
||||
|
||||
string_init(subghz->file_path);
|
||||
string_init(subghz->file_path_tmp);
|
||||
|
||||
// GUI
|
||||
subghz->gui = furi_record_open("gui");
|
||||
|
||||
@@ -241,9 +246,9 @@ void subghz_free(SubGhz* subghz) {
|
||||
furi_record_close("notification");
|
||||
subghz->notifications = NULL;
|
||||
|
||||
// About birds
|
||||
furi_assert(subghz->file_path[SUBGHZ_MAX_LEN_NAME] == 0);
|
||||
furi_assert(subghz->file_path_tmp[SUBGHZ_MAX_LEN_NAME] == 0);
|
||||
// Path strings
|
||||
string_clear(subghz->file_path);
|
||||
string_clear(subghz->file_path_tmp);
|
||||
|
||||
// The rest
|
||||
free(subghz);
|
||||
@@ -260,7 +265,7 @@ int32_t subghz_app(void* p) {
|
||||
// Check argument and run corresponding scene
|
||||
if(p) {
|
||||
if(subghz_key_load(subghz, p)) {
|
||||
strncpy(subghz->file_path, p, SUBGHZ_MAX_LEN_NAME);
|
||||
string_set_str(subghz->file_path, p);
|
||||
|
||||
if((!strcmp(subghz->txrx->decoder_result->protocol->name, "RAW"))) {
|
||||
//Load Raw TX
|
||||
@@ -276,12 +281,13 @@ int32_t subghz_app(void* p) {
|
||||
view_dispatcher_stop(subghz->view_dispatcher);
|
||||
}
|
||||
} else {
|
||||
string_set_str(subghz->file_path, SUBGHZ_APP_FOLDER);
|
||||
if(load_database) {
|
||||
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneStart);
|
||||
} else {
|
||||
scene_manager_set_scene_state(
|
||||
subghz->scene_manager, SubGhzSceneShowError, SubGhzCustomEventManagerSet);
|
||||
string_set(
|
||||
string_set_str(
|
||||
subghz->error_str,
|
||||
"No SD card or\ndatabase found.\nSome app function\nmay be reduced.");
|
||||
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneShowError);
|
||||
|
||||
@@ -303,7 +303,7 @@ void subghz_cli_command_decode_raw(Cli* cli, string_t args, void* context) {
|
||||
UNUSED(context);
|
||||
string_t file_name;
|
||||
string_init(file_name);
|
||||
string_set(file_name, "/any/subghz/test.sub");
|
||||
string_set_str(file_name, "/any/subghz/test.sub");
|
||||
|
||||
Storage* storage = furi_record_open("storage");
|
||||
FlipperFormat* fff_data_file = flipper_format_file_alloc(storage);
|
||||
|
||||
@@ -169,14 +169,14 @@ bool subghz_history_add_to_history(
|
||||
break;
|
||||
}
|
||||
if(!strcmp(string_get_cstr(instance->tmp_string), "KeeLoq")) {
|
||||
string_set(instance->tmp_string, "KL ");
|
||||
string_set_str(instance->tmp_string, "KL ");
|
||||
if(!flipper_format_read_string(item->flipper_string, "Manufacture", text)) {
|
||||
FURI_LOG_E(TAG, "Missing Protocol");
|
||||
break;
|
||||
}
|
||||
string_cat(instance->tmp_string, text);
|
||||
} else if(!strcmp(string_get_cstr(instance->tmp_string), "Star Line")) {
|
||||
string_set(instance->tmp_string, "SL ");
|
||||
string_set_str(instance->tmp_string, "SL ");
|
||||
if(!flipper_format_read_string(item->flipper_string, "Manufacture", text)) {
|
||||
FURI_LOG_E(TAG, "Missing Protocol");
|
||||
break;
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
#include "subghz_i.h"
|
||||
|
||||
#include "assets_icons.h"
|
||||
#include "m-string.h"
|
||||
#include "subghz/types.h"
|
||||
#include <math.h>
|
||||
#include <furi.h>
|
||||
#include <furi_hal.h>
|
||||
@@ -45,11 +48,11 @@ void subghz_get_frequency_modulation(SubGhz* subghz, string_t frequency, string_
|
||||
if(modulation != NULL) {
|
||||
if(subghz->txrx->preset == FuriHalSubGhzPresetOok650Async ||
|
||||
subghz->txrx->preset == FuriHalSubGhzPresetOok270Async) {
|
||||
string_set(modulation, "AM");
|
||||
string_set_str(modulation, "AM");
|
||||
} else if(
|
||||
subghz->txrx->preset == FuriHalSubGhzPreset2FSKDev238Async ||
|
||||
subghz->txrx->preset == FuriHalSubGhzPreset2FSKDev476Async) {
|
||||
string_set(modulation, "FM");
|
||||
string_set_str(modulation, "FM");
|
||||
} else {
|
||||
furi_crash("SugGhz: Modulation is incorrect.");
|
||||
}
|
||||
@@ -189,8 +192,9 @@ void subghz_tx_stop(SubGhz* subghz) {
|
||||
|
||||
//if protocol dynamic then we save the last upload
|
||||
if((subghz->txrx->decoder_result->protocol->type == SubGhzProtocolTypeDynamic) &&
|
||||
(strcmp(subghz->file_path, ""))) {
|
||||
subghz_save_protocol_to_file(subghz, subghz->txrx->fff_data, subghz->file_path);
|
||||
(subghz_path_is_file(subghz->file_path))) {
|
||||
subghz_save_protocol_to_file(
|
||||
subghz, subghz->txrx->fff_data, string_get_cstr(subghz->file_path));
|
||||
}
|
||||
subghz_idle(subghz);
|
||||
notification_message(subghz->notifications, &sequence_reset_red);
|
||||
@@ -332,10 +336,10 @@ bool subghz_get_next_name_file(SubGhz* subghz, uint8_t max_len) {
|
||||
|
||||
bool res = false;
|
||||
|
||||
if(strcmp(subghz->file_path, "")) {
|
||||
if(subghz_path_is_file(subghz->file_path)) {
|
||||
//get the name of the next free file
|
||||
path_extract_filename_no_ext(subghz->file_path, file_name);
|
||||
path_extract_dirname(subghz->file_path, file_path);
|
||||
path_extract_filename(subghz->file_path, file_name, true);
|
||||
path_extract_dirname(string_get_cstr(subghz->file_path), file_path);
|
||||
|
||||
storage_get_next_filename(
|
||||
storage,
|
||||
@@ -351,7 +355,7 @@ bool subghz_get_next_name_file(SubGhz* subghz, uint8_t max_len) {
|
||||
string_get_cstr(file_path),
|
||||
string_get_cstr(file_name),
|
||||
SUBGHZ_APP_EXTENSION);
|
||||
strncpy(subghz->file_path, string_get_cstr(temp_str), SUBGHZ_MAX_LEN_NAME);
|
||||
string_set(subghz->file_path, temp_str);
|
||||
res = true;
|
||||
}
|
||||
|
||||
@@ -411,19 +415,17 @@ bool subghz_load_protocol_from_file(SubGhz* subghz) {
|
||||
string_init(file_path);
|
||||
|
||||
// Input events and views are managed by file_select
|
||||
bool res = dialog_file_select_show(
|
||||
bool res = dialog_file_browser_show(
|
||||
subghz->dialogs,
|
||||
SUBGHZ_APP_FOLDER,
|
||||
SUBGHZ_APP_EXTENSION,
|
||||
subghz->file_path,
|
||||
sizeof(subghz->file_path),
|
||||
NULL);
|
||||
subghz->file_path,
|
||||
SUBGHZ_APP_EXTENSION,
|
||||
true,
|
||||
&I_sub1_10px,
|
||||
true);
|
||||
|
||||
if(res) {
|
||||
string_printf(
|
||||
file_path, "%s/%s%s", SUBGHZ_APP_FOLDER, subghz->file_path, SUBGHZ_APP_EXTENSION);
|
||||
strncpy(subghz->file_path, string_get_cstr(file_path), SUBGHZ_MAX_LEN_NAME);
|
||||
res = subghz_key_load(subghz, subghz->file_path);
|
||||
res = subghz_key_load(subghz, string_get_cstr(subghz->file_path));
|
||||
}
|
||||
|
||||
string_clear(file_path);
|
||||
@@ -437,9 +439,9 @@ bool subghz_rename_file(SubGhz* subghz) {
|
||||
|
||||
Storage* storage = furi_record_open("storage");
|
||||
|
||||
if(strcmp(subghz->file_path_tmp, subghz->file_path)) {
|
||||
FS_Error fs_result =
|
||||
storage_common_rename(storage, subghz->file_path_tmp, subghz->file_path);
|
||||
if(string_cmp(subghz->file_path_tmp, subghz->file_path)) {
|
||||
FS_Error fs_result = storage_common_rename(
|
||||
storage, string_get_cstr(subghz->file_path_tmp), string_get_cstr(subghz->file_path));
|
||||
|
||||
if(fs_result != FSE_OK) {
|
||||
dialog_message_show_storage_error(subghz->dialogs, "Cannot rename\n file/directory");
|
||||
@@ -455,7 +457,7 @@ bool subghz_delete_file(SubGhz* subghz) {
|
||||
furi_assert(subghz);
|
||||
|
||||
Storage* storage = furi_record_open("storage");
|
||||
bool result = storage_simply_remove(storage, subghz->file_path_tmp);
|
||||
bool result = storage_simply_remove(storage, string_get_cstr(subghz->file_path_tmp));
|
||||
furi_record_close("storage");
|
||||
|
||||
subghz_file_name_clear(subghz);
|
||||
@@ -465,8 +467,12 @@ bool subghz_delete_file(SubGhz* subghz) {
|
||||
|
||||
void subghz_file_name_clear(SubGhz* subghz) {
|
||||
furi_assert(subghz);
|
||||
memset(subghz->file_path, 0, sizeof(subghz->file_path));
|
||||
memset(subghz->file_path_tmp, 0, sizeof(subghz->file_path_tmp));
|
||||
string_set_str(subghz->file_path, SUBGHZ_APP_FOLDER);
|
||||
string_reset(subghz->file_path_tmp);
|
||||
}
|
||||
|
||||
bool subghz_path_is_file(string_t path) {
|
||||
return string_end_with_str_p(path, SUBGHZ_APP_EXTENSION);
|
||||
}
|
||||
|
||||
uint32_t subghz_random_serial(void) {
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
#include <gui/modules/variable_item_list.h>
|
||||
#include <lib/toolbox/path.h>
|
||||
|
||||
#define SUBGHZ_MAX_LEN_NAME 250
|
||||
#define SUBGHZ_MAX_LEN_NAME 64
|
||||
|
||||
/** SubGhzNotification state */
|
||||
typedef enum {
|
||||
@@ -119,10 +119,9 @@ struct SubGhz {
|
||||
TextInput* text_input;
|
||||
Widget* widget;
|
||||
DialogsApp* dialogs;
|
||||
char file_path[SUBGHZ_MAX_LEN_NAME + 1];
|
||||
char file_path_tmp[SUBGHZ_MAX_LEN_NAME + 1];
|
||||
//ToDo you can get rid of it, you need to refactor text input to return the path to the folder
|
||||
char file_dir[SUBGHZ_MAX_LEN_NAME + 1];
|
||||
string_t file_path;
|
||||
string_t file_path_tmp;
|
||||
char file_name_tmp[SUBGHZ_MAX_LEN_NAME];
|
||||
SubGhzNotificationState state_notifications;
|
||||
|
||||
SubGhzViewReceiver* subghz_receiver;
|
||||
@@ -173,5 +172,6 @@ bool subghz_load_protocol_from_file(SubGhz* subghz);
|
||||
bool subghz_rename_file(SubGhz* subghz);
|
||||
bool subghz_delete_file(SubGhz* subghz);
|
||||
void subghz_file_name_clear(SubGhz* subghz);
|
||||
bool subghz_path_is_file(string_t path);
|
||||
uint32_t subghz_random_serial(void);
|
||||
void subghz_hopper_update(SubGhz* subghz);
|
||||
|
||||
@@ -111,9 +111,9 @@ void subghz_view_receiver_add_data_statusbar(
|
||||
furi_assert(subghz_receiver);
|
||||
with_view_model(
|
||||
subghz_receiver->view, (SubGhzViewReceiverModel * model) {
|
||||
string_set(model->frequency_str, frequency_str);
|
||||
string_set(model->preset_str, preset_str);
|
||||
string_set(model->history_stat_str, history_stat_str);
|
||||
string_set_str(model->frequency_str, frequency_str);
|
||||
string_set_str(model->preset_str, preset_str);
|
||||
string_set_str(model->history_stat_str, history_stat_str);
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -46,8 +46,8 @@ void subghz_read_raw_add_data_statusbar(
|
||||
furi_assert(instance);
|
||||
with_view_model(
|
||||
instance->view, (SubGhzReadRAWModel * model) {
|
||||
string_set(model->frequency_str, frequency_str);
|
||||
string_set(model->preset_str, preset_str);
|
||||
string_set_str(model->frequency_str, frequency_str);
|
||||
string_set_str(model->preset_str, preset_str);
|
||||
return true;
|
||||
});
|
||||
}
|
||||
@@ -372,7 +372,7 @@ bool subghz_read_raw_input(InputEvent* event, void* context) {
|
||||
model->satus = SubGhzReadRAWStatusStart;
|
||||
model->rssi_history_end = false;
|
||||
model->ind_write = 0;
|
||||
string_set(model->sample_write, "0 spl.");
|
||||
string_set_str(model->sample_write, "0 spl.");
|
||||
string_reset(model->file_name);
|
||||
instance->callback(SubGhzCustomEventViewReadRAWErase, instance->context);
|
||||
}
|
||||
@@ -424,7 +424,7 @@ void subghz_read_raw_set_status(
|
||||
model->rssi_history_end = false;
|
||||
model->ind_write = 0;
|
||||
string_reset(model->file_name);
|
||||
string_set(model->sample_write, "0 spl.");
|
||||
string_set_str(model->sample_write, "0 spl.");
|
||||
return true;
|
||||
});
|
||||
break;
|
||||
@@ -441,8 +441,8 @@ void subghz_read_raw_set_status(
|
||||
model->satus = SubGhzReadRAWStatusLoadKeyIDLE;
|
||||
model->rssi_history_end = false;
|
||||
model->ind_write = 0;
|
||||
string_set(model->file_name, file_name);
|
||||
string_set(model->sample_write, "RAW");
|
||||
string_set_str(model->file_name, file_name);
|
||||
string_set_str(model->sample_write, "RAW");
|
||||
return true;
|
||||
});
|
||||
break;
|
||||
@@ -451,8 +451,8 @@ void subghz_read_raw_set_status(
|
||||
instance->view, (SubGhzReadRAWModel * model) {
|
||||
model->satus = SubGhzReadRAWStatusLoadKeyIDLE;
|
||||
if(!model->ind_write) {
|
||||
string_set(model->file_name, file_name);
|
||||
string_set(model->sample_write, "RAW");
|
||||
string_set_str(model->file_name, file_name);
|
||||
string_set_str(model->sample_write, "RAW");
|
||||
} else {
|
||||
string_reset(model->file_name);
|
||||
}
|
||||
|
||||
@@ -36,9 +36,9 @@ void subghz_view_transmitter_add_data_to_show(
|
||||
furi_assert(subghz_transmitter);
|
||||
with_view_model(
|
||||
subghz_transmitter->view, (SubGhzViewTransmitterModel * model) {
|
||||
string_set(model->key_str, key_str);
|
||||
string_set(model->frequency_str, frequency_str);
|
||||
string_set(model->preset_str, preset_str);
|
||||
string_set_str(model->key_str, key_str);
|
||||
string_set_str(model->frequency_str, frequency_str);
|
||||
string_set_str(model->preset_str, preset_str);
|
||||
model->show_button = show_button;
|
||||
return true;
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user