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

refactor: port iOS location architecture to Android #568

Merged
merged 9 commits into from
Dec 6, 2024

Conversation

boringcactus
Copy link
Member

@boringcactus boringcactus commented Dec 4, 2024

Summary

Ticket: 🤖 | Map | Map => Nearby Transit location sharing architecture

The log gets spammed with "sending message to a Handler on a dead thread" via some Google Play location stuff, but only if location permission was already granted when the app first launched. I tried to investigate this, but I don't think anything is actually running on a different thread than it's supposed to, and it doesn't appear to be interfering with the actual functionality.

android

  • All user-facing strings added to strings resource

Testing

Manually verified that both follow puck and manually select states properly track the current location.

@boringcactus boringcactus requested a review from a team as a code owner December 4, 2024 22:04
var hasPermission by mutableStateOf(false)

/**
* Attach the event handlers for this [LocationDataManager] in the context of the current
Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for the comment, much appreciated!

import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.asStateFlow

open class LocationDataManager {
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we actually want this class to be open? My reading of the comment is that we only want to call the rememberLocationManager function, which seems incompatible with extending this. In general it would be nice if we could throw an error if LocationDataManager is initialized twice, rather than relying on the next dev to have read your comment.

Copy link
Member Author

Choose a reason for hiding this comment

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

This has to be open so that the MockLocationDataManager can inherit from it. I could've made LocationDataManager an interface instead, but I don't like the pattern of making everything a redundant interface; that said, we already do that for all our dependency injection repositories, so if you'd rather I also do that here for consistency I could make that change.

Copy link
Contributor

Choose a reason for hiding this comment

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

Nah, I didn't realize it was for testing. That's fine IMO

@@ -282,17 +292,108 @@ fun HomeMapView(

val context = LocalContext.current

val locationProvider = remember {
object : LocationProvider {
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we move this to it's own file? HomeMapView is pretty big already, I think it would help readability to pull this out. Nonblocking!

Copy link
Member Author

Choose a reason for hiding this comment

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

Moved.


DisposableMapEffect { map ->
val listener =
object : OnMoveListener, OnScaleListener, OnShoveListener {
Copy link
Contributor

Choose a reason for hiding this comment

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

I also think this would benefit from being moved out of the file

Copy link
Member Author

Choose a reason for hiding this comment

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

Moved.

Copy link
Contributor

@JackVCurtis JackVCurtis left a comment

Choose a reason for hiding this comment

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

Looks great with a couple suggestions. I agree about the log message, it's low priority even if it's not some weird simulator thing.

@boringcactus boringcactus merged commit 8f0ba13 into main Dec 6, 2024
7 checks passed
@boringcactus boringcactus deleted the mth-android-location branch December 6, 2024 23:08
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