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

[Location sharing] - Message for live sharing in timeline (PSF-884) #5989

Merged
merged 46 commits into from
May 18, 2022

Conversation

mnaturel
Copy link
Contributor

@mnaturel mnaturel commented May 9, 2022

Type of change

  • Feature
  • Bugfix
  • Technical
  • Other :

Content

Handling of the UI for the message associated to a live location share in the timeline. The message stays at the same position (at the timestamp of the start of the live). The message has 3 states:

  • Loading (live has been start but no location has been received yet)
  • Running (showing the last location of the user who is sharing)
  • Ended (the live has been stopped by the user or is timed out)

The UI will also change depending if the user is the creator of the live or not.

Known issues that will be fixed later:

  • Long waiting after pressing stop: a loader will be shown after pressing "Stop"
  • No refresh of the message if the user is viewing the timeline and the live goes from running state to timed out
  • Blinking of the map when location is updated

Motivation and context

Closes #5689

Screenshots / GIFs

Note: in the running state on emitter side, the live locatiion sharing top bar is not visible is some of the captures due to missing handling when restarting the app (like when toggling dark mode)

Running state (Emitter/default layout) Running state (Emitter/bubble layout)
Running state (Watcher/default layout) Running state (Watcher/bubble layout)
Ended state (default layout) Ended state (bubble layout)

Tests

  • Ensure to enable location sharing in Settings -> Preferences
  • Ensure to enable developer mode in Settings -> Advanced settings
  • Ensure to enable the live location feature in the developer setting
  • Go to a room where you can send state event
  • Press the plus button on the new message layout
  • Press the location icon
  • Choose the "Live location" option
  • Check the message displays "Loading" state
  • Check the message displays the correct last location
  • Check the location is updated when moving (can be emulated by a fake route on emulator)
  • Press the stop button
  • Check the message displays the "Ended" state

Tested devices

  • Physical
  • Emulator
  • OS version(s): Android 11

Checklist

@github-actions
Copy link

github-actions bot commented May 9, 2022

Unit Test Results

122 files  ±0  122 suites  ±0   2m 10s ⏱️ -10s
205 tests ±0  205 ✔️ ±0  0 💤 ±0  0 ±0 
690 runs  ±0  690 ✔️ ±0  0 💤 ±0  0 ±0 

Results for commit 4ebd1ea. ± Comparison against base commit 3674ae7.

♻️ This comment has been updated with latest results.

@mnaturel mnaturel marked this pull request as ready for review May 11, 2022 09:10
@mnaturel mnaturel requested review from a team, bmarty, ganfra and onurays and removed request for a team May 11, 2022 09:11
Copy link
Contributor

@ganfra ganfra left a comment

Choose a reason for hiding this comment

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

Some remarks, otherwise good work!

@@ -60,22 +60,27 @@ internal class DefaultLiveLocationAggregationProcessor @Inject constructor() : L
aggregatedSummary.isActive = content.isLive
}

