Clarify browser package priority by preserving insertion order in providers - #70
Merged
Merged
Conversation
The KDoc states that non-Chrome browser packages are prioritized from the top of the list, but the implementation kept them as `Set<String>`, which does not guarantee iteration order. This made the actual behavior depend on the concrete Set implementation rather than the API contract.
Replace it with linkedSetOf() so the ordered nature of the collection is explicit and the priority semantics are preserved correctly. This is an internal change and does not affect the public API.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR changes the custom tabs package provider contract from an unordered set to an ordered list so the caller can express browser package priority deterministically (insertion order), and updates the non-Chrome provider/test accordingly.
Changes:
- Change
CustomTabsPackageProvider.invoke()and related implementations to returnList<String>instead ofSet<String>. - Preserve/clarify priority ordering by using ordered collections and returning lists from package discovery.
- Update tests to reflect ordered return values.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| launcher/src/test/java/com/droibit/android/customtabs/launcher/NonChromeCustomTabsTest.kt | Updates test input to use List to match the provider’s ordered contract. |
| launcher/src/main/java/com/droibit/android/customtabs/launcher/CustomTabsPackageProvider.kt | Changes provider API to List<String> and updates NonChromeCustomTabs accordingly. |
| launcher/src/main/java/com/droibit/android/customtabs/launcher/CustomTabsPackage.kt | Returns a List<String> from non-Chrome package discovery and makes Chrome package ordering explicit. |
Comments suppressed due to low confidence (3)
launcher/src/main/java/com/droibit/android/customtabs/launcher/CustomTabsPackage.kt:39
- Switching from
toSet()totoList()can introduce duplicate package names when a single package exposes multiple browsable activities. This regresses the previous de-duplication behavior and can lead to redundant package entries (and potentially confusing priority handling). Consider de-duping while preserving first-seen order.
.toList()
launcher/src/main/java/com/droibit/android/customtabs/launcher/CustomTabsPackageProvider.kt:21
- Changing
CustomTabsPackageProvider.invoke()fromSet<String>toList<String>is a source and binary breaking API change for library consumers (the JVM method descriptor changes, so previously compiled code can hitNoSuchMethodError). If this library is already published, consider providing a migration path (e.g., keep the old interface until the next major release, or introduce a new provider type) and/or ensure the next release is a major version bump with clear release notes.
operator fun invoke(): List<String>
launcher/src/main/java/com/droibit/android/customtabs/launcher/CustomTabsPackageProvider.kt:40
- This secondary constructor accepts a
Set, but the new behavior relies on list order for priority. BecauseSetiteration order is not guaranteed, callers may get an unexpected priority ordering. Consider deprecating this constructor (keep it for compatibility, but guide users to the orderedListconstructor).
constructor(packages: Set<String>) : this(packages.toList())
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
…age names in CustomTabsPackageProvider
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.