From e4e2ace10fb8292b4dccc0e70885f9eabb8ea444 Mon Sep 17 00:00:00 2001 From: yamilmedina Date: Mon, 4 Dec 2023 18:45:46 +0100 Subject: [PATCH 01/14] feat: clickable location --- .../mapper/MessagePreviewContentMapper.kt | 7 ++ .../mapper/RegularMessageContentMapper.kt | 9 ++ .../com/wire/android/notification/Models.kt | 2 + .../ui/home/conversations/MessageItem.kt | 17 +++ .../ui/home/conversations/model/UIMessage.kt | 21 ++++ .../location/LocationMessageType.kt | 108 ++++++++++++++++++ app/src/main/res/values/strings.xml | 4 + kalium | 2 +- 8 files changed, 169 insertions(+), 1 deletion(-) create mode 100644 app/src/main/kotlin/com/wire/android/ui/home/conversations/model/messagetypes/location/LocationMessageType.kt diff --git a/app/src/main/kotlin/com/wire/android/mapper/MessagePreviewContentMapper.kt b/app/src/main/kotlin/com/wire/android/mapper/MessagePreviewContentMapper.kt index 4d0676f6ca2..853a5333f38 100644 --- a/app/src/main/kotlin/com/wire/android/mapper/MessagePreviewContentMapper.kt +++ b/app/src/main/kotlin/com/wire/android/mapper/MessagePreviewContentMapper.kt @@ -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 + ) + ) } } diff --git a/app/src/main/kotlin/com/wire/android/mapper/RegularMessageContentMapper.kt b/app/src/main/kotlin/com/wire/android/mapper/RegularMessageContentMapper.kt index ef6043ccb7e..eb8d02baf5a 100644 --- a/app/src/main/kotlin/com/wire/android/mapper/RegularMessageContentMapper.kt +++ b/app/src/main/kotlin/com/wire/android/mapper/RegularMessageContentMapper.kt @@ -121,6 +121,15 @@ class RegularMessageMapper @Inject constructor( ) } + is MessageContent.Location -> { + UIMessageContent.Location( + latitude = content.latitude, + longitude = content.longitude, + name = content.name.orEmpty(), + deliveryStatus = mapRecipientsFailure(userList, message.deliveryStatus) + ) + } + else -> toText(message.conversationId, content, userList, message.deliveryStatus) } diff --git a/app/src/main/kotlin/com/wire/android/notification/Models.kt b/app/src/main/kotlin/com/wire/android/notification/Models.kt index 5cffda76073..64ffb2ed5e2 100644 --- a/app/src/main/kotlin/com/wire/android/notification/Models.kt +++ b/app/src/main/kotlin/com/wire/android/notification/Models.kt @@ -141,6 +141,7 @@ enum class CommentResId(@StringRes val value: Int) { 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), } fun LocalNotification.Conversation.intoNotificationConversation(): NotificationConversation { @@ -233,4 +234,5 @@ fun LocalNotificationCommentType.intoCommentResId(): CommentResId = LocalNotificationCommentType.REACTION -> CommentResId.REACTION LocalNotificationCommentType.MISSED_CALL -> CommentResId.MISSED_CALL LocalNotificationCommentType.NOT_SUPPORTED_YET -> CommentResId.NOT_SUPPORTED + LocalNotificationCommentType.LOCATION -> CommentResId.LOCATION } diff --git a/app/src/main/kotlin/com/wire/android/ui/home/conversations/MessageItem.kt b/app/src/main/kotlin/com/wire/android/ui/home/conversations/MessageItem.kt index e23af8337fb..b96f30730fb 100644 --- a/app/src/main/kotlin/com/wire/android/ui/home/conversations/MessageItem.kt +++ b/app/src/main/kotlin/com/wire/android/ui/home/conversations/MessageItem.kt @@ -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 @@ -635,6 +636,22 @@ private fun MessageContent( } } + is UIMessageContent.Location -> { + val resources = LocalContext.current.resources + val locationUrl = messageContent.createLink(resources) + Column { + LocationMessageContent( + locationName = messageContent.name, + locationUrl = locationUrl, + onLocationClick = Clickable( + enabled = !message.isPending && message.isAvailable, + onClick = { onLinkClick(locationUrl) }, + onLongClick = onLongClick + )) + PartialDeliveryInformation(messageContent.deliveryStatus) + } + } + UIMessageContent.Deleted -> {} null -> { throw NullPointerException("messageContent is null") diff --git a/app/src/main/kotlin/com/wire/android/ui/home/conversations/model/UIMessage.kt b/app/src/main/kotlin/com/wire/android/ui/home/conversations/model/UIMessage.kt index c3ebca9845c..897b85d6dda 100644 --- a/app/src/main/kotlin/com/wire/android/ui/home/conversations/model/UIMessage.kt +++ b/app/src/main/kotlin/com/wire/android/ui/home/conversations/model/UIMessage.kt @@ -212,6 +212,13 @@ sealed class UIMessageContent { val deliveryStatus: DeliveryStatusContent } + /** + * Interface for [UIMessage] classes that can generate a link. + */ + interface Linkable { + fun createLink(resources: Resources): String + } + data class TextMessage( val messageBody: MessageBody, override val deliveryStatus: DeliveryStatusContent = DeliveryStatusContent.CompleteDelivery @@ -267,6 +274,18 @@ sealed class UIMessageContent { 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, + override val deliveryStatus: DeliveryStatusContent = DeliveryStatusContent.CompleteDelivery + ) : Regular(), PartialDeliverable, Linkable { + override fun createLink(resources: Resources): String = + resources.getString(R.string.url_maps_location_coordinates, zoom, latitude, longitude) + } + sealed class SystemMessage( @DrawableRes val iconResId: Int?, @StringRes open val stringResId: Int, @@ -558,3 +577,5 @@ data class MessageButton( val text: String, val isSelected: Boolean, ) + +const val DEFAULT_LOCATION_ZOOM = 20 diff --git a/app/src/main/kotlin/com/wire/android/ui/home/conversations/model/messagetypes/location/LocationMessageType.kt b/app/src/main/kotlin/com/wire/android/ui/home/conversations/model/messagetypes/location/LocationMessageType.kt new file mode 100644 index 00000000000..1d35bc69d61 --- /dev/null +++ b/app/src/main/kotlin/com/wire/android/ui/home/conversations/model/messagetypes/location/LocationMessageType.kt @@ -0,0 +1,108 @@ +/* + * 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.BorderStroke +import androidx.compose.foundation.layout.Arrangement +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.Card +import androidx.compose.material3.ExperimentalMaterial3Api +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.res.painterResource +import androidx.compose.ui.text.style.TextOverflow +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 + +@OptIn(ExperimentalMaterial3Api::class) +@Composable +fun LocationMessageContent( + locationName: String, + locationUrl: String, + onLocationClick: Clickable +) { + Card( + onClick = { }, + modifier = Modifier.clickable(onLocationClick), + shape = RoundedCornerShape(dimensions().messageAssetBorderRadius), + border = BorderStroke(dimensions().spacing1x, MaterialTheme.wireColorScheme.secondaryButtonDisabledOutline) + ) { + Row( + modifier = Modifier + .fillMaxWidth() + .padding(PaddingValues(horizontal = dimensions().spacing8x)) + .height(dimensions().audioMessageHeight), + horizontalArrangement = Arrangement.Start, + verticalAlignment = Alignment.CenterVertically + ) { + Icon( + painter = painterResource(id = R.drawable.ic_location), + contentDescription = "location desc", + modifier = Modifier.size(MaterialTheme.wireDimensions.wireIconButtonSize) + ) + Spacer(modifier = Modifier.width(dimensions().spacing4x)) + Text( + text = locationName, + style = MaterialTheme.wireTypography.body02.copy(color = MaterialTheme.wireColorScheme.secondaryText), + overflow = TextOverflow.Ellipsis, + maxLines = 1 + ) + } + 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() + ) +} diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index c82699a498f..72f0838651f 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -186,6 +186,7 @@ https://support.wire.com/hc/categories/4719917054365-Federation https://support.wire.com/hc/articles/115004082129 https://medium.com/wire-news/android-updates/home + http://maps.google.com/maps?z=%1d&q=%2f,%2f Vault Archive @@ -659,6 +660,8 @@ shared a video. shared an audio message. shared an audio message. + shared a location. + shared a location. pinged. pinged. called. @@ -770,6 +773,7 @@ Phone Shared a picture + Shared a location Shared a file Added a reaction Missed call diff --git a/kalium b/kalium index 2ddf5b82add..9ce3291f4b1 160000 --- a/kalium +++ b/kalium @@ -1 +1 @@ -Subproject commit 2ddf5b82add97ed9bf32bd642847f2e095f5dbf2 +Subproject commit 9ce3291f4b192c0aea1e0f8f6237f05c65b63dfc From 24f04e693d5e5532d8a4e8dc3b90b1fa415ce81d Mon Sep 17 00:00:00 2001 From: yamilmedina Date: Mon, 4 Dec 2023 18:48:21 +0100 Subject: [PATCH 02/14] feat: clickable location --- .../com/wire/android/ui/home/conversations/MessageItem.kt | 5 +++-- .../model/messagetypes/location/LocationMessageType.kt | 1 - 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/src/main/kotlin/com/wire/android/ui/home/conversations/MessageItem.kt b/app/src/main/kotlin/com/wire/android/ui/home/conversations/MessageItem.kt index b96f30730fb..09d9451095d 100644 --- a/app/src/main/kotlin/com/wire/android/ui/home/conversations/MessageItem.kt +++ b/app/src/main/kotlin/com/wire/android/ui/home/conversations/MessageItem.kt @@ -644,10 +644,11 @@ private fun MessageContent( locationName = messageContent.name, locationUrl = locationUrl, onLocationClick = Clickable( - enabled = !message.isPending && message.isAvailable, + enabled = message.isAvailable, onClick = { onLinkClick(locationUrl) }, onLongClick = onLongClick - )) + ) + ) PartialDeliveryInformation(messageContent.deliveryStatus) } } diff --git a/app/src/main/kotlin/com/wire/android/ui/home/conversations/model/messagetypes/location/LocationMessageType.kt b/app/src/main/kotlin/com/wire/android/ui/home/conversations/model/messagetypes/location/LocationMessageType.kt index 1d35bc69d61..1fa738c48ed 100644 --- a/app/src/main/kotlin/com/wire/android/ui/home/conversations/model/messagetypes/location/LocationMessageType.kt +++ b/app/src/main/kotlin/com/wire/android/ui/home/conversations/model/messagetypes/location/LocationMessageType.kt @@ -55,7 +55,6 @@ fun LocationMessageContent( onLocationClick: Clickable ) { Card( - onClick = { }, modifier = Modifier.clickable(onLocationClick), shape = RoundedCornerShape(dimensions().messageAssetBorderRadius), border = BorderStroke(dimensions().spacing1x, MaterialTheme.wireColorScheme.secondaryButtonDisabledOutline) From bab143d78f1d203fcda4f14aa47676eb79b419e6 Mon Sep 17 00:00:00 2001 From: yamilmedina Date: Mon, 4 Dec 2023 23:38:02 +0100 Subject: [PATCH 03/14] chore: refactor structure of url generation --- .../android/ui/home/conversations/MessageItem.kt | 9 ++++----- .../ui/home/conversations/model/UIMessage.kt | 13 ++----------- .../messagetypes/location/LocationMessageType.kt | 2 -- 3 files changed, 6 insertions(+), 18 deletions(-) diff --git a/app/src/main/kotlin/com/wire/android/ui/home/conversations/MessageItem.kt b/app/src/main/kotlin/com/wire/android/ui/home/conversations/MessageItem.kt index 09d9451095d..ac83f9e24da 100644 --- a/app/src/main/kotlin/com/wire/android/ui/home/conversations/MessageItem.kt +++ b/app/src/main/kotlin/com/wire/android/ui/home/conversations/MessageItem.kt @@ -636,12 +636,11 @@ private fun MessageContent( } } - is UIMessageContent.Location -> { - val resources = LocalContext.current.resources - val locationUrl = messageContent.createLink(resources) + is UIMessageContent.Location -> with(messageContent) { + val locationUrl = stringResource(urlCoordinates, zoom, latitude, longitude) Column { LocationMessageContent( - locationName = messageContent.name, + locationName = name, locationUrl = locationUrl, onLocationClick = Clickable( enabled = message.isAvailable, @@ -649,7 +648,7 @@ private fun MessageContent( onLongClick = onLongClick ) ) - PartialDeliveryInformation(messageContent.deliveryStatus) + PartialDeliveryInformation(deliveryStatus) } } diff --git a/app/src/main/kotlin/com/wire/android/ui/home/conversations/model/UIMessage.kt b/app/src/main/kotlin/com/wire/android/ui/home/conversations/model/UIMessage.kt index 897b85d6dda..3266f6c70ac 100644 --- a/app/src/main/kotlin/com/wire/android/ui/home/conversations/model/UIMessage.kt +++ b/app/src/main/kotlin/com/wire/android/ui/home/conversations/model/UIMessage.kt @@ -212,13 +212,6 @@ sealed class UIMessageContent { val deliveryStatus: DeliveryStatusContent } - /** - * Interface for [UIMessage] classes that can generate a link. - */ - interface Linkable { - fun createLink(resources: Resources): String - } - data class TextMessage( val messageBody: MessageBody, override val deliveryStatus: DeliveryStatusContent = DeliveryStatusContent.CompleteDelivery @@ -280,11 +273,9 @@ sealed class UIMessageContent { 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, Linkable { - override fun createLink(resources: Resources): String = - resources.getString(R.string.url_maps_location_coordinates, zoom, latitude, longitude) - } + ) : Regular(), PartialDeliverable sealed class SystemMessage( @DrawableRes val iconResId: Int?, diff --git a/app/src/main/kotlin/com/wire/android/ui/home/conversations/model/messagetypes/location/LocationMessageType.kt b/app/src/main/kotlin/com/wire/android/ui/home/conversations/model/messagetypes/location/LocationMessageType.kt index 1fa738c48ed..974fd1dd380 100644 --- a/app/src/main/kotlin/com/wire/android/ui/home/conversations/model/messagetypes/location/LocationMessageType.kt +++ b/app/src/main/kotlin/com/wire/android/ui/home/conversations/model/messagetypes/location/LocationMessageType.kt @@ -29,7 +29,6 @@ import androidx.compose.foundation.layout.size import androidx.compose.foundation.layout.width import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.material3.Card -import androidx.compose.material3.ExperimentalMaterial3Api import androidx.compose.material3.Icon import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Text @@ -47,7 +46,6 @@ import com.wire.android.ui.theme.wireDimensions import com.wire.android.ui.theme.wireTypography import com.wire.android.util.ui.PreviewMultipleThemes -@OptIn(ExperimentalMaterial3Api::class) @Composable fun LocationMessageContent( locationName: String, From 27885fce6ef94b64fef5fa2c5fba2bc718423be6 Mon Sep 17 00:00:00 2001 From: yamilmedina Date: Tue, 5 Dec 2023 10:27:36 +0100 Subject: [PATCH 04/14] feat: displaying shared location --- .../location/LocationMessageType.kt | 39 +++++++++++++------ app/src/main/res/values/strings.xml | 1 + 2 files changed, 28 insertions(+), 12 deletions(-) diff --git a/app/src/main/kotlin/com/wire/android/ui/home/conversations/model/messagetypes/location/LocationMessageType.kt b/app/src/main/kotlin/com/wire/android/ui/home/conversations/model/messagetypes/location/LocationMessageType.kt index 974fd1dd380..ab6a3705a66 100644 --- a/app/src/main/kotlin/com/wire/android/ui/home/conversations/model/messagetypes/location/LocationMessageType.kt +++ b/app/src/main/kotlin/com/wire/android/ui/home/conversations/model/messagetypes/location/LocationMessageType.kt @@ -17,8 +17,10 @@ */ package com.wire.android.ui.home.conversations.model.messagetypes.location -import androidx.compose.foundation.BorderStroke +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 @@ -28,15 +30,17 @@ 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.Card 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 @@ -52,30 +56,41 @@ fun LocationMessageContent( locationUrl: String, onLocationClick: Clickable ) { - Card( - modifier = Modifier.clickable(onLocationClick), - shape = RoundedCornerShape(dimensions().messageAssetBorderRadius), - border = BorderStroke(dimensions().spacing1x, MaterialTheme.wireColorScheme.secondaryButtonDisabledOutline) + Column( + modifier = Modifier + .clickable(onLocationClick) + .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)) - .height(dimensions().audioMessageHeight), + .padding(PaddingValues(horizontal = dimensions().spacing8x)), horizontalArrangement = Arrangement.Start, verticalAlignment = Alignment.CenterVertically ) { Icon( painter = painterResource(id = R.drawable.ic_location), - contentDescription = "location desc", + 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.copy(color = MaterialTheme.wireColorScheme.secondaryText), - overflow = TextOverflow.Ellipsis, - maxLines = 1 + style = MaterialTheme.wireTypography.body02, + fontSize = 15.sp, + maxLines = 1, + overflow = TextOverflow.Ellipsis ) } Text( diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 72f0838651f..fb379736aeb 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -174,6 +174,7 @@ All devices of all participants have a valid MLS certificate All of all participants are verified (Proteus) Scroll down to last message, button + Location item https://support.wire.com https://support.wire.com/hc/articles/207948115-Why-was-I-notified-that-a-message-from-a-contact-was-not-received- From 894454aff024eadb99c8e16c8802efcc48972288 Mon Sep 17 00:00:00 2001 From: yamilmedina Date: Tue, 5 Dec 2023 10:30:49 +0100 Subject: [PATCH 05/14] feat: displaying shared location --- .../com/wire/android/mapper/RegularMessageContentMapper.kt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/src/main/kotlin/com/wire/android/mapper/RegularMessageContentMapper.kt b/app/src/main/kotlin/com/wire/android/mapper/RegularMessageContentMapper.kt index eb8d02baf5a..85566c2f1a0 100644 --- a/app/src/main/kotlin/com/wire/android/mapper/RegularMessageContentMapper.kt +++ b/app/src/main/kotlin/com/wire/android/mapper/RegularMessageContentMapper.kt @@ -23,6 +23,7 @@ package com.wire.android.mapper 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 @@ -126,6 +127,7 @@ class RegularMessageMapper @Inject constructor( latitude = content.latitude, longitude = content.longitude, name = content.name.orEmpty(), + zoom = content.zoom ?: DEFAULT_LOCATION_ZOOM, deliveryStatus = mapRecipientsFailure(userList, message.deliveryStatus) ) } From 408001f249ccb5d1b6a4c9e00e095870b43cb0ab Mon Sep 17 00:00:00 2001 From: yamilmedina Date: Tue, 5 Dec 2023 10:54:38 +0100 Subject: [PATCH 06/14] feat: displaying shared location --- app/src/main/res/values/strings.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index fb379736aeb..c23d53650d6 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -187,7 +187,7 @@ https://support.wire.com/hc/categories/4719917054365-Federation https://support.wire.com/hc/articles/115004082129 https://medium.com/wire-news/android-updates/home - http://maps.google.com/maps?z=%1d&q=%2f,%2f + http://maps.google.com/maps?z=%1d&q=loc:%2f+%2f Vault Archive From a68a6d73f76de9891210cf680865a6ea9494829f Mon Sep 17 00:00:00 2001 From: yamilmedina Date: Wed, 6 Dec 2023 16:06:32 +0100 Subject: [PATCH 07/14] chore: kalium ref --- kalium | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kalium b/kalium index 9ce3291f4b1..33dfbb3bfdc 160000 --- a/kalium +++ b/kalium @@ -1 +1 @@ -Subproject commit 9ce3291f4b192c0aea1e0f8f6237f05c65b63dfc +Subproject commit 33dfbb3bfdc603355cdaa311dcd47ae89f46240a From ebcf7bc741f7ce772b3e361599bdcd5bdde5de09 Mon Sep 17 00:00:00 2001 From: yamilmedina Date: Wed, 6 Dec 2023 16:10:57 +0100 Subject: [PATCH 08/14] chore: padding --- .../model/messagetypes/location/LocationMessageType.kt | 1 + 1 file changed, 1 insertion(+) diff --git a/app/src/main/kotlin/com/wire/android/ui/home/conversations/model/messagetypes/location/LocationMessageType.kt b/app/src/main/kotlin/com/wire/android/ui/home/conversations/model/messagetypes/location/LocationMessageType.kt index ab6a3705a66..505a1087143 100644 --- a/app/src/main/kotlin/com/wire/android/ui/home/conversations/model/messagetypes/location/LocationMessageType.kt +++ b/app/src/main/kotlin/com/wire/android/ui/home/conversations/model/messagetypes/location/LocationMessageType.kt @@ -59,6 +59,7 @@ fun LocationMessageContent( Column( modifier = Modifier .clickable(onLocationClick) + .padding(top = dimensions().spacing4x) .clip(shape = RoundedCornerShape(dimensions().messageAssetBorderRadius)) .border( width = dimensions().spacing1x, From 4d44545f09c755b71efd5f9a96f91e2b0d2fcfe1 Mon Sep 17 00:00:00 2001 From: yamilmedina Date: Thu, 7 Dec 2023 11:07:02 +0100 Subject: [PATCH 09/14] chore: detekt --- .../mapper/RegularMessageContentMapper.kt | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/app/src/main/kotlin/com/wire/android/mapper/RegularMessageContentMapper.kt b/app/src/main/kotlin/com/wire/android/mapper/RegularMessageContentMapper.kt index 66f33fd8c6a..801f15f51b5 100644 --- a/app/src/main/kotlin/com/wire/android/mapper/RegularMessageContentMapper.kt +++ b/app/src/main/kotlin/com/wire/android/mapper/RegularMessageContentMapper.kt @@ -122,19 +122,23 @@ class RegularMessageMapper @Inject constructor( ) } - is MessageContent.Location -> { - UIMessageContent.Location( - latitude = content.latitude, - longitude = content.longitude, - name = content.name.orEmpty(), - zoom = content.zoom ?: DEFAULT_LOCATION_ZOOM, - deliveryStatus = mapRecipientsFailure(userList, message.deliveryStatus) - ) - } + is MessageContent.Location -> toLocation(content, userList, message) else -> toText(message.conversationId, content, userList, message.deliveryStatus) } + private fun toLocation( + content: MessageContent.Location, + userList: List, + message: Message.Regular + ) = UIMessageContent.Location( + latitude = content.latitude, + longitude = content.longitude, + name = content.name.orEmpty(), + zoom = content.zoom ?: DEFAULT_LOCATION_ZOOM, + deliveryStatus = mapRecipientsFailure(userList, message.deliveryStatus) + ) + private fun mapAudio( assetContent: AssetContent, metadata: AssetContent.AssetMetadata.Audio, From aa35f9435b163d374914f49c637f066b32de5cc7 Mon Sep 17 00:00:00 2001 From: yamilmedina Date: Fri, 8 Dec 2023 12:40:13 +0100 Subject: [PATCH 10/14] feat: address pr comments --- .../ui/home/conversations/MessageItem.kt | 4 +- .../ui/home/conversations/model/UIMessage.kt | 2 +- .../com/wire/android/util/CommonIntentUtil.kt | 46 +++++++++++++++++++ app/src/main/res/values/strings.xml | 5 +- 4 files changed, 52 insertions(+), 5 deletions(-) create mode 100644 app/src/main/kotlin/com/wire/android/util/CommonIntentUtil.kt diff --git a/app/src/main/kotlin/com/wire/android/ui/home/conversations/MessageItem.kt b/app/src/main/kotlin/com/wire/android/ui/home/conversations/MessageItem.kt index ac83f9e24da..e8df1da46ad 100644 --- a/app/src/main/kotlin/com/wire/android/ui/home/conversations/MessageItem.kt +++ b/app/src/main/kotlin/com/wire/android/ui/home/conversations/MessageItem.kt @@ -87,6 +87,7 @@ import com.wire.android.ui.home.conversations.model.messagetypes.image.ImageMess 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.android.util.launchGeoIntent import com.wire.kalium.logic.data.message.Message import com.wire.kalium.logic.data.user.UserId @@ -637,6 +638,7 @@ private fun MessageContent( } is UIMessageContent.Location -> with(messageContent) { + val context = LocalContext.current val locationUrl = stringResource(urlCoordinates, zoom, latitude, longitude) Column { LocationMessageContent( @@ -644,7 +646,7 @@ private fun MessageContent( locationUrl = locationUrl, onLocationClick = Clickable( enabled = message.isAvailable, - onClick = { onLinkClick(locationUrl) }, + onClick = { launchGeoIntent(latitude, longitude, name, locationUrl, context) }, onLongClick = onLongClick ) ) diff --git a/app/src/main/kotlin/com/wire/android/ui/home/conversations/model/UIMessage.kt b/app/src/main/kotlin/com/wire/android/ui/home/conversations/model/UIMessage.kt index 3266f6c70ac..8d0d6a94af8 100644 --- a/app/src/main/kotlin/com/wire/android/ui/home/conversations/model/UIMessage.kt +++ b/app/src/main/kotlin/com/wire/android/ui/home/conversations/model/UIMessage.kt @@ -273,7 +273,7 @@ sealed class UIMessageContent { val longitude: Float, val name: String, val zoom: Int = DEFAULT_LOCATION_ZOOM, - @StringRes val urlCoordinates: Int = R.string.url_maps_location_coordinates, + @StringRes val urlCoordinates: Int = R.string.url_maps_location_coordinates_fallback, override val deliveryStatus: DeliveryStatusContent = DeliveryStatusContent.CompleteDelivery ) : Regular(), PartialDeliverable diff --git a/app/src/main/kotlin/com/wire/android/util/CommonIntentUtil.kt b/app/src/main/kotlin/com/wire/android/util/CommonIntentUtil.kt new file mode 100644 index 00000000000..a5f57863088 --- /dev/null +++ b/app/src/main/kotlin/com/wire/android/util/CommonIntentUtil.kt @@ -0,0 +1,46 @@ +/* + * 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.util + +import android.content.ActivityNotFoundException +import android.content.Context +import android.content.Intent +import android.net.Uri +import androidx.core.net.toUri +import com.wire.android.appLogger + +/** + * Launches a geo intent with the given latitude and longitude. + * If no intent can be found to handle the geo intent, a fallback to url is used. + */ +fun launchGeoIntent( + latitude: Float, + longitude: Float, + placeName: String?, + fallbackUrl: String, + context: Context +) { + val geoStringUrl = StringBuilder("geo:0,0?q=$latitude,$longitude") + if (!placeName.isNullOrEmpty()) geoStringUrl.append("(${Uri.encode(placeName)})") + try { + context.startActivity(Intent(Intent.ACTION_VIEW, Uri.parse(geoStringUrl.toString()))) + } catch (e: ActivityNotFoundException) { + appLogger.e("No activity found to handle geo intent, fallback to url", e) + context.startActivity(Intent(Intent.ACTION_VIEW, fallbackUrl.toUri())) + } +} diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index c39cfc3ac05..a02b115b38b 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1,5 +1,4 @@ - - Vault Archive From 30c31cca107c35aed4804828d523add85df72785 Mon Sep 17 00:00:00 2001 From: yamilmedina Date: Fri, 8 Dec 2023 12:43:23 +0100 Subject: [PATCH 11/14] feat: address pr comments --- app/src/main/kotlin/com/wire/android/util/CommonIntentUtil.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/main/kotlin/com/wire/android/util/CommonIntentUtil.kt b/app/src/main/kotlin/com/wire/android/util/CommonIntentUtil.kt index a5f57863088..4e363bb1b29 100644 --- a/app/src/main/kotlin/com/wire/android/util/CommonIntentUtil.kt +++ b/app/src/main/kotlin/com/wire/android/util/CommonIntentUtil.kt @@ -26,7 +26,7 @@ import com.wire.android.appLogger /** * Launches a geo intent with the given latitude and longitude. - * If no intent can be found to handle the geo intent, a fallback to url is used. + * If no app/activity can be found to handle the geo intent, a fallback to url is used. */ fun launchGeoIntent( latitude: Float, @@ -38,7 +38,7 @@ fun launchGeoIntent( val geoStringUrl = StringBuilder("geo:0,0?q=$latitude,$longitude") if (!placeName.isNullOrEmpty()) geoStringUrl.append("(${Uri.encode(placeName)})") try { - context.startActivity(Intent(Intent.ACTION_VIEW, Uri.parse(geoStringUrl.toString()))) + context.startActivity(Intent(Intent.ACTION_VIEW, geoStringUrl.toString().toUri())) } catch (e: ActivityNotFoundException) { appLogger.e("No activity found to handle geo intent, fallback to url", e) context.startActivity(Intent(Intent.ACTION_VIEW, fallbackUrl.toUri())) From de661618c3bc2f5c88c6811b7048842ad1b7cf3a Mon Sep 17 00:00:00 2001 From: yamilmedina Date: Fri, 8 Dec 2023 13:04:49 +0100 Subject: [PATCH 12/14] feat: address pr comments --- .../main/kotlin/com/wire/android/util/CommonIntentUtil.kt | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/src/main/kotlin/com/wire/android/util/CommonIntentUtil.kt b/app/src/main/kotlin/com/wire/android/util/CommonIntentUtil.kt index 4e363bb1b29..a2efb3c4d2c 100644 --- a/app/src/main/kotlin/com/wire/android/util/CommonIntentUtil.kt +++ b/app/src/main/kotlin/com/wire/android/util/CommonIntentUtil.kt @@ -24,9 +24,12 @@ import android.net.Uri import androidx.core.net.toUri import com.wire.android.appLogger +// geo intent url scheme +internal const val GEO_INTENT_URL = "geo:0,0?q=%1f,%2f" + /** * Launches a geo intent with the given latitude and longitude. - * If no app/activity can be found to handle the geo intent, a fallback to url is used. + * If no app/activity can be found to handle the [GEO_INTENT_URL], a [fallbackUrl] is used. */ fun launchGeoIntent( latitude: Float, @@ -35,7 +38,7 @@ fun launchGeoIntent( fallbackUrl: String, context: Context ) { - val geoStringUrl = StringBuilder("geo:0,0?q=$latitude,$longitude") + val geoStringUrl = StringBuilder(String.format(GEO_INTENT_URL, latitude, longitude)) if (!placeName.isNullOrEmpty()) geoStringUrl.append("(${Uri.encode(placeName)})") try { context.startActivity(Intent(Intent.ACTION_VIEW, geoStringUrl.toString().toUri())) From 702b3d405eee4af3194516c5904097d88e766a08 Mon Sep 17 00:00:00 2001 From: yamilmedina Date: Fri, 8 Dec 2023 13:06:32 +0100 Subject: [PATCH 13/14] feat: address pr comments --- app/src/main/kotlin/com/wire/android/util/CommonIntentUtil.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/kotlin/com/wire/android/util/CommonIntentUtil.kt b/app/src/main/kotlin/com/wire/android/util/CommonIntentUtil.kt index a2efb3c4d2c..0c591f6f8f2 100644 --- a/app/src/main/kotlin/com/wire/android/util/CommonIntentUtil.kt +++ b/app/src/main/kotlin/com/wire/android/util/CommonIntentUtil.kt @@ -25,7 +25,7 @@ import androidx.core.net.toUri import com.wire.android.appLogger // geo intent url scheme -internal const val GEO_INTENT_URL = "geo:0,0?q=%1f,%2f" +internal const val GEO_INTENT_URL = "geo:0,0?q=%f,%f" /** * Launches a geo intent with the given latitude and longitude. From 9e0912712f01e43f104d38247139fcc8a9d971c2 Mon Sep 17 00:00:00 2001 From: yamilmedina Date: Fri, 8 Dec 2023 13:50:41 +0100 Subject: [PATCH 14/14] chore: kalium ref --- kalium | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kalium b/kalium index 43a6e27e26e..3c8ceb09e61 160000 --- a/kalium +++ b/kalium @@ -1 +1 @@ -Subproject commit 43a6e27e26ef1b1bacfb5708a4469dc15d4d8220 +Subproject commit 3c8ceb09e61f25ad91771f95f49b8fe4da63c223