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

feat: display received location messages - default placeholder (WPB-5483) #2503

Merged
merged 17 commits into from
Dec 8, 2023
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,13 @@ fun MessagePreview.uiLastMessageContent(): UILastMessageContent {

is WithUser.MembersCreationAdded -> UILastMessageContent.None
is WithUser.MembersFailedToAdd -> UILastMessageContent.None
is WithUser.Location -> UILastMessageContent.SenderWithMessage(
userUIText,
UIText.StringResource(
if (isSelfMessage) R.string.last_message_self_user_shared_location
else R.string.last_message_other_user_shared_location
)
)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import com.wire.android.R
import com.wire.android.model.ImageAsset
import com.wire.android.ui.home.conversations.findUser
import com.wire.android.ui.home.conversations.model.DEFAULT_LOCATION_ZOOM
import com.wire.android.ui.home.conversations.model.DeliveryStatusContent
import com.wire.android.ui.home.conversations.model.MessageBody
import com.wire.android.ui.home.conversations.model.MessageButton
Expand Down Expand Up @@ -121,9 +122,23 @@
)
}

is MessageContent.Location -> toLocation(content, userList, message)

else -> toText(message.conversationId, content, userList, message.deliveryStatus)
}

private fun toLocation(
content: MessageContent.Location,
userList: List<User>,
message: Message.Regular
) = UIMessageContent.Location(
latitude = content.latitude,
longitude = content.longitude,

Check warning on line 136 in app/src/main/kotlin/com/wire/android/mapper/RegularMessageContentMapper.kt

View check run for this annotation

Codecov / codecov/patch

app/src/main/kotlin/com/wire/android/mapper/RegularMessageContentMapper.kt#L134-L136

Added lines #L134 - L136 were not covered by tests
name = content.name.orEmpty(),
zoom = content.zoom ?: DEFAULT_LOCATION_ZOOM,
deliveryStatus = mapRecipientsFailure(userList, message.deliveryStatus)
)

Check warning on line 140 in app/src/main/kotlin/com/wire/android/mapper/RegularMessageContentMapper.kt

View check run for this annotation

Codecov / codecov/patch

app/src/main/kotlin/com/wire/android/mapper/RegularMessageContentMapper.kt#L139-L140

Added lines #L139 - L140 were not covered by tests

private fun mapAudio(
assetContent: AssetContent,
metadata: AssetContent.AssetMetadata.Audio,
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/kotlin/com/wire/android/notification/Models.kt
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@
MISSED_CALL(R.string.notification_missed_call),
NOT_SUPPORTED(R.string.notification_not_supported_issue),
KNOCK(R.string.notification_knock),
LOCATION(R.string.notification_shared_location),

Check warning on line 144 in app/src/main/kotlin/com/wire/android/notification/Models.kt

View check run for this annotation

Codecov / codecov/patch

app/src/main/kotlin/com/wire/android/notification/Models.kt#L144

Added line #L144 was not covered by tests
}

fun LocalNotification.Conversation.intoNotificationConversation(): NotificationConversation {
Expand Down Expand Up @@ -233,4 +234,5 @@
LocalNotificationCommentType.REACTION -> CommentResId.REACTION
LocalNotificationCommentType.MISSED_CALL -> CommentResId.MISSED_CALL
LocalNotificationCommentType.NOT_SUPPORTED_YET -> CommentResId.NOT_SUPPORTED
LocalNotificationCommentType.LOCATION -> CommentResId.LOCATION
}
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ import com.wire.android.ui.home.conversations.model.messagetypes.asset.Restricte
import com.wire.android.ui.home.conversations.model.messagetypes.asset.RestrictedGenericFileMessage
import com.wire.android.ui.home.conversations.model.messagetypes.audio.AudioMessage
import com.wire.android.ui.home.conversations.model.messagetypes.image.ImageMessageParams
import com.wire.android.ui.home.conversations.model.messagetypes.location.LocationMessageContent
import com.wire.android.ui.theme.wireColorScheme
import com.wire.android.ui.theme.wireTypography
import com.wire.kalium.logic.data.message.Message
Expand Down Expand Up @@ -635,6 +636,22 @@ private fun MessageContent(
}
}

