From 374e96bb7da6c053cb4ed82dbdc1ed1ee502b639 Mon Sep 17 00:00:00 2001 From: MX <10697207+xMasterX@users.noreply.github.com> Date: Fri, 3 May 2024 20:59:28 +0300 Subject: [PATCH] ibutton and lfrfid small ui improvements --- .../scenes/ibutton_scene_delete_confirm.c | 19 ++++++++++----- .../ibutton/scenes/ibutton_scene_emulate.c | 15 +++++------- .../main/ibutton/scenes/ibutton_scene_info.c | 23 ++++++++++++++----- .../main/ibutton/scenes/ibutton_scene_write.c | 13 +++++------ .../main/lfrfid/scenes/lfrfid_scene_emulate.c | 13 +++++------ .../main/lfrfid/scenes/lfrfid_scene_write.c | 10 ++++++-- .../scenes/lfrfid_scene_write_and_set_pass.c | 10 ++++++-- 7 files changed, 64 insertions(+), 39 deletions(-) diff --git a/applications/main/ibutton/scenes/ibutton_scene_delete_confirm.c b/applications/main/ibutton/scenes/ibutton_scene_delete_confirm.c index a7eba672a3..30db341d60 100644 --- a/applications/main/ibutton/scenes/ibutton_scene_delete_confirm.c +++ b/applications/main/ibutton/scenes/ibutton_scene_delete_confirm.c @@ -17,14 +17,21 @@ void ibutton_scene_delete_confirm_on_enter(void* context) { 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); + furi_string_push_back(tmp, '\n'); + + const char* protocol = + ibutton_protocols_get_name(ibutton->protocols, ibutton_key_get_protocol_id(key)); + const char* manufacturer = + ibutton_protocols_get_manufacturer(ibutton->protocols, ibutton_key_get_protocol_id(key)); + + if(strcasecmp(protocol, manufacturer) != 0 && strcasecmp(manufacturer, "N/A") != 0) { + furi_string_cat_printf(tmp, "%s ", manufacturer); + } + + furi_string_cat(tmp, protocol); + widget_add_text_box_element( widget, 0, 0, 128, 64, AlignCenter, AlignTop, furi_string_get_cstr(tmp), false); diff --git a/applications/main/ibutton/scenes/ibutton_scene_emulate.c b/applications/main/ibutton/scenes/ibutton_scene_emulate.c index 070f229109..1f3684b7a5 100644 --- a/applications/main/ibutton/scenes/ibutton_scene_emulate.c +++ b/applications/main/ibutton/scenes/ibutton_scene_emulate.c @@ -21,17 +21,14 @@ void ibutton_scene_emulate_on_enter(void* context) { widget_add_icon_element(widget, 3, 10, &I_iButtonKey_49x44); - if(furi_string_empty(ibutton->file_path)) { - furi_string_printf( - tmp, - "Unsaved\n%s", - ibutton_protocols_get_name(ibutton->protocols, ibutton_key_get_protocol_id(key))); - } else { - furi_string_printf(tmp, "%s", ibutton->key_name); - } + furi_string_printf( + tmp, + "[%s]\n%s", + ibutton_protocols_get_name(ibutton->protocols, ibutton_key_get_protocol_id(key)), + furi_string_empty(ibutton->file_path) ? "Unsaved Key" : ibutton->key_name); widget_add_text_box_element( - widget, 52, 23, 75, 26, AlignCenter, AlignTop, furi_string_get_cstr(tmp), false); + widget, 52, 24, 75, 40, AlignCenter, AlignTop, furi_string_get_cstr(tmp), true); widget_add_string_multiline_element( widget, 88, 10, AlignCenter, AlignTop, FontPrimary, "Emulating"); diff --git a/applications/main/ibutton/scenes/ibutton_scene_info.c b/applications/main/ibutton/scenes/ibutton_scene_info.c index ba72de6ca7..656e45247a 100644 --- a/applications/main/ibutton/scenes/ibutton_scene_info.c +++ b/applications/main/ibutton/scenes/ibutton_scene_info.c @@ -10,12 +10,23 @@ void ibutton_scene_info_on_enter(void* context) { FuriString* tmp = furi_string_alloc(); FuriString* brief_data = furi_string_alloc(); - furi_string_printf( - tmp, - "Name:%s\n\e#%s %s\e#\n", - ibutton->key_name, - ibutton_protocols_get_manufacturer(ibutton->protocols, protocol_id), - ibutton_protocols_get_name(ibutton->protocols, protocol_id)); + if((strcmp( + ibutton_protocols_get_manufacturer(ibutton->protocols, protocol_id), + ibutton_protocols_get_name(ibutton->protocols, protocol_id)) != 0) && + (strcmp(ibutton_protocols_get_manufacturer(ibutton->protocols, protocol_id), "N/A") != 0)) { + furi_string_printf( + tmp, + "Name:%s\n\e#%s %s\e#\n", + ibutton->key_name, + ibutton_protocols_get_manufacturer(ibutton->protocols, protocol_id), + ibutton_protocols_get_name(ibutton->protocols, protocol_id)); + } else { + furi_string_printf( + tmp, + "Name:%s\n\e#%s\e#\n", + ibutton->key_name, + ibutton_protocols_get_name(ibutton->protocols, protocol_id)); + } ibutton_protocols_render_brief_data(ibutton->protocols, key, brief_data); diff --git a/applications/main/ibutton/scenes/ibutton_scene_write.c b/applications/main/ibutton/scenes/ibutton_scene_write.c index f8a0971ecd..0fc073fdae 100644 --- a/applications/main/ibutton/scenes/ibutton_scene_write.c +++ b/applications/main/ibutton/scenes/ibutton_scene_write.c @@ -40,15 +40,14 @@ void ibutton_scene_write_on_enter(void* context) { widget_add_icon_element(widget, 3, 10, &I_iButtonKey_49x44); - if(furi_string_empty(ibutton->file_path)) { - furi_string_printf( - tmp, "Unsaved\n%s", ibutton_protocols_get_name(ibutton->protocols, protocol_id)); - } else { - furi_string_printf(tmp, "%s", ibutton->key_name); - } + furi_string_printf( + tmp, + "[%s]\n%s", + ibutton_protocols_get_name(ibutton->protocols, protocol_id), + furi_string_empty(ibutton->file_path) ? "Unsaved Key" : ibutton->key_name); widget_add_text_box_element( - widget, 52, 23, 75, 26, AlignCenter, AlignTop, furi_string_get_cstr(tmp), false); + widget, 52, 24, 75, 40, AlignCenter, AlignTop, furi_string_get_cstr(tmp), true); ibutton_worker_write_set_callback(worker, ibutton_scene_write_callback, ibutton); diff --git a/applications/main/lfrfid/scenes/lfrfid_scene_emulate.c b/applications/main/lfrfid/scenes/lfrfid_scene_emulate.c index 049c24d002..b606666953 100644 --- a/applications/main/lfrfid/scenes/lfrfid_scene_emulate.c +++ b/applications/main/lfrfid/scenes/lfrfid_scene_emulate.c @@ -6,16 +6,15 @@ void lfrfid_scene_emulate_on_enter(void* context) { FuriString* display_text = furi_string_alloc_set("\e#Emulating\e#\n"); - if(furi_string_empty(app->file_name)) { - furi_string_cat(display_text, "Unsaved\n"); - furi_string_cat(display_text, protocol_dict_get_name(app->dict, app->protocol_id)); - } else { - furi_string_cat(display_text, app->file_name); - } + furi_string_cat_printf( + display_text, + "[%s]\n%s", + protocol_dict_get_name(app->dict, app->protocol_id), + furi_string_empty(app->file_name) ? "Unsaved Tag" : furi_string_get_cstr(app->file_name)); widget_add_icon_element(widget, 0, 0, &I_NFC_dolphin_emulation_51x64); widget_add_text_box_element( - widget, 55, 16, 67, 48, AlignCenter, AlignTop, furi_string_get_cstr(display_text), true); + widget, 51, 6, 79, 50, AlignCenter, AlignTop, furi_string_get_cstr(display_text), false); furi_string_free(display_text); diff --git a/applications/main/lfrfid/scenes/lfrfid_scene_write.c b/applications/main/lfrfid/scenes/lfrfid_scene_write.c index 55973d09d7..b9d0d4b2ec 100644 --- a/applications/main/lfrfid/scenes/lfrfid_scene_write.c +++ b/applications/main/lfrfid/scenes/lfrfid_scene_write.c @@ -25,12 +25,18 @@ void lfrfid_scene_write_on_enter(void* context) { popup_set_header(popup, "Writing", 94, 16, AlignCenter, AlignTop); if(!furi_string_empty(app->file_name)) { - popup_set_text(popup, furi_string_get_cstr(app->file_name), 94, 29, AlignCenter, AlignTop); + snprintf( + app->text_store, + LFRFID_TEXT_STORE_SIZE, + "[%s]\n%s", + protocol_dict_get_name(app->dict, app->protocol_id), + furi_string_get_cstr(app->file_name)); + popup_set_text(popup, app->text_store, 94, 29, AlignCenter, AlignTop); } else { snprintf( app->text_store, LFRFID_TEXT_STORE_SIZE, - "Unsaved\n%s", + "[%s]\nUnsaved Tag", protocol_dict_get_name(app->dict, app->protocol_id)); popup_set_text(popup, app->text_store, 94, 29, AlignCenter, AlignTop); } diff --git a/applications/main/lfrfid/scenes/lfrfid_scene_write_and_set_pass.c b/applications/main/lfrfid/scenes/lfrfid_scene_write_and_set_pass.c index 275a3e8893..b8b443c66b 100644 --- a/applications/main/lfrfid/scenes/lfrfid_scene_write_and_set_pass.c +++ b/applications/main/lfrfid/scenes/lfrfid_scene_write_and_set_pass.c @@ -22,8 +22,14 @@ void lfrfid_scene_write_and_set_pass_on_enter(void* context) { LfRfid* app = context; Popup* popup = app->popup; - popup_set_header(popup, "Writing\nwith password", 89, 30, AlignCenter, AlignTop); - popup_set_icon(popup, 0, 3, &I_RFIDDolphinSend_97x61); + popup_set_header(popup, "Writing\nwith\npassword", 94, 8, AlignCenter, AlignTop); + popup_set_icon(popup, 0, 8, &I_NFC_manual_60x50); + snprintf( + app->text_store, + LFRFID_TEXT_STORE_SIZE, + "[%s]", + protocol_dict_get_name(app->dict, app->protocol_id)); + popup_set_text(popup, app->text_store, 94, 45, AlignCenter, AlignTop); view_dispatcher_switch_to_view(app->view_dispatcher, LfRfidViewPopup);