Skip to content

Commit

Permalink
Merge branch 'release/candidate' into feat/disable-x86-support
Browse files Browse the repository at this point in the history
  • Loading branch information
MohamadJaara authored Nov 26, 2024
2 parents 237e01b + b5ec027 commit 5a35092
Show file tree
Hide file tree
Showing 36 changed files with 208 additions and 112 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/build-edge-env.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,4 +95,5 @@ jobs:
serviceAccountJson: service_account.json
packageName: com.wire.internal
releaseFiles: app/build/outputs/bundle/internalCompat/*.aab
track: alpha
track: production
status: completed
8 changes: 8 additions & 0 deletions app/src/main/kotlin/com/wire/android/model/UserAvatarData.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
package com.wire.android.model

import androidx.compose.runtime.Stable
import com.wire.android.R
import com.wire.android.ui.home.conversationslist.model.Membership
import com.wire.android.util.EMPTY
import com.wire.kalium.logic.data.user.ConnectionState
Expand All @@ -37,6 +38,13 @@ data class UserAvatarData(
return asset == null && nameBasedAvatar != null &&
nameBasedAvatar.initials.isEmpty().not() && membership != Membership.Service
}

fun getAvailabilityStatusDescriptionId(): Int? = when (availabilityStatus) {
UserAvailabilityStatus.NONE -> null
UserAvailabilityStatus.AVAILABLE -> R.string.user_profile_status_available
UserAvailabilityStatus.AWAY -> R.string.user_profile_status_away
UserAvailabilityStatus.BUSY -> R.string.user_profile_status_busy
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,6 @@ data class CreateAccountOverviewParams(
val contentText: String = "",
@DrawableRes val contentIconResId: Int = 0,
val learnMoreText: String = "",
val learnMoreUrl: String = ""
val learnMoreUrl: String = "",
val isContentTextSemanticAccessible: Boolean = false
)
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,8 @@ fun CreateTeamAccountOverviewScreen(
contentText = stringResource(id = overviewResources.overviewContentTextResId),
contentIconResId = overviewResources.overviewContentIconResId,
learnMoreText = stringResource(id = overviewResources.overviewLearnMoreTextResId),
learnMoreUrl = viewModel.learnMoreUrl()
learnMoreUrl = viewModel.learnMoreUrl(),
isContentTextSemanticAccessible = true
)
)
}
Expand Down Expand Up @@ -193,7 +194,15 @@ private fun OverviewTexts(
text = overviewParams.contentText,
style = MaterialTheme.wireTypography.body02,
textAlign = TextAlign.Center,
modifier = Modifier.fillMaxWidth().clearAndSetSemantics {}
modifier = Modifier
.fillMaxWidth()
.run {
if (overviewParams.isContentTextSemanticAccessible) {
this
} else {
clearAndSetSemantics {}
}
}
)
Text(
text = overviewParams.learnMoreText,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ import androidx.compose.ui.platform.testTag
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.res.vectorResource
import androidx.compose.ui.semantics.clearAndSetSemantics
import androidx.compose.ui.semantics.contentDescription
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp
import com.wire.android.BuildConfig
Expand Down Expand Up @@ -189,13 +191,22 @@ private fun ColumnScope.DeviceItemTexts(
.fillMaxWidth()
.shimmerPlaceholder(visible = placeholder)
) {
val deviceName = device.name.asString()
val shouldAddNotVerifiedLabel = shouldShowVerifyLabel && !shouldShowE2EIInfo && !(device.isVerifiedProteus && !isCurrentClient)
val semantic = if (shouldAddNotVerifiedLabel) {
val notVerifiedLabel = stringResource(R.string.label_client_unverified)
Modifier.clearAndSetSemantics { contentDescription = "$deviceName, $notVerifiedLabel" }
} else {
Modifier
}
Text(
style = MaterialTheme.wireTypography.body02,
color = MaterialTheme.wireColorScheme.onBackground,
text = device.name.asString(),
text = deviceName,
modifier = Modifier
.wrapContentWidth()
.shimmerPlaceholder(visible = placeholder)
.then(semantic)
)
if (shouldShowVerifyLabel) {
if (shouldShowE2EIInfo) {
Expand Down Expand Up @@ -223,6 +234,16 @@ private fun ColumnScope.DeviceItemTexts(

Spacer(modifier = Modifier.height(MaterialTheme.wireDimensions.removeDeviceItemTitleVerticalPadding))

MLSDetails(device, placeholder)

ProteusDetails(device, placeholder)
}

@Composable
private fun MLSDetails(
device: Device,
placeholder: Boolean
) {
device.mlsClientIdentity?.let { identity ->
Text(
style = MaterialTheme.wireTypography.subline01,
Expand All @@ -238,7 +259,13 @@ private fun ColumnScope.DeviceItemTexts(
.shimmerPlaceholder(visible = placeholder)
)
}
}

@Composable
private fun ProteusDetails(
device: Device,
placeholder: Boolean
) {
val proteusDetails: String = if (!device.registrationTime.isNullOrBlank()) {
if (device.lastActiveInWholeWeeks != null) {
stringResource(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,10 @@ import androidx.compose.ui.platform.LocalInspectionMode
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.semantics.Role
import androidx.compose.ui.semantics.clearAndSetSemantics
import androidx.compose.ui.semantics.contentDescription
import androidx.compose.ui.semantics.role
import androidx.compose.ui.semantics.semantics
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.tooling.preview.Preview
Expand Down Expand Up @@ -248,12 +251,19 @@ private fun DefaultInitialsAvatar(
type: UserProfileAvatarType,
size: Dp,
modifier: Modifier = Modifier,
contentDescription: String? = null
) {
val contentDescription = stringResource(R.string.content_description_user_avatar)
val semantics = if (contentDescription != null) {
Modifier.semantics {
this.contentDescription = contentDescription
this.role = Role.Image
}
} else {
Modifier.clearAndSetSemantics { }
}
Box(
contentAlignment = Alignment.Center,
modifier = modifier
.semantics { this.contentDescription = contentDescription }
.size(size)
.clip(CircleShape)
.background(
Expand All @@ -266,6 +276,7 @@ private fun DefaultInitialsAvatar(
)
}
)
.then(semantics)
) {
Text(
text = nameBasedAvatar.initials,
Expand Down
21 changes: 15 additions & 6 deletions app/src/main/kotlin/com/wire/android/ui/common/WireDropDown.kt
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.semantics.onClick
import androidx.compose.ui.semantics.paneTitle
import androidx.compose.ui.semantics.selected
import androidx.compose.ui.semantics.semantics
import androidx.compose.ui.tooling.preview.Preview
Expand Down Expand Up @@ -164,6 +165,8 @@ private fun MenuPopUp(
hidePopUp: () -> Unit,
onChange: (selectedIndex: Int) -> Unit
) {
val dropdownDescription = stringResource(R.string.content_description_drop_down)

MaterialTheme(shapes = MaterialTheme.shapes.copy(extraSmall = shape)) {
// we want PopUp to cover the selection field, so we set this offset.
// "- 8.dp" is because DropdownMenu has inner top padding, which can't be changed,
Expand All @@ -178,14 +181,15 @@ private fun MenuPopUp(
.width(with(LocalDensity.current) { textFieldWidth.width.toDp() })
.background(color = MaterialTheme.wireColorScheme.secondaryButtonEnabled)
.border(width = 1.dp, color = borderColor, shape)
.semantics { paneTitle = dropdownDescription }
) {

SelectionField(
Modifier.clickable(onClickLabel = stringResource(R.string.content_description_close_dropdown)) { hidePopUp() },
leadingCompose,
selectedIndex,
selectionText,
arrowRotation
arrowRotation,
Modifier.clickable(onClickLabel = stringResource(R.string.content_description_close_dropdown)) { hidePopUp() }
)

List(items.size) { index ->
Expand All @@ -210,11 +214,11 @@ private fun MenuPopUp(

@Composable
private fun SelectionField(
modifier: Modifier = Modifier,
leadingCompose: @Composable ((index: Int) -> Unit)?,
selectedIndex: Int,
text: String,
arrowRotation: Float
arrowRotation: Float,
modifier: Modifier = Modifier
) {
Row(
modifier
Expand Down Expand Up @@ -262,6 +266,7 @@ private fun DropdownItem(
onClick: () -> Unit
) {
val selectLabel = stringResource(R.string.content_description_select_label)
val closeDropdownLabel = stringResource(R.string.content_description_close_dropdown)
return DropdownMenuItem(
text = {
Text(
Expand All @@ -281,8 +286,12 @@ private fun DropdownItem(
onClick = onClick,
modifier = Modifier
.semantics {
onClick(selectLabel) { false }
if (isSelected) selected = true
if (isSelected) {
selected = true
onClick(closeDropdownLabel) { false }
} else {
onClick(selectLabel) { false }
}
}
.background(
color = if (isSelected) MaterialTheme.wireColorScheme.secondaryButtonSelected
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/kotlin/com/wire/android/ui/home/HomeScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ fun HomeContent(
}
},
collapsingEnabled = !searchBarState.isSearchActive,
contentLazyListState = homeStateHolder.currentLazyListState,
contentLazyListState = homeStateHolder.lazyListStateFor(currentNavigationItem),
content = {
/**
* This "if" is a workaround, otherwise it can crash because of the SubcomposeLayout's nature.
Expand Down
38 changes: 21 additions & 17 deletions app/src/main/kotlin/com/wire/android/ui/home/HomeStateHolder.kt
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ import androidx.compose.material3.DrawerState
import androidx.compose.material3.DrawerValue
import androidx.compose.material3.rememberDrawerState
import androidx.compose.runtime.Composable
import androidx.compose.runtime.State
import androidx.compose.runtime.derivedStateOf
import androidx.compose.runtime.getValue
import androidx.compose.runtime.remember
import androidx.compose.runtime.rememberCoroutineScope
Expand All @@ -42,12 +44,15 @@ class HomeStateHolder(
val coroutineScope: CoroutineScope,
val navController: NavHostController,
val drawerState: DrawerState,
val currentNavigationItem: HomeDestination,
val searchBarState: SearchBarState,
val navigator: Navigator,
lazyListStates: Map<HomeDestination, LazyListState>,
private val currentNavigationItemState: State<HomeDestination>,
private val lazyListStates: Map<HomeDestination, LazyListState>,
) {
val currentLazyListState = lazyListStates[currentNavigationItem] ?: error("No LazyListState found for $currentNavigationItem")
val currentNavigationItem
get() = currentNavigationItemState.value
fun lazyListStateFor(destination: HomeDestination): LazyListState =
lazyListStates[destination] ?: error("No LazyListState found for $destination")

fun closeDrawer() {
coroutineScope.launch {
Expand All @@ -73,23 +78,22 @@ fun rememberHomeScreenState(
): HomeStateHolder {
val searchBarState = rememberSearchbarState()
val navBackStackEntry by navController.currentBackStackEntryAsState()
val currentRoute = navBackStackEntry?.destination?.route
val currentNavigationItem = currentRoute?.let { HomeDestination.fromRoute(it) } ?: HomeDestination.Conversations
val currentNavigationItemState = remember {
derivedStateOf {
navBackStackEntry?.destination?.route?.let { HomeDestination.fromRoute(it) } ?: HomeDestination.Conversations
}
}
val lazyListStates = HomeDestination.values().associateWith { rememberLazyListState() }

val homeState = remember(
currentNavigationItem
) {
return remember {
HomeStateHolder(
coroutineScope,
navController,
drawerState,
currentNavigationItem,
searchBarState,
navigator,
lazyListStates
coroutineScope = coroutineScope,
navController = navController,
drawerState = drawerState,
searchBarState = searchBarState,
navigator = navigator,
currentNavigationItemState = currentNavigationItemState,
lazyListStates = lazyListStates
)
}

return homeState
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ package com.wire.android.ui.home.archive

import androidx.compose.foundation.text.input.TextFieldState
import androidx.compose.runtime.Composable
import com.wire.android.navigation.HomeDestination
import com.wire.android.navigation.HomeNavGraph
import com.wire.android.navigation.WireDestination
import com.wire.android.navigation.rememberNavigator
Expand All @@ -42,7 +43,7 @@ fun ArchiveScreen(homeStateHolder: HomeStateHolder) {
navigator = navigator,
searchBarState = searchBarState,
conversationsSource = ConversationsSource.ARCHIVE,
lazyListState = currentLazyListState,
lazyListState = lazyListStateFor(HomeDestination.Archive),
emptyListContent = { ArchiveEmptyContent() }
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.semantics.contentDescription
import androidx.compose.ui.semantics.semantics
import com.wire.android.BuildConfig
import com.wire.android.R
import com.wire.android.model.Clickable
Expand Down Expand Up @@ -124,10 +126,18 @@ fun ConversationParticipantItem(
}
},
subtitle = {
val userName = processUsername(uiParticipant)
// Availability status should be called after username by TalkBack
val subtitleModifier = uiParticipant.avatarData.getAvailabilityStatusDescriptionId()?.let {
val contentDescription = stringResource(it)
Modifier.semantics { this.contentDescription = "$userName, $contentDescription" }
} ?: Modifier

HighlightSubtitle(
subTitle = processUsername(uiParticipant),
subTitle = userName,
searchQuery = searchQuery,
prefix = processUsernamePrefix(uiParticipant)
prefix = processUsernamePrefix(uiParticipant),
modifier = subtitleModifier
)
},
actions = {
Expand Down
Loading

0 comments on commit 5a35092

Please sign in to comment.