Skip to content

Make the zoom out button reach the minimum zoom - #736

Open
munzzyy wants to merge 1 commit into
GrapheneOS:mainfrom
munzzyy:fix/zoom-min
Open

munzzyy wants to merge 1 commit into
GrapheneOS:mainfrom
munzzyy:fix/zoom-min

Conversation

@munzzyy

@munzzyy munzzyy commented Sep 9, 2026

Copy link
Copy Markdown

Fixes #711.

The zoom out button clamps at 25% because ZOOM_PRESETS starts at 25, while pinch to zoom and the custom zoom dialog both go down to MIN_ZOOM_RATIO (20%). This keeps the presets as they are and has previousZoomPreset fall back to MIN_ZOOM_RATIO once no preset is left below the current zoom. Zooming out goes 50% to 25% to 20% and the button disables at the minimum.

The first version of this PR replaced the 25 preset with the minimum. @xhon-pelushi pointed out in #721 that this drops the 25% step. That was right, so this now takes the same fallback shape as #721.

Two tests sit next to the existing min/max button tests. zoomOutButton_reachesMinZoom sets zoom to 25%, clicks zoom out, and asserts the ratio lands on MIN_ZOOM_RATIO and the button disables there. It fails on main, where the button is already disabled at 25%. zoomOutButton_stopsAtLowestPreset sets zoom to 50%, clicks zoom out, and asserts it lands on 25% with zoom out still enabled. It fails against the first version of this PR, which jumped from 50% to 20%.

Ran PdfViewerNavigationTest, PdfViewerMenuStateTest and PdfViewerRenderTest on an API 36 x86_64 emulator, 43 tests passing.

The zoom out button stops at 25% because that is the lowest entry in
ZOOM_PRESETS, while pinch to zoom and the custom zoom dialog go down to
MIN_ZOOM_RATIO (20%).

Keep the presets as they are and let previousZoomPreset fall back to
MIN_ZOOM_RATIO once no preset is left below the current zoom. Zooming
out now goes 50% -> 25% -> 20% and the button disables at the minimum.

Two tests cover it: one that the button reaches the minimum and then
disables, and one that 50% still steps to 25% instead of skipping
straight to the minimum.

Fixes GrapheneOS#711
@munzzyy

munzzyy commented Sep 21, 2026

Copy link
Copy Markdown
Author

Reworked as discussed in #721: the presets stay as they were and zoom out falls back to the minimum once no preset is left, so it goes 50% to 25% to 20%. I added a test that 50% still steps to 25%. It fails against my first version, which is the case @xhon-pelushi caught.

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.

zoom menu item can't be used to reach minimum zoom

1 participant