Merge branch 'fz-dev' into dev

This commit is contained in:
MX
2022-11-28 23:12:17 +03:00
109 changed files with 1267 additions and 737 deletions

View File

@@ -56,7 +56,7 @@ extern const size_t FLIPPER_DEBUG_APPS_COUNT;
extern const FlipperApplication FLIPPER_SYSTEM_APPS[];
extern const size_t FLIPPER_SYSTEM_APPS_COUNT;
/* Seperate scene app holder
/* Separate scene app holder
* Spawned by loader
*/
extern const FlipperApplication FLIPPER_SCENE;

View File

@@ -69,7 +69,7 @@ View* animation_manager_get_animation_view(AnimationManager* animation_manager);
void animation_manager_set_context(AnimationManager* animation_manager, void* context);
/**
* Set callback for Animation Manager for defered calls
* Set callback for Animation Manager for deferred calls
* for animation_manager_new_idle_process().
* Animation Manager doesn't have it's own thread, so main thread gives
* callbacks to A.M. to call when it should perform some inner manipulations.
@@ -96,7 +96,7 @@ void animation_manager_set_new_idle_callback(
void animation_manager_new_idle_process(AnimationManager* animation_manager);
/**
* Set callback for Animation Manager for defered calls
* Set callback for Animation Manager for deferred calls
* for animation_manager_check_blocking_process().
*
* @animation_manager instance
@@ -115,7 +115,7 @@ void animation_manager_set_check_callback(
void animation_manager_check_blocking_process(AnimationManager* animation_manager);
/**
* Set callback for Animation Manager for defered calls
* Set callback for Animation Manager for deferred calls
* for animation_manager_interact_process().
*
* @animation_manager instance

View File

@@ -90,7 +90,7 @@ void elements_button_center(Canvas* canvas, const char* str);
*
* @param canvas Canvas instance
* @param x, y coordinates based on align param
* @param horizontal, vertical aligment of multiline text
* @param horizontal, vertical alignment of multiline text
* @param text string (possible multiline)
*/
void elements_multiline_text_aligned(

View File

@@ -76,8 +76,8 @@ void dialog_ex_set_context(DialogEx* dialog_ex, void* context);
* @param text text to be shown, can be multiline
* @param x x position
* @param y y position
* @param horizontal horizontal text aligment
* @param vertical vertical text aligment
* @param horizontal horizontal text alignment
* @param vertical vertical text alignment
*/
void dialog_ex_set_header(
DialogEx* dialog_ex,
@@ -95,8 +95,8 @@ void dialog_ex_set_header(
* @param text text to be shown, can be multiline
* @param x x position
* @param y y position
* @param horizontal horizontal text aligment
* @param vertical vertical text aligment
* @param horizontal horizontal text alignment
* @param vertical vertical text alignment
*/
void dialog_ex_set_text(
DialogEx* dialog_ex,

View File

@@ -232,7 +232,10 @@ static bool browser_is_item_in_array(FileBrowserModel* model, uint32_t idx) {
static bool browser_is_list_load_required(FileBrowserModel* model) {
size_t array_size = items_array_size(model->items);
uint32_t item_cnt = (model->is_root) ? model->item_cnt : model->item_cnt - 1;
if((array_size > 0) && (!model->is_root) && (model->array_offset == 0)) {
array_size--;
}
uint32_t item_cnt = (model->is_root) ? (model->item_cnt) : (model->item_cnt - 1);
if((model->list_loading) || (array_size >= item_cnt)) {
return false;
@@ -524,7 +527,7 @@ static bool file_browser_view_input_callback(InputEvent* event, void* context) {
model->list_loading = true;
int32_t load_offset = CLAMP(
model->item_idx - ITEM_LIST_LEN_MAX / 4 * 3,
(int32_t)model->item_cnt - ITEM_LIST_LEN_MAX,
(int32_t)model->item_cnt,
0);
file_browser_worker_load(
browser->worker, load_offset, ITEM_LIST_LEN_MAX);
@@ -535,7 +538,7 @@ static bool file_browser_view_input_callback(InputEvent* event, void* context) {
model->list_loading = true;
int32_t load_offset = CLAMP(
model->item_idx - ITEM_LIST_LEN_MAX / 4 * 1,
(int32_t)model->item_cnt - ITEM_LIST_LEN_MAX,
(int32_t)model->item_cnt,
0);
file_browser_worker_load(
browser->worker, load_offset, ITEM_LIST_LEN_MAX);
@@ -590,6 +593,19 @@ static bool file_browser_view_input_callback(InputEvent* event, void* context) {
}
consumed = true;
}
} else if(event->key == InputKeyBack) {
if(event->type == InputTypeShort) {
bool is_root = false;
with_view_model(
browser->view, FileBrowserModel * model, { is_root = model->is_root; }, false);
if(!is_root && !file_browser_worker_is_in_start_folder(browser->worker)) {
consumed = true;
if(!is_root) {
file_browser_worker_folder_exit(browser->worker);
}
}
}
}
return consumed;

View File

@@ -37,6 +37,8 @@ struct BrowserWorker {
FuriThread* thread;
FuriString* filter_extension;
FuriString* path_start;
FuriString* path_current;
FuriString* path_next;
int32_t item_sel_idx;
uint32_t load_offset;
@@ -293,6 +295,7 @@ static int32_t browser_worker(void* context) {
int32_t file_idx = 0;
browser_folder_init(browser, path, filename, &items_cnt, &file_idx);
furi_string_set(browser->path_current, path);
FURI_LOG_D(
TAG,
"Enter folder: %s items: %lu idx: %ld",
@@ -315,6 +318,7 @@ static int32_t browser_worker(void* context) {
// Pop previous selected item index from history array
idx_last_array_pop_back(&file_idx, browser->idx_last);
}
furi_string_set(browser->path_current, path);
FURI_LOG_D(
TAG,
"Exit to: %s items: %lu idx: %ld",
@@ -369,8 +373,14 @@ BrowserWorker*
browser->filter_extension = furi_string_alloc_set(filter_ext);
browser->skip_assets = skip_assets;
browser->path_start = furi_string_alloc_set(path);
browser->path_current = furi_string_alloc_set(path);
browser->path_next = furi_string_alloc_set(path);
if(browser_path_is_file(browser->path_start)) {
browser_path_trim(browser->path_start);
}
browser->thread = furi_thread_alloc_ex("BrowserWorker", 2048, browser_worker, browser);
furi_thread_start(browser->thread);
@@ -386,6 +396,8 @@ void file_browser_worker_free(BrowserWorker* browser) {
furi_string_free(browser->filter_extension);
furi_string_free(browser->path_next);
furi_string_free(browser->path_current);
furi_string_free(browser->path_start);
idx_last_array_clear(browser->idx_last);
@@ -444,6 +456,11 @@ void file_browser_worker_folder_enter(BrowserWorker* browser, FuriString* path,
furi_thread_flags_set(furi_thread_get_id(browser->thread), WorkerEvtFolderEnter);
}
bool file_browser_worker_is_in_start_folder(BrowserWorker* browser) {
furi_assert(browser);
return (furi_string_cmp(browser->path_start, browser->path_current) == 0);
}
void file_browser_worker_folder_exit(BrowserWorker* browser) {
furi_assert(browser);
furi_thread_flags_set(furi_thread_get_id(browser->thread), WorkerEvtFolderExit);

View File

@@ -52,6 +52,8 @@ void file_browser_worker_set_config(
void file_browser_worker_folder_enter(BrowserWorker* browser, FuriString* path, int32_t item_idx);
bool file_browser_worker_is_in_start_folder(BrowserWorker* browser);
void file_browser_worker_folder_exit(BrowserWorker* browser);
void file_browser_worker_folder_refresh(BrowserWorker* browser, int32_t item_idx);

View File

@@ -64,7 +64,7 @@ void popup_set_context(Popup* popup, void* context);
* @param x x position
* @param y y position
* @param horizontal horizontal alignment
* @param vertical vertical aligment
* @param vertical vertical alignment
*/
void popup_set_header(
Popup* popup,
@@ -83,7 +83,7 @@ void popup_set_header(
* @param x x position
* @param y y position
* @param horizontal horizontal alignment
* @param vertical vertical aligment
* @param vertical vertical alignment
*/
void popup_set_text(
Popup* popup,

View File

@@ -43,7 +43,7 @@ static void text_box_process_up(TextBox* text_box) {
model->scroll_pos--;
// Reach last symbol of previous line
model->text_pos--;
// Search prevous line start
// Search previous line start
while((model->text_pos != model->text) && (*(--model->text_pos) != '\n'))
;
if(*model->text_pos == '\n') {

View File

@@ -1,6 +1,6 @@
/**
* @file text_input.h
* GUI: TextInput keybord view module API
* GUI: TextInput keyboard view module API
*/
#pragma once

View File

@@ -152,7 +152,7 @@ void view_dispatcher_remove_view(ViewDispatcher* view_dispatcher, uint32_t view_
if(view_dispatcher->current_view == view) {
view_dispatcher_set_current_view(view_dispatcher, NULL);
}
// Check if view is recieving input
// Check if view is receiving input
if(view_dispatcher->ongoing_input_view == view) {
view_dispatcher->ongoing_input_view = NULL;
}

View File

@@ -20,8 +20,8 @@ typedef enum {
InputTypePress, /**< Press event, emitted after debounce */
InputTypeRelease, /**< Release event, emitted after debounce */
InputTypeShort, /**< Short event, emitted after InputTypeRelease done withing INPUT_LONG_PRESS interval */
InputTypeLong, /**< Long event, emmited after INPUT_LONG_PRESS interval, asynchronouse to InputTypeRelease */
InputTypeRepeat, /**< Repeat event, emmited with INPUT_REPEATE_PRESS period after InputTypeLong event */
InputTypeLong, /**< Long event, emitted after INPUT_LONG_PRESS_COUNTS interval, asynchronous to InputTypeRelease */
InputTypeRepeat, /**< Repeat event, emitted with INPUT_LONG_PRESS_COUNTS period after InputTypeLong event */
InputTypeMAX, /**< Special value for exceptional */
} InputType;

View File

@@ -86,7 +86,7 @@ FuriPubSub* power_get_pubsub(Power* power);
*/
bool power_is_battery_healthy(Power* power);
/** Enable or disable battery low level notification mesage
/** Enable or disable battery low level notification message
*
* @param power Power instance
* @param enable true - enable, false - disable

View File

@@ -25,7 +25,7 @@ typedef void (*RpcSendBytesCallback)(void* context, uint8_t* bytes, size_t bytes
typedef void (*RpcBufferIsEmptyCallback)(void* context);
/** Callback to notify transport layer that close_session command
* is received. Any other actions lays on transport layer.
* No destruction or session close preformed. */
* No destruction or session close performed. */
typedef void (*RpcSessionClosedCallback)(void* context);
/** Callback to notify transport layer that session was closed
* and all operations were finished */

View File

@@ -330,7 +330,7 @@ static void rpc_system_storage_read_process(const PB_Main* request, void* contex
rpc_system_storage_reset_state(rpc_storage, session, true);
/* use same message memory to send reponse */
/* use same message memory to send response */
PB_Main* response = malloc(sizeof(PB_Main));
const char* path = request->content.storage_read_request.path;
Storage* fs_api = furi_record_open(RECORD_STORAGE);

View File

@@ -25,13 +25,13 @@ typedef enum {
typedef enum {
FSE_OK, /**< No error */
FSE_NOT_READY, /**< FS not ready */
FSE_EXIST, /**< File/Dir alrady exist */
FSE_EXIST, /**< File/Dir already exist */
FSE_NOT_EXIST, /**< File/Dir does not exist */
FSE_INVALID_PARAMETER, /**< Invalid API parameter */
FSE_DENIED, /**< Access denied */
FSE_INVALID_NAME, /**< Invalid name/path */
FSE_INTERNAL, /**< Internal error */
FSE_NOT_IMPLEMENTED, /**< Functon not implemented */
FSE_NOT_IMPLEMENTED, /**< Function not implemented */
FSE_ALREADY_OPEN, /**< File/Dir already opened */
} FS_Error;

View File

@@ -17,7 +17,7 @@ typedef enum {
struct File {
uint32_t file_id; /**< File ID for internal references */
FileType type;
FS_Error error_id; /**< Standart API error from FS_Error enum */
FS_Error error_id; /**< Standard API error from FS_Error enum */
int32_t internal_error_id; /**< Internal API error value */
void* storage;
};

View File

@@ -255,19 +255,19 @@ FS_Error storage_common_fs_info(
const char* storage_error_get_desc(FS_Error error_id);
/** Retrieves the error id from the file object
* @param file pointer to file object. Pointer must not point to NULL. YOU CANNOT RETREIVE THE ERROR ID IF THE FILE HAS BEEN CLOSED
* @param file pointer to file object. Pointer must not point to NULL. YOU CANNOT RETRIEVE THE ERROR ID IF THE FILE HAS BEEN CLOSED
* @return FS_Error error id
*/
FS_Error storage_file_get_error(File* file);
/** Retrieves the internal (storage-specific) error id from the file object
* @param file pointer to file object. Pointer must not point to NULL. YOU CANNOT RETREIVE THE INTERNAL ERROR ID IF THE FILE HAS BEEN CLOSED
* @param file pointer to file object. Pointer must not point to NULL. YOU CANNOT RETRIEVE THE INTERNAL ERROR ID IF THE FILE HAS BEEN CLOSED
* @return FS_Error error id
*/
int32_t storage_file_get_internal_error(File* file);
/** Retrieves the error text from the file object
* @param file pointer to file object. Pointer must not point to NULL. YOU CANNOT RETREIVE THE ERROR TEXT IF THE FILE HAS BEEN CLOSED
* @param file pointer to file object. Pointer must not point to NULL. YOU CANNOT RETRIEVE THE ERROR TEXT IF THE FILE HAS BEEN CLOSED
* @return const char* error text
*/
const char* storage_file_get_error_desc(File* file);