-
Notifications
You must be signed in to change notification settings - Fork 739
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
[Location sharing] - Show message on start of a live #5722
Conversation
import org.matrix.android.sdk.api.session.room.model.message.LocationAsset | ||
import org.matrix.android.sdk.api.session.room.model.message.LocationAssetType | ||
import org.matrix.android.sdk.api.session.room.model.message.MessageContent | ||
import org.matrix.android.sdk.api.session.room.model.message.MessageType | ||
import org.matrix.android.sdk.api.session.room.model.relation.RelationDefaultContent | ||
|
||
@JsonClass(generateAdapter = true) | ||
data class LiveLocationBeaconContent( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only way I found to be able to show the content as a message in the timeline is to inherit from MessageContent
even though it does not correspond to a message event but a state event. Is there a better way to implement it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it looks like we use this pattern for other timeline types, eg stickers, polls, verification. Would lean towards this being ok, although will delegate to @ganfra
val startOfLive = DateProvider.toLocalDateTime(startTimestamp) | ||
val timeout = liveLocationContent.getBestBeaconInfo()?.timeout ?: 0L | ||
val endOfLive = startOfLive.plus(timeout, ChronoUnit.MILLIS) | ||
now.isAfter(endOfLive) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comparison seems to not work correctly when phone timezone is changed. Maybe need to express all dates in UTC to ensure correctness.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed, we are using the timestamp of last received and attached location event to check the validity of the beacon.
9e9ce13
to
e995c20
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -0,0 +1 @@ | |||
Live Location Sharing - Show message on start of a live |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should this be of a live location
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I supposed the "Live Location Sharing" prefix was enough to infer the type of live but I can add it if you really think it is not clear enough.
return | ||
beaconInfoContent.hasTimedOut = true | ||
} else { | ||
// Update last location info of the beacon state event |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this comment doesn't add any extra information, is it needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right, we can remove it since what we do here is clear.
/** | ||
* Client side tracking of whether the beacon has timed out. | ||
*/ | ||
var hasTimedOut: Boolean = false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm a little weary of polluting the JSON model with mutable client state, is it possible to have this somewhere else , or does this model change mean the least amount of changes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes I don't really like it either. I have seen we use Entity
classes for that case in the project. I will try to update it with a corresponding Entity class.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤞
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will try to refact this in another following PR when handling the location message update.
@@ -33,5 +33,5 @@ object RoomSummaryConstants { | |||
EventType.ENCRYPTED, | |||
EventType.STICKER, | |||
EventType.REACTION | |||
) + EventType.POLL_START | |||
) + EventType.POLL_START + EventType.STATE_ROOM_BEACON_INFO |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks like these event types could be inside the listOf()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In fact these event types are not of type String
values but of type List<String>
in order to support stable/unstable fields. That's why they are added to the `listOf().
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ahhhhhhh thanks for explaining!
@@ -121,30 +122,31 @@ import org.matrix.android.sdk.internal.database.lightweight.LightweightSettingsS | |||
import javax.inject.Inject | |||
|
|||
class MessageItemFactory @Inject constructor( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's very tricky to know what changed in this file due to the formatting 😢
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I will try to revert to only the changes I have done. I guess this class will be reformatted in the future with new coding styles.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if you're able to point out the changes that would be enough for me (rather than having to revert)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Too late 😄 Now you can see clearly the changes.
1673f51
to
4670072
Compare
attributes: AbsMessageItem.Attributes, | ||
): MessageLiveLocationStartItem { | ||
val width = timelineMediaSizeProvider.getMaxSize().first | ||
val height = dimensionConverter.dpToPx(200) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've seen this 200
in a few places, wondering if it could be a constant somewhere~
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no blockers from my side, LGTM! 💯 might be worth checking in with @ganfra to confirm about the MessageContent
usage
Type of change
Content
Handling beacon state event in the timeline to indicate a live location share has been started. This state of the message will be displayed until a location is received. Adding support for preview of live location sharing message as well.
Motivation and context
Closes #5710
Screenshots / GIFs
Default layout mode
Bubble layout mode
UX
Tests
Tested devices
Checklist