mirror of
https://github.com/element-hq/element-android
synced 2024-11-27 03:48:12 +03:00
Add "io.element.voice_broadcast_info" state event
This commit is contained in:
parent
9335242ce1
commit
4091d27311
4 changed files with 122 additions and 0 deletions
|
@ -43,4 +43,7 @@ object MessageType {
|
|||
// Fake message types for live location events to be able to inherit them from MessageContent
|
||||
const val MSGTYPE_BEACON_INFO = "org.matrix.android.sdk.beacon.info"
|
||||
const val MSGTYPE_BEACON_LOCATION_DATA = "org.matrix.android.sdk.beacon.location.data"
|
||||
|
||||
// Fake message types for voice broadcast events to be able to inherit them from MessageContent
|
||||
const val MSGTYPE_VOICE_BROADCAST_INFO = "io.element.voicebroadcast.info"
|
||||
}
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
/*
|
||||
* Copyright (c) 2022 New Vector Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package im.vector.app.features.voicebroadcast
|
||||
|
||||
/** Voice Broadcast State Event. */
|
||||
const val STATE_ROOM_VOICE_BROADCAST_INFO = "io.element.voice_broadcast_info"
|
|
@ -0,0 +1,53 @@
|
|||
/*
|
||||
* Copyright (c) 2022 New Vector Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package im.vector.app.features.voicebroadcast.model
|
||||
|
||||
import com.squareup.moshi.Json
|
||||
import com.squareup.moshi.JsonClass
|
||||
import im.vector.app.features.voicebroadcast.STATE_ROOM_VOICE_BROADCAST_INFO
|
||||
import org.matrix.android.sdk.api.session.events.model.Content
|
||||
import org.matrix.android.sdk.api.session.room.model.message.MessageContent
|
||||
import org.matrix.android.sdk.api.session.room.model.message.MessageType.MSGTYPE_VOICE_BROADCAST_INFO
|
||||
import org.matrix.android.sdk.api.session.room.model.relation.RelationDefaultContent
|
||||
import timber.log.Timber
|
||||
|
||||
/**
|
||||
* Content of the state event of type [STATE_ROOM_VOICE_BROADCAST_INFO].
|
||||
*
|
||||
* It contains general info related to a voice broadcast.
|
||||
*/
|
||||
@JsonClass(generateAdapter = true)
|
||||
data class MessageVoiceBroadcastInfoContent(
|
||||
/** Local message type, not from server. */
|
||||
@Transient override val msgType: String = MSGTYPE_VOICE_BROADCAST_INFO,
|
||||
@Json(name = "body") override val body: String = "",
|
||||
@Json(name = "m.relates_to") override val relatesTo: RelationDefaultContent? = null,
|
||||
@Json(name = "m.new_content") override val newContent: Content? = null,
|
||||
|
||||
/** The [VoiceBroadcastState] value. **/
|
||||
@Json(name = "state") val voiceBroadcastStateStr: String = "",
|
||||
/** The length of the voice chunks in seconds. **/
|
||||
@Json(name = "chunk_length") val chunkLength: Long? = null,
|
||||
) : MessageContent {
|
||||
|
||||
val voiceBroadcastState: VoiceBroadcastState? = VoiceBroadcastState.values()
|
||||
.find { it.value == voiceBroadcastStateStr }
|
||||
?: run {
|
||||
Timber.w("Invalid value for state: `$voiceBroadcastStateStr`")
|
||||
null
|
||||
}
|
||||
}
|
|
@ -0,0 +1,46 @@
|
|||
/*
|
||||
* Copyright 2020 The Matrix.org Foundation C.I.C.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package im.vector.app.features.voicebroadcast.model
|
||||
|
||||
import com.squareup.moshi.Json
|
||||
import com.squareup.moshi.JsonClass
|
||||
|
||||
/**
|
||||
* Ref: https://github.com/vector-im/element-meta/discussions/632
|
||||
*/
|
||||
@JsonClass(generateAdapter = false)
|
||||
enum class VoiceBroadcastState(val value: String) {
|
||||
/**
|
||||
* The voice broadcast had been started and is currently being live.
|
||||
*/
|
||||
@Json(name = "started") STARTED("started"),
|
||||
|
||||
/**
|
||||
* The voice broadcast has been paused and may be resumed at any time by the recorder.
|
||||
*/
|
||||
@Json(name = "paused") PAUSED("paused"),
|
||||
|
||||
/**
|
||||
* The voice broadcast is currently being live again.
|
||||
*/
|
||||
@Json(name = "resumed") RESUMED("resumed"),
|
||||
|
||||
/**
|
||||
* The voice broadcast has ended.
|
||||
*/
|
||||
@Json(name = "stopped") STOPPED("stopped"),
|
||||
}
|
Loading…
Reference in a new issue