fix(core/send_override): audio note transcription

This commit is contained in:
rhunk 2024-05-06 22:36:00 +02:00
parent 8864be6814
commit da19408c75
2 changed files with 9 additions and 2 deletions

View File

@ -13,6 +13,7 @@ import me.rhunk.snapenhance.core.features.impl.experiments.MediaFilePicker
import me.rhunk.snapenhance.core.messaging.MessageSender
import me.rhunk.snapenhance.core.ui.ViewAppearanceHelper
import me.rhunk.snapenhance.nativelib.NativeLib
import java.util.Locale
class SendOverride : Feature("Send Override", loadParams = FeatureLoadParams.INIT_SYNC) {
private var isLastSnapSavable = false
@ -129,7 +130,10 @@ class SendOverride : Feature("Send Override", loadParams = FeatureLoadParams.INI
"NOTE" -> {
localMessageContent.contentType = ContentType.NOTE
localMessageContent.content =
MessageSender.audioNoteProto(messageProtoReader.getVarInt(3, 3, 5, 1, 1, 15) ?: context.feature(MediaFilePicker::class).lastMediaDuration ?: 0)
MessageSender.audioNoteProto(
messageProtoReader.getVarInt(3, 3, 5, 1, 1, 15) ?: context.feature(MediaFilePicker::class).lastMediaDuration ?: 0,
Locale.getDefault().toLanguageTag()
)
}
}

View File

@ -38,7 +38,7 @@ class MessageSender(
}.toByteArray()
}
val audioNoteProto: (Long) -> ByteArray = { duration ->
val audioNoteProto: (Long, String?) -> ByteArray = { duration, userLocale ->
ProtoWriter().apply {
from(6, 1) {
from(1) {
@ -50,6 +50,9 @@ class MessageSender(
addVarInt(7, 0)
addVarInt(13, duration)
}
if (userLocale != null) {
addString(3, userLocale)
}
}
}.toByteArray()
}