Skip to content

Commit 88197b6

Browse files
committed
Music app : when title/track name are truncated, add an ellipsis at the end of the strings.
1 parent f973f1c commit 88197b6

1 file changed

Lines changed: 13 additions & 5 deletions

File tree

src/components/ble/MusicService.cpp

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
*/
1818
#include "components/ble/MusicService.h"
1919
#include "systemtask/SystemTask.h"
20+
#include <cstring>
2021

2122
namespace {
2223
// 0000yyxx-78fc-48fe-8e23-433b3a1942d0
@@ -127,14 +128,21 @@ void Pinetime::Controllers::MusicService::Init() {
127128
int Pinetime::Controllers::MusicService::OnCommand(uint16_t conn_handle, uint16_t attr_handle, struct ble_gatt_access_ctxt* ctxt) {
128129
if (ctxt->op == BLE_GATT_ACCESS_OP_WRITE_CHR) {
129130
size_t notifSize = OS_MBUF_PKTLEN(ctxt->om);
130-
131+
size_t bufferSize = notifSize;
131132
if (notifSize > MaxStringSize) {
132-
notifSize = MaxStringSize;
133+
bufferSize = MaxStringSize;
134+
}
135+
136+
char data[bufferSize + 1];
137+
os_mbuf_copydata(ctxt->om, 0, bufferSize, data);
138+
139+
if (notifSize > bufferSize) {
140+
data[bufferSize-1] = '.';
141+
data[bufferSize-2] = '.';
142+
data[bufferSize-3] = '.';
133143
}
144+
data[bufferSize] = '\0';
134145

135-
char data[notifSize + 1];
136-
data[notifSize] = '\0';
137-
os_mbuf_copydata(ctxt->om, 0, notifSize, data);
138146
char* s = &data[0];
139147
if (ble_uuid_cmp(ctxt->chr->uuid, &msArtistCharUuid.u) == 0) {
140148
artistName = s;

0 commit comments

Comments
 (0)