Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

[android] Adding pulsing circle to LocationComponent options #13942

Closed

Conversation

langsmith
Copy link
Contributor

@langsmith langsmith commented Feb 18, 2019

This pr adds a pulsing circle functionality to the Android LocationComponent.

The following options/methods have been added to LocationComponentOptions for styling the pulsing circle:

  • whether the pulsing circle is enabled or not
  • circle's color
  • circle's opacity
  • number of milliseconds of length of a single pulse
  • type of interpolated animation (linear, decelerate, accelerate, or bounce)
  • whether the circle's opacity fades during the pulse

Fade enabled:
ezgif com-resize 2

Fade disabled:
ezgif com-resize 3

@langsmith langsmith added Android Mapbox Maps SDK for Android in progress labels Feb 18, 2019
@langsmith langsmith self-assigned this Feb 18, 2019
@langsmith langsmith requested a review from a team February 18, 2019 23:38
@langsmith
Copy link
Contributor Author

Still definitely a work in progress but opening this pr to start discussion and review from @mapbox/maps-android . Not sure whether my implementation is correct. Once things are 👌 on the back end, I can finish the test app example, write tests, finish Javadocs, etc.

Also, as you'll see in the fade enabled GIF above, there's a weird "hitch" when a pulse is finished and a new one is about to begin. I assume it probably has to do with how I'm tracking things in the PulsingLocationCircleAnimator class. Any thoughts on a better way to achieve this effect? Something to do with the speed of the ValueAnimator and the Maps SDK's ability to catch up with new values?

@langsmith langsmith requested review from LukasPaczos, tobrun and osana and removed request for a team February 18, 2019 23:43
@langsmith langsmith force-pushed the ls-android]-adding-locationComponent-circle-pulse branch from 2bdda13 to 5eddbb6 Compare February 19, 2019 00:12
@langsmith
Copy link
Contributor Author

I've got https://github.com/mapbox/mapbox-gl-native/pull/13942/files#diff-e6b14cce649c4c464b5c466cbda57938R76 , which is used here and then ultimately here. Doesn't seem to be working though. If you open the pulsing circle test app activity and then go back, it'll crash the app:

2019-02-18 16:11:09.093 29293-29293/? A/libc: Fatal signal 6 (SIGABRT), code -6 (SI_TKILL) in tid 29293 (pboxsdk.testapp), pid 29293 (pboxsdk.testapp)

Thoughts on how I might manage lifecycle with this background runnable and all?...

tobrun
tobrun previously requested changes Feb 19, 2019
Copy link
Member

@tobrun tobrun left a comment

Choose a reason for hiding this comment

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

sub module pins were updated but not required for this PR?
might be good to refactor all the pulsing fields into a new object?

@langsmith langsmith force-pushed the ls-android]-adding-locationComponent-circle-pulse branch from 5eddbb6 to 55a49db Compare February 19, 2019 20:18
@langsmith
Copy link
Contributor Author

langsmith commented Feb 19, 2019

sub module pins were updated but not required for this PR?

Yes, they snuck in here 😢

@langsmith
Copy link
Contributor Author

might be good to refactor all the pulsing fields into a new object?

Yea, wasn't sure whether we should have completely separate builder or not for these pulsing options. I didn't make one as a start, 'cause it might be too many nested builders into one another. 3 levels deep: PulsingCircleOptions into LocationComponentOptions and then LocationComponentOptions into LocationComponentActivationOptions. Thoughts? @LukasPaczos ?

@langsmith
Copy link
Contributor Author

Yea, wasn't sure whether we should have completely separate builder or not for these pulsing options

Note: @LukasPaczos followed up offline and confirmed that the current setup is fine. Pulsing options can be in LocationComponentOptions rather than being part of another builder process.

@langsmith langsmith force-pushed the ls-android]-adding-locationComponent-circle-pulse branch 2 times, most recently from 7846ce9 to 2547b7d Compare February 22, 2019 03:55
@langsmith langsmith force-pushed the ls-android]-adding-locationComponent-circle-pulse branch 2 times, most recently from eaadbd0 to 7834827 Compare March 6, 2019 18:38
@langsmith langsmith force-pushed the ls-android]-adding-locationComponent-circle-pulse branch 3 times, most recently from 0878689 to 365fb1f Compare March 11, 2019 06:56
@langsmith langsmith force-pushed the ls-android]-adding-locationComponent-circle-pulse branch 4 times, most recently from 2a4f7ab to 9b877fa Compare April 1, 2019 23:54
@langsmith langsmith force-pushed the ls-android]-adding-locationComponent-circle-pulse branch 2 times, most recently from 9a44ddf to 15f8bf2 Compare April 10, 2019 00:25
@langsmith langsmith force-pushed the ls-android]-adding-locationComponent-circle-pulse branch 6 times, most recently from 54145bb to ca202fc Compare August 2, 2019 06:41
@langsmith
Copy link
Contributor Author

Status update. Things are looking great. I've added a number of different tests but I'm wrestling with a weird testing bug that's happening during the building of LocationComponentOptions.

  java.lang.IllegalArgumentException: You cannot set both layerAbove and layerBelow options. Choose one or the other.
        at com.mapbox.mapboxsdk.location.LocationComponentOptions$Builder.build(LocationComponentOptions.java:1300)
        at com.mapbox.mapboxsdk.location.LocationComponentOptions.createFromAttributes(LocationComponentOptions.java:373)
        at com.mapbox.mapboxsdk.location.LocationComponentOptions.builder(LocationComponentOptions.java:398)
        at com.mapbox.mapboxsdk.location.LocationAnimatorCoordinatorTest.setUp(LocationAnimatorCoordinatorTest.kt:42)

Screen Shot 2019-08-02 at 4 47 05 PM

The pulsing now continues after returning to the activity from a different app. Pulsing now stops when the LocationComponent is deactivated and the pulsing resumes when the LocationComponent is reactivated. Pulsing also resumes when the map style has changed.

ezgif com-resize (1)

ezgif com-resize (2)

cancelPulsingCircleAnimation() is now working. It cancels the pulsing animator and hides the pulsing circle's layer.
ezgif com-resize (3)

Along with CustomizedLocationPulsingCircleActivity, which has the speed/color toggle, I've added BasicLocationPulsingCircleActivity. It shows the basic default pulsing circle:

ezgif com-resize

@langsmith langsmith force-pushed the ls-android]-adding-locationComponent-circle-pulse branch from ca202fc to dceb95e Compare August 6, 2019 21:05
@langsmith langsmith removed the request for review from osana August 7, 2019 01:36
@langsmith langsmith force-pushed the ls-android]-adding-locationComponent-circle-pulse branch from 71d3a2e to 1a885b1 Compare August 7, 2019 01:40
@langsmith
Copy link
Contributor Author

Ok @LukasPaczos , things are looking good visually and all tests are passing. This is ready for yet another round of review when you have the time and are in the mood.

@tobrun tobrun dismissed their stale review August 19, 2019 11:04

old stale review

@langsmith langsmith force-pushed the ls-android]-adding-locationComponent-circle-pulse branch from a50f17c to 3f1abeb Compare September 24, 2019 22:49
@langsmith langsmith force-pushed the ls-android]-adding-locationComponent-circle-pulse branch from 3f1abeb to 3829e79 Compare October 1, 2019 01:54
@patrickkempff
Copy link

Looks good! Looking forward to use this. Any updates when this PR will be merged? 👍

@tobrun
Copy link
Member

tobrun commented Dec 3, 2019

We are removing platform code from gl-native in #15970. If you want to see this PR merged, it will require re-implementation in https://github.com/mapbox/mapbox-gl-native-android.

@tobrun tobrun closed this Dec 3, 2019
@DntPullALockett
Copy link

@malwoodsantoro When can we get this re implemented?

@langsmith
Copy link
Contributor Author

For anyone following this pr and/or interested in using this feature, you should know that this feature has been added to the Mapbox Maps SDK for Android at mapbox/mapbox-gl-native-android#172.

The current Mapbox Maps SDK for Android is in the https://github.com/mapbox/mapbox-gl-native-android repository because the Mapbox team decided to move the Maps SDK for Android to a standalone repo: #15971

@Cloud9Clone
Copy link

Cloud9Clone commented May 8, 2020

When the new version 9.2.0. will be officially announced? I see that on the Mapbox page stays still 9.1.0.

@langsmith
Copy link
Contributor Author

Hey @Cloud9Clone, 9.2.0 is out and available. It went out yesterday https://github.com/mapbox/mapbox-gl-native-android/releases/tag/android-v9.2.0

https://docs.mapbox.com/android/maps/overview/ and other docs pages just haven't been updated yet.

Docs about pulsing LocationComponent are at the bottom of the https://docs.mapbox.com/android/maps/overview/location-component/#active-styling-options section.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Android Mapbox Maps SDK for Android feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants