Skip to content

Commit

Permalink
feat: send and receive in-call reactions [#WPB-14254]
Browse files Browse the repository at this point in the history
  • Loading branch information
sbakhtiarov committed Dec 19, 2024
1 parent 22a0b22 commit 424abf8
Show file tree
Hide file tree
Showing 33 changed files with 1,521 additions and 147 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -202,4 +202,9 @@ class CallsModule {
@Provides
fun provideObserveConferenceCallingEnabledUseCase(callsScope: CallsScope) =
callsScope.observeConferenceCallingEnabled

@ViewModelScoped
@Provides
fun provideObserveInCallReactionsUseCase(callsScope: CallsScope) =
callsScope.observeInCallReactions
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import com.wire.kalium.logic.feature.asset.ObserveAssetStatusesUseCase
import com.wire.kalium.logic.feature.asset.ObservePaginatedAssetImageMessages
import com.wire.kalium.logic.feature.asset.ScheduleNewAssetMessageUseCase
import com.wire.kalium.logic.feature.asset.UpdateAssetMessageTransferStatusUseCase
import com.wire.kalium.logic.feature.incallreaction.SendInCallReactionUseCase
import com.wire.kalium.logic.feature.message.DeleteMessageUseCase
import com.wire.kalium.logic.feature.message.GetMessageByIdUseCase
import com.wire.kalium.logic.feature.message.GetNotificationsUseCase
Expand Down Expand Up @@ -216,4 +217,9 @@ class MessageModule {
@Provides
fun provideRemoveMessageDraftUseCase(messageScope: MessageScope): RemoveMessageDraftUseCase =
messageScope.removeMessageDraftUseCase

@ViewModelScoped
@Provides
fun provideSendInCallReactionUseCase(messageScope: MessageScope): SendInCallReactionUseCase =
messageScope.sendInCallReactionUseCase
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,8 @@ package com.wire.android.ui.calling.controlbuttons

import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.Dp
import com.wire.android.R
import com.wire.android.appLogger
import com.wire.android.ui.common.dimensions
import com.wire.android.ui.theme.WireTheme
import com.wire.android.util.permission.rememberCameraPermissionFlow
import com.wire.android.util.ui.PreviewMultipleThemes
Expand All @@ -34,7 +32,6 @@ fun CameraButton(
onPermissionPermanentlyDenied: () -> Unit,
modifier: Modifier = Modifier,
isCameraOn: Boolean = false,
size: Dp = dimensions().defaultCallingControlsSize,
) {
val cameraPermissionCheck = rememberCameraPermissionFlow(
onPermissionGranted = {
Expand All @@ -56,7 +53,6 @@ fun CameraButton(
false -> R.string.content_description_calling_turn_camera_on
},
onClick = cameraPermissionCheck::launch,
size = size,
modifier = modifier,
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ import com.wire.android.util.ui.PreviewMultipleThemes
fun HangUpButton(
onHangUpButtonClicked: () -> Unit,
modifier: Modifier = Modifier,
size: Dp = dimensions().bigCallingControlsSize,
size: Dp = dimensions().defaultCallingControlsHeight,
iconSize: Dp = dimensions().bigCallingHangUpButtonIconSize,
) {
WirePrimaryIconButton(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/*
* Wire
* Copyright (C) 2024 Wire Swiss GmbH
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see http://www.gnu.org/licenses/.
*/

package com.wire.android.ui.calling.controlbuttons

import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.material3.MaterialTheme
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.DpSize
import com.wire.android.R
import com.wire.android.ui.common.button.WireButtonState
import com.wire.android.ui.common.button.WirePrimaryIconButton
import com.wire.android.ui.common.dimensions
import com.wire.android.ui.theme.WireTheme
import com.wire.android.ui.theme.wireDimensions
import com.wire.android.util.ui.PreviewMultipleThemes

@Composable
fun HangUpOngoingButton(
onHangUpButtonClicked: () -> Unit,
modifier: Modifier = Modifier,
width: Dp = dimensions().defaultCallingControlsWidth,
height: Dp = dimensions().defaultCallingControlsHeight,
iconSize: Dp = dimensions().bigCallingHangUpButtonIconSize,
) {
WirePrimaryIconButton(
iconResource = R.drawable.ic_call_reject,
contentDescription = R.string.content_description_calling_hang_up_call,
state = WireButtonState.Error,
shape = CircleShape,
minSize = DpSize(width, height),
minClickableSize = DpSize(width, height),
iconSize = iconSize,
onButtonClicked = onHangUpButtonClicked,
modifier = modifier,
)
}

@PreviewMultipleThemes
@Composable
fun PreviewComposableHangUpOngoingButton() = WireTheme {
HangUpOngoingButton(
modifier = Modifier
.width(MaterialTheme.wireDimensions.bigCallingControlsSize)
.height(MaterialTheme.wireDimensions.bigCallingControlsSize),
onHangUpButtonClicked = { }
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,48 +15,49 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see http://www.gnu.org/licenses/.
*/

package com.wire.android.ui.calling.controlbuttons

import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.Dp
import com.wire.android.R
import com.wire.android.ui.common.dimensions
import com.wire.android.ui.theme.WireTheme
import com.wire.android.util.ui.PreviewMultipleThemes

@Composable
fun CameraFlipButton(
onCameraFlipButtonClicked: () -> Unit,
fun InCallReactionsButton(
isSelected: Boolean,
onInCallReactionsClick: () -> Unit,
modifier: Modifier = Modifier,
isOnFrontCamera: Boolean = false,
size: Dp = dimensions().defaultCallingControlsSize
) {
WireCallControlButton(
isSelected = !isOnFrontCamera,
iconResId = when (isOnFrontCamera) {
true -> R.drawable.ic_camera_flipped
false -> R.drawable.ic_camera_flip
isSelected = isSelected,
iconResId = when (isSelected) {
true -> R.drawable.ic_incall_reactions
false -> R.drawable.ic_incall_reactions
},
contentDescription = when (isOnFrontCamera) {
true -> R.string.content_description_calling_flip_camera_on
false -> R.string.content_description_calling_flip_camera_off
contentDescription = when (isSelected) {
true -> R.string.content_description_calling_unmute_call
false -> R.string.content_description_calling_mute_call
},
onClick = onCameraFlipButtonClicked,
size = size,
modifier = modifier,
onClick = onInCallReactionsClick,
modifier = modifier
)
}

@PreviewMultipleThemes
@Composable
fun PreviewCameraFlipButtonOn() = WireTheme {
CameraFlipButton(isOnFrontCamera = true, onCameraFlipButtonClicked = { })
fun PreviewInCallReactionsButton() = WireTheme {
InCallReactionsButton(
isSelected = false,
onInCallReactionsClick = { }
)
}

@PreviewMultipleThemes
@Composable
fun PreviewCameraFlipButtonOff() = WireTheme {
CameraFlipButton(isOnFrontCamera = false, onCameraFlipButtonClicked = { })
fun PreviewInCallReactionsButtonSelected() = WireTheme {
InCallReactionsButton(
isSelected = true,
onInCallReactionsClick = { }
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@ package com.wire.android.ui.calling.controlbuttons

import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.Dp
import com.wire.android.R
import com.wire.android.ui.common.dimensions
import com.wire.android.ui.theme.WireTheme
import com.wire.android.util.ui.PreviewMultipleThemes

Expand All @@ -31,7 +29,6 @@ fun MicrophoneButton(
isMuted: Boolean,
onMicrophoneButtonClicked: () -> Unit,
modifier: Modifier = Modifier,
size: Dp = dimensions().defaultCallingControlsSize
) {
WireCallControlButton(
isSelected = !isMuted,
Expand All @@ -44,7 +41,6 @@ fun MicrophoneButton(
false -> R.string.content_description_calling_mute_call
},
onClick = onMicrophoneButtonClicked,
size = size,
modifier = modifier
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@ package com.wire.android.ui.calling.controlbuttons

import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.Dp
import com.wire.android.R
import com.wire.android.ui.common.dimensions
import com.wire.android.ui.theme.WireTheme
import com.wire.android.util.ui.PreviewMultipleThemes

Expand All @@ -31,7 +29,6 @@ fun SpeakerButton(
isSpeakerOn: Boolean,
onSpeakerButtonClicked: () -> Unit,
modifier: Modifier = Modifier,
size: Dp = dimensions().defaultCallingControlsSize
) {
WireCallControlButton(
isSelected = isSpeakerOn,
Expand All @@ -44,7 +41,6 @@ fun SpeakerButton(
false -> R.string.content_description_calling_turn_speaker_on
},
onClick = onSpeakerButtonClicked,
size = size,
modifier = modifier,
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,13 @@ package com.wire.android.ui.calling.controlbuttons

import androidx.annotation.DrawableRes
import androidx.annotation.StringRes
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.DpSize
import com.wire.android.ui.common.button.WireButtonState
import com.wire.android.ui.common.button.WireSecondaryIconButton
import com.wire.android.ui.common.button.WirePrimaryIconButton
import com.wire.android.ui.common.button.wireSecondaryButtonColors
import com.wire.android.ui.common.colorsScheme
import com.wire.android.ui.common.dimensions
Expand All @@ -39,10 +38,11 @@ fun WireCallControlButton(
@StringRes contentDescription: Int,
onClick: () -> Unit,
modifier: Modifier = Modifier,
size: Dp = dimensions().defaultCallingControlsSize,
width: Dp = dimensions().defaultCallingControlsWidth,
height: Dp = dimensions().defaultCallingControlsHeight,
iconSize: Dp = dimensions().defaultCallingControlsIconSize
) {
WireSecondaryIconButton(
WirePrimaryIconButton(
onButtonClicked = onClick,
iconResource = iconResId,
shape = CircleShape,
Expand All @@ -60,9 +60,9 @@ fun WireCallControlButton(
},
contentDescription = contentDescription,
state = if (isSelected) WireButtonState.Selected else WireButtonState.Default,
minSize = DpSize(size, size),
minClickableSize = DpSize(size, size),
minSize = DpSize(width, height),
minClickableSize = DpSize(width, height),
iconSize = iconSize,
modifier = modifier.size(size),
modifier = modifier,
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* Wire
* Copyright (C) 2024 Wire Swiss GmbH
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see http://www.gnu.org/licenses/.
*/
package com.wire.android.ui.calling.model

data class InCallReaction(
val emoji: String,
val sender: ReactionSender,
)

sealed interface ReactionSender {
data object You : ReactionSender
data class Other(val name: String) : ReactionSender
data object Unknown : ReactionSender
}
Loading

0 comments on commit 424abf8

Please sign in to comment.