mirror of
https://github.com/szkolny-eu/szkolny-android.git
synced 2025-04-01 22:34:28 +02:00
[Vulcan/Hebe] Add getting attachments in messages.
This commit is contained in:
parent
4c081c970e
commit
a939d95ea3
@ -17,6 +17,7 @@ import pl.szczodrzynski.edziennik.data.db.entity.*
|
|||||||
import pl.szczodrzynski.edziennik.data.db.entity.Message.Companion.TYPE_DELETED
|
import pl.szczodrzynski.edziennik.data.db.entity.Message.Companion.TYPE_DELETED
|
||||||
import pl.szczodrzynski.edziennik.data.db.entity.Message.Companion.TYPE_RECEIVED
|
import pl.szczodrzynski.edziennik.data.db.entity.Message.Companion.TYPE_RECEIVED
|
||||||
import pl.szczodrzynski.edziennik.data.db.entity.Message.Companion.TYPE_SENT
|
import pl.szczodrzynski.edziennik.data.db.entity.Message.Companion.TYPE_SENT
|
||||||
|
import pl.szczodrzynski.edziennik.utils.Utils
|
||||||
import pl.szczodrzynski.navlib.crc16
|
import pl.szczodrzynski.navlib.crc16
|
||||||
import kotlin.text.replace
|
import kotlin.text.replace
|
||||||
|
|
||||||
@ -110,6 +111,23 @@ class VulcanHebeMessages(
|
|||||||
data.messageRecipientList.add(messageRecipientObject)
|
data.messageRecipientList.add(messageRecipientObject)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val attachments = message.getJsonArray("Attachments")
|
||||||
|
?.asJsonObjectList()
|
||||||
|
?: return@forEach
|
||||||
|
|
||||||
|
for (attachment in attachments) {
|
||||||
|
val fileName = attachment.getString("Name") ?: continue
|
||||||
|
val url = attachment.getString("Link") ?: continue
|
||||||
|
val attachmentName = "$fileName:$url"
|
||||||
|
val attachmentId = Utils.crc32(attachmentName.toByteArray())
|
||||||
|
|
||||||
|
messageObject.addAttachment(
|
||||||
|
id = attachmentId,
|
||||||
|
name = attachmentName,
|
||||||
|
size = -1
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
data.messageList.add(messageObject)
|
data.messageList.add(messageObject)
|
||||||
data.setSeenMetadataList.add(
|
data.setSeenMetadataList.add(
|
||||||
Metadata(
|
Metadata(
|
||||||
|
@ -121,19 +121,21 @@ class AttachmentsView @JvmOverloads constructor(
|
|||||||
// open file by name, or first part before ':' (Vulcan OneDrive)
|
// open file by name, or first part before ':' (Vulcan OneDrive)
|
||||||
Utils.openFile(context, File(Utils.getStorageDir(), attachment.name.substringBefore(":")))
|
Utils.openFile(context, File(Utils.getStorageDir(), attachment.name.substringBefore(":")))
|
||||||
return
|
return
|
||||||
}
|
} else if (attachment.name.contains(":")) {
|
||||||
|
Utils.openUrl(context, attachment.name.substringAfter(":"))
|
||||||
|
} else {
|
||||||
|
attachment.isDownloading = true
|
||||||
|
(adapter as? AttachmentAdapter)?.let {
|
||||||
|
it.notifyItemChanged(it.items.indexOf(attachment))
|
||||||
|
}
|
||||||
|
|
||||||
attachment.isDownloading = true
|
EdziennikTask.attachmentGet(
|
||||||
(adapter as? AttachmentAdapter)?.let {
|
|
||||||
it.notifyItemChanged(it.items.indexOf(attachment))
|
|
||||||
}
|
|
||||||
|
|
||||||
EdziennikTask.attachmentGet(
|
|
||||||
attachment.profileId,
|
attachment.profileId,
|
||||||
attachment.owner,
|
attachment.owner,
|
||||||
attachment.id,
|
attachment.id,
|
||||||
attachment.name
|
attachment.name
|
||||||
).enqueue(context)
|
).enqueue(context)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private val lastUpdate: Long = 0
|
private val lastUpdate: Long = 0
|
||||||
|
Loading…
x
Reference in New Issue
Block a user