Skip to content

Make pdf edge-to-edge and add logic to dodge window insets#588

Open
hunterstich wants to merge 2 commits intoGrapheneOS:mainfrom
hunterstich:canvas-insets
Open

Make pdf edge-to-edge and add logic to dodge window insets#588
hunterstich wants to merge 2 commits intoGrapheneOS:mainfrom
hunterstich:canvas-insets

Conversation

@hunterstich
Copy link

👋 This change makes the PDF WebView always edge-to-edge, avoiding any jumps in the pdf's location on screen when hiding/showing system insets or app UI.

Resolves #273.
The AppBarLayout's show/hide animation could still be improved if that's something the project would like!

Summary:

  • Draw PDF WebView under AppBarLayout by removing the scrolling behavior and correcting z-order
  • Enable edge-to-edge with WindowCompat#enableEdgeToEdge(window) to make WebView draw behind insets. enableEdgeToEdge internally calls WindowCompat#setDecorFitsSystemWindows(window, false) which can be removed
  • Add PDF canvas insetting based on system WindowInsets and the height of the AppBarLayout so all parts of a PDF can be scrolled into view regardless of system/app UI visibility

Before:

before_.pixel5_api34_withCameraHolePunch_480.mov

After:

after_pixel2_api28_480.mov
after_pixel5_api34_wCameraHolePunch_480.mov

Copy link

@ggtlvkma356 ggtlvkma356 left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@inthewaves
Copy link
Member

Actually, I just noticed #538 which seems to be more fleshed out (though marked as a draft)

@octocorvus
Copy link
Member

I planned on submitting more changes along with #538 for review

@octocorvus
Copy link
Member

The text layer alignment is fragile with the current approach. So, upcoming PDF.js updates and changes to code often breaks it. #538 also aims to improve the overall architecture by introducing a page element.

@hunterstich
Copy link
Author

@octocorvus oh nice! Yea, just updated this PR to fix the text layer but it feels somewhat brittle. Having a page wrapper or similar to your PR seems like a nice approach.

@hunterstich hunterstich requested a review from inthewaves March 5, 2026 18:41
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.

Improve Animations

4 participants