Music app : when title/track name are truncated, add an ellipsis at the end of the strings.
This commit is contained in:
parent
4e227135a9
commit
720e5ede29
|
@ -17,6 +17,7 @@
|
||||||
*/
|
*/
|
||||||
#include "components/ble/MusicService.h"
|
#include "components/ble/MusicService.h"
|
||||||
#include "systemtask/SystemTask.h"
|
#include "systemtask/SystemTask.h"
|
||||||
|
#include <cstring>
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
// 0000yyxx-78fc-48fe-8e23-433b3a1942d0
|
// 0000yyxx-78fc-48fe-8e23-433b3a1942d0
|
||||||
|
@ -127,14 +128,21 @@ void Pinetime::Controllers::MusicService::Init() {
|
||||||
int Pinetime::Controllers::MusicService::OnCommand(uint16_t conn_handle, uint16_t attr_handle, struct ble_gatt_access_ctxt* ctxt) {
|
int Pinetime::Controllers::MusicService::OnCommand(uint16_t conn_handle, uint16_t attr_handle, struct ble_gatt_access_ctxt* ctxt) {
|
||||||
if (ctxt->op == BLE_GATT_ACCESS_OP_WRITE_CHR) {
|
if (ctxt->op == BLE_GATT_ACCESS_OP_WRITE_CHR) {
|
||||||
size_t notifSize = OS_MBUF_PKTLEN(ctxt->om);
|
size_t notifSize = OS_MBUF_PKTLEN(ctxt->om);
|
||||||
|
size_t bufferSize = notifSize;
|
||||||
if (notifSize > MaxStringSize) {
|
if (notifSize > MaxStringSize) {
|
||||||
notifSize = MaxStringSize;
|
bufferSize = MaxStringSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
char data[notifSize + 1];
|
char data[bufferSize + 1];
|
||||||
data[notifSize] = '\0';
|
os_mbuf_copydata(ctxt->om, 0, bufferSize, data);
|
||||||
os_mbuf_copydata(ctxt->om, 0, notifSize, data);
|
|
||||||
|
if (notifSize > bufferSize) {
|
||||||
|
data[bufferSize-1] = '.';
|
||||||
|
data[bufferSize-2] = '.';
|
||||||
|
data[bufferSize-3] = '.';
|
||||||
|
}
|
||||||
|
data[bufferSize] = '\0';
|
||||||
|
|
||||||
char* s = &data[0];
|
char* s = &data[0];
|
||||||
if (ble_uuid_cmp(ctxt->chr->uuid, &msArtistCharUuid.u) == 0) {
|
if (ble_uuid_cmp(ctxt->chr->uuid, &msArtistCharUuid.u) == 0) {
|
||||||
artistName = s;
|
artistName = s;
|
||||||
|
|
Loading…
Reference in New Issue