Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: replace deprecated functions #2931

Merged
merged 9 commits into from
Apr 25, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import com.wire.kalium.logic.data.user.OtherUser
import com.wire.kalium.logic.data.user.SelfUser
import com.wire.kalium.logic.data.user.User
import com.wire.kalium.logic.data.user.UserId
import java.util.Locale
import javax.inject.Inject
import kotlin.time.Duration.Companion.milliseconds

Expand Down Expand Up @@ -82,7 +83,7 @@ class SystemMessageContentMapper @Inject constructor(
return UIMessageContent.SystemMessage.ConversationMessageCreated(
author = authorName,
isAuthorSelfUser = sender is SelfUser,
date.formatFullDateShortTime().orDefault(date).toUpperCase()
date.formatFullDateShortTime().orDefault(date).uppercase(Locale.getDefault())
)
}

Expand Down
2 changes: 1 addition & 1 deletion app/src/main/kotlin/com/wire/android/ui/WireActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ class WireActivity : AppCompatActivity() {
}

DisposableEffect(navController) {
val updateScreenSettingsListener = NavController.OnDestinationChangedListener { _, navDestination, _ ->
val updateScreenSettingsListener = NavController.OnDestinationChangedListener { _, _, _ ->
currentKeyboardController?.hide()
}
navController.addOnDestinationChangedListener(updateScreenSettingsListener)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.text.KeyboardActions
import androidx.compose.foundation.text.KeyboardOptions
import androidx.compose.material3.Divider
import androidx.compose.material3.HorizontalDivider
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
Expand Down Expand Up @@ -73,7 +73,7 @@ private fun ProxyContent(
Column(
modifier = Modifier
) {
Divider(color = MaterialTheme.wireColorScheme.divider, thickness = Dp.Hairline)
HorizontalDivider(thickness = Dp.Hairline, color = MaterialTheme.wireColorScheme.divider)
Text(
text = stringResource(R.string.label_proxy_credentials),
style = MaterialTheme.wireTypography.title03.copy(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ fun LoginSSOScreen(
// TODO: replace with retrieved ServerConfig from sso login
onLoginButtonClick = loginSSOViewModel::login,
ssoLoginResult = ssoLoginResult,
serverTitle = loginSSOViewModel.serverConfig.title,
onCustomServerDialogDismiss = loginSSOViewModel::onCustomServerDialogDismiss,
onCustomServerDialogConfirm = loginSSOViewModel::onCustomServerDialogConfirm
)
Expand All @@ -105,8 +104,7 @@ private fun LoginSSOContent(
onLoginButtonClick: () -> Unit,
onCustomServerDialogDismiss: () -> Unit,
onCustomServerDialogConfirm: () -> Unit,
ssoLoginResult: DeepLinkResult.SSOLogin?,
serverTitle: String
ssoLoginResult: DeepLinkResult.SSOLogin?
) {
Column(
modifier = Modifier
Expand Down Expand Up @@ -188,6 +186,6 @@ private fun LoginButton(modifier: Modifier, loading: Boolean, enabled: Boolean,
@Composable
fun PreviewLoginSSOScreen() {
WireTheme {
LoginSSOContent(rememberScrollState(), LoginState(), {}, {}, {}, {}, {}, {}, null, "Test Server")
LoginSSOContent(rememberScrollState(), LoginState(), {}, {}, {}, {}, {}, {}, null)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.DropdownMenuItem
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.ExpandMore
import androidx.compose.material3.Divider
import androidx.compose.material3.DropdownMenu
import androidx.compose.material3.HorizontalDivider
import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
Expand Down Expand Up @@ -185,7 +185,7 @@ private fun MenuPopUp(
)

List(items.size) { index ->
Divider(
HorizontalDivider(
color = colorsScheme().divider
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.Divider
import androidx.compose.material3.HorizontalDivider
import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Surface
Expand Down Expand Up @@ -85,7 +85,7 @@ private fun SecurityClassificationBanner(
) {
if (state != SecurityClassificationType.NONE) {
Column(modifier = modifier) {
Divider(color = getDividerColorFor(state))
HorizontalDivider(color = getDividerColorFor(state))
Row(
horizontalArrangement = Arrangement.Center,
verticalAlignment = Alignment.CenterVertically,
Expand All @@ -106,7 +106,7 @@ private fun SecurityClassificationBanner(
style = MaterialTheme.wireTypography.label03
)
}
Divider(color = getDividerColorFor(state))
HorizontalDivider(color = getDividerColorFor(state))
}
}
}
Expand Down Expand Up @@ -165,11 +165,11 @@ fun PreviewClassifiedIndicator() {
SecurityClassificationBanner(
state = SecurityClassificationType.NONE
)
Divider()
HorizontalDivider()
SecurityClassificationBanner(
state = SecurityClassificationType.NOT_CLASSIFIED
)
Divider()
HorizontalDivider()
SecurityClassificationBanner(
state = SecurityClassificationType.CLASSIFIED
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ class HandleDraggableBottomSheetDialog : AppCompatDialog {
}
}
)
bottomSheet!!.setOnTouchListener { _, event -> // Consume the event and prevent it from falling through
bottomSheet!!.setOnTouchListener { _, _ -> // Consume the event and prevent it from falling through
true
}
return container
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 @@ -112,7 +112,7 @@ fun HomeScreen(
val lifecycleOwner = LocalLifecycleOwner.current

DisposableEffect(lifecycleOwner) {
val observer = LifecycleEventObserver { source, event ->
val observer = LifecycleEventObserver { _, event ->
if (event == Lifecycle.Event.ON_RESUME) {
appSyncViewModel.startSyncingAppConfig()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.LazyListState
import androidx.compose.foundation.lazy.rememberLazyListState
import androidx.compose.material3.Divider
import androidx.compose.material3.HorizontalDivider
import androidx.compose.material3.MaterialTheme
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
Expand Down Expand Up @@ -220,7 +220,7 @@ private fun GroupNameItem(
onLongClick = { /* not handled */ }),
arrowType = if (!canBeChanged) ArrowType.NONE else ArrowType.CENTER_ALIGNED
)
Divider(color = MaterialTheme.wireColorScheme.divider, thickness = Dp.Hairline)
HorizontalDivider(thickness = Dp.Hairline, color = MaterialTheme.wireColorScheme.divider)
}

@Composable
Expand All @@ -230,7 +230,7 @@ private fun ProtocolDetails(label: UIText, text: UIText) {
title = text.asString(),
arrowType = ArrowType.NONE
)
Divider(color = MaterialTheme.wireColorScheme.divider, thickness = Dp.Hairline)
HorizontalDivider(thickness = Dp.Hairline, color = MaterialTheme.wireColorScheme.divider)
}

@Composable
Expand Down Expand Up @@ -289,7 +289,7 @@ fun GroupOptionWithSwitch(
},
arrowType = ArrowType.NONE
)
Divider(color = MaterialTheme.wireColorScheme.divider, thickness = Dp.Hairline)
HorizontalDivider(thickness = Dp.Hairline, color = MaterialTheme.wireColorScheme.divider)
}

@Composable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,12 @@ fun MLSProgressIndicator(
contentAlignment = Alignment.Center
) {
LinearProgressIndicator(
progress = progress,
progress = { progress },
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if passing this as lambda will cause unnecessary recomposition?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually it's the opposite, using the lambda will prevent recomposition. If progress value changes then only the lambda function will re-run not all the screen

Copy link
Member

@MohamadJaara MohamadJaara Apr 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not really, a new state value a composition for the whole screen and when evaluating lambda objects it will always not be equal in this case (even if the value of progress did not change)
i can be wrong tho

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The read of the value will be done in the child composable, so it won't effect as explained here
https://youtu.be/ahXLwg2JYpc?t=356

And the current one is deprecated: "Use the overload that takes progress as a lambda "

modifier = Modifier
.fillMaxWidth()
.fillMaxHeight(),
color = color,
trackColor = trackColor
trackColor = trackColor,
)
Text(
style = MaterialTheme.typography.labelLarge,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,8 +237,7 @@ fun ConversationRouterHomeBridge(
callHistory = callHistory,
onCallItemClick = onOpenConversation,
onEditConversationItem = onEditConversationItem,
onOpenUserProfile = onOpenUserProfile,
openConversationNotificationsSettings = onEditNotifications
onOpenUserProfile = onOpenUserProfile
)

ConversationItemType.MENTIONS ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,7 @@ fun CallsScreenContent(
callHistory: List<ConversationItem> = emptyList(),
onCallItemClick: (ConversationId) -> Unit,
onEditConversationItem: (ConversationItem) -> Unit,
onOpenUserProfile: (UserId) -> Unit,
openConversationNotificationsSettings: (ConversationItem) -> Unit,
onOpenUserProfile: (UserId) -> Unit
) {
val lazyListState = rememberLazyListState()

Expand All @@ -72,8 +71,7 @@ fun CallsScreenContent(
callHistory = callHistory,
onCallItemClick = onCallItemClick,
onEditConversationItem = onEditConversationItem,
onOpenUserProfile = onOpenUserProfile,
openConversationNotificationsSettings = openConversationNotificationsSettings,
onOpenUserProfile = onOpenUserProfile
)
}

Expand All @@ -84,8 +82,7 @@ fun CallContent(
callHistory: List<ConversationItem>,
onCallItemClick: (ConversationId) -> Unit,
onEditConversationItem: (ConversationItem) -> Unit,
onOpenUserProfile: (UserId) -> Unit,
openConversationNotificationsSettings: (ConversationItem) -> Unit
onOpenUserProfile: (UserId) -> Unit
) {
val context = LocalContext.current
LazyColumn(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.LazyListState
import androidx.compose.foundation.lazy.rememberLazyListState
import androidx.compose.material3.Divider
import androidx.compose.material3.HorizontalDivider
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
Expand Down Expand Up @@ -66,7 +66,7 @@ fun ConversationList(
* it so it wants to keep this dummy top item as the first one on list and show all other items below it.
*/
item("empty-top-header") {
Divider(
HorizontalDivider(
thickness = Dp.Hairline,
color = Color.Transparent
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ fun MentionScreenContent(
onMentionItemClick = onMentionItemClick,
onEditConversationItem = onEditConversationItem,
onOpenUserProfile = onOpenUserProfile,
openConversationNotificationsSettings = openConversationNotificationsSettings,
)
}

Expand All @@ -85,7 +84,6 @@ private fun MentionContent(
onMentionItemClick: (ConversationId) -> Unit,
onEditConversationItem: (ConversationItem) -> Unit,
onOpenUserProfile: (UserId) -> Unit,
openConversationNotificationsSettings: (ConversationItem) -> Unit,
) {
val context = LocalContext.current
LazyColumn(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import androidx.compose.ui.layout.ContentScale
import com.wire.android.model.ImageAsset

@Composable
fun ZoomableImage(imageAsset: ImageAsset.Remote, contentDescription: String, imageScale: Float = 1.0f) {
fun ZoomableImage(imageAsset: ImageAsset.Remote, contentDescription: String) {
var offsetX by remember { mutableStateOf(0f) }
var offsetY by remember { mutableStateOf(0f) }
var zoom by remember { mutableStateOf(1f) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.wrapContentSize
import androidx.compose.material3.Divider
import androidx.compose.material3.HorizontalDivider
import androidx.compose.material3.MaterialTheme
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
Expand Down Expand Up @@ -161,7 +161,7 @@ fun AttachmentAndAdditionalOptionsMenuItems(
modifier: Modifier = Modifier
) {
Column(modifier.wrapContentSize()) {
Divider(color = MaterialTheme.wireColorScheme.outline)
HorizontalDivider(color = MaterialTheme.wireColorScheme.outline)
MessageComposeActions(
isEditing = isEditing,
selectedOption = selectedOption,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ private fun calculateMaxHeight(
val baseHeightInt = with(density) { defaultMaxHeightDropdownMenu.toPx().toInt() }

var sum = with(density) { DropdownMenuVerticalPadding.toPx().toInt() } * TWO
for ((i, itemSize) in itemHeights.toSortedMap()) {
for ((_, itemSize) in itemHeights.toSortedMap()) {
sum += itemSize
if (sum >= baseHeightInt) {
return with(density) { (sum - itemSize / TWO).toDp() }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ package com.wire.android.ui.home.messagecomposer

import androidx.compose.foundation.background
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.material3.Divider
import androidx.compose.material3.HorizontalDivider
import androidx.compose.material3.MaterialTheme
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
Expand All @@ -38,7 +38,9 @@ fun MembersMentionList(
onMentionPicked: (Contact) -> Unit,
modifier: Modifier
) {
if (membersToMention.isNotEmpty()) Divider()
if (membersToMention.isNotEmpty()) {
HorizontalDivider()
}
LazyColumn(
modifier = modifier.background(colorsScheme().background),
reverseLayout = true
Expand All @@ -55,9 +57,9 @@ fun MembersMentionList(
searchQuery = searchQuery,
modifier = Modifier
)
Divider(
color = MaterialTheme.wireColorScheme.divider,
thickness = Dp.Hairline
HorizontalDivider(
thickness = Dp.Hairline,
color = MaterialTheme.wireColorScheme.divider
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxHeight
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.Divider
import androidx.compose.material3.HorizontalDivider
import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Surface
Expand Down Expand Up @@ -198,7 +198,7 @@ private fun DisabledInteractionMessageComposer(
messageListContent()
}
if (warningText != null) {
Divider(color = MaterialTheme.wireColorScheme.outline)
HorizontalDivider(color = MaterialTheme.wireColorScheme.outline)
Row(
verticalAlignment = Alignment.CenterVertically,
modifier = Modifier
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import androidx.compose.foundation.layout.heightIn
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.wrapContentHeight
import androidx.compose.material3.Divider
import androidx.compose.material3.HorizontalDivider
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.MaterialTheme
Expand Down Expand Up @@ -97,7 +97,7 @@ fun ActiveMessageComposerInput(
modifier = modifier
.background(inputType.backgroundColor())
) {
Divider(color = MaterialTheme.wireColorScheme.outline)
HorizontalDivider(color = MaterialTheme.wireColorScheme.outline)
if (showOptions) {
CollapseButton(
isCollapsed = !isTextExpanded,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,10 @@ fun RestoreProgressDialog(
}
}
VerticalSpace.x16()
LinearProgressIndicator(modifier = Modifier.fillMaxWidth(), progress = progress)
LinearProgressIndicator(
progress = { progress },
modifier = Modifier.fillMaxWidth(),
)
VerticalSpace.x16()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ class FeatureFlagNotificationViewModel @Inject constructor(

private suspend fun setFileSharingState(userId: UserId) {
coreLogic.getSessionScope(userId).observeFileSharingStatus().collect { fileSharingStatus ->
fileSharingStatus.state?.let {
fileSharingStatus.state.let {
// TODO: handle restriction when sending assets
val (fileSharingRestrictedState, state) = if (it is FileSharingStatus.Value.EnabledAll) {
FeatureFlagState.SharingRestrictedState.NONE to true
Expand Down
Loading
Loading