@@ -6,6 +6,7 @@ import com.benasher44.uuid.uuidOf
66import com.soywiz.klock.DateTime
77import io.rebble.libpebblecommon.structmapper.SUInt
88import io.rebble.libpebblecommon.structmapper.StructMapper
9+ import io.rebble.libpebblecommon.util.TimelineAttributeFactory
910import kotlin.random.Random
1011
1112private val notifsUUID = uuidFrom(" B2CAE818-10F8-46DF-AD2B-98AD2254A3C1" )
@@ -24,37 +25,20 @@ enum class NotificationSource(val id: UInt) { //TODO: There's likely more... (pr
2425open class PushNotification (subject : String , sender : String? = null , message : String? = null , source : NotificationSource = NotificationSource .Generic , backgroundColor : UByte? = null ): BlobCommand.InsertCommand(Random .nextInt(0, UShort .MAX_VALUE .toInt()).toUShort(),
2526 BlobDatabase .Notification , ubyteArrayOf(), ubyteArrayOf()) {
2627 init {
27- val iconID = SUInt (StructMapper (), source.id or 0x80000000u ).toBytes() // TODO: Work out why GB masks this, and why that makes it work
2828 val itemID = uuid4()
2929
3030 // TODO: Replies, open on phone, detect dismiss
3131 val attributes = mutableListOf (
32- TimelineItem .Attribute (
33- TimelineItem .Attribute .Timeline .Sender .id,
34- sender?.encodeToByteArray()?.toUByteArray() ? : ubyteArrayOf()
35- ),
36- TimelineItem .Attribute (
37- TimelineItem .Attribute .Timeline .Icon .id,
38- iconID,
39- contentEndianness = ' <'
40- )
41- )
42- if (message != null ) attributes + = TimelineItem .Attribute (
43- TimelineItem .Attribute .Timeline .Message .id,
44- message.encodeToByteArray().toUByteArray()
45- )
46- attributes + = TimelineItem .Attribute (
47- TimelineItem .Attribute .Timeline .Subject .id,
48- subject.encodeToByteArray().toUByteArray()
32+ TimelineAttributeFactory .sender(sender ? : " " ),
33+ TimelineAttributeFactory .icon(TimelineIcon .fromId(source.id))
4934 )
35+ if (message != null ) attributes + = TimelineAttributeFactory .body(message)
36+ attributes + = TimelineAttributeFactory .subtitle(subject)
5037
5138 if (backgroundColor != null ) {
5239 // XXX: https://youtrack.jetbrains.com/issue/KT-49366
5340 val bgColTemp = backgroundColor.toUByte()
54- attributes + = TimelineItem .Attribute (
55- TimelineItem .Attribute .Timeline .BackgroundCol .id,
56- ubyteArrayOf(bgColTemp)
57- )
41+ attributes + = TimelineAttributeFactory .primaryColor(bgColTemp)
5842 }
5943
6044 val actions = mutableListOf (
0 commit comments