Skip to content

Clarify browser package priority by preserving insertion order in providers - #70

Merged
droibit merged 5 commits into
mainfrom
feature/clarify-browser-package-priority-order
Jul 23, 2026
Merged

Clarify browser package priority by preserving insertion order in providers#70
droibit merged 5 commits into
mainfrom
feature/clarify-browser-package-priority-order

Conversation

@droibit

@droibit droibit commented Jul 23, 2026

Copy link
Copy Markdown
Owner

No description provided.

droibit added 3 commits July 23, 2026 21:55
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.
@droibit
droibit requested a review from Copilot July 23, 2026 13:06
@droibit droibit self-assigned this Jul 23, 2026
@droibit droibit added this to the 4.3.0 milestone Jul 23, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 return List<String> instead of Set<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() to toList() 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() from Set<String> to List<String> is a source and binary breaking API change for library consumers (the JVM method descriptor changes, so previously compiled code can hit NoSuchMethodError). 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. Because Set iteration order is not guaranteed, callers may get an unexpected priority ordering. Consider deprecating this constructor (keep it for compatibility, but guide users to the ordered List constructor).
  constructor(packages: Set<String>) : this(packages.toList())

droibit and others added 2 commits July 23, 2026 23:11
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@droibit
droibit merged commit 498ea99 into main Jul 23, 2026
1 check passed
@droibit
droibit deleted the feature/clarify-browser-package-priority-order branch July 23, 2026 14:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants