mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-27 12:05:22 +00:00
quick code refactoring
This commit is contained in:
parent
7cdffc1801
commit
4fc0c3dddc
@ -31,19 +31,17 @@ class Attachment {
|
||||
result.contentType = proto.contentType ?: inferContentType()
|
||||
result.key = proto.key.toByteArray()
|
||||
result.digest = proto.digest.toByteArray()
|
||||
val kind: Kind
|
||||
if (proto.hasFlags() && (proto.flags and SignalServiceProtos.AttachmentPointer.Flags.VOICE_MESSAGE_VALUE) > 0) { //TODO validate that 'and' operator = swift '&'
|
||||
kind = Kind.VOICE_MESSAGE
|
||||
val kind: Kind = if (proto.hasFlags() && (proto.flags and SignalServiceProtos.AttachmentPointer.Flags.VOICE_MESSAGE_VALUE) > 0) { //TODO validate that 'and' operator = swift '&'
|
||||
Kind.VOICE_MESSAGE
|
||||
} else {
|
||||
kind = Kind.GENERIC
|
||||
Kind.GENERIC
|
||||
}
|
||||
result.kind = kind
|
||||
result.caption = if (proto.hasCaption()) proto.caption else null
|
||||
val size: Size
|
||||
if (proto.hasWidth() && proto.width > 0 && proto.hasHeight() && proto.height > 0) {
|
||||
size = Size(proto.width, proto.height)
|
||||
val size: Size = if (proto.hasWidth() && proto.width > 0 && proto.hasHeight() && proto.height > 0) {
|
||||
Size(proto.width, proto.height)
|
||||
} else {
|
||||
size = Size(0,0) //TODO check that it's equivalent to swift: CGSize.zero
|
||||
Size(0,0) //TODO check that it's equivalent to swift: CGSize.zero
|
||||
}
|
||||
result.size = size
|
||||
result.sizeInBytes = if (proto.size > 0) proto.size else null
|
||||
|
@ -48,7 +48,7 @@ class Quote() {
|
||||
quoteProto.id = timestamp
|
||||
quoteProto.author = publicKey
|
||||
text?.let { quoteProto.text = text }
|
||||
addAttachmentsIfNeeded(quoteProto, MessagingConfiguration.shared.messageDataProvider)
|
||||
addAttachmentsIfNeeded(quoteProto)
|
||||
// Build
|
||||
try {
|
||||
return quoteProto.build()
|
||||
@ -58,9 +58,9 @@ class Quote() {
|
||||
}
|
||||
}
|
||||
|
||||
private fun addAttachmentsIfNeeded(quoteProto: SignalServiceProtos.DataMessage.Quote.Builder, messageDataProvider: MessageDataProvider) {
|
||||
private fun addAttachmentsIfNeeded(quoteProto: SignalServiceProtos.DataMessage.Quote.Builder) {
|
||||
val attachmentID = attachmentID ?: return
|
||||
val attachmentProto = messageDataProvider.getAttachmentStream(attachmentID)
|
||||
val attachmentProto = MessagingConfiguration.shared.messageDataProvider.getAttachmentStream(attachmentID)
|
||||
if (attachmentProto == null) {
|
||||
Log.w(TAG, "Ignoring invalid attachment for quoted message.")
|
||||
return
|
||||
|
Loading…
Reference in New Issue
Block a user