override fun handleBeaconLocationData(realm: Realm, event: Event, content: MessageBeaconLocationDataContent, roomId: String, isLocalEcho: Boolean) {
override fun handleBeaconLocationData(
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure we should have an interface for this

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed, see 4a23109

zoneId.rules.getOffset(now)
}
// recompute the zoneId each time we access it to handle change of timezones
private val defaultZoneId: ZoneId
Copy link
Contributor

Choose a reason for hiding this comment

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

Might be too costly?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have done this change to handle the case of a change of timezone when the app is running. If we don't recompute the ZoneId, in some cases, we don't use the same as the one defined in the system and dates and times are not correct in the app. Do you have another solution in mind to fix this issue?

Copy link
Contributor

Choose a reason for hiding this comment

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

We should probably listen to android.intent.action.TIMEZONE_CHANGED intent if we really want this to be updated. But thats really not a common case, so I don't know?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have created a dedicated issue to improve it: #6076

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe remove the change waiting for the improvement? What do you think @bmarty?

Copy link
Member

Choose a reason for hiding this comment

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

This can be handled later and this can stay like that for now I think.

// Calls
EventType.CALL_INVITE,
EventType.CALL_HANGUP,
EventType.CALL_REJECT,
EventType.CALL_ANSWER -> callItemFactory.create(params)
EventType.CALL_ANSWER -> callItemFactory.create(params)
in EventType.BEACON_LOCATION_DATA -> noticeItemFactory.create(params)
Copy link
Contributor

Choose a reason for hiding this comment

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

Should be grouped with other NoticeItem

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed see 2aeee79

@@ -119,7 +119,8 @@ class MessageInformationDataFactory @Inject constructor(private val session: Ses
isFirstFromThisSender = isFirstFromThisSender,
isLastFromThisSender = isLastFromThisSender,
e2eDecoration = e2eDecoration,
sendStateDecoration = sendStateDecoration
sendStateDecoration = sendStateDecoration,
liveLocationShareSummaryData = getLiveLocationShareSummaryData(event)
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure it should be part of this class

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I tried to follow the same practice as for other extra information of events. Do you think I should extract it into its own LiveLocationShareSummaryData and associated LiveLocationShareSummaryDataFactory?

Copy link
Contributor

Choose a reason for hiding this comment

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

You could just add this as attribute of needed items. MessageInformationData should be used for data used by all items

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have removed the data class from MessageInformationData and encapsulated it into the live location item factory since this is the only area where it is used. See cbf8306

import android.widget.ImageView
import im.vector.app.features.home.room.detail.timeline.style.TimelineMessageLayout

interface LiveLocationShareStatusItem {
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't see other implementations happening, so would remove the interface

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The purpose of this interface was to be able to use delegation pattern to mutualize code in MessageLiveLocationInactiveItem and MessageLiveLocationStartItem. If I remove it, I will not be able to use it. Do you have another solution?

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok, I hadn't seen the delegation, sorry

import im.vector.app.features.themes.ThemeUtils
import org.threeten.bp.Duration

sealed class LocationLiveMessageBannerViewState(
Copy link
Contributor

Choose a reason for hiding this comment

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

Extract in a separate file?

Copy link
Contributor Author

@mnaturel mnaturel May 16, 2022

Choose a reason for hiding this comment

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

Yes, done in b077351 and 3d13611

@mnaturel mnaturel requested a review from ganfra May 16, 2022 08:40
@Johennes Johennes changed the title [Location sharing] - Message for live sharing in timeline [Location sharing] - Message for live sharing in timeline (PSF-884) May 16, 2022
Copy link
Contributor

@ganfra ganfra left a comment

Choose a reason for hiding this comment

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

LGTM now, thanks for the changes

Copy link
Member

@bmarty bmarty left a comment

Choose a reason for hiding this comment

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

LGTM, just small remarks about the strings.

@@ -322,6 +322,14 @@
<string name="start_chatting">Start Chatting</string>
<string name="spaces">Spaces</string>

<!-- Time units -->
<plurals name="time_unit_hour_short">
Copy link
Member

Choose a reason for hiding this comment

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

Maybe add a comment for translator that if a short version exists in their language, it has to be used. For English there is no short version, so it can confuse the translators.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done see e9d9319

<item quantity="other">hours</item>
</plurals>
<string name="time_unit_minute_short">min</string>
<string name="time_unit_second_short">sec</string>
Copy link
Member

Choose a reason for hiding this comment

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

It's weird to have a plural for hours, but not for minutes and seconds. It can be better to have only plurals to give more flexibility to the translators.
All plural items for English can be identical.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree. I decided to remove the plural and use "h" instead of "hour" to be consistent with other platforms. See e9d9319

@@ -3014,7 +3022,11 @@
<string name="location_timeline_failed_to_load_map">Failed to load map</string>
<string name="location_share_live_enabled">Live location enabled</string>
<string name="location_share_live_started">Loading live location…</string>
<string name="location_share_live_ended">Live location ended</string>
<string name="location_share_live_view">View live location</string>
<string name="location_share_live_until">Live until %1$s</string>
Copy link
Member

Choose a reason for hiding this comment

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

Maybe add a comment to explain what will replace the template, with an example

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done in e9d9319.

<string name="location_share_live_stop">Stop</string>
<string name="location_share_live_remaining_time">%1$s left</string>
Copy link
Member

Choose a reason for hiding this comment

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

Maybe add a comment to explain what will replace the template, with an example

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done in e9d9319.

@mnaturel mnaturel requested a review from bmarty May 18, 2022 07:51
Copy link
Member

@bmarty bmarty left a comment

Choose a reason for hiding this comment

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

Thanks for the update!

@mnaturel mnaturel merged commit 738ce18 into develop May 18, 2022
@mnaturel mnaturel deleted the feature/mna/PSF-884-location-view branch May 18, 2022 13:39
@github-actions
Copy link

Matrix SDK

Integration Tests Results:

  • [org.matrix.android.sdk.session]
    = passed=18 failures=2 errors=0 skipped=3
  • [org.matrix.android.sdk.account]
    = passed=3 failures=0 errors=0 skipped=2
  • [org.matrix.android.sdk.internal]
    = passed=5 failures=1 errors=0 skipped=0
  • [org.matrix.android.sdk.ordering]
    = passed=16 failures=0 errors=0 skipped=0
  • [org.matrix.android.sdk.PermalinkParserTest]
    = passed=2 failures=0 errors=0 skipped=0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Location sharing] - Show message for live sharing in timeline
3 participants