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] - Navigation to Map view from live location message (PSF-888) #6092

Merged
merged 11 commits into from
May 23, 2022

Conversation

mnaturel
Copy link
Contributor

Type of change

  • Feature
  • Bugfix
  • Technical
  • Other :

Content

Add possibility to navigate to a map screen from a running live location share message.
User pins on map and other UI will be implemented in another pull request.

Motivation and context

Part of #6012

Screenshots / GIFs

Tests

  • Ensure to enable location sharing in Settings -> Preferences
  • Ensure to enable developer mode in Settings -> Advanced
  • Ensure to enable the feature flaf for live location sharing
  • Start a live location share in a room
  • Press the running live message
  • Check a new screen is opened with a map of the world
  • Press back
  • Stop the live
  • Check pressing on the ended live message does nothing

Tested devices

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

Checklist

@mnaturel mnaturel requested review from a team, bmarty and ganfra and removed request for a team May 18, 2022 13:58
@github-actions
Copy link

github-actions bot commented May 18, 2022

Unit Test Results

124 files  +  2  124 suites  +2   2m 10s ⏱️ +8s
217 tests +12  217 ✔️ +12  0 💤 ±0  0 ±0 
714 runs  +24  714 ✔️ +24  0 💤 ±0  0 ±0 

Results for commit 7bb73ff. ± Comparison against base commit 738ce18.

♻️ This comment has been updated with latest results.

@@ -75,7 +75,8 @@ class LiveLocationShareMessageItemFactory @Inject constructor(
val height = dimensionConverter.dpToPx(MessageItemFactory.MESSAGE_LOCATION_ITEM_HEIGHT_IN_DP)

return MessageLiveLocationInactiveItem_()
.attributes(attributes)
// disable the click on this state item
.attributes(attributes.copy(itemClickListener = null))
Copy link
Member

Choose a reason for hiding this comment

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

Maybe we can avoid to add the clickListener before or add a new boolean to disable instead?

Copy link
Contributor Author

@mnaturel mnaturel May 23, 2022

Choose a reason for hiding this comment

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

I am not sure I can do better and more simple for that. Deciding whether the item should be clickable depends on the status of the live which is computed inside this factory using some fields of the summary data. Unless you have a solution in mind?

Copy link
Member

Choose a reason for hiding this comment

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

I agree it's a bit strange to do like this. Also I am pretty sure that in the future, if we want the item to be clickable, we may hardly understand why the item is not clickable because of this.

Not a blocker anyway.

/**
* Screen showing a map with all the current users sharing their live location in room.
*/
class LocationLiveMapViewFragment @Inject constructor(
Copy link
Member

Choose a reason for hiding this comment

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

Maybe start using @androidentrypoint for fragment with field injection?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I will try to make the change.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

See c46aaa2

Copy link
Member

@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 small remarks, otherwise LGTM

/*@Binds
@IntoMap
@FragmentKey(LocationLiveMapViewFragment::class)
fun bindLocationLiveMapViewFragment(fragment: LocationLiveMapViewFragment): Fragment*/
Copy link
Member

Choose a reason for hiding this comment

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

Please remove commented out code, or will it be uncommented in a future PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oups not intended, sorry.

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 am wondering if we could have this type of auto verification (no commented code) in Danger?

Copy link
Member

Choose a reason for hiding this comment

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

Sonar is checking that

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 in 721d7cb

@@ -75,7 +75,8 @@ class LiveLocationShareMessageItemFactory @Inject constructor(
val height = dimensionConverter.dpToPx(MessageItemFactory.MESSAGE_LOCATION_ITEM_HEIGHT_IN_DP)

return MessageLiveLocationInactiveItem_()
.attributes(attributes)
// disable the click on this state item
.attributes(attributes.copy(itemClickListener = null))
Copy link
Member

Choose a reason for hiding this comment

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

I agree it's a bit strange to do like this. Also I am pretty sure that in the future, if we want the item to be clickable, we may hardly understand why the item is not clickable because of this.

Not a blocker anyway.


/**
* Screen showing a map with all the current users sharing their live location in room.
*/
Copy link
Member

Choose a reason for hiding this comment

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

Thanks for the comment!

val fragment = SupportMapFragment.newInstance(options)
addFragment(R.id.liveLocationMapContainer, fragment, tag = MAP_FRAGMENT_TAG)
fragment
}
Copy link
Member

Choose a reason for hiding this comment

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

Maybe reduce to

                        ?: run {
                            val options = MapboxMapOptions.createFromAttributes(requireContext(), null)
                            SupportMapFragment.newInstance(options)
                                    .also { addFragment(R.id.liveLocationMapContainer, it, tag = MAP_FRAGMENT_TAG) }
                        }

Also maybe extract to a private fun getOrCreateSupportMapFragment() for code clarity.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the suggestion. Done in b331521


private fun setupMap() {
val mapFragment: SupportMapFragment =
parentFragmentManager.findFragmentByTag(MAP_FRAGMENT_TAG) as? SupportMapFragment
Copy link
Member

Choose a reason for hiding this comment

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

I think you should use the childFramentManager here

?: run {
val options = MapboxMapOptions.createFromAttributes(requireContext(), null)
val fragment = SupportMapFragment.newInstance(options)
addFragment(R.id.liveLocationMapContainer, fragment, tag = MAP_FRAGMENT_TAG)
Copy link
Member

Choose a reason for hiding this comment

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

I think you should use addChildFragment here.

@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
Copy link
Member

Choose a reason for hiding this comment

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

Maybe rename the file to something more generic and reusable like fragment_simple_container.xml. I have check and a similar fragment layout does not exist yet.

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 7bb73ff

@mnaturel mnaturel requested a review from bmarty May 23, 2022 09:45
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!
As discussed, OK for the click listener management.

@mnaturel mnaturel merged commit 9a38d59 into develop May 23, 2022
@mnaturel mnaturel deleted the feature/mna/PSF-888-navigation branch May 23, 2022 11:54
@github-actions
Copy link

Matrix SDK

Integration Tests Results:

  • [org.matrix.android.sdk.session]
    = passed=19 failures=1 errors=0 skipped=3
  • [org.matrix.android.sdk.account]
    = passed=3 failures=0 errors=0 skipped=2
  • [org.matrix.android.sdk.internal]
    = passed=6 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.

3 participants