Hide the join call button if the user is already in the call.
This is at the account level so if the user has joined the call on another device, the join button will be hidden. Extract room call state presenter to its own module and update RoomCallState model. Let RoomDetailsPresenter use the new RoomCallStatePresenter
This commit is contained in:
parent
6b71994321
commit
2a35edb14a
27 changed files with 419 additions and 153 deletions
20
features/roomcall/api/build.gradle.kts
Normal file
20
features/roomcall/api/build.gradle.kts
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
/*
|
||||
* Copyright 2024 New Vector Ltd.
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
* Please see LICENSE in the repository root for full details.
|
||||
*/
|
||||
|
||||
plugins {
|
||||
id("io.element.android-library")
|
||||
}
|
||||
|
||||
android {
|
||||
namespace = "io.element.android.features.roomcall.api"
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation(projects.libraries.architecture)
|
||||
implementation(projects.libraries.matrix.api)
|
||||
implementation(libs.androidx.compose.ui.tooling.preview)
|
||||
}
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
/*
|
||||
* Copyright 2024 New Vector Ltd.
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
* Please see LICENSE in the repository root for full details.
|
||||
*/
|
||||
|
||||
package io.element.android.features.roomcall.api
|
||||
|
||||
import androidx.compose.runtime.Immutable
|
||||
import io.element.android.features.roomcall.api.RoomCallState.OnGoing
|
||||
import io.element.android.features.roomcall.api.RoomCallState.StandBy
|
||||
|
||||
@Immutable
|
||||
sealed interface RoomCallState {
|
||||
data class StandBy(
|
||||
val canStartCall: Boolean,
|
||||
) : RoomCallState
|
||||
|
||||
data class OnGoing(
|
||||
val canJoinCall: Boolean,
|
||||
val isUserInTheCall: Boolean,
|
||||
) : RoomCallState
|
||||
}
|
||||
|
||||
fun RoomCallState.hasPermissionToJoin() = when (this) {
|
||||
is StandBy -> canStartCall
|
||||
is OnGoing -> canJoinCall
|
||||
}
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
/*
|
||||
* Copyright 2024 New Vector Ltd.
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
* Please see LICENSE in the repository root for full details.
|
||||
*/
|
||||
|
||||
package io.element.android.features.roomcall.api
|
||||
|
||||
import androidx.compose.ui.tooling.preview.PreviewParameterProvider
|
||||
|
||||
open class RoomCallStateProvider : PreviewParameterProvider<RoomCallState> {
|
||||
override val values: Sequence<RoomCallState> = sequenceOf(
|
||||
aStandByCallState(),
|
||||
aStandByCallState(canStartCall = false),
|
||||
anOngoingCallState(),
|
||||
anOngoingCallState(canJoinCall = false),
|
||||
anOngoingCallState(canJoinCall = true, isUserInTheCall = true),
|
||||
)
|
||||
}
|
||||
|
||||
fun anOngoingCallState(
|
||||
canJoinCall: Boolean = true,
|
||||
isUserInTheCall: Boolean = false,
|
||||
) = RoomCallState.OnGoing(
|
||||
canJoinCall = canJoinCall,
|
||||
isUserInTheCall = isUserInTheCall,
|
||||
)
|
||||
|
||||
fun aStandByCallState(
|
||||
canStartCall: Boolean = true,
|
||||
) = RoomCallState.StandBy(
|
||||
canStartCall = canStartCall,
|
||||
)
|
||||
Loading…
Add table
Add a link
Reference in a new issue