mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-05-22 05:14:46 -07:00
Init work on rev3, but this is not working code
This commit is contained in:
@@ -1,35 +1,29 @@
|
||||
#include <m-string.h>
|
||||
#include <subghz/types.h>
|
||||
#include <lib/toolbox/random_name.h>
|
||||
#include <gui/modules/validators.h>
|
||||
#include <lib/toolbox/path.h>
|
||||
|
||||
#include "../subbrute_i.h"
|
||||
#include "../subbrute_custom_event.h"
|
||||
#include "subbrute_scene.h"
|
||||
#include <lib/toolbox/random_name.h>
|
||||
|
||||
#define TAG "SubBruteSceneSaveFile"
|
||||
|
||||
void subbrute_scene_save_name_on_enter(void* context) {
|
||||
SubBruteState* instance = (SubBruteState*)context;
|
||||
SubBruteDevice* device = instance->device;
|
||||
|
||||
// Setup view
|
||||
TextInput* text_input = instance->text_input;
|
||||
set_random_name(device->text_store, sizeof(device->text_store));
|
||||
set_random_name(instance->text_store, sizeof(instance->text_store));
|
||||
|
||||
text_input_set_header_text(text_input, "Name of file");
|
||||
text_input_set_result_callback(
|
||||
text_input,
|
||||
subbrute_text_input_callback,
|
||||
instance,
|
||||
device->text_store,
|
||||
instance->text_store,
|
||||
SUBBRUTE_MAX_LEN_NAME,
|
||||
true);
|
||||
|
||||
string_set_str(device->load_path, SUBBRUTE_PATH);
|
||||
string_set_str(instance->file_path, SUBBRUTE_PATH);
|
||||
|
||||
ValidatorIsFile* validator_is_file =
|
||||
validator_is_file_alloc_init(string_get_cstr(device->load_path), SUBBRUTE_FILE_EXT, "");
|
||||
validator_is_file_alloc_init(string_get_cstr(instance->file_path), SUBBRUTE_FILE_EXT, "");
|
||||
text_input_set_validator(text_input, validator_is_file_callback, validator_is_file);
|
||||
|
||||
view_dispatcher_switch_to_view(instance->view_dispatcher, SubBruteViewTextInput);
|
||||
@@ -46,18 +40,14 @@ bool subbrute_scene_save_name_on_event(void* context, SceneManagerEvent event) {
|
||||
event.type == SceneManagerEventTypeCustom &&
|
||||
event.event == SubBruteCustomEventTypeTextEditDone) {
|
||||
#ifdef FURI_DEBUG
|
||||
FURI_LOG_D(TAG, "Saving: %s", instance->device->text_store);
|
||||
FURI_LOG_D(TAG, "Saving: %s", instance->text_store);
|
||||
#endif
|
||||
bool success = false;
|
||||
if(strcmp(instance->device->text_store, "")) {
|
||||
if(strcmp(instance->text_store, "")) {
|
||||
string_cat_printf(
|
||||
instance->device->load_path,
|
||||
"/%s%s",
|
||||
instance->device->text_store,
|
||||
SUBBRUTE_FILE_EXT);
|
||||
instance->file_path, "/%s%s", instance->text_store, SUBBRUTE_FILE_EXT);
|
||||
|
||||
if(subbrute_device_save_file(
|
||||
instance->device, string_get_cstr(instance->device->load_path))) {
|
||||
if(subbrute_device_save_file(instance->device, string_get_cstr(instance->file_path))) {
|
||||
scene_manager_next_scene(instance->scene_manager, SubBruteSceneSaveSuccess);
|
||||
success = true;
|
||||
consumed = true;
|
||||
@@ -83,5 +73,5 @@ void subbrute_scene_save_name_on_exit(void* context) {
|
||||
|
||||
text_input_reset(instance->text_input);
|
||||
|
||||
string_reset(instance->device->load_path);
|
||||
string_reset(instance->file_path);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user