Skip to content

Commit

Permalink
Merge branch 'develop' into dependabot/gradle/androidx.navigation-nav…
Browse files Browse the repository at this point in the history
…igation-compose-2.7.4
  • Loading branch information
ohassine authored Oct 30, 2023
2 parents 947643b + 0b2fed5 commit 1d55599
Show file tree
Hide file tree
Showing 137 changed files with 3,044 additions and 391 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/publish-test-results.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ jobs:
PR_NUMBER=$(jq --raw-output .pull_request.number "$EVENT_FILE_PATH")
gh pr comment "$PR_NUMBER" --body "APKs built during tests are available [here]($CHECKS_LINK). Scroll down to **Artifacts**!"
- uses: actions/setup-node@v3
- uses: actions/setup-node@v4
with:
node-version: 18
- name: Install datadog-ci
Expand Down
6 changes: 6 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
<uses-permission android:name="android.permission.USE_FULL_SCREEN_INTENT" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_PHONE_CALL" />
<uses-permission android:name="android.permission.MANAGE_OWN_CALLS" />

<!-- Allows showing incoming call when device is sleeping -->
<uses-permission android:name="android.permission.WAKE_LOCK" />
Expand All @@ -58,6 +60,10 @@
android:glEsVersion="0x00020000"
android:required="false" />

<uses-feature
android:name="android.hardware.camera"
android:required="false" />

