Skip to content

Commit

Permalink
Merge remote-tracking branch 'refs/remotes/origin/release/candidate' …
Browse files Browse the repository at this point in the history
…into fix/reusing_pagingdata_crash
  • Loading branch information
saleniuk committed Dec 30, 2024
2 parents a67ed50 + 10efa7e commit 63dfb82
Show file tree
Hide file tree
Showing 13 changed files with 183 additions and 63 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ private fun UsernameTile(
modifier: Modifier = Modifier,
) {
val color =
if (isSpeaking) colorsScheme().primary else darkColorsScheme().surfaceContainerLowest
if (isSpeaking) colorsScheme().primary else darkColorsScheme().inverseOnSurface
val nameLabelColor =
when {
isSpeaking -> colorsScheme().onPrimary
Expand Down
33 changes: 27 additions & 6 deletions app/src/main/kotlin/com/wire/android/ui/home/HomeTopBar.kt
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,11 @@ fun HomeTopBar(
}
if (navigationItem.withUserAvatar) {
val openLabel = stringResource(R.string.content_description_open_label)
val contentDescription = if (shouldShowCreateTeamUnreadIndicator) {
stringResource(R.string.content_description_home_profile_btn_with_notification)
} else {
stringResource(R.string.content_description_home_profile_btn)
}
val contentDescription = if (shouldShowCreateTeamUnreadIndicator) {
stringResource(R.string.content_description_home_profile_btn_with_notification)
} else {
stringResource(R.string.content_description_home_profile_btn)
}
UserProfileAvatar(
avatarData = userAvatarData,
clickable = remember {
Expand All @@ -87,7 +87,7 @@ fun HomeTopBar(
legalHoldIndicatorVisible = withLegalHoldIndicator
),
shouldShowCreateTeamUnreadIndicator = shouldShowCreateTeamUnreadIndicator,
contentDescription = contentDescription
contentDescription = contentDescription
)
}
},
Expand All @@ -112,6 +112,27 @@ fun PreviewTopBar() {
}
}

@PreviewMultipleThemes
@Composable
fun PreviewTopBarWithSelectedFilter() {
WireTheme {
HomeTopBar(
navigationItem = HomeDestination.Group,
userAvatarData = UserAvatarData(
asset = null,
availabilityStatus = UserAvailabilityStatus.AVAILABLE,
nameBasedAvatar = NameBasedAvatar("Jon Doe", -1)
),
elevation = 0.dp,
withLegalHoldIndicator = false,
shouldShowCreateTeamUnreadIndicator = false,
onHamburgerMenuClick = {},
onNavigateToSelfUserProfile = {},
onOpenConversationFilter = {}
)
}
}

@PreviewMultipleThemes
@Composable
fun PreviewSettingsTopBarWithoutAvatar() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,12 +186,13 @@ fun ConversationProtocolDetails(
) {
Column(modifier = modifier) {
FolderHeader(name = stringResource(R.string.folder_label_protocol_details))
if (protocolInfo is Conversation.ProtocolInfo.MLS) {
ProtocolDetails(
label = UIText.StringResource(R.string.protocol),
text = UIText.DynamicString(protocolInfo.name())
)

ProtocolDetails(
label = UIText.StringResource(R.string.protocol),
text = UIText.DynamicString(protocolInfo.name())
)

if (protocolInfo is Conversation.ProtocolInfo.MLS) {
ProtocolDetails(
label = UIText.StringResource(R.string.cipher_suite),
text = UIText.DynamicString(protocolInfo.cipherSuite.toString())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ import androidx.compose.foundation.layout.isImeVisible
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.wrapContentHeight
import androidx.compose.foundation.layout.wrapContentSize
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.foundation.shape.GenericShape
import androidx.compose.material3.Surface
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
Expand All @@ -55,12 +55,20 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.draw.drawBehind
import androidx.compose.ui.geometry.CornerRadius
import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.geometry.Rect
import androidx.compose.ui.geometry.RoundRect
import androidx.compose.ui.geometry.Size
import androidx.compose.ui.geometry.toRect
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.RectangleShape
import androidx.compose.ui.graphics.Path
import androidx.compose.ui.graphics.drawscope.Fill
import androidx.compose.ui.graphics.drawscope.Stroke
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.unit.Density
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.IntOffset
import androidx.compose.ui.unit.dp
import androidx.compose.ui.window.Popup
Expand Down Expand Up @@ -326,11 +334,12 @@ fun EnabledMessageComposer(
showAttachments(false)
}
) {
val rippleColor = colorsScheme().surface
val shape = if (isImeVisible) {
RectangleShape
} else {
RoundedCornerShape(dimensions().corner14x)
val rippleColor = colorsScheme().surfaceContainerLowest
val borderColor = colorsScheme().divider
val borderWidthPx = if (isImeVisible) 0f else dimensions().spacing1x.toPx(density)
val cornerRadiusPx = if (isImeVisible) 0f else dimensions().corner14x.toPx(density)
val shape = GenericShape { size, _ ->
addPath(calculateOptionsPath(cornerRadiusPx, rippleProgress.value, isImeVisible, size))
}

Box(
Expand All @@ -351,21 +360,22 @@ fun EnabledMessageComposer(
.clip(shape)
.drawBehind {
if (!hideRipple || rippleProgress.value > 0f) {
val maxRadius = size.getDistanceToCorner(Offset(0f, 0f))
val currentRadius = maxRadius * rippleProgress.value

drawCircle(
color = rippleColor,
radius = currentRadius,
center = Offset(
0f,
if (isImeVisible) {
0f
} else {
size.height
}
calculateOptionsPath(cornerRadiusPx, rippleProgress.value, isImeVisible, size).let {
drawPath(
path = it,
color = rippleColor,
style = Fill
)
)
if (borderWidthPx > 0f) {
drawPath(
path = it,
color = borderColor,
style = Stroke(
width = borderWidthPx * 2f // double to make inner stroke, outer half is clipped anyway
)
)
}
}
}
}

Expand Down Expand Up @@ -402,7 +412,30 @@ fun EnabledMessageComposer(
}
}

fun Size.getDistanceToCorner(corner: Offset): Float {
private fun Size.getDistanceToCorner(corner: Offset): Float {
val cornerOffset = Offset(width - corner.x, height - corner.y)
return cornerOffset.getDistance()
}

private fun calculateOptionsPath(cornerRadiusPx: Float, rippleProgress: Float, isImeVisible: Boolean, size: Size): Path {
val ripplePath = Path()
ripplePath.addOval(
oval = Rect(
center = Offset(
x = 0f,
y = if (isImeVisible) 0f else size.height
),
radius = rippleProgress * size.getDistanceToCorner(Offset(0f, 0f))
)
)
val shapePath = Path()
shapePath.addRoundRect(
roundRect = RoundRect(
rect = size.toRect(),
cornerRadius = CornerRadius(cornerRadiusPx, cornerRadiusPx)
)
)
return ripplePath.and(shapePath)
}

private fun Dp.toPx(density: Density) = with(density) { toPx() }
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.wrapContentHeight
import androidx.compose.foundation.text.KeyboardOptions
import androidx.compose.foundation.text.input.TextFieldLineLimits
import androidx.compose.foundation.text.input.TextFieldState
import androidx.compose.material3.HorizontalDivider
import androidx.compose.material3.Icon
Expand Down Expand Up @@ -312,7 +313,8 @@ private fun MessageComposerTextInput(
},
interactionSource = interactionSource,
onSelectedLineIndexChanged = onSelectedLineIndexChanged,
onLineBottomYCoordinateChanged = onLineBottomYCoordinateChanged
onLineBottomYCoordinateChanged = onLineBottomYCoordinateChanged,
lineLimits = TextFieldLineLimits.MultiLine()
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,14 +201,25 @@ class DeviceDetailsViewModel @Inject constructor(
canBeRemoved = !result.isCurrentClient && isSelfClient && result.client.type != ClientType.LegalHold,
mlsCipherSuiteSignature = MLSPublicKeyType.from(
result.client.mlsPublicKeys?.keys?.firstOrNull().orEmpty()
).value.toString()
).let { mapCipherSuiteSignatureToShortName(it) }
)
}
}
}
}
}

private fun mapCipherSuiteSignatureToShortName(signature: MLSPublicKeyType): String {
return when (signature) {
MLSPublicKeyType.ECDSA_SECP256R1_SHA256 -> "P256"
MLSPublicKeyType.ECDSA_SECP384R1_SHA384 -> "P384"
MLSPublicKeyType.ECDSA_SECP521R1_SHA512 -> "P521"
MLSPublicKeyType.ED25519 -> "ED25519"
MLSPublicKeyType.ED448 -> "ED448"
is MLSPublicKeyType.Unknown -> "Unknown"
}
}

fun removeDevice(onSuccess: () -> Unit) {
viewModelScope.launch {
val isPasswordRequired: Boolean = when (val passwordRequiredResult = isPasswordRequired()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ class TeamMigrationViewModel @Inject constructor(
fun migrateFromPersonalToTeamAccount(onSuccess: () -> Unit) {
viewModelScope.launch {
migrateFromPersonalToTeam.invoke(
teamMigrationState.teamNameTextState.text.toString(),
teamMigrationState.teamNameTextState.text.trim().toString(),
).let { result ->
when (result) {
is MigrateFromPersonalToTeamResult.Success -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ private fun TeamMigrationTeamNameStepScreenContent(
textFieldState = teamNameTextFieldState,
)
}
val isContinueButtonEnabled = teamNameTextFieldState.text.isNotEmpty()
val isContinueButtonEnabled = teamNameTextFieldState.text.isNotEmpty() && teamNameTextFieldState.text.isNotBlank()
BottomLineButtons(
isContinueButtonEnabled = isContinueButtonEnabled,
onContinue = onContinueButtonClicked,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,22 @@ class TeamMigrationViewModelTest {
Assertions.assertNull(viewModel.teamMigrationState.migrationFailure)
}

@Test
fun `given team name with spaces at start or end, when invoking migration, then trim the name`() = runTest {
// given
val (arrangement, viewModel) = Arrangement()
.withMigrateFromPersonalToTeamSuccess()
.arrange()
val onSuccess = {}
viewModel.teamMigrationState.teamNameTextState.setTextAndPlaceCursorAtEnd(" ${Arrangement.TEAM_NAME} ")
// when
viewModel.migrateFromPersonalToTeamAccount(onSuccess)
// then
coVerify(exactly = 1) {
arrangement.migrateFromPersonalToTeam(Arrangement.TEAM_NAME)
}
}

private class Arrangement {

@MockK
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,15 @@ import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Shape
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.DpSize
import androidx.compose.ui.unit.dp
import com.wire.android.model.ClickBlockParams
import com.wire.android.ui.common.Icon
import com.wire.android.ui.theme.WireTheme
import com.wire.android.ui.theme.wireDimensions
import com.wire.android.ui.theme.wireTypography
import com.wire.android.util.PreviewMultipleThemes

@Composable
fun WireTertiaryButton(
Expand Down Expand Up @@ -93,15 +94,15 @@ fun WireTertiaryButton(
description = description
)

@Preview(name = "Default WireSecondaryButton")
@PreviewMultipleThemes
@Composable
fun PreviewWireTertiaryButton() {
fun PreviewWireTertiaryButton() = WireTheme {
WireTertiaryButton(onClick = { }, text = "text")
}

@Preview(name = "Default narrow WireTertiaryButton with icon")
@PreviewMultipleThemes
@Composable
fun PreviewWireTertiaryButtonNarrowWithIcons() {
fun PreviewWireTertiaryButtonNarrowWithIcons() = WireTheme {
WireTertiaryButton(
onClick = { },
text = "text",
Expand All @@ -111,9 +112,9 @@ fun PreviewWireTertiaryButtonNarrowWithIcons() {
)
}

@Preview(name = "Default narrow WireTertiaryButton only icon")
@PreviewMultipleThemes
@Composable
fun PreviewWireTertiaryButtonNarrowOnlyIcons() {
fun PreviewWireTertiaryButtonNarrowOnlyIcons() = WireTheme {
WireTertiaryButton(
onClick = { },
leadingIcon = Icons.Filled.Search.Icon(),
Expand All @@ -122,20 +123,20 @@ fun PreviewWireTertiaryButtonNarrowOnlyIcons() {
)
}

@Preview(name = "Default narrow Disabled WireSecondaryButton")
@PreviewMultipleThemes
@Composable
fun PreviewWireTertiaryButtonDisabled() {
fun PreviewWireTertiaryButtonDisabled() = WireTheme {
WireTertiaryButton(onClick = { }, state = WireButtonState.Disabled, text = "text", fillMaxWidth = false)
}

@Preview(name = "Selected narrow WireSecondaryButton")
@PreviewMultipleThemes
@Composable
fun PreviewWireTertiaryButtonSelected() {
fun PreviewWireTertiaryButtonSelected() = WireTheme {
WireTertiaryButton(onClick = { }, state = WireButtonState.Selected, text = "text", fillMaxWidth = false)
}

@Preview(name = "Error narrow WireSecondaryButton")
@PreviewMultipleThemes
@Composable
fun PreviewWireTertiaryButtonError() {
fun PreviewWireTertiaryButtonError() = WireTheme {
WireTertiaryButton(onClick = { }, state = WireButtonState.Error, text = "text", fillMaxWidth = false)
}
Loading

0 comments on commit 63dfb82

Please sign in to comment.