mirror of
https://github.com/Novaloop-AG/element-x-android.git
synced 2026-11-02 21:32:34 +00:00
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:
committed by
Benoit Marty
parent
98bf6856ab
commit
58e66963d8
@@ -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)
|
||||
}
|
||||
+29
@@ -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
|
||||
}
|
||||
+34
@@ -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,
|
||||
)
|
||||
Reference in New Issue
Block a user