<application
android:name=".WireApplication"
android:allowBackup="false"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import com.wire.kalium.logic.feature.asset.GetMessageAssetUseCase
import com.wire.kalium.logic.feature.asset.ScheduleNewAssetMessageUseCase
import com.wire.kalium.logic.feature.asset.UpdateAssetMessageDownloadStatusUseCase
import com.wire.kalium.logic.feature.message.DeleteMessageUseCase
import com.wire.kalium.logic.feature.message.GetConversationMessagesFromSearchQueryUseCase
import com.wire.kalium.logic.feature.message.GetMessageByIdUseCase
import com.wire.kalium.logic.feature.message.GetNotificationsUseCase
import com.wire.kalium.logic.feature.message.GetPaginatedFlowOfMessagesByConversationUseCase
Expand Down Expand Up @@ -147,4 +148,9 @@ class MessageModule {
@Provides
fun provideGetPaginatedMessagesUseCase(messageScope: MessageScope): GetPaginatedFlowOfMessagesByConversationUseCase =
messageScope.getPaginatedFlowOfMessagesByConversation

@ViewModelScoped
@Provides
fun provideGetConversationMessagesFromSearchQueryUseCase(messageScope: MessageScope): GetConversationMessagesFromSearchQueryUseCase =
messageScope.getConversationMessagesFromSearchQuery
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,13 @@ package com.wire.android.di.accountScoped

import com.wire.android.di.CurrentAccount
import com.wire.android.di.KaliumCoreLogic
import dagger.Module
import dagger.Provides
import com.wire.kalium.logic.CoreLogic
import com.wire.kalium.logic.data.user.UserId
import com.wire.kalium.logic.feature.asset.DeleteAssetUseCase
import com.wire.kalium.logic.feature.asset.GetAssetSizeLimitUseCase
import com.wire.kalium.logic.feature.asset.GetAvatarAssetUseCase
import com.wire.kalium.logic.feature.conversation.GetAllContactsNotInConversationUseCase
import com.wire.kalium.logic.feature.e2ei.usecase.GetE2eiCertificateUseCase
import com.wire.kalium.logic.feature.publicuser.GetAllContactsUseCase
import com.wire.kalium.logic.feature.publicuser.GetKnownUserUseCase
import com.wire.kalium.logic.feature.publicuser.RefreshUsersWithoutMetadataUseCase
Expand All @@ -49,6 +48,8 @@ import com.wire.kalium.logic.feature.user.readReceipts.ObserveReadReceiptsEnable
import com.wire.kalium.logic.feature.user.readReceipts.PersistReadReceiptsStatusConfigUseCase
import com.wire.kalium.logic.feature.user.typingIndicator.ObserveTypingIndicatorEnabledUseCase
import com.wire.kalium.logic.feature.user.typingIndicator.PersistTypingIndicatorStatusConfigUseCase
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.android.components.ViewModelComponent
import dagger.hilt.android.scopes.ViewModelScoped
Expand Down Expand Up @@ -212,4 +213,9 @@ class UserModule {
@Provides
fun provideSetUserHandleUseCase(userScope: UserScope): SetUserHandleUseCase =
userScope.setUserHandle

@ViewModelScoped
@Provides
fun provideGetE2EICertificateUseCase(userScope: UserScope): GetE2eiCertificateUseCase =
userScope.getE2EICertificate
}
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,14 @@ fun MessagePreview.uiLastMessageContent(): UILastMessageContent {
}

MessagePreviewContent.CryptoSessionReset -> UILastMessageContent.None
MessagePreviewContent.VerificationChanged.VerifiedMls ->
UILastMessageContent.VerificationChanged(R.string.last_message_verified_conversation_mls)
MessagePreviewContent.VerificationChanged.VerifiedProteus ->
UILastMessageContent.VerificationChanged(R.string.last_message_verified_conversation_proteus)
MessagePreviewContent.VerificationChanged.DegradedMls ->
UILastMessageContent.VerificationChanged(R.string.last_message_conversations_verification_degraded_mls)
MessagePreviewContent.VerificationChanged.DegradedProteus ->
UILastMessageContent.VerificationChanged(R.string.last_message_conversations_verification_degraded_proteus)
Unknown -> UILastMessageContent.None
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ class SystemMessageContentMapper @Inject constructor(
is MessageContent.ConversationVerifiedProteus -> mapConversationVerified(Conversation.Protocol.PROTEUS)
is MessageContent.FederationStopped -> mapFederationMessage(content)
is MessageContent.ConversationProtocolChanged -> mapConversationProtocolChanged(content)
is MessageContent.ConversationStartedUnverifiedWarning -> mapConversationCreatedUnverifiedWarning()
}

private fun mapConversationCreated(senderUserId: UserId, date: String, userList: List<User>): UIMessageContent.SystemMessage {
Expand All @@ -85,6 +86,10 @@ class SystemMessageContentMapper @Inject constructor(
)
}

private fun mapConversationCreatedUnverifiedWarning(): UIMessageContent.SystemMessage {
return UIMessageContent.SystemMessage.ConversationMessageCreatedUnverifiedWarning
}

private fun mapConversationTimerChanged(
senderUserId: UserId,
content: MessageContent.ConversationMessageTimerChanged,
Expand Down Expand Up @@ -246,12 +251,16 @@ class SystemMessageContentMapper @Inject constructor(

private fun mapConversationHistoryLost(): UIMessageContent.SystemMessage =
UIMessageContent.SystemMessage.HistoryLost

private fun mapMLSWrongEpochWarning(): UIMessageContent.SystemMessage =
UIMessageContent.SystemMessage.MLSWrongEpochWarning()

private fun mapConversationHistoryListProtocolChanged(): UIMessageContent.SystemMessage =
UIMessageContent.SystemMessage.HistoryLostProtocolChanged

private fun mapConversationDegraded(protocol: Conversation.Protocol): UIMessageContent.SystemMessage =
UIMessageContent.SystemMessage.ConversationDegraded(protocol)

private fun mapConversationVerified(protocol: Conversation.Protocol): UIMessageContent.SystemMessage =
UIMessageContent.SystemMessage.ConversationVerified(protocol)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,8 @@ class MigrationMapper @Inject constructor() {
userMessageTimer = null,
archived = false,
archivedDateTime = null,
verificationStatus = Conversation.VerificationStatus.NOT_VERIFIED
mlsVerificationStatus = Conversation.VerificationStatus.NOT_VERIFIED,
proteusVerificationStatus = Conversation.VerificationStatus.NOT_VERIFIED
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ sealed class HomeDestination(

private const val ITEM_NAME_PREFIX = "HomeNavigationItem."
fun fromRoute(fullRoute: String): HomeDestination? =
values().find { it.direction.route.getPrimaryRoute() == fullRoute.getPrimaryRoute() }
values().find { it.direction.route.getBaseRoute() == fullRoute.getBaseRoute() }
fun values(): Array<HomeDestination> =
arrayOf(Conversations, Calls, Mentions, Settings, Vault, Archive, Support, WhatsNew)
}
Expand Down
16 changes: 5 additions & 11 deletions app/src/main/kotlin/com/wire/android/navigation/NavigationUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ internal fun NavController.navigateToItem(command: NavigationCommand) {
fun lastDestination() = currentBackStack.value.lastOrNull { it.route() is DestinationSpec<*> }
fun lastNestedGraph() = lastDestination()?.takeIf { it.navGraph() != navGraph }?.navGraph()
fun firstDestinationWithRoute(route: String) =
currentBackStack.value.firstOrNull { it.destination.route?.getPrimaryRoute() == route.getPrimaryRoute() }
currentBackStack.value.firstOrNull { it.destination.route?.getBaseRoute() == route.getBaseRoute() }
fun lastDestinationFromOtherGraph(graph: NavGraphSpec) = currentBackStack.value.lastOrNull { it.navGraph() != graph }

appLogger.d("[$TAG] -> command: ${command.destination.route.obfuscateId()}")
Expand Down Expand Up @@ -104,17 +104,11 @@ private fun NavOptionsBuilder.popUpTo(
internal fun NavDestination.toDestination(): Destination? =
this.route?.let { currentRoute -> NavGraphs.root.destinationsByRoute[currentRoute] }

fun String.getPrimaryRoute(): String {
val splitByQuestion = this.split("?")
val splitBySlash = this.split("/")

val primaryRoute = when {
splitByQuestion.size > 1 -> splitByQuestion[0]
splitBySlash.size > 1 -> splitBySlash[0]
else -> this
fun String.getBaseRoute(): String =
this.indexOfAny(listOf("?", "/")).let {
if (it != -1) this.substring(0, it)
else this
}
return primaryRoute
}

fun Direction.handleNavigation(context: Context, handleOtherDirection: (Direction) -> Unit) = when (this) {
is ExternalUriDirection -> CustomTabsHelper.launchUri(context, this.uri)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ private fun DeviceItemTexts(
)
if (shouldShowVerifyLabel) {
Spacer(modifier = Modifier.width(MaterialTheme.wireDimensions.spacing8x))
if (device.isVerifiedProteus) ProteusVerifiedIcon(Modifier.wrapContentWidth())
if (device.isVerifiedProteus) ProteusVerifiedIcon(Modifier.wrapContentWidth().align(Alignment.CenterVertically))
}
}

Expand Down
57 changes: 23 additions & 34 deletions app/src/main/kotlin/com/wire/android/ui/common/SearchBar.kt
Original file line number Diff line number Diff line change
Expand Up @@ -31,47 +31,20 @@ import androidx.compose.material3.IconButton
import androidx.compose.material3.LocalTextStyle
import androidx.compose.material3.MaterialTheme
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.input.TextFieldValue
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import com.wire.android.R
import com.wire.android.ui.common.textfield.WireTextField
import com.wire.android.ui.theme.WireTheme
import com.wire.android.ui.theme.wireColorScheme

@Composable
fun SearchBar(
placeholderText: String,
onTextTyped: (TextFieldValue) -> Unit = {},
modifier: Modifier = Modifier
) {
SearchBarInput(
placeholderText = placeholderText,
leadingIcon =
{
IconButton(onClick = { }) {
Icon(
painter = painterResource(id = R.drawable.ic_search),
contentDescription = stringResource(R.string.content_description_conversation_search_icon),
tint = MaterialTheme.wireColorScheme.onBackground
)
}
},
placeholderTextStyle = LocalTextStyle.current.copy(textAlign = TextAlign.Center),
textStyle = LocalTextStyle.current.copy(textAlign = TextAlign.Start),
onTextTyped = onTextTyped,
modifier = modifier
)
}
import com.wire.android.util.ui.PreviewMultipleThemes

@Composable
fun SearchBarInput(
Expand All @@ -80,10 +53,12 @@ fun SearchBarInput(
text: TextFieldValue = TextFieldValue(""),
onTextTyped: (TextFieldValue) -> Unit = {},
placeholderTextStyle: TextStyle = LocalTextStyle.current,
placeholderAlignment: Alignment.Horizontal = Alignment.CenterHorizontally,
interactionSource: MutableInteractionSource = remember { MutableInteractionSource() },
textStyle: TextStyle = LocalTextStyle.current,
modifier: Modifier = Modifier
modifier: Modifier = Modifier,
) {

WireTextField(
modifier = modifier,
value = text,
Expand Down Expand Up @@ -112,14 +87,28 @@ fun SearchBarInput(
interactionSource = interactionSource,
textStyle = textStyle.copy(fontSize = 14.sp),
placeholderTextStyle = placeholderTextStyle.copy(fontSize = 14.sp),
placeholderAlignment = placeholderAlignment,
placeholderText = placeholderText,
maxLines = 1,
singleLine = true,
)
}

@Preview(showBackground = true)
@PreviewMultipleThemes
@Composable
fun PreviewSearchBarCollapsed() {
SearchBar("Search text")
fun PreviewSearchBarInput() {
WireTheme {
SearchBarInput(
placeholderText = "placeholder",
leadingIcon = {
IconButton(onClick = { }) {
Icon(
painter = painterResource(id = R.drawable.ic_search),
contentDescription = stringResource(R.string.content_description_conversation_search_icon),
tint = MaterialTheme.wireColorScheme.onBackground
)
}
},
)
}
}
20 changes: 18 additions & 2 deletions app/src/main/kotlin/com/wire/android/ui/common/VerifiedIcons.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
*/
package com.wire.android.ui.common

import androidx.annotation.StringRes
import androidx.compose.foundation.Image
import androidx.compose.foundation.layout.padding
import androidx.compose.runtime.Composable
Expand All @@ -26,10 +27,25 @@ import androidx.compose.ui.res.stringResource
import com.wire.android.R

@Composable
fun ProteusVerifiedIcon(modifier: Modifier = Modifier) {
fun ProteusVerifiedIcon(
modifier: Modifier = Modifier,
@StringRes contentDescriptionId: Int = R.string.label_client_verified
) {
Image(
modifier = modifier.padding(start = dimensions().spacing4x),
painter = painterResource(id = R.drawable.ic_certificate_valid_proteus),
contentDescription = stringResource(R.string.label_client_verified)
contentDescription = stringResource(contentDescriptionId)
)
}

@Composable
fun MLSVerifiedIcon(
modifier: Modifier = Modifier,
@StringRes contentDescriptionId: Int = R.string.label_client_verified
) {
Image(
modifier = modifier.padding(start = dimensions().spacing4x),
painter = painterResource(id = R.drawable.ic_certificate_valid_mls),
contentDescription = stringResource(contentDescriptionId)
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,10 @@ data class ConversationSheetContent(
val conversationTypeDetail: ConversationTypeDetail,
val selfRole: Conversation.Member.Role?,
val isTeamConversation: Boolean,
val isArchived: Boolean
val isArchived: Boolean,
val protocol: Conversation.ProtocolInfo,
val mlsVerificationStatus: Conversation.VerificationStatus,
val proteusVerificationStatus: Conversation.VerificationStatus
) {

private val isSelfUserMember: Boolean get() = selfRole != null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,14 @@ fun rememberConversationSheetState(
),
isTeamConversation = teamId != null,
selfRole = selfMemberRole,
isArchived = conversationItem.isArchived
isArchived = conversationItem.isArchived,
protocol = Conversation.ProtocolInfo.Proteus,
mlsVerificationStatus = Conversation.VerificationStatus.VERIFIED,
proteusVerificationStatus = Conversation.VerificationStatus.VERIFIED
)
}
}

is ConversationItem.PrivateConversation -> {
with(conversationItem) {
ConversationSheetContent(
Expand All @@ -95,10 +99,14 @@ fun rememberConversationSheetState(
),
isTeamConversation = isTeamConversation,
selfRole = Conversation.Member.Role.Member,
isArchived = conversationItem.isArchived
isArchived = conversationItem.isArchived,
protocol = Conversation.ProtocolInfo.Proteus,
mlsVerificationStatus = Conversation.VerificationStatus.VERIFIED,
proteusVerificationStatus = Conversation.VerificationStatus.VERIFIED
)
}
}

is ConversationItem.ConnectionConversation -> {
with(conversationItem) {
ConversationSheetContent(
Expand All @@ -110,7 +118,10 @@ fun rememberConversationSheetState(
),
isTeamConversation = isTeamConversation,
selfRole = Conversation.Member.Role.Member,
isArchived = conversationItem.isArchived
isArchived = conversationItem.isArchived,
protocol = Conversation.ProtocolInfo.Proteus,
mlsVerificationStatus = Conversation.VerificationStatus.VERIFIED,
proteusVerificationStatus = Conversation.VerificationStatus.VERIFIED
)
}
}
Expand Down
Loading

0 comments on commit 1d55599

Please sign in to comment.