Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ class LibPebbleNotificationListener : NotificationListenerService(), LibPebbleKo
id = channel.id,
name = channel.name.toString(),
muteState = MuteState.Never,
vibrationPattern = channel.getVibrationPattern().map { it.toUInt() }.let { listOf(0u) + it }
)
val group = groups[channel.group]
if (group == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class BasicNotificationProcessor(
val contactEntries = contactKeys.mapNotNull {
contactDao.getContact(it)
}
val sendVibePattern = selectVibrationPattern(contactEntries, app, sbn)
val sendVibePattern = selectVibrationPattern(contactEntries, app, sbn, channel)
val appProperties = NotificationProperties.lookup(app.packageName)

val color = selectColor(app, sbn, appProperties)
Expand All @@ -83,7 +83,7 @@ class BasicNotificationProcessor(
},
actions = actions,
people = contactEntries,
vibrationPattern = sendVibePattern,
vibrationPattern = sendVibePattern,
color = color,
)
return NotificationResult.Extracted(notification, NotificationDecision.SendToWatch)
Expand Down Expand Up @@ -113,18 +113,31 @@ class BasicNotificationProcessor(
contactEntries: List<ContactEntity>,
app: NotificationAppItem,
sbn: StatusBarNotification,
channel: ChannelItem?,
): List<UInt>? {
// TODO we're only picking the pattern from the first contact. I don't know if the first
// contact is always the one that sent the message, in a group chat?
val vibePatternForContact = findVibePattern(contactEntries.firstOrNull()?.vibePatternName)
val vibePatternForApp = findVibePattern(app.vibePatternName)
val vibePatternForChannel = if (notificationConfigFlow.value.useAndroidVibePatterns) {
channel?.vibrationPattern
} else {
null
}
val vibePatternFromNotification = if (notificationConfigFlow.value.useAndroidVibePatterns) {
sbn.notification.vibrationPattern()
} else {
null
}
val vibePatternFromTaskerNotification = if (notificationConfigFlow.value.useAndroidVibePatterns) {
var patt = emptyList<UInt>()
runCatching { patt = sbn.getNotification().extras.getString("extraautonotificationinfo", "").split(",").map { it.toUInt() } }
if (patt.size == 0) null else patt
} else {
null
}
val vibePatternDefaultOverride = findVibePattern(notificationConfigFlow.value.overrideDefaultVibePattern)
return vibePatternForContact ?: vibePatternForApp ?: vibePatternFromNotification ?: vibePatternDefaultOverride
return vibePatternForContact ?: vibePatternFromTaskerNotification ?: vibePatternFromNotification ?: vibePatternForApp ?: vibePatternForChannel ?: vibePatternDefaultOverride
}

private suspend fun findVibePattern(name: String?): List<UInt>? {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ data class MillisecondInstant(val instant: Instant) {
fun Instant.asMillisecond(): MillisecondInstant = MillisecondInstant(this)

class RoomTypeConverters {
@TypeConverter
fun ListUIntToString(value: List<UInt>): String = value.joinToString(",");
@TypeConverter
fun ListUIntToString(value: List<UInt>): String = value.joinToString(",");

@TypeConverter
fun StringToListUInt(value: String): List<UInt> = value.split(",").mapNotNull { it.toUIntOrNull() };
@TypeConverter
fun StringToListUInt(value: String): List<UInt> = value.split(",").mapNotNull { it.toUIntOrNull() };

@TypeConverter
fun StringToUuid(string: String?): Uuid? = string?.let { Uuid.parse(it) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ data class ChannelItem(
val id: String,
val name: String,
val muteState: MuteState,
val vibrationPattern: List<UInt>? = null,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This won't work unless you bump the database version and add a migration to create the column - see e.g. https://github.com/coredevices/CoreApp/commit/d1e34ef7116aa69170ff47ba9561a144a8bd9873#diff-4bbbd39fe1ff5faa4ceef66355eb272f66db7ac0e0e462a95647c1b6c4272ea7 (otherwiswe it will crash, unless you're running a fresh install of the app)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Huh. It was crashing before I added the default value, but it was working fine for me after I set the default value. Maybe it just ignores that column in the db right now?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh my bad - got confused with db fields vs this object which is serialized into a db field (so adding the default value fixing it makes sense)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good. So I think I can just leave it, right? The vibration pattern just won't get added to the db as a column?

)

class NotificationAppBlobItem(
Expand Down