Skip to content

Small wins: default browser, print, custom search, tab cap, per-site ad allowlist - #17

Merged
GothwadTech merged 1 commit into
mainfrom
feat/small-wins
Nov 28, 2026
Merged

GothwadTech merged 1 commit into
mainfrom
feat/small-wins

Conversation

@GothwadTech

@GothwadTech GothwadTech commented Nov 28, 2026 •

Copy link
Copy Markdown
Member

Five gaps that each blocked an everyday browser task.

# Gap Fix
1 "Set as default" only opened Android's settings list RoleManager.createRequestRoleIntent(ROLE_BROWSER) one-tap request on API 29+, status shown when the role is already held, old fallback kept
2 No way to print or save a page as PDF Print row in the page menu → system print dialog with the current WebView (its "Save as PDF" target does the rest)
3 Search engines were a fixed enum of six SearchEngine.CUSTOM + name and %s template in settings; UrlUtils honours it, with inline validation ("the URL must contain %s")
4 Unlimited tabs → OOM killed tabs Cap at 25 tabs with a snackbar that opens the tab switcher; background renderers demoted via setRendererPriorityPolicy so the visible tab survives memory pressure
5 Ad blocking was all-or-nothing Per-site allowlist: Allow ads on this site in the page menu, plus a settings list to re-block one site or clear all

Notes

  • setRendererPriorityPolicy and RoleManager are API 26 / 29, both guarded.
  • The custom template is validated: a template without %s never reaches the URL builder, which falls back to Google rather than producing a broken link.
  • The allowlist is stored in the existing site-permission DataStore, so no schema change.

Checks

The PR's own Quality Gate & Tests run compiles, unit-tests and lints it.

Summary by CodeRabbit

  • New Features
    • Configure a custom search engine with a name and search URL.
    • Allow ads on specific sites, manage allowed sites, or allow ads everywhere.
    • Print web pages from the browser menu.
    • Set the browser as the default using the Android browser-role prompt where available.
  • Updates
    • Browser tabs are limited to 25; a message appears when the limit is reached.
    • Custom search settings are used when searching from the address bar.

…d allowlist

Five small gaps that each blocked a normal browser task:

- Default browser: the settings screen now asks Android for ROLE_BROWSER directly
  (RoleManager, API 29+) and shows when the role is already held; older versions keep
  the Manage-default-apps fallback.
- Print / Save as PDF: new "Print" row in the page menu opens the system print dialog
  with the current WebView.
- Custom search engine: SearchEngine gains CUSTOM, with a name and a %s URL template
  stored in settings and honoured by UrlUtils.resolveInputToUrl/buildSearchUrl.
- Tab cap: 25 tabs, with a snackbar that offers the tab switcher instead of silently
  failing; background renderers are demoted so the visible tab keeps its process
  (setRendererPriorityPolicy, API 26+).
- Per-site ad blocking: an allowlist in the site-permission store, an "Allow ads on this
  site" page-menu row, and a settings list to re-block a site or clear the whole list.
@coderabbitai

coderabbitai Bot commented Nov 28, 2026 •

Copy link
Copy Markdown

Explain Change →

Caution

Review failed

The pull request is closed.

Walkthrough

Changes: Custom search

Layer / File(s) Summary
Custom search settings and persistence
app/src/main/java/com/bansify/browser/data/BrowserModels.kt, app/src/main/java/com/bansify/browser/data/BrowserPreferences.kt, app/src/main/java/com/bansify/browser/ui/screens/SettingsSubScreens.kt
Settings add a custom search name and template. Preferences load and persist both values. The settings screen displays and validates the custom template.
Custom search URL resolution
app/src/main/java/com/bansify/browser/browser/UrlUtils.kt, app/src/main/java/com/bansify/browser/viewmodel/BrowserViewModel.kt
URL resolution uses a custom template when it contains %s; browser URL actions pass the configured template.

Browser runtime and site controls

Layer / File(s) Summary
Site allowlist and tab state
app/src/main/java/com/bansify/browser/data/SitePermissions.kt, app/src/main/java/com/bansify/browser/viewmodel/BrowserViewModel.kt
The site-permission store persists allowed ad hosts. The view model exposes allowlist actions and stops tab creation at 25 tabs, showing a snackbar with a Tabs action.
WebView and application integration
app/src/main/java/com/bansify/browser/browser/WebViewPool.kt, app/src/main/java/com/bansify/browser/ui/BrowserApp.kt
The pool bypasses ad-block interception for allowed hosts and updates renderer priorities when the active tab changes. BrowserApp connects the allowlist to the pool.
Menu and settings controls
app/src/main/java/com/bansify/browser/ui/BrowserApp.kt, app/src/main/java/com/bansify/browser/ui/components/ChromeOverflowMenu.kt, app/src/main/java/com/bansify/browser/ui/screens/SettingsScreen.kt, app/src/main/java/com/bansify/browser/ui/screens/SettingsSubScreens.kt
The menu adds Print and an optional allow-ads action. Settings list allowed hosts and provide actions to re-block a host or clear the allowlist. BrowserApp connects these actions and prints the active WebView when available.

Default browser role

Layer / File(s) Summary
Browser-role status and request
app/src/main/java/com/bansify/browser/ui/screens/SettingsSubScreens.kt
On Android Q and later, the screen checks browser-role status and requests the role when possible. Otherwise, it opens Default Apps settings.

Possibly related PRs

  • Bansify/browser#14: Adds the ad blocker and site-permission storage that this change extends with a persisted per-site ad allowlist.

Change: Feature

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

@GothwadTech
GothwadTech merged commit 2bfb3f5 into main Nov 28, 2026
4 of 5 checks passed
@GothwadTech
GothwadTech deleted the feat/small-wins branch November 28, 2026 11:31
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