kopia lustrzana https://github.com/ryukoposting/Signal-Android
43 wiersze
1.3 KiB
Kotlin
43 wiersze
1.3 KiB
Kotlin
package org.thoughtcrime.securesms.mediasend
|
|
|
|
import android.content.Intent
|
|
import android.os.Parcelable
|
|
import kotlinx.parcelize.Parcelize
|
|
import org.thoughtcrime.securesms.conversation.MessageSendType
|
|
import org.thoughtcrime.securesms.database.model.Mention
|
|
import org.thoughtcrime.securesms.database.model.StoryType
|
|
import org.thoughtcrime.securesms.recipients.RecipientId
|
|
import org.thoughtcrime.securesms.sms.MessageSender.PreUploadResult
|
|
|
|
/**
|
|
* A class that lets us nicely format data that we'll send back to [ConversationActivity].
|
|
*/
|
|
@Parcelize
|
|
class MediaSendActivityResult(
|
|
val recipientId: RecipientId,
|
|
val preUploadResults: List<PreUploadResult> = emptyList(),
|
|
val nonUploadedMedia: List<Media> = emptyList(),
|
|
val body: String,
|
|
val messageSendType: MessageSendType,
|
|
val isViewOnce: Boolean,
|
|
val mentions: List<Mention>,
|
|
val storyType: StoryType
|
|
) : Parcelable {
|
|
|
|
val isPushPreUpload: Boolean
|
|
get() = preUploadResults.isNotEmpty()
|
|
|
|
init {
|
|
require((preUploadResults.isNotEmpty() && nonUploadedMedia.isEmpty()) || (preUploadResults.isEmpty() && nonUploadedMedia.isNotEmpty()))
|
|
}
|
|
|
|
companion object {
|
|
const val EXTRA_RESULT = "result"
|
|
|
|
@JvmStatic
|
|
fun fromData(data: Intent): MediaSendActivityResult {
|
|
return data.getParcelableExtra(EXTRA_RESULT) ?: throw IllegalArgumentException()
|
|
}
|
|
}
|
|
}
|