[FL-1962, FL-2464, FL-2465, FL-2466, FL-2560, FL-2637, FL-2595] Ibutton, Infrared, LfRFID GUI fixes (#1392)

* Ibutton, Infrared, LfRFID GUI fixes
* Loading screens update

Co-authored-by: あく <alleteam@gmail.com>
This commit is contained in:
Nikolay Minaylov
2022-07-17 10:41:16 +03:00
committed by GitHub
parent edc6ca0c8f
commit 877c5c8122
30 changed files with 147 additions and 44 deletions

View File

@@ -125,6 +125,10 @@ Nfc* nfc_alloc() {
nfc->popup = popup_alloc();
view_dispatcher_add_view(nfc->view_dispatcher, NfcViewPopup, popup_get_view(nfc->popup));
// Loading
nfc->loading = loading_alloc();
view_dispatcher_add_view(nfc->view_dispatcher, NfcViewLoading, loading_get_view(nfc->loading));
// Text Input
nfc->text_input = text_input_alloc();
view_dispatcher_add_view(
@@ -179,6 +183,10 @@ void nfc_free(Nfc* nfc) {
view_dispatcher_remove_view(nfc->view_dispatcher, NfcViewPopup);
popup_free(nfc->popup);
// Loading
view_dispatcher_remove_view(nfc->view_dispatcher, NfcViewLoading);
loading_free(nfc->loading);
// TextInput
view_dispatcher_remove_view(nfc->view_dispatcher, NfcViewTextInput);
text_input_free(nfc->text_input);
@@ -258,12 +266,27 @@ void nfc_blink_stop(Nfc* nfc) {
notification_message(nfc->notifications, &sequence_blink_stop);
}
void nfc_show_loading_popup(void* context, bool show) {
Nfc* nfc = context;
TaskHandle_t timer_task = xTaskGetHandle(configTIMER_SERVICE_TASK_NAME);
if(show) {
// Raise timer priority so that animations can play
vTaskPrioritySet(timer_task, configMAX_PRIORITIES - 1);
view_dispatcher_switch_to_view(nfc->view_dispatcher, NfcViewLoading);
} else {
// Restore default timer priority
vTaskPrioritySet(timer_task, configTIMER_TASK_PRIORITY);
}
}
int32_t nfc_app(void* p) {
Nfc* nfc = nfc_alloc();
char* args = p;
// Check argument and run corresponding scene
if((*args != '\0')) {
nfc_device_set_loading_callback(nfc->dev, nfc_show_loading_popup, nfc);
uint32_t rpc_ctx = 0;
if(sscanf(p, "RPC %lX", &rpc_ctx) == 1) {
nfc->rpc_ctx = (void*)rpc_ctx;
@@ -281,6 +304,7 @@ int32_t nfc_app(void* p) {
// Exit app
view_dispatcher_stop(nfc->view_dispatcher);
}
nfc_device_set_loading_callback(nfc->dev, NULL, nfc);
} else {
scene_manager_next_scene(nfc->scene_manager, NfcSceneStart);
}

View File

@@ -846,6 +846,10 @@ static bool nfc_device_load_data(NfcDevice* dev, string_t path, bool show_dialog
string_init(temp_str);
bool deprecated_version = false;
if(dev->loading_cb) {
dev->loading_cb(dev->loading_cb_ctx, true);
}
do {
// Check existance of shadow file
nfc_device_get_shadow_path(path, temp_str);
@@ -887,6 +891,10 @@ static bool nfc_device_load_data(NfcDevice* dev, string_t path, bool show_dialog
parsed = true;
} while(false);
if(dev->loading_cb) {
dev->loading_cb(dev->loading_cb_ctx, false);
}
if((!parsed) && (show_dialog)) {
if(deprecated_version) {
dialog_message_show_storage_error(dev->dialogs, "File format deprecated");
@@ -1024,3 +1032,10 @@ bool nfc_device_restore(NfcDevice* dev, bool use_load_path) {
string_clear(path);
return restored;
}
void nfc_device_set_loading_callback(NfcDevice* dev, NfcLoadingCallback callback, void* context) {
furi_assert(dev);
dev->loading_cb = callback;
dev->loading_cb_ctx = context;
}

View File

@@ -18,6 +18,8 @@
#define NFC_APP_EXTENSION ".nfc"
#define NFC_APP_SHADOW_EXTENSION ".shd"
typedef void (*NfcLoadingCallback)(void* context, bool state);
typedef enum {
NfcDeviceProtocolUnknown,
NfcDeviceProtocolEMV,
@@ -59,6 +61,9 @@ typedef struct {
string_t load_path;
NfcDeviceSaveFormat format;
bool shadow_file_exist;
NfcLoadingCallback loading_cb;
void* loading_cb_ctx;
} NfcDevice;
NfcDevice* nfc_device_alloc();
@@ -82,3 +87,5 @@ void nfc_device_clear(NfcDevice* dev);
bool nfc_device_delete(NfcDevice* dev, bool use_load_path);
bool nfc_device_restore(NfcDevice* dev, bool use_load_path);
void nfc_device_set_loading_callback(NfcDevice* dev, NfcLoadingCallback callback, void* context);

View File

@@ -18,6 +18,7 @@
#include <gui/modules/submenu.h>
#include <gui/modules/dialog_ex.h>
#include <gui/modules/popup.h>
#include <gui/modules/loading.h>
#include <gui/modules/text_input.h>
#include <gui/modules/byte_input.h>
#include <gui/modules/text_box.h>
@@ -63,6 +64,7 @@ struct Nfc {
Submenu* submenu;
DialogEx* dialog_ex;
Popup* popup;
Loading* loading;
TextInput* text_input;
ByteInput* byte_input;
TextBox* text_box;
@@ -77,6 +79,7 @@ typedef enum {
NfcViewMenu,
NfcViewDialogEx,
NfcViewPopup,
NfcViewLoading,
NfcViewTextInput,
NfcViewByteInput,
NfcViewTextBox,
@@ -97,4 +100,6 @@ void nfc_blink_start(Nfc* nfc);
void nfc_blink_stop(Nfc* nfc);
void nfc_show_loading_popup(void* context, bool show);
void nfc_rpc_exit_callback(Nfc* nfc);

View File

@@ -1,13 +1,16 @@
#include "../nfc_i.h"
#include "nfc/nfc_device.h"
void nfc_scene_file_select_on_enter(void* context) {
Nfc* nfc = context;
// Process file_select return
nfc_device_set_loading_callback(nfc->dev, nfc_show_loading_popup, nfc);
if(nfc_file_select(nfc->dev)) {
scene_manager_next_scene(nfc->scene_manager, NfcSceneSavedMenu);
} else {
scene_manager_search_and_switch_to_previous_scene(nfc->scene_manager, NfcSceneStart);
}
nfc_device_set_loading_callback(nfc->dev, NULL, nfc);
}
bool nfc_scene_file_select_on_event(void* context, SceneManagerEvent event) {