Skip to content

Commit

Permalink
Merge branch 'develop' into Push-notification-on-top-of-calling-UI-shown
Browse files Browse the repository at this point in the history
  • Loading branch information
ohassine authored Nov 7, 2024
2 parents b7e739c + 8f9cd86 commit fef26d1
Show file tree
Hide file tree
Showing 14 changed files with 133 additions and 90 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ class KaliumConfigsModule {
shouldEncryptData = !BuildConfig.DEBUG || Build.VERSION.SDK_INT < Build.VERSION_CODES.R,
lowerKeyPackageLimits = BuildConfig.LOWER_KEYPACKAGE_LIMIT,
lowerKeyingMaterialsUpdateThreshold = BuildConfig.PRIVATE_BUILD,
isMLSSupportEnabled = BuildConfig.MLS_SUPPORT_ENABLED,
developmentApiEnabled = BuildConfig.DEVELOPMENT_API_ENABLED,
ignoreSSLCertificatesForUnboundCalls = BuildConfig.IGNORE_SSL_CERTIFICATES,
encryptProteusStorage = runBlocking { globalDataStore.isEncryptedProteusStorageEnabled().first() },
Expand Down
75 changes: 48 additions & 27 deletions app/src/main/kotlin/com/wire/android/ui/WireActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,12 @@ import androidx.compose.runtime.getValue
import androidx.compose.runtime.remember
import androidx.compose.runtime.rememberUpdatedState
import androidx.compose.runtime.staticCompositionLocalOf
import androidx.compose.ui.ExperimentalComposeUiApi
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.LocalSoftwareKeyboardController
import androidx.compose.ui.semantics.semantics
import androidx.compose.ui.semantics.testTagsAsResourceId
import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen
import androidx.core.view.WindowCompat
import androidx.lifecycle.Lifecycle
Expand Down Expand Up @@ -71,6 +74,7 @@ import com.wire.android.ui.common.bottomsheet.rememberWireModalSheetState
import com.wire.android.ui.common.bottomsheet.show
import com.wire.android.ui.common.snackbar.LocalSnackbarHostState
import com.wire.android.ui.common.topappbar.CommonTopAppBar
import com.wire.android.ui.common.topappbar.CommonTopAppBarState
import com.wire.android.ui.common.topappbar.CommonTopAppBarViewModel
import com.wire.android.ui.common.visbility.rememberVisibilityState
import com.wire.android.ui.destinations.ConversationScreenDestination
Expand Down Expand Up @@ -120,6 +124,7 @@ import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import javax.inject.Inject

@OptIn(ExperimentalComposeUiApi::class)
@AndroidEntryPoint
@Suppress("TooManyFunctions")
class WireActivity : AppCompatActivity() {
Expand Down Expand Up @@ -203,6 +208,7 @@ class WireActivity : AppCompatActivity() {
}
}

@Suppress("LongMethod")
private fun setComposableContent(
startDestination: Route,
onComplete: () -> Unit
Expand All @@ -220,36 +226,15 @@ class WireActivity : AppCompatActivity() {
LocalActivity provides this
) {
WireTheme {
Column(modifier = Modifier.statusBarsPadding()) {
Column(
modifier = Modifier
.statusBarsPadding()
.semantics { testTagsAsResourceId = true }
) {
val navigator = rememberNavigator(this@WireActivity::finish)
CommonTopAppBar(
WireTopAppBar(
themeOption = viewModel.globalAppState.themeOption,
commonTopAppBarState = commonTopAppBarViewModel.state,
onReturnToCallClick = { establishedCall ->
getOngoingCallIntent(
this@WireActivity,
establishedCall.conversationId.toString()
).run {
startActivity(this)
}
},
onReturnToIncomingCallClick = {
getIncomingCallIntent(
this@WireActivity,
it.conversationId.toString(),
null
).run {
startActivity(this)
}
},
onReturnToOutgoingCallClick = {
getOutgoingCallIntent(
this@WireActivity,
it.conversationId.toString()
).run {
startActivity(this)
}
}
)
CompositionLocalProvider(LocalNavigator provides navigator) {
MainNavHost(
Expand All @@ -269,6 +254,42 @@ class WireActivity : AppCompatActivity() {
}
}

@Composable
private fun WireTopAppBar(
themeOption: ThemeOption,
commonTopAppBarState: CommonTopAppBarState
) {
CommonTopAppBar(
themeOption = themeOption,
commonTopAppBarState = commonTopAppBarState,
onReturnToCallClick = { establishedCall ->
getOngoingCallIntent(
this@WireActivity,
establishedCall.conversationId.toString()
).run {
startActivity(this)
}
},
onReturnToIncomingCallClick = {
getIncomingCallIntent(
this@WireActivity,
it.conversationId.toString(),
null
).run {
startActivity(this)
}
},
onReturnToOutgoingCallClick = {
getOutgoingCallIntent(
this@WireActivity,
it.conversationId.toString()
).run {
startActivity(this)
}
}
)
}

@Composable
private fun HandleThemeChanges(themeOption: ThemeOption) {
LaunchedEffect(themeOption) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.ui.ExperimentalComposeUiApi
import androidx.compose.ui.Modifier
import androidx.compose.ui.semantics.semantics
import androidx.compose.ui.semantics.testTagsAsResourceId
import androidx.core.view.WindowCompat
import com.wire.android.appLogger
import com.wire.android.navigation.style.TransitionAnimationType
Expand All @@ -52,6 +56,7 @@ import javax.inject.Inject
* @see IncomingCallScreen
* @see OutgoingCallScreen
*/
@OptIn(ExperimentalComposeUiApi::class)
@AndroidEntryPoint
class StartingCallActivity : CallActivity() {
@Inject
Expand Down Expand Up @@ -90,6 +95,7 @@ class StartingCallActivity : CallActivity() {
TransitionAnimationType.POP_UP.exitTransition
)
},
modifier = Modifier.semantics { testTagsAsResourceId = true },
label = currentScreenType.name
) { screenType ->
conversationId?.let {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ import androidx.compose.animation.togetherWith
import androidx.compose.material3.SnackbarHostState
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.runtime.remember
import androidx.compose.ui.ExperimentalComposeUiApi
import androidx.compose.ui.Modifier
import androidx.compose.ui.semantics.semantics
import androidx.compose.ui.semantics.testTagsAsResourceId
import androidx.core.view.WindowCompat
import com.wire.android.R
import com.wire.android.appLogger
Expand All @@ -56,6 +60,7 @@ import javax.inject.Inject
*
* @see OngoingCallScreen
*/
@OptIn(ExperimentalComposeUiApi::class)
@AndroidEntryPoint
class OngoingCallActivity : CallActivity() {
@Inject
Expand Down Expand Up @@ -91,6 +96,7 @@ class OngoingCallActivity : CallActivity() {
TransitionAnimationType.POP_UP.exitTransition
)
},
modifier = Modifier.semantics { testTagsAsResourceId = true },
label = TAG
) { _ ->
OngoingCallScreen(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ import com.wire.kalium.logic.data.call.CallStatus
import com.wire.kalium.logic.data.conversation.Conversation
import com.wire.kalium.logic.data.id.ConversationId
import com.wire.kalium.logic.data.id.QualifiedID
import com.wire.kalium.logic.data.user.UserId
import kotlinx.collections.immutable.PersistentList
import kotlinx.collections.immutable.persistentListOf
import kotlinx.collections.immutable.toPersistentList
Expand Down Expand Up @@ -161,6 +162,7 @@ fun OngoingCallScreen(
}
}

val inPictureInPictureMode = activity.isInPictureInPictureMode
OngoingCallContent(
callState = sharedCallingViewModel.callState,
shouldShowDoubleTapToast = ongoingCallViewModel.shouldShowDoubleTapToast,
Expand All @@ -175,7 +177,9 @@ fun OngoingCallScreen(
requestVideoStreams = ongoingCallViewModel::requestVideoStreams,
hideDoubleTapToast = ongoingCallViewModel::hideDoubleTapToast,
onCameraPermissionPermanentlyDenied = onCameraPermissionPermanentlyDenied,
participants = sharedCallingViewModel.participantsState
participants = sharedCallingViewModel.participantsState,
inPictureInPictureMode = inPictureInPictureMode,
currentUserId = ongoingCallViewModel.currentUserId,
)

BackHandler {
Expand Down Expand Up @@ -283,10 +287,10 @@ private fun OngoingCallContent(
hideDoubleTapToast: () -> Unit,
onCameraPermissionPermanentlyDenied: () -> Unit,
requestVideoStreams: (participants: List<UICallParticipant>) -> Unit,
participants: PersistentList<UICallParticipant>
participants: PersistentList<UICallParticipant>,
inPictureInPictureMode: Boolean,
currentUserId: UserId,
) {
val activity = LocalActivity.current

val sheetInitialValue = SheetValue.PartiallyExpanded
val sheetState = rememberStandardBottomSheetState(
initialValue = sheetInitialValue
Expand All @@ -301,7 +305,7 @@ private fun OngoingCallContent(

WireBottomSheetScaffold(
sheetDragHandle = null,
topBar = if (activity.isInPictureInPictureMode) {
topBar = if (inPictureInPictureMode) {
null
} else {
{
Expand All @@ -319,10 +323,10 @@ private fun OngoingCallContent(
)
}
},
sheetPeekHeight = if (activity.isInPictureInPictureMode) 0.dp else dimensions().defaultSheetPeekHeight,
sheetPeekHeight = if (inPictureInPictureMode) 0.dp else dimensions().defaultSheetPeekHeight,
scaffoldState = scaffoldState,
sheetContent = {
if (!activity.isInPictureInPictureMode) {
if (!inPictureInPictureMode) {
CallingControls(
conversationId = callState.conversationId,
isMuted = callState.isMuted ?: true,
Expand All @@ -343,7 +347,7 @@ private fun OngoingCallContent(
modifier = Modifier
.padding(
top = it.calculateTopPadding(),
bottom = if (activity.isInPictureInPictureMode) 0.dp else dimensions().defaultSheetPeekHeight
bottom = if (inPictureInPictureMode) 0.dp else dimensions().defaultSheetPeekHeight
)
) {

Expand Down Expand Up @@ -399,14 +403,16 @@ private fun OngoingCallContent(
participants = participants,
isSelfUserCameraOn = callState.isCameraOn,
isSelfUserMuted = callState.isMuted ?: true,
isInPictureInPictureMode = inPictureInPictureMode,
contentHeight = this@BoxWithConstraints.maxHeight,
onSelfVideoPreviewCreated = setVideoPreview,
onSelfClearVideoPreview = clearVideoPreview,
requestVideoStreams = requestVideoStreams,
currentUserId = currentUserId,
onDoubleTap = { selectedParticipant ->
selectedParticipantForFullScreen = selectedParticipant
shouldOpenFullScreen = !shouldOpenFullScreen
}
},
)
DoubleTapToast(
modifier = Modifier.align(Alignment.TopCenter),
Expand All @@ -416,11 +422,16 @@ private fun OngoingCallContent(
)
}
if (BuildConfig.PICTURE_IN_PICTURE_ENABLED && participants.size > 1) {
val selfUser =
participants.first { participant ->
// API returns only id.value, without domain, till this get changed compare only id.value
participant.id.equalsIgnoringBlankDomain(currentUserId)
}
FloatingSelfUserTile(
modifier = Modifier.align(Alignment.TopEnd),
contentHeight = this@BoxWithConstraints.maxHeight,
contentWidth = this@BoxWithConstraints.maxWidth,
participant = participants.first(),
participant = selfUser,
onSelfUserVideoPreviewCreated = setVideoPreview,
onClearSelfUserVideoPreview = clearVideoPreview
)
Expand Down Expand Up @@ -564,7 +575,9 @@ fun PreviewOngoingCallContent(participants: PersistentList<UICallParticipant>) {
hideDoubleTapToast = {},
onCameraPermissionPermanentlyDenied = {},
requestVideoStreams = {},
participants = participants
participants = participants,
inPictureInPictureMode = false,
currentUserId = UserId("userId", "domain"),
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
import com.wire.android.BuildConfig
import com.wire.android.ui.LocalActivity
import com.wire.android.ui.calling.model.UICallParticipant
import com.wire.android.ui.calling.ongoing.buildPreviewParticipantsList
import com.wire.android.ui.calling.ongoing.fullscreen.SelectedParticipant
Expand All @@ -52,6 +51,7 @@ 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
import com.wire.kalium.logic.data.user.UserId

private const val MAX_TILES_PER_PAGE = 8
private const val MAX_ITEMS_FOR_HORIZONTAL_VIEW = 3
Expand All @@ -61,15 +61,15 @@ fun VerticalCallingPager(
participants: List<UICallParticipant>,
isSelfUserMuted: Boolean,
isSelfUserCameraOn: Boolean,
isInPictureInPictureMode: Boolean,
contentHeight: Dp,
currentUserId: UserId,
onSelfVideoPreviewCreated: (view: View) -> Unit,
onSelfClearVideoPreview: () -> Unit,
requestVideoStreams: (participants: List<UICallParticipant>) -> Unit,
onDoubleTap: (selectedParticipant: SelectedParticipant) -> Unit,
modifier: Modifier = Modifier,
) {
val activity = LocalActivity.current

Column(
modifier = modifier
.fillMaxWidth()
Expand Down Expand Up @@ -101,13 +101,13 @@ fun VerticalCallingPager(
if (participantsChunkedList[pageIndex].size <= MAX_ITEMS_FOR_HORIZONTAL_VIEW) {
CallingHorizontalView(
participants = participantsChunkedList[pageIndex],
pageIndex = pageIndex,
isSelfUserMuted = isSelfUserMuted,
isSelfUserCameraOn = isSelfUserCameraOn,
contentHeight = contentHeight,
onSelfVideoPreviewCreated = onSelfVideoPreviewCreated,
onSelfClearVideoPreview = onSelfClearVideoPreview,
onDoubleTap = onDoubleTap
onDoubleTap = onDoubleTap,
currentUserId = currentUserId,
)
} else {
GroupCallGrid(
Expand All @@ -118,7 +118,8 @@ fun VerticalCallingPager(
contentHeight = contentHeight,
onSelfVideoPreviewCreated = onSelfVideoPreviewCreated,
onSelfClearVideoPreview = onSelfClearVideoPreview,
onDoubleTap = onDoubleTap
onDoubleTap = onDoubleTap,
currentUserId = currentUserId,
)
}

Expand All @@ -132,7 +133,7 @@ fun VerticalCallingPager(
}
}
// we don't need to display the indicator if we have one page and when it's in PiP mode
if (pagesCount(participants.size) > 1 && !activity.isInPictureInPictureMode) {
if (pagesCount(participants.size) > 1 && !isInPictureInPictureMode) {
Surface(
shape = RoundedCornerShape(dimensions().corner16x),
modifier = Modifier
Expand Down Expand Up @@ -165,7 +166,9 @@ private fun pagesCount(size: Int): Int {
val pages = size / MAX_TILES_PER_PAGE
return if (size % MAX_TILES_PER_PAGE > 0) {
pages + 1
} else pages
} else {
pages
}
}

@Composable
Expand All @@ -178,7 +181,9 @@ private fun PreviewVerticalCallingPager(participants: List<UICallParticipant>) {
onSelfVideoPreviewCreated = {},
onSelfClearVideoPreview = {},
requestVideoStreams = {},
onDoubleTap = { }
onDoubleTap = { },
isInPictureInPictureMode = false,
currentUserId = UserId("id", "domain")
)
}

Expand Down
Loading

0 comments on commit fef26d1

Please sign in to comment.