mirror of
https://github.com/meshtastic/firmware.git
synced 2025-10-27 15:02:41 +00:00
Improve layout of messages screen
This commit is contained in:
parent
f09ac16f19
commit
b26c95d4b9
@ -456,7 +456,7 @@ void drawTextMessageFrame(OLEDDisplay *display, OLEDDisplayUiState *state, int16
|
|||||||
char chanType[32] = "";
|
char chanType[32] = "";
|
||||||
if (currentMode == ThreadMode::ALL) {
|
if (currentMode == ThreadMode::ALL) {
|
||||||
if (m.dest == NODENUM_BROADCAST) {
|
if (m.dest == NODENUM_BROADCAST) {
|
||||||
snprintf(chanType, sizeof(chanType), "(Ch%d)", m.channelIndex);
|
snprintf(chanType, sizeof(chanType), "#%s", channels.getName(m.channelIndex));
|
||||||
} else {
|
} else {
|
||||||
snprintf(chanType, sizeof(chanType), "(DM)");
|
snprintf(chanType, sizeof(chanType), "(DM)");
|
||||||
}
|
}
|
||||||
@ -504,6 +504,7 @@ void drawTextMessageFrame(OLEDDisplay *display, OLEDDisplayUiState *state, int16
|
|||||||
|
|
||||||
// Build header line for this message
|
// Build header line for this message
|
||||||
meshtastic_NodeInfoLite *node = nodeDB->getMeshNode(m.sender);
|
meshtastic_NodeInfoLite *node = nodeDB->getMeshNode(m.sender);
|
||||||
|
meshtastic_NodeInfoLite *node_recipient = nodeDB->getMeshNode(m.dest);
|
||||||
|
|
||||||
char senderBuf[48] = "???";
|
char senderBuf[48] = "???";
|
||||||
if (node && node->has_user) {
|
if (node && node->has_user) {
|
||||||
@ -514,9 +515,10 @@ void drawTextMessageFrame(OLEDDisplay *display, OLEDDisplayUiState *state, int16
|
|||||||
// If this is *our own* message, override sender to "Me"
|
// If this is *our own* message, override sender to "Me"
|
||||||
bool mine = (m.sender == nodeDB->getNodeNum());
|
bool mine = (m.sender == nodeDB->getNodeNum());
|
||||||
if (mine) {
|
if (mine) {
|
||||||
strcpy(senderBuf, "Me");
|
strcpy(senderBuf, node_recipient->user.long_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Shrink Sender name if needed
|
||||||
int availWidth = SCREEN_WIDTH - display->getStringWidth(timeBuf) - display->getStringWidth(chanType) -
|
int availWidth = SCREEN_WIDTH - display->getStringWidth(timeBuf) - display->getStringWidth(chanType) -
|
||||||
display->getStringWidth(" @...") - 10;
|
display->getStringWidth(" @...") - 10;
|
||||||
if (availWidth < 0)
|
if (availWidth < 0)
|
||||||
@ -535,7 +537,15 @@ void drawTextMessageFrame(OLEDDisplay *display, OLEDDisplayUiState *state, int16
|
|||||||
// Final header line
|
// Final header line
|
||||||
char headerStr[96];
|
char headerStr[96];
|
||||||
if (mine) {
|
if (mine) {
|
||||||
snprintf(headerStr, sizeof(headerStr), "%s %s", timeBuf, chanType);
|
if (currentMode == ThreadMode::ALL) {
|
||||||
|
if (strcmp(chanType, "(DM)") == 0) {
|
||||||
|
snprintf(headerStr, sizeof(headerStr), "%s to %s", timeBuf, senderBuf);
|
||||||
|
} else {
|
||||||
|
snprintf(headerStr, sizeof(headerStr), "%s to %s", timeBuf, chanType);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
snprintf(headerStr, sizeof(headerStr), "%s", timeBuf);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
snprintf(headerStr, sizeof(headerStr), "%s @%s %s", timeBuf, senderBuf, chanType);
|
snprintf(headerStr, sizeof(headerStr), "%s @%s %s", timeBuf, senderBuf, chanType);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user