[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:
Nikolay Minaylov
2022-05-27 14:19:21 +03:00
committed by GitHub
parent 533f12af15
commit 79920a3522
82 changed files with 2025 additions and 1007 deletions

View File

@@ -1,4 +1,6 @@
#include "../infrared_app.h"
#include "m-string.h"
#include "toolbox/path.h"
void InfraredAppSceneEditRename::on_enter(InfraredApp* app) {
InfraredAppViewManager* view_manager = app->get_view_manager();
@@ -21,9 +23,18 @@ void InfraredAppSceneEditRename::on_enter(InfraredApp* app) {
enter_name_length = InfraredAppRemoteManager::max_remote_name_length;
text_input_set_header_text(text_input, "Name the remote");
string_t folder_path;
string_init(folder_path);
if(string_end_with_str_p(app->file_path, InfraredApp::infrared_extension)) {
path_extract_dirname(string_get_cstr(app->file_path), folder_path);
}
ValidatorIsFile* validator_is_file = validator_is_file_alloc_init(
app->infrared_directory, app->infrared_extension, remote_name.c_str());
string_get_cstr(folder_path), app->infrared_extension, remote_name.c_str());
text_input_set_validator(text_input, validator_is_file_callback, validator_is_file);
string_clear(folder_path);
}
text_input_set_result_callback(

View File

@@ -1,4 +1,5 @@
#include "../infrared_app.h"
#include "assets_icons.h"
#include "infrared/infrared_app_event.h"
#include <text_store.h>
@@ -8,11 +9,6 @@ void InfraredAppSceneRemoteList::on_enter(InfraredApp* app) {
bool result = false;
bool file_select_result;
auto remote_manager = app->get_remote_manager();
auto last_selected_remote = remote_manager->get_remote_name();
const char* last_selected_remote_name =
last_selected_remote.size() ? last_selected_remote.c_str() : nullptr;
auto filename_ts =
std::make_unique<TextStore>(InfraredAppRemoteManager::max_remote_name_length);
DialogsApp* dialogs = app->get_dialogs();
InfraredAppViewManager* view_manager = app->get_view_manager();
@@ -20,16 +16,17 @@ void InfraredAppSceneRemoteList::on_enter(InfraredApp* app) {
button_menu_reset(button_menu);
view_manager->switch_to(InfraredAppViewManager::ViewId::ButtonMenu);
file_select_result = dialog_file_select_show(
file_select_result = dialog_file_browser_show(
dialogs,
InfraredApp::infrared_directory,
app->file_path,
app->file_path,
InfraredApp::infrared_extension,
filename_ts->text,
filename_ts->text_size,
last_selected_remote_name);
true,
&I_ir_10px,
true);
if(file_select_result) {
if(remote_manager->load(InfraredApp::infrared_directory, std::string(filename_ts->text))) {
if(remote_manager->load(app->file_path)) {
app->switch_to_next_scene(InfraredApp::Scene::Remote);
result = true;
}

View File

@@ -26,6 +26,8 @@ void InfraredAppSceneStart::on_enter(InfraredApp* app) {
submenu, "Learn New Remote", SubmenuIndexLearnNewRemote, submenu_callback, app);
submenu_add_item(submenu, "Saved Remotes", SubmenuIndexSavedRemotes, submenu_callback, app);
submenu_set_selected_item(submenu, submenu_item_selected);
string_set_str(app->file_path, InfraredApp::infrared_directory);
submenu_item_selected = 0;
view_manager->switch_to(InfraredAppViewManager::ViewId::Submenu);