Skip to content

GT-1993 Replace the deprecated Accompanist tutorial pager indicator - #4652

Open
smgoss wants to merge 13 commits into
developfrom
fix/issue-4608
Open

smgoss wants to merge 13 commits into
developfrom
fix/issue-4608

Conversation

@smgoss

@smgoss smgoss commented Sep 28, 2026 •

Copy link
Copy Markdown
Collaborator

Resolves #4608

TutorialPagerIndicator was the last place the app used Accompanist (accompanist-pager-indicators, which is deprecated). The pager itself was already the Foundation HorizontalPager, so only the indicator had to move. It now draws its own row of dots straight from the PagerState, which is the approach the Compose docs suggest for Foundation pagers.

Changes

  • TutorialPagerIndicator: works the same way Accompanist's did. A Row shows one 8dp CircleShape dot per page, 8dp apart, in MaterialTheme.colorScheme.primary at 38% alpha. The active dot, in full primary, is drawn on top and offset by currentPage + currentPageOffsetFraction (limited to the valid range), so it slides with the pager while you swipe. TEST_TAG_PAGE_INDICATOR, the tutorial_indicator_height height, wrapContentSize() and the caller's modifier are applied in the same order as before. Each page dot has a new TEST_TAG_PAGE_INDICATOR_PAGE tag and selected semantics for tests, and is hidden from accessibility services (like Accompanist's indicator, it gives TalkBack nothing to focus). The active dot's step is rounded to whole pixels the same way the dot row is, so it lines up at any display size.
  • The selected page is pagerState.currentPage.coerceAtMost(pageCount - 1). currentPage is not clamped right away when an app language change shrinks the page list (the same cause as TutorialLayout can throw IndexOutOfBoundsException when the app language changes the number of tutorial pages #4544), so this stops the indicator from pointing at a page that no longer exists.
  • Removed accompanist-pager-indicators from :ui:tutorial-renderer and dropped the accompanist version and library entries from gradle/libs.versions.toml. No Accompanist imports or dependencies are left.
  • Added the Paparazzi plugin and testFixtures(projects.ui.base) to :ui:tutorial-renderer so it can use BasePaparazziTest, and added TutorialLayoutPaparazziTest.
  • TutorialLayoutTest: moved the whole file to the v2 runComposeUiTest import, since the v1 one is deprecated and the file gains new page indicator tests.

OnboardingLayout in :app uses the same TutorialPagerIndicator and looks and behaves the same as before.

Snapshots

  • No existing goldens show the tutorial pager indicator. There are no Paparazzi tests for TutorialLayout or OnboardingLayout, and the DashboardLayoutPaparazziTest "Banner - Tutorial" goldens only show the dashboard banner. No existing goldens needed to be re-recorded.
  • New: TutorialLayoutPaparazziTest > TutorialLayout() - LIVE_SHARE (Nexus 5 / Pixel 6 Pro x NIGHT / NOTNIGHT, plus Nexus 5 accessibility). Recorded by the Record Snapshots workflow.

Tests

  • TutorialLayoutTest (Page Indicator region):
    • FEATURES - one indicator per page: the dot count matches pagesFor(Locale.ENGLISH), and the first dot is selected.
    • FEATURES - indicators hidden from accessibility: every dot has HideFromAccessibility set. Fails without it.
    • FEATURES - updates when app language changes page count: switching from English (5 pages) to French (4 pages) gives 4 dots with the first one selected. This is a no-crash check; the clamp itself is covered below.
    • The existing TIPS visible and LIVE_SHARE_START_PAGE_ONLY hidden tests are unchanged apart from the v2 runComposeUiTest import.
  • TutorialLayoutTest > TutorialPagerIndicator() - active indicator follows current page: drives a HorizontalPager and the indicator from the same PagerState, scrolls to page 2 with requestScrollToPage(1), and checks that the selection moves from dot 1 to dot 2. This uses the PagerState directly instead of tapping Continue, so it doesn't depend on page animations settling.
  • TutorialLayoutTest > TutorialPagerIndicator() - clamps active indicator when page count shrinks: shrinking a PagerState from 5 pages to 3 while it sits on page 4 leaves the last dot selected. This test fails without the clamp.
  • TutorialLayoutPaparazziTest > TutorialLayout() - LIVE_SHARE.

Review

  • Checked against the project conventions, a correctness review and a simplification pass. Security review skipped (no intents, links, IO, networking or auth).
  • Fixed: the page dots had selected semantics with no role, which Compose reports as checkable, so TalkBack got one focus stop per dot. They are now hidden from accessibility, with a test.
  • Fixed: the active dot's offset used unrounded pixels while the row rounds, so it drifted at non-integer densities.
  • Changed: the Paparazzi scenario now uses LIVE_SHARE (static first image) instead of FEATURES (async Lottie animation that could make the golden flaky).
  • Changed: TutorialLayoutTest now uses the v2 runComposeUiTest import (the v1 import is deprecated for new layout tests).
  • Not changed: the stale-page clamp now exists in both TutorialLayout and TutorialPagerIndicator (small, and each guards its own reader).

Stephen Goss and others added 9 commits September 27, 2026 21:40
Accompanist pager is deprecated and this was its last usage in the app.
TutorialPagerIndicator now draws its own row of dots from the
PagerState, keeping the Accompanist defaults (8dp circles with 8dp
spacing, primary active color, 38% alpha inactive color) and the
existing test tag, height and modifier chain.

Like Accompanist's indicator, the active dot is drawn on top of the
inactive row and offset by currentPage plus currentPageOffsetFraction,
so it slides between pages while swiping instead of jumping when
currentPage changes. The offset step is rounded to whole pixels the
same way the Row rounds the dot size and spacing, so the active dot
lines up with the other dots at any display density.

The page dots carry selected semantics so tests can check which page is
active, and are hidden from accessibility services. Without a Tab role
Compose reports a selected node as checkable, which would give TalkBack
a focus stop per dot. Accompanist's indicator exposed nothing to
TalkBack either.

The selected dot and the active dot's offset are clamped to the current
page count, since pagerState.currentPage is not clamped synchronously
when an app language change shrinks the page list (same cause as
#4544).

TutorialLayoutTest also moves to the v2 runComposeUiTest entry point,
since the v1 one is deprecated and the file gains new page indicator
tests here.
TutorialPagerIndicator no longer uses Accompanist, and nothing else in
the app does, so drop the dependency and its version catalog entries.
Covers the page indicator drawn by TutorialPagerIndicator now that it no
longer comes from Accompanist. The tutorial renderer had no snapshot
tests yet, so this also applies the Paparazzi plugin to the module and
pulls in BasePaparazziTest from the :ui:base test fixtures.

The test snapshots the LIVE_SHARE tutorial, which opens on a static
image and still shows the page indicator. The FEATURES and TIPS
tutorials open on Lottie animations that rememberLottieComposition
loads in the background, so whether they show up in the single
Paparazzi frame depends on timing.
The signature fits within 120 characters, so ktlint wants it on a single
line with the expression body on the next one.
Tapping Continue animates the pager to the next page, and the v2
runComposeUiTest does not run that animation to the end before the
next assertion. Wait until the second dot is selected, and click the
first Continue button in case the pager also composed the next page.
Tapping Continue in the FEATURES tutorial never moved the pager under
the v2 runComposeUiTest, so the test timed out waiting for the second
dot. Test TutorialPagerIndicator() directly against a HorizontalPager
and move it with requestScrollToPage(), like the page count test.
@codecov

codecov Bot commented Sep 29, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 93.54839% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 53.96%. Comparing base (513da9d) to head (53282cb).

Files with missing lines Patch % Lines
...org/cru/godtools/tutorial/layout/TutorialLayout.kt 93.54% 0 Missing and 2 partials ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #4652      +/-   ##
===========================================
+ Coverage    53.86%   53.96%   +0.09%     
===========================================
  Files          439      439              
  Lines        11645    11668      +23     
  Branches      1967     1970       +3     
===========================================
+ Hits          6273     6297      +24     
+ Misses        4785     4781       -4     
- Partials       587      590       +3     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@smgoss
smgoss marked this pull request as ready for review September 29, 2026 14:25
@smgoss
smgoss requested a review from a team September 29, 2026 14:25

smgoss commented Nov 7, 2026

Copy link
Copy Markdown
Collaborator Author

Build App is failing on this PR after merging develop, but the failure does not come from this PR. It also fails on develop at 491d722 (Update android.gradle.plugin to v9.5.1, #4693). The last develop build on 9.5.0 (760d90f) passed.

The errors are in code this PR does not touch, and they change from run to run:

  • develop 491d722: :app:hiltJavaCompileProductionRelease fails with Dagger MissingBinding for the repositories from DatabaseModule (:library:db:compileReleaseJavaWithJavac ran as NO-SOURCE).
  • this PR 59d32e4: :ui:cyoa-renderer:kaptDebugKotlin fails with a data binding error for app:visibleIf.

This PR only changes ui/tutorial-renderer and removes the accompanist entries. There is no fix for the 9.5.1 build failure yet. I am re-running Build App once, and I will merge develop again when it has a fix.


Generated by Claude Code

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.

Replace the deprecated Accompanist tutorial pager indicator

1 participant