is UIMessageContent.Location -> with(messageContent) {
val locationUrl = stringResource(urlCoordinates, zoom, latitude, longitude)
Column {
LocationMessageContent(
locationName = name,
locationUrl = locationUrl,
onLocationClick = Clickable(
enabled = message.isAvailable,
onClick = { onLinkClick(locationUrl) },
onLongClick = onLongClick
)
)
PartialDeliveryInformation(deliveryStatus)
}
}

UIMessageContent.Deleted -> {}
null -> {
throw NullPointerException("messageContent is null")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,16 @@
override val deliveryStatus: DeliveryStatusContent = DeliveryStatusContent.CompleteDelivery
) : Regular(), PartialDeliverable

@Stable
data class Location(
val latitude: Float,
val longitude: Float,
val name: String,
val zoom: Int = DEFAULT_LOCATION_ZOOM,
@StringRes val urlCoordinates: Int = R.string.url_maps_location_coordinates,
override val deliveryStatus: DeliveryStatusContent = DeliveryStatusContent.CompleteDelivery
) : Regular(), PartialDeliverable

Check warning on line 278 in app/src/main/kotlin/com/wire/android/ui/home/conversations/model/UIMessage.kt

View check run for this annotation

Codecov / codecov/patch

app/src/main/kotlin/com/wire/android/ui/home/conversations/model/UIMessage.kt#L271-L278

Added lines #L271 - L278 were not covered by tests

sealed class SystemMessage(
@DrawableRes val iconResId: Int?,
@StringRes open val stringResId: Int,
Expand Down Expand Up @@ -558,3 +568,5 @@
val text: String,
val isSelected: Boolean,
)

const val DEFAULT_LOCATION_ZOOM = 20
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
/*
* Wire
* Copyright (C) 2023 Wire Swiss GmbH
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see http://www.gnu.org/licenses/.
*/
package com.wire.android.ui.home.conversations.model.messagetypes.location

import androidx.compose.foundation.background
import androidx.compose.foundation.border
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.sp
import com.wire.android.R
import com.wire.android.model.Clickable
import com.wire.android.ui.common.clickable
import com.wire.android.ui.common.dimensions
import com.wire.android.ui.theme.wireColorScheme
import com.wire.android.ui.theme.wireDimensions
import com.wire.android.ui.theme.wireTypography
import com.wire.android.util.ui.PreviewMultipleThemes

@Composable
fun LocationMessageContent(
locationName: String,
locationUrl: String,
onLocationClick: Clickable
) {
Column(
modifier = Modifier
.clickable(onLocationClick)
.padding(top = dimensions().spacing4x)
.clip(shape = RoundedCornerShape(dimensions().messageAssetBorderRadius))
.border(
width = dimensions().spacing1x,
color = MaterialTheme.wireColorScheme.secondaryButtonDisabledOutline,
shape = RoundedCornerShape(dimensions().messageAssetBorderRadius)
)
.background(
color = MaterialTheme.wireColorScheme.surfaceVariant,
shape = RoundedCornerShape(dimensions().messageAssetBorderRadius)
)
.height(dimensions().spacing64x),
verticalArrangement = Arrangement.SpaceEvenly,
) {
Row(
modifier = Modifier
.fillMaxWidth()
.padding(PaddingValues(horizontal = dimensions().spacing8x)),
horizontalArrangement = Arrangement.Start,
verticalAlignment = Alignment.CenterVertically
) {
Icon(
painter = painterResource(id = R.drawable.ic_location),
contentDescription = stringResource(id = R.string.content_description_location_icon),
modifier = Modifier.size(MaterialTheme.wireDimensions.wireIconButtonSize)
)
Spacer(modifier = Modifier.width(dimensions().spacing4x))
Text(
text = locationName,
style = MaterialTheme.wireTypography.body02,
fontSize = 15.sp,
maxLines = 1,
overflow = TextOverflow.Ellipsis
)
}
Text(
text = locationUrl,
style = MaterialTheme.wireTypography.subline01.copy(color = MaterialTheme.wireColorScheme.secondaryText),
overflow = TextOverflow.Ellipsis,
maxLines = 1,
modifier = Modifier.padding(
PaddingValues(
bottom = dimensions().spacing8x,
start = dimensions().spacing8x,
end = dimensions().spacing8x
)
)
)
}
}

@Composable
@PreviewMultipleThemes
fun PreviewLocationMessageContent() {
LocationMessageContent(
locationName = "Rapa Nui",
locationUrl = "https://www.google.com/maps/place/Rapa+Nui",
onLocationClick = Clickable()
)
}
5 changes: 5 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@
<string name="content_description_mls_certificate_valid">All devices of all participants have a valid MLS certificate</string>
<string name="content_description_proteus_certificate_valid">All of all participants are verified (Proteus)</string>
<string name="content_description_jump_to_last_message">Scroll down to last message, button</string>
<string name="content_description_location_icon">Location item</string>
<!-- Non translatable strings-->
<string name="url_support" translatable="false">https://support.wire.com</string>
<string name="url_decryption_failure_learn_more" translatable="false">https://support.wire.com/hc/articles/207948115-Why-was-I-notified-that-a-message-from-a-contact-was-not-received-</string>
Expand All @@ -186,6 +187,7 @@
<string name="url_federation_support" translatable="false">https://support.wire.com/hc/categories/4719917054365-Federation</string>
<string name="url_create_account_learn_more" translatable="false">https://support.wire.com/hc/articles/115004082129</string>
<string name="url_android_release_notes" translatable="false">https://medium.com/wire-news/android-updates/home</string>
<string name="url_maps_location_coordinates" translatable="false">http://maps.google.com/maps?z=%1d&amp;q=loc:%2f+%2f</string>
yamilmedina marked this conversation as resolved.
Show resolved Hide resolved
<!-- Navigation -->
<string name="vault_screen_title">Vault</string>
<string name="archive_screen_title">Archive</string>
Expand Down Expand Up @@ -659,6 +661,8 @@
<string name="last_message_other_user_shared_video">shared a video.</string>
<string name="last_message_self_user_shared_audio">shared an audio message.</string>
<string name="last_message_other_user_shared_audio">shared an audio message.</string>
<string name="last_message_self_user_shared_location">shared a location.</string>
<string name="last_message_other_user_shared_location">shared a location.</string>
<string name="last_message_self_user_knock">pinged.</string>
<string name="last_message_other_user_knock">pinged.</string>
<string name="last_message_call">called.</string>
Expand Down Expand Up @@ -775,6 +779,7 @@
<string name="phone_label">Phone</string>
<!-- Notifications -->
<string name="notification_shared_picture">Shared a picture</string>
<string name="notification_shared_location">Shared a location</string>
<string name="notification_shared_file">Shared a file</string>
<string name="notification_reacted">Added a reaction</string>
<string name="notification_missed_call">Missed call</string>
Expand Down
2 changes: 1 addition & 1 deletion kalium
Submodule kalium updated 85 files
+10 −7 cryptography/src/commonJvmAndroid/kotlin/com.wire.kalium.cryptography/MLSClientImpl.kt
+6 −1 cryptography/src/commonMain/kotlin/com/wire/kalium/cryptography/IDs.kt
+4 −2 logic/src/appleMain/kotlin/com/wire/kalium/logic/feature/e2ei/CertificateStatusChecker.kt
+4 −2 logic/src/appleMain/kotlin/com/wire/kalium/logic/feature/e2ei/PemCertificateDecoder.kt
+9 −8 logic/src/commonJvmAndroid/kotlin/com/wire/kalium/logic/feature/e2ei/CertificateStatusChecker.kt
+4 −3 logic/src/commonJvmAndroid/kotlin/com/wire/kalium/logic/feature/e2ei/PemCertificateDecoder.kt
+2 −2 logic/src/commonMain/kotlin/com/wire/kalium/logic/CoreFailure.kt
+82 −2 logic/src/commonMain/kotlin/com/wire/kalium/logic/data/conversation/ConversationGroupRepository.kt
+0 −7 logic/src/commonMain/kotlin/com/wire/kalium/logic/data/conversation/ConversationRepository.kt
+2 −1 logic/src/commonMain/kotlin/com/wire/kalium/logic/data/conversation/NewConversationMembersRepository.kt
+20 −20 .../src/commonMain/kotlin/com/wire/kalium/logic/data/conversation/NewGroupConversationSystemMessagesCreator.kt
+15 −14 logic/src/commonMain/kotlin/com/wire/kalium/logic/data/keypackage/KeyPackageRepository.kt
+4 −0 logic/src/commonMain/kotlin/com/wire/kalium/logic/data/message/Message.kt
+9 −0 logic/src/commonMain/kotlin/com/wire/kalium/logic/data/message/MessageContent.kt
+21 −0 logic/src/commonMain/kotlin/com/wire/kalium/logic/data/message/MessageMapper.kt
+1 −0 logic/src/commonMain/kotlin/com/wire/kalium/logic/data/message/PersistMessageUseCase.kt
+28 −2 logic/src/commonMain/kotlin/com/wire/kalium/logic/data/message/ProtoContentMapper.kt
+1 −1 logic/src/commonMain/kotlin/com/wire/kalium/logic/data/notification/LocalNotification.kt
+44 −1 logic/src/commonMain/kotlin/com/wire/kalium/logic/data/team/TeamRepository.kt
+3 −3 logic/src/commonMain/kotlin/com/wire/kalium/logic/data/user/UserRepository.kt
+18 −15 logic/src/commonMain/kotlin/com/wire/kalium/logic/feature/UserSessionScope.kt
+3 −1 logic/src/commonMain/kotlin/com/wire/kalium/logic/feature/e2ei/CertificateStatusChecker.kt
+3 −1 logic/src/commonMain/kotlin/com/wire/kalium/logic/feature/e2ei/PemCertificateDecoder.kt
+1 −1 logic/src/commonMain/kotlin/com/wire/kalium/logic/feature/e2ei/usecase/GetE2EICertificateUseCase.kt
+1 −0 logic/src/commonMain/kotlin/com/wire/kalium/logic/feature/message/PersistMigratedMessagesUseCase.kt
+15 −6 logic/src/commonMain/kotlin/com/wire/kalium/logic/feature/team/SyncSelfTeamUseCase.kt
+2 −1 logic/src/commonMain/kotlin/com/wire/kalium/logic/featureFlags/KaliumConfigs.kt
+1 −22 logic/src/commonMain/kotlin/com/wire/kalium/logic/sync/receiver/UserEventReceiver.kt
+1 −1 logic/src/commonMain/kotlin/com/wire/kalium/logic/sync/receiver/conversation/NewConversationEventHandler.kt
+2 −0 ...src/commonMain/kotlin/com/wire/kalium/logic/sync/receiver/conversation/message/ApplicationMessageHandler.kt
+152 −1 logic/src/commonTest/kotlin/com/wire/kalium/logic/data/conversation/ConversationGroupRepositoryTest.kt
+2 −1 logic/src/commonTest/kotlin/com/wire/kalium/logic/data/conversation/MLSConversationRepositoryTest.kt
+9 −4 .../commonTest/kotlin/com/wire/kalium/logic/data/conversation/NewGroupConversationSystemMessagesCreatorTest.kt
+3 −3 logic/src/commonTest/kotlin/com/wire/kalium/logic/data/keypackage/KeyPackageRepositoryTest.kt
+62 −12 logic/src/commonTest/kotlin/com/wire/kalium/logic/data/team/TeamRepositoryTest.kt
+0 −1 logic/src/commonTest/kotlin/com/wire/kalium/logic/data/user/UserRepositoryTest.kt
+3 −1 logic/src/commonTest/kotlin/com/wire/kalium/logic/feature/e2ei/GetE2eiCertificateUseCaseTest.kt
+79 −13 logic/src/commonTest/kotlin/com/wire/kalium/logic/feature/team/SyncSelfTeamUseCaseTest.kt
+2 −13 logic/src/commonTest/kotlin/com/wire/kalium/logic/sync/receiver/UserEventReceiverTest.kt
+1 −1 ...c/src/commonTest/kotlin/com/wire/kalium/logic/sync/receiver/conversation/NewConversationEventHandlerTest.kt
+3 −3 logic/src/commonTest/kotlin/com/wire/kalium/logic/util/arrangement/UserRepositoryArrangement.kt
+26 −3 logic/src/jvmTest/kotlin/com/wire/kalium/logic/feature/e2ei/CertificateStatusCheckerTest.kt
+3 −2 logic/src/jvmTest/kotlin/com/wire/kalium/logic/feature/e2ei/PemCertificateDecoderTest.kt
+104 −18 monkeys/schema.json
+4 −3 monkeys/src/main/kotlin/com/wire/kalium/monkeys/ActionScheduler.kt
+9 −11 monkeys/src/main/kotlin/com/wire/kalium/monkeys/MonkeyApplication.kt
+2 −0 monkeys/src/main/kotlin/com/wire/kalium/monkeys/actions/Action.kt
+65 −0 monkeys/src/main/kotlin/com/wire/kalium/monkeys/actions/HandleExternalRequestAction.kt
+1 −1 monkeys/src/main/kotlin/com/wire/kalium/monkeys/actions/LeaveConversationAction.kt
+32 −0 monkeys/src/main/kotlin/com/wire/kalium/monkeys/actions/SendExternalRequestAction.kt
+88 −8 monkeys/src/main/kotlin/com/wire/kalium/monkeys/actions/SendMessageAction.kt
+83 −32 monkeys/src/main/kotlin/com/wire/kalium/monkeys/conversation/Monkey.kt
+1 −1 monkeys/src/main/kotlin/com/wire/kalium/monkeys/conversation/MonkeyConversation.kt
+3 −3 monkeys/src/main/kotlin/com/wire/kalium/monkeys/homeDirectory.kt
+27 −1 monkeys/src/main/kotlin/com/wire/kalium/monkeys/importer/TestData.kt
+79 −76 monkeys/src/main/kotlin/com/wire/kalium/monkeys/importer/TestDataImporter.kt
+30 −3 monkeys/src/main/kotlin/com/wire/kalium/monkeys/importer/UserData.kt
+4 −4 monkeys/src/main/kotlin/com/wire/kalium/monkeys/pool/ConversationPool.kt
+47 −15 monkeys/src/main/kotlin/com/wire/kalium/monkeys/pool/MonkeyPool.kt
+0 −41 monkeys/src/test/kotlin/com/wire/kalium/monkeys/actions/AddUserToConversationActionTest.kt
+0 −61 monkeys/src/test/kotlin/com/wire/kalium/monkeys/actions/LeaveConversationActionTest.kt
+0 −43 monkeys/src/test/kotlin/com/wire/kalium/monkeys/actions/LoginActionTest.kt
+0 −105 monkeys/src/test/kotlin/com/wire/kalium/monkeys/actions/SendMessageActionTest.kt
+0 −51 monkeys/src/test/kotlin/com/wire/kalium/monkeys/actions/SendRequestActionTest.kt
+5 −1 network/src/commonMain/kotlin/com/wire/kalium/network/api/v5/authenticated/KeyPackageApiV5.kt
+5 −1 network/src/commonMain/kotlin/com/wire/kalium/network/api/v5/authenticated/MLSMessageApiV5.kt
+2 −0 network/src/commonMain/kotlin/com/wire/kalium/network/utils/NetworkUtils.kt
+0 −8 persistence/src/commonMain/db_user/com/wire/kalium/persistence/Members.sq
+6 −1 persistence/src/commonMain/db_user/com/wire/kalium/persistence/MessageDetailsView.sq
+1 −1 persistence/src/commonMain/db_user/com/wire/kalium/persistence/MessagePreview.sq
+18 −1 persistence/src/commonMain/db_user/com/wire/kalium/persistence/Messages.sq
+1 −1 persistence/src/commonMain/db_user/com/wire/kalium/persistence/Notification.sq
+12 −3 persistence/src/commonMain/db_user/com/wire/kalium/persistence/Users.sq
+171 −0 persistence/src/commonMain/db_user/migrations/68.sqm
+1 −1 persistence/src/commonMain/kotlin/com/wire/kalium/persistence/dao/UserDAO.kt
+33 −21 persistence/src/commonMain/kotlin/com/wire/kalium/persistence/dao/UserDAOImpl.kt
+0 −1 persistence/src/commonMain/kotlin/com/wire/kalium/persistence/dao/conversation/ConversationDAO.kt
+0 −4 persistence/src/commonMain/kotlin/com/wire/kalium/persistence/dao/conversation/ConversationDAOImpl.kt
+8 −1 persistence/src/commonMain/kotlin/com/wire/kalium/persistence/dao/message/MessageEntity.kt
+11 −0 persistence/src/commonMain/kotlin/com/wire/kalium/persistence/dao/message/MessageInsertExtension.kt
+12 −2 persistence/src/commonMain/kotlin/com/wire/kalium/persistence/dao/message/MessageMapper.kt
+10 −1 persistence/src/commonMain/kotlin/com/wire/kalium/persistence/db/TableMapper.kt
+2 −1 persistence/src/commonMain/kotlin/com/wire/kalium/persistence/db/UserDatabaseBuilder.kt
+91 −3 persistence/src/commonTest/kotlin/com/wire/kalium/persistence/dao/UserDAOTest.kt
+10 −2 persistence/src/commonTest/kotlin/com/wire/kalium/persistence/dao/message/MessageMapperTest.kt
Loading