[FL-1849] NFC and iButton gui fixes (#943)
* nfc: fix spaces between lines in delete and info scenes * gui widget: add extern c * ibutton: rework gui in info and delete scenes * Loader, Desktop: fix debug apps and plugins start from cli, fix deadlock in archive Co-authored-by: あく <alleteam@gmail.com>
This commit is contained in:
56
applications/ibutton/scene/ibutton-scene-delete-confirm.cpp
Normal file → Executable file
56
applications/ibutton/scene/ibutton-scene-delete-confirm.cpp
Normal file → Executable file
@@ -6,17 +6,22 @@
|
||||
|
||||
void iButtonSceneDeleteConfirm::on_enter(iButtonApp* app) {
|
||||
iButtonAppViewManager* view_manager = app->get_view_manager();
|
||||
DialogEx* dialog_ex = view_manager->get_dialog_ex();
|
||||
auto callback = cbc::obtain_connector(this, &iButtonSceneDeleteConfirm::dialog_ex_callback);
|
||||
Widget* widget = view_manager->get_widget();
|
||||
auto callback = cbc::obtain_connector(this, &iButtonSceneDeleteConfirm::widget_callback);
|
||||
|
||||
iButtonKey* key = app->get_key();
|
||||
uint8_t* key_data = key->get_data();
|
||||
|
||||
app->set_text_store("\e#Delete %s?\e#", key->get_name());
|
||||
widget_add_text_box_element(
|
||||
widget, 0, 0, 128, 23, AlignCenter, AlignCenter, app->get_text_store());
|
||||
widget_add_button_element(widget, GuiButtonTypeLeft, "Back", callback, app);
|
||||
widget_add_button_element(widget, GuiButtonTypeRight, "Delete", callback, app);
|
||||
|
||||
switch(key->get_key_type()) {
|
||||
case iButtonKeyType::KeyDallas:
|
||||
app->set_text_store(
|
||||
"Delete %s?\nID: %02X %02X %02X %02X %02X %02X %02X %02X\nType: Dallas",
|
||||
key->get_name(),
|
||||
"%02X %02X %02X %02X %02X %02X %02X %02X\nDallas",
|
||||
key_data[0],
|
||||
key_data[1],
|
||||
key_data[2],
|
||||
@@ -27,34 +32,24 @@ void iButtonSceneDeleteConfirm::on_enter(iButtonApp* app) {
|
||||
key_data[7]);
|
||||
break;
|
||||
case iButtonKeyType::KeyCyfral:
|
||||
app->set_text_store(
|
||||
"Delete %s?\nID: %02X %02X\nType: Cyfral", key->get_name(), key_data[0], key_data[1]);
|
||||
app->set_text_store("%02X %02X\nCyfral", key_data[0], key_data[1]);
|
||||
break;
|
||||
case iButtonKeyType::KeyMetakom:
|
||||
app->set_text_store(
|
||||
"Delete %s?\nID: %02X %02X %02X %02X\nType: Metakom",
|
||||
key->get_name(),
|
||||
key_data[0],
|
||||
key_data[1],
|
||||
key_data[2],
|
||||
key_data[3]);
|
||||
"%02X %02X %02X %02X\nMetakom", key_data[0], key_data[1], key_data[2], key_data[3]);
|
||||
break;
|
||||
}
|
||||
widget_add_string_multiline_element(
|
||||
widget, 64, 23, AlignCenter, AlignTop, FontSecondary, app->get_text_store());
|
||||
|
||||
dialog_ex_set_text(dialog_ex, app->get_text_store(), 64, 20, AlignCenter, AlignCenter);
|
||||
dialog_ex_set_left_button_text(dialog_ex, "Back");
|
||||
dialog_ex_set_right_button_text(dialog_ex, "Delete");
|
||||
dialog_ex_set_result_callback(dialog_ex, callback);
|
||||
dialog_ex_set_context(dialog_ex, app);
|
||||
|
||||
view_manager->switch_to(iButtonAppViewManager::Type::iButtonAppViewDialogEx);
|
||||
view_manager->switch_to(iButtonAppViewManager::Type::iButtonAppViewWidget);
|
||||
}
|
||||
|
||||
bool iButtonSceneDeleteConfirm::on_event(iButtonApp* app, iButtonEvent* event) {
|
||||
bool consumed = false;
|
||||
|
||||
if(event->type == iButtonEvent::Type::EventTypeDialogResult) {
|
||||
if(event->payload.dialog_result == DialogExResultRight) {
|
||||
if(event->type == iButtonEvent::Type::EventTypeWidgetButtonResult) {
|
||||
if(event->payload.widget_button_result == GuiButtonTypeRight) {
|
||||
if(app->delete_key()) {
|
||||
app->switch_to_next_scene(iButtonApp::Scene::SceneDeleteSuccess);
|
||||
}
|
||||
@@ -70,23 +65,24 @@ bool iButtonSceneDeleteConfirm::on_event(iButtonApp* app, iButtonEvent* event) {
|
||||
|
||||
void iButtonSceneDeleteConfirm::on_exit(iButtonApp* app) {
|
||||
iButtonAppViewManager* view_manager = app->get_view_manager();
|
||||
DialogEx* dialog_ex = view_manager->get_dialog_ex();
|
||||
Widget* widget = view_manager->get_widget();
|
||||
|
||||
app->set_text_store("");
|
||||
|
||||
dialog_ex_set_text(dialog_ex, NULL, 0, 0, AlignCenter, AlignTop);
|
||||
dialog_ex_set_left_button_text(dialog_ex, NULL);
|
||||
dialog_ex_set_right_button_text(dialog_ex, NULL);
|
||||
dialog_ex_set_result_callback(dialog_ex, NULL);
|
||||
dialog_ex_set_context(dialog_ex, NULL);
|
||||
widget_clear(widget);
|
||||
}
|
||||
|
||||
void iButtonSceneDeleteConfirm::dialog_ex_callback(DialogExResult result, void* context) {
|
||||
void iButtonSceneDeleteConfirm::widget_callback(
|
||||
GuiButtonType result,
|
||||
InputType type,
|
||||
void* context) {
|
||||
iButtonApp* app = static_cast<iButtonApp*>(context);
|
||||
iButtonEvent event;
|
||||
|
||||
event.type = iButtonEvent::Type::EventTypeDialogResult;
|
||||
event.payload.dialog_result = result;
|
||||
if(type == InputTypeShort) {
|
||||
event.type = iButtonEvent::Type::EventTypeWidgetButtonResult;
|
||||
event.payload.widget_button_result = result;
|
||||
}
|
||||
|
||||
app->get_view_manager()->send_event(&event);
|
||||
}
|
@@ -1,6 +1,5 @@
|
||||
#pragma once
|
||||
#include "ibutton-scene-generic.h"
|
||||
#include <gui/modules/dialog_ex.h>
|
||||
|
||||
class iButtonSceneDeleteConfirm : public iButtonScene {
|
||||
public:
|
||||
@@ -9,5 +8,5 @@ public:
|
||||
void on_exit(iButtonApp* app) final;
|
||||
|
||||
private:
|
||||
void dialog_ex_callback(DialogExResult result, void* context);
|
||||
void widget_callback(GuiButtonType result, InputType type, void* context);
|
||||
};
|
51
applications/ibutton/scene/ibutton-scene-info.cpp
Normal file → Executable file
51
applications/ibutton/scene/ibutton-scene-info.cpp
Normal file → Executable file
@@ -6,17 +6,21 @@
|
||||
|
||||
void iButtonSceneInfo::on_enter(iButtonApp* app) {
|
||||
iButtonAppViewManager* view_manager = app->get_view_manager();
|
||||
DialogEx* dialog_ex = view_manager->get_dialog_ex();
|
||||
auto callback = cbc::obtain_connector(this, &iButtonSceneInfo::dialog_ex_callback);
|
||||
Widget* widget = view_manager->get_widget();
|
||||
auto callback = cbc::obtain_connector(this, &iButtonSceneInfo::widget_callback);
|
||||
|
||||
iButtonKey* key = app->get_key();
|
||||
uint8_t* key_data = key->get_data();
|
||||
|
||||
app->set_text_store("%s", key->get_name());
|
||||
widget_add_text_box_element(
|
||||
widget, 0, 0, 128, 23, AlignCenter, AlignCenter, app->get_text_store());
|
||||
widget_add_button_element(widget, GuiButtonTypeLeft, "Back", callback, app);
|
||||
|
||||
switch(key->get_key_type()) {
|
||||
case iButtonKeyType::KeyDallas:
|
||||
app->set_text_store(
|
||||
"%s\n%02X %02X %02X %02X %02X %02X %02X %02X\nDallas",
|
||||
key->get_name(),
|
||||
"\e#%02X %02X %02X %02X %02X %02X %02X %02X\e#\nDallas",
|
||||
key_data[0],
|
||||
key_data[1],
|
||||
key_data[2],
|
||||
@@ -28,32 +32,30 @@ void iButtonSceneInfo::on_enter(iButtonApp* app) {
|
||||
break;
|
||||
case iButtonKeyType::KeyMetakom:
|
||||
app->set_text_store(
|
||||
"%s\n%02X %02X %02X %02X\nMetakom",
|
||||
key->get_name(),
|
||||
"\e#%02X %02X %02X %02X\e#\nMetakom",
|
||||
key_data[0],
|
||||
key_data[1],
|
||||
key_data[2],
|
||||
key_data[3]);
|
||||
break;
|
||||
case iButtonKeyType::KeyCyfral:
|
||||
app->set_text_store("%s\n%02X %02X\nCyfral", key->get_name(), key_data[0], key_data[1]);
|
||||
app->set_text_store("\e#%02X %02X\e#\nCyfral", key_data[0], key_data[1]);
|
||||
break;
|
||||
}
|
||||
widget_add_text_box_element(
|
||||
widget, 0, 23, 128, 40, AlignCenter, AlignTop, app->get_text_store());
|
||||
|
||||
dialog_ex_set_text(dialog_ex, app->get_text_store(), 64, 26, AlignCenter, AlignCenter);
|
||||
dialog_ex_set_left_button_text(dialog_ex, "Back");
|
||||
dialog_ex_set_result_callback(dialog_ex, callback);
|
||||
dialog_ex_set_context(dialog_ex, app);
|
||||
|
||||
view_manager->switch_to(iButtonAppViewManager::Type::iButtonAppViewDialogEx);
|
||||
view_manager->switch_to(iButtonAppViewManager::Type::iButtonAppViewWidget);
|
||||
}
|
||||
|
||||
bool iButtonSceneInfo::on_event(iButtonApp* app, iButtonEvent* event) {
|
||||
bool consumed = false;
|
||||
|
||||
if(event->type == iButtonEvent::Type::EventTypeDialogResult) {
|
||||
app->switch_to_previous_scene();
|
||||
consumed = true;
|
||||
if(event->type == iButtonEvent::Type::EventTypeWidgetButtonResult) {
|
||||
if(event->payload.widget_button_result == GuiButtonTypeLeft) {
|
||||
app->switch_to_previous_scene();
|
||||
consumed = true;
|
||||
}
|
||||
}
|
||||
|
||||
return consumed;
|
||||
@@ -61,22 +63,21 @@ bool iButtonSceneInfo::on_event(iButtonApp* app, iButtonEvent* event) {
|
||||
|
||||
void iButtonSceneInfo::on_exit(iButtonApp* app) {
|
||||
iButtonAppViewManager* view_manager = app->get_view_manager();
|
||||
DialogEx* dialog_ex = view_manager->get_dialog_ex();
|
||||
Widget* widget = view_manager->get_widget();
|
||||
|
||||
app->set_text_store("");
|
||||
|
||||
dialog_ex_set_text(dialog_ex, NULL, 0, 0, AlignCenter, AlignTop);
|
||||
dialog_ex_set_left_button_text(dialog_ex, NULL);
|
||||
dialog_ex_set_result_callback(dialog_ex, NULL);
|
||||
dialog_ex_set_context(dialog_ex, NULL);
|
||||
widget_clear(widget);
|
||||
}
|
||||
|
||||
void iButtonSceneInfo::dialog_ex_callback(DialogExResult result, void* context) {
|
||||
void iButtonSceneInfo::widget_callback(GuiButtonType result, InputType type, void* context) {
|
||||
iButtonApp* app = static_cast<iButtonApp*>(context);
|
||||
iButtonEvent event;
|
||||
|
||||
event.type = iButtonEvent::Type::EventTypeDialogResult;
|
||||
event.payload.dialog_result = result;
|
||||
if(type == InputTypeShort) {
|
||||
event.type = iButtonEvent::Type::EventTypeWidgetButtonResult;
|
||||
event.payload.widget_button_result = result;
|
||||
}
|
||||
|
||||
app->get_view_manager()->send_event(&event);
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,5 @@
|
||||
#pragma once
|
||||
#include "ibutton-scene-generic.h"
|
||||
#include <gui/modules/dialog_ex.h>
|
||||
|
||||
class iButtonSceneInfo : public iButtonScene {
|
||||
public:
|
||||
@@ -9,5 +8,5 @@ public:
|
||||
void on_exit(iButtonApp* app) final;
|
||||
|
||||
private:
|
||||
void dialog_ex_callback(DialogExResult result, void* context);
|
||||
void widget_callback(GuiButtonType result, InputType type, void* context);
|
||||
};
|
Reference in New Issue
Block a user