Skip to content

Commit

Permalink
Merge pull request #1038 from att55/refactor-code-order
Browse files Browse the repository at this point in the history
Refactor code order of navigateToNativeApp
  • Loading branch information
takahirom authored Sep 12, 2024
2 parents cf4f87e + ab6336d commit 10e1cdf
Showing 1 changed file with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,14 @@ private class ExternalNavController(
): Boolean {
val pm = context.packageManager

// Get all apps that resolve the specific Url
val specializedActivityIntent = Intent(Intent.ACTION_VIEW, uri)
.addCategory(Intent.CATEGORY_BROWSABLE)
val resolvedSpecializedList: MutableSet<String> =
pm.queryIntentActivities(specializedActivityIntent, 0)
.map { it.activityInfo.packageName }
.toMutableSet()

// Get all Apps that resolve a generic url
val browserActivityIntent = Intent()
.setAction(Intent.ACTION_VIEW)
Expand All @@ -404,14 +412,6 @@ private class ExternalNavController(
.map { it.activityInfo.packageName }
.toSet()

// Get all apps that resolve the specific Url
val specializedActivityIntent = Intent(Intent.ACTION_VIEW, uri)
.addCategory(Intent.CATEGORY_BROWSABLE)
val resolvedSpecializedList: MutableSet<String> =
pm.queryIntentActivities(specializedActivityIntent, 0)
.map { it.activityInfo.packageName }
.toMutableSet()

// Keep only the Urls that resolve the specific, but not the generic urls.
resolvedSpecializedList.removeAll(genericResolvedList)

Expand Down

0 comments on commit 10e1cdf

Please sign in to comment.