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

Feat: Filter allowed CustomTabs browsers #353

Merged
merged 9 commits into from
Sep 25, 2020
Prev Previous commit
Next Next commit
Adding support to search all the browsers in the device
  • Loading branch information
nelsonmaia authored and lbalmaceda committed Sep 22, 2020
commit 723698123c2c7622c34bb17501d0ac27077e1df2
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,19 @@ static String getBestSupportedBrowserPackage(@NonNull Context context, @Nullable
PackageManager pm = context.getPackageManager();
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http:https://www.example.com"));

String[] browserPackages = overrideBrowserPackages == null ? getBrowserPackages(pm) : overrideBrowserPackages;
String[] browserPackages;
int packageManagerFlags;

// if the overrideBrowserPackages is null, preserve old behaviour of the library
if(overrideBrowserPackages != null){
browserPackages = overrideBrowserPackages;
packageManagerFlags = PackageManager.MATCH_ALL;
}else{
browserPackages = getBrowserPackages(pm);
packageManagerFlags = 0;
}

List<ResolveInfo> resolvedActivityList = pm.queryIntentActivities(browserIntent, 0);
List<ResolveInfo> resolvedActivityList = pm.queryIntentActivities(browserIntent, packageManagerFlags);
List<String> customTabsBrowsers = new ArrayList<>();
for (ResolveInfo info : resolvedActivityList) {
Intent serviceIntent = new Intent();
Expand Down