diff --git a/examples/simple_secure_chat_ui/main.cpp b/examples/simple_secure_chat_ui/main.cpp index 7d9963760..cfc37515f 100644 --- a/examples/simple_secure_chat_ui/main.cpp +++ b/examples/simple_secure_chat_ui/main.cpp @@ -293,8 +293,12 @@ void msgstore_load_dm(const uint8_t* pub_key) { int p2 = line.indexOf('|', p1 + 1); if (p1 < 1 || p2 < p1 + 2) continue; uint32_t ts = (uint32_t) line.substring(0, p1).toInt(); + if (ts == 0) continue; // skip unsync'd entries char dir = line.charAt(p1 + 1); + if (dir != '>' && dir != '<') continue; // skip malformed direction String text = line.substring(p2 + 1); + text.trim(); + if (text.length() == 0) continue; // skip empty messages char time_buf[16]; format_time(ts, time_buf, sizeof(time_buf)); uiManager->addPrivateChatBubble(time_buf, text.c_str(), dir == '>'); @@ -315,9 +319,13 @@ void msgstore_load_public() { int p3 = line.indexOf('|', p2 + 1); if (p1 < 1 || p2 < p1 + 2 || p3 < p2 + 2) continue; uint32_t ts = (uint32_t) line.substring(0, p1).toInt(); + if (ts == 0) continue; String sender = line.substring(p1 + 1, p2); char dir = line.charAt(p2 + 1); + if (dir != '>' && dir != '<') continue; String text = line.substring(p3 + 1); + text.trim(); + if (text.length() == 0) continue; char time_buf[16]; format_time(ts, time_buf, sizeof(time_buf)); uiManager->addChatBubble(time_buf, sender.c_str(), text.c_str(), dir == '>'); diff --git a/examples/simple_secure_chat_ui/uiManager.cpp b/examples/simple_secure_chat_ui/uiManager.cpp index 6b67a532f..0fe91389e 100644 --- a/examples/simple_secure_chat_ui/uiManager.cpp +++ b/examples/simple_secure_chat_ui/uiManager.cpp @@ -1181,7 +1181,13 @@ void UIManager::ui_Screen1_screen_init(void) .scrollable(false) .clickable(true) .raw(); - lv_obj_remove_style_all(ui_DimOverlay); // no border/padding + // Remove only border/padding — do NOT use remove_style_all because it also + // resets width/height (style props in LVGL8) back to 100×100 default, + // which causes the white-square artifact when night mode activates. + lv_obj_set_style_border_width(ui_DimOverlay, 0, 0); + lv_obj_set_style_outline_width(ui_DimOverlay, 0, 0); + lv_obj_set_style_shadow_width(ui_DimOverlay, 0, 0); + lv_obj_set_style_pad_all(ui_DimOverlay, 0, 0); lv_obj_clear_flag(ui_DimOverlay, LV_OBJ_FLAG_SCROLL_CHAIN_HOR); lv_obj_clear_flag(ui_DimOverlay, LV_OBJ_FLAG_SCROLL_CHAIN_VER); @@ -1348,12 +1354,14 @@ void UIManager::ui_Screen1_screen_init(void) } void UIManager::setNightMode(bool night) { - if (!ui_DimOverlay) return; + if (night == night_mode_active) return; // debounce — avoids LVGL redraw every second + night_mode_active = night; if (night) { - lv_obj_set_style_bg_opa(ui_DimOverlay, 192, 0); // 75% dark + lv_obj_set_style_bg_color(ui_DimOverlay, lv_color_black(), 0); // explicit black + lv_obj_set_style_bg_opa(ui_DimOverlay, 192, 0); // 75% dark } else { - lv_obj_set_style_bg_opa(ui_DimOverlay, 0, 0); // none + lv_obj_set_style_bg_opa(ui_DimOverlay, 0, 0); // invisible } } diff --git a/include/uiManager.h b/include/uiManager.h index 26a8c2b87..828a8ad41 100644 --- a/include/uiManager.h +++ b/include/uiManager.h @@ -73,6 +73,7 @@ class UIManager { char currentContactName[32] = {0}; uint8_t currentContactPubKey[32] = {0}; bool hasCurrentContact = false; + bool night_mode_active = false; char myNodeName[32] = {0}; lv_obj_t* ui_ContactStatus = nullptr;