2022-05-06 16:48:39 +00:00
|
|
|
#include "../ibutton_i.h"
|
2022-05-27 11:19:21 +00:00
|
|
|
#include <toolbox/path.h>
|
2022-05-06 16:48:39 +00:00
|
|
|
|
|
|
|
void ibutton_scene_delete_confirm_on_enter(void* context) {
|
|
|
|
iButton* ibutton = context;
|
|
|
|
iButtonKey* key = ibutton->key;
|
2023-03-02 13:23:33 +00:00
|
|
|
Widget* widget = ibutton->widget;
|
2022-05-06 16:48:39 +00:00
|
|
|
|
2023-03-02 13:23:33 +00:00
|
|
|
FuriString* tmp = furi_string_alloc();
|
2024-04-17 23:05:37 +00:00
|
|
|
FuriString* uid = furi_string_alloc();
|
2022-05-27 11:19:21 +00:00
|
|
|
|
2023-03-02 13:23:33 +00:00
|
|
|
widget_add_button_element(widget, GuiButtonTypeLeft, "Back", ibutton_widget_callback, context);
|
2022-05-06 16:48:39 +00:00
|
|
|
widget_add_button_element(
|
2023-03-02 13:23:33 +00:00
|
|
|
widget, GuiButtonTypeRight, "Delete", ibutton_widget_callback, context);
|
2022-05-06 16:48:39 +00:00
|
|
|
|
2024-04-17 23:05:37 +00:00
|
|
|
furi_string_printf(tmp, "\e#Delete %s?\e#\n", ibutton->key_name);
|
|
|
|
|
|
|
|
ibutton_protocols_render_uid(ibutton->protocols, key, uid);
|
|
|
|
|
|
|
|
furi_string_cat_printf(
|
|
|
|
uid,
|
|
|
|
"\n%s %s",
|
|
|
|
ibutton_protocols_get_manufacturer(ibutton->protocols, ibutton_key_get_protocol_id(key)),
|
|
|
|
ibutton_protocols_get_name(ibutton->protocols, ibutton_key_get_protocol_id(key)));
|
|
|
|
|
|
|
|
furi_string_cat(tmp, uid);
|
|
|
|
|
2023-07-17 08:03:27 +00:00
|
|
|
widget_add_text_box_element(
|
2024-04-17 23:05:37 +00:00
|
|
|
widget, 0, 0, 128, 64, AlignCenter, AlignTop, furi_string_get_cstr(tmp), false);
|
2022-05-06 16:48:39 +00:00
|
|
|
|
2023-03-02 13:23:33 +00:00
|
|
|
furi_string_reset(tmp);
|
2024-04-17 23:05:37 +00:00
|
|
|
furi_string_reset(uid);
|
2022-05-06 16:48:39 +00:00
|
|
|
|
|
|
|
view_dispatcher_switch_to_view(ibutton->view_dispatcher, iButtonViewWidget);
|
2023-03-02 13:23:33 +00:00
|
|
|
furi_string_free(tmp);
|
2024-04-17 23:05:37 +00:00
|
|
|
furi_string_free(uid);
|
2022-05-06 16:48:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool ibutton_scene_delete_confirm_on_event(void* context, SceneManagerEvent event) {
|
|
|
|
iButton* ibutton = context;
|
|
|
|
SceneManager* scene_manager = ibutton->scene_manager;
|
|
|
|
bool consumed = false;
|
|
|
|
|
|
|
|
if(event.type == SceneManagerEventTypeCustom) {
|
|
|
|
consumed = true;
|
|
|
|
if(event.event == GuiButtonTypeRight) {
|
|
|
|
if(ibutton_delete_key(ibutton)) {
|
|
|
|
scene_manager_next_scene(scene_manager, iButtonSceneDeleteSuccess);
|
2023-03-02 13:23:33 +00:00
|
|
|
} else {
|
|
|
|
dialog_message_show_storage_error(ibutton->dialogs, "Cannot delete\nkey file");
|
|
|
|
scene_manager_previous_scene(scene_manager);
|
2022-05-06 16:48:39 +00:00
|
|
|
}
|
|
|
|
} else if(event.event == GuiButtonTypeLeft) {
|
|
|
|
scene_manager_previous_scene(scene_manager);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return consumed;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ibutton_scene_delete_confirm_on_exit(void* context) {
|
|
|
|
iButton* ibutton = context;
|
|
|
|
widget_reset(ibutton->widget);
|
|
|
|
}
|