Skip to content

Selectable location providers#124

Open
jackpf wants to merge 5 commits intomainfrom
selectable-providers
Open

Selectable location providers#124
jackpf wants to merge 5 commits intomainfrom
selectable-providers

Conversation

@jackpf
Copy link
Owner

@jackpf jackpf commented Jan 22, 2026

TODO

  • Tidy up the settings a bit (order)
  • Pre-select provider(s) that make sense
  • Capitalise providers list
  • Does it make sense to allow passive?

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @jackpf, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces a significant enhancement to how the application acquires location data. It empowers users with greater control by allowing them to explicitly select and prioritize the location providers (such as GPS or network-based location) that the app should utilize. This customization is persisted across sessions and directly influences the LocationService's behavior, ensuring that location requests are made according to user preferences. Additionally, the system now captures and transmits metadata about the specific provider used for each location update, enriching the data sent to the backend.

Highlights

  • Configurable Location Providers: Users can now select and reorder their preferred location providers (e.g., GPS, Network) directly from the settings, giving them more control over location accuracy and battery usage.
  • Persistent Provider Settings: The chosen order and enabled/disabled status of location providers are saved and retrieved using ConfigRepository, ensuring preferences are maintained across sessions.
  • Location Metadata Transmission: Beacon requests now include metadata about the specific location provider used to obtain the coordinates, enriching the data sent to the backend.
  • Dynamic Location Service Requests: The LocationService has been updated to accept a list of desired location sources, allowing it to dynamically request location from the user-configured providers.
  • New UI for Provider Management: A RecyclerView with drag-and-drop functionality has been added to the settings screen for an intuitive way to manage location providers.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a feature to allow users to select and prioritize location providers. This is achieved by adding a new settings screen with a reorderable list of providers. The LocationService is refactored to use this configuration when fetching locations. Additionally, the chosen provider is now sent as metadata with the location data to the server. The changes are well-structured. I have a couple of suggestions for code improvements.

Comment on lines +24 to +26
new HashMap<String, String>() {{
put("provider", location.getProvider());
}}
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The use of double-brace initialization for creating and initializing the HashMap is generally considered an anti-pattern. It creates an anonymous inner class, which can have a performance overhead and potential for memory leaks.

A more standard and efficient approach is to use Collections.singletonMap(), especially since only one entry is being added and the map is effectively immutable. Please also add the required import for java.util.Collections.

                Collections.singletonMap("provider", location.getProvider())

Comment on lines +198 to +199
List<ProviderRequest> allRequests = Stream.concat(cachedRequests.stream(), highAccuracyRequests.stream())
.collect(Collectors.toList());
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

Using Stream.concat to merge two lists can be less readable and performant than using standard list operations. For improved clarity and performance, consider using ArrayList's constructor and the addAll method.

Suggested change
List<ProviderRequest> allRequests = Stream.concat(cachedRequests.stream(), highAccuracyRequests.stream())
.collect(Collectors.toList());
List<ProviderRequest> allRequests = new ArrayList<>(cachedRequests);
allRequests.addAll(highAccuracyRequests);

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.

1 participant