diff --git a/examples/companion_radio/ui-new/UITask.cpp b/examples/companion_radio/ui-new/UITask.cpp index 8c9b3167..030852e5 100644 --- a/examples/companion_radio/ui-new/UITask.cpp +++ b/examples/companion_radio/ui-new/UITask.cpp @@ -911,6 +911,12 @@ public: } } + int getTotalChannelUnread() const { + int total = 0; + for (int i = 0; i < MAX_GROUP_CHANNELS; i++) total += _ch_unread[i]; + return total; + } + void reset() { _phase = MODE_SELECT; _mode_sel = 0; @@ -1950,16 +1956,14 @@ public: } else if (_page == HomePage::QUICK_MSG) { display.setColor(DisplayDriver::LIGHT); display.setTextSize(1); - display.drawTextCentered(display.width() / 2, 30, "Messages"); - int dm_unread = _task->getMsgCount(); - if (dm_unread > 0) { - char badge[16]; - snprintf(badge, sizeof(badge), "%d unread DM", dm_unread); - display.drawTextCentered(display.width() / 2, 41, badge); - display.drawTextCentered(display.width() / 2, 54, PRESS_LABEL " to open"); - } else { - display.drawTextCentered(display.width() / 2, 46, PRESS_LABEL " to open"); + display.drawTextCentered(display.width() / 2, 22, "Messages"); + int total_unread = _task->getMsgCount() + _task->getChannelUnreadCount(); + if (total_unread > 0) { + char badge[20]; + snprintf(badge, sizeof(badge), "%d unread", total_unread); + display.drawTextCentered(display.width() / 2, 35, badge); } + display.drawTextCentered(display.width() / 2, 50, PRESS_LABEL " to open"); } else if (_page == HomePage::SHUTDOWN) { display.setColor(DisplayDriver::LIGHT); display.setTextSize(1); @@ -2257,6 +2261,10 @@ void UITask::addChannelMsg(uint8_t channel_idx, const char* text) { ((QuickMsgScreen*)quick_msg)->addChannelMsg(channel_idx, text); } +int UITask::getChannelUnreadCount() const { + return ((QuickMsgScreen*)quick_msg)->getTotalChannelUnread(); +} + void UITask::showAlert(const char* text, int duration_millis) { strcpy(_alert, text); _alert_expiry = millis() + duration_millis; diff --git a/examples/companion_radio/ui-new/UITask.h b/examples/companion_radio/ui-new/UITask.h index 282959d8..147f44a3 100644 --- a/examples/companion_radio/ui-new/UITask.h +++ b/examples/companion_radio/ui-new/UITask.h @@ -86,6 +86,7 @@ public: void showAlert(const char* text, int duration_millis); void addChannelMsg(uint8_t channel_idx, const char* text) override; int getMsgCount() const { return _msgcount; } + int getChannelUnreadCount() const; bool hasDisplay() const { return _display != NULL; } bool isButtonPressed() const;