From a492e2def3dabe5e8de5ef4486b92859850503db Mon Sep 17 00:00:00 2001 From: Peter Stone Date: Tue, 29 Sep 2026 07:12:48 +0000 Subject: Reflow reader text live while pinching, and let a zoomed image pan Pinching in the reader used to scale the whole WebView like a photo and snap back to the real font size on release. It now drives WebSettings.textZoom as the fingers move, so the text itself resizes and reflows during the gesture with nothing to snap back from; images and margins stay put. The reload at the new saved size is what returns textZoom to 100%, so the two never overlap -- and loading reader HTML now goes through ReaderWebView.loadReaderHtml, which does both together, so a future load site can't forget the reset. Reader view for a tapped link now honors the saved font size and the same pinch gesture, instead of always rendering at the 18px default. A zoomed image can be panned again. The viewer computed its pan bounds from values captured when the dialog first composed -- an empty viewport around a not-yet-decoded image -- because a pointerInput(Unit) block keeps the lambda it was created with. Those bounds allowed exactly one offset, 0, so zooming worked and dragging did nothing. The whole pinch/pan step is now one pure function the gesture callback calls with values it reads fresh each time. --- .../java/org/terst/feedreader/data/SettingsTest.kt | 23 ++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'app/src/test/java/org/terst/feedreader/data/SettingsTest.kt') diff --git a/app/src/test/java/org/terst/feedreader/data/SettingsTest.kt b/app/src/test/java/org/terst/feedreader/data/SettingsTest.kt index 5b2048b..5cace1a 100644 --- a/app/src/test/java/org/terst/feedreader/data/SettingsTest.kt +++ b/app/src/test/java/org/terst/feedreader/data/SettingsTest.kt @@ -29,4 +29,27 @@ class SettingsTest { fun `pinch zoom result is clamped to the maximum reader font size`() { assertEquals(READER_FONT_SIZE_RANGE_PX.last, pinchZoomFontSizePx(28, 3.0f)) } + + @Test + fun `text already laid out at the wanted size needs no zoom`() { + assertEquals(UNZOOMED_TEXT_ZOOM_PERCENT, readerTextZoomPercent(renderedPx = 18, targetPx = 18)) + } + + @Test + fun `a bigger wanted size lifts the text zoom proportionally`() { + assertEquals(156, readerTextZoomPercent(renderedPx = 18, targetPx = 28)) + } + + @Test + fun `a smaller wanted size drops the text zoom proportionally`() { + assertEquals(78, readerTextZoomPercent(renderedPx = 18, targetPx = 14)) + } + + @Test + fun `text zoom is measured against the size the page is laid out at, not the saved size`() { + // Pinch, release, pinch again before the reload at the new size has landed: the page is + // still laid out at 18px even though 22px is the saved size, so going on to 24px has to + // be 24/18 -- measuring it against the saved 22px would visibly shrink the text first. + assertEquals(133, readerTextZoomPercent(renderedPx = 18, targetPx = 24)) + } } -- cgit v1.2.3