Skip to content

fix(android): report zoom in onScaleChanged so resizing the view isn't reported as a scale change - #1050

Open
GCyganek wants to merge 1 commit into
wonday:masterfrom
GCyganek:fix/android-scale-changed-on-resize
Open

GCyganek wants to merge 1 commit into
wonday:masterfrom
GCyganek:fix/android-scale-changed-on-resize

Conversation

@GCyganek

@GCyganek GCyganek commented Oct 12, 2026 •

Copy link
Copy Markdown

Summary

Fixes #1049

On Android, onScaleChanged reported the drawn page width divided by the page width of the first draw. When the view is resized (e.g. on device rotation), AndroidPdfViewer fits the page to the new view size, so the page width changes and the resize was reported as a zoom change: ~2 after rotating from portrait to landscape and ~0.5 the other way, without the user zooming.

Change

Report the viewer's zoom in onLayerDrawn (PdfView.java)

  • Emits scaleChanged| + getZoom() instead of pageWidth / originalWidth
  • Only emits the event when the zoom changes, instead of whenever the drawn page size changes
  • Removes the now-unused originalWidth, lastPageWidth and lastPageHeight fields

getZoom() is relative to the page size fitted to the current view size, so resizing the view doesn't change it. This matches iOS, which reports scaleFactor / _fixScaleFactor, recalculates _fixScaleFactor on every resize and only emits the event when the value changes.

Downstream, this was found in Expensify: Expensify/App#103207

Verification

I opened an Expensify PR with the same changes as a patch

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.

Android: onScaleChanged reports a scale change when the PDF view is resized (e.g. on device rotation)

1 participant