feat(wear): add One-Handed Gestures demo snippet - #1001
Merged
ithinkihaveacat merged 31 commits intoAug 10, 2026
Merged
Conversation
Add self-contained Wear OS One-Handed Gestures demo snippet to com.example.wear.snippets.m3.gestures. Gate SNAPSHOT dependencies (compose-material3 and foundation) on isUsingSnapshot in wear/build.gradle.kts to avoid modifying shared catalog versions in libs.versions.toml. Update CI workflows to pass -PsnapshotVersion=1.7.0-SNAPSHOT during PR validation builds.
Move the KDoc note about -PsnapshotVersion=1.7.0-SNAPSHOT below the package declaration so that ktlint does not report multiple header blocks above package.
Pin third-party GitHub Actions to immutable commit SHAs and define explicit job-level permissions blocks in build.yml and apply_spotless.yml to remediate mandatory Zizmor security analysis findings.
Namespace Wear snapshot gating property to wearSnapshotVersion so that passing -PwearSnapshotVersion=1.7.0-SNAPSHOT in CI workflows does not trigger snapshot builds in the xr module.
Rename wearSnapshotVersion to wearComposeOverride to match the wearCompose prefix convention used in libs.versions.toml.
Add concise 5-6 line snippet examples for scrollable and button one-handed gestures so they can be included cleanly in developer documentation without embedding an entire screen.
Include compose.foundation in the isUsingSnapshot override block so that -PwearComposeOverride=1.7.0-SNAPSHOT also updates Wear Compose Foundation to 1.7.0-SNAPSHOT during CI builds.
Remove priority setting from ButtonGestureSnippet so the initial interactive button example in documentation is minimal and simple.
Update ButtonGestureSnippet to show a clean Button composable with Modifier.oneHandedGesture without unnecessary conditional modifiers or indicator state boilerplate.
Declare remember { MutableInteractionSource() } inside
ButtonGestureSnippet so the documentation example is self-contained and
runnable, and add an inline comment explaining why interactionSource
is shared.
Make ScrollGestureSnippet self-contained and runnable without priority, and add highlight region tags around .oneHandedGesture in both snippets.
Remove nested highlight region tags from ButtonGestureSnippet and ScrollGestureSnippet.
Add self-contained ButtonGestureHintSnippet demonstrating how to wrap a button with OneHandedGestureClickIndicator and call showIndicator inside onGestureAvailable.
Add self-contained ScrollGestureHintSnippet demonstrating how to display OneHandedGestureScrollIndicator within ScreenScaffold.
Address review feedback by aligning OneHandedGestureScreen and ScrollGestureHintSnippet with official AndroidX samples: - Wire onGestureAvailable to trigger indicatorState.showIndicator() on all gesture modifiers so animated hints display correctly. - Remove redundant onVisibilityChanged modifier from always-visible button in OneHandedGestureScreen. - Remove unused interactionSource from scrollable list containers.
Address review feedback across OneHandedGestures.kt snippets: - Use lowercase verb phrase strings for onGestureLabel to prevent redundant screen reader accessibility prompts. - Key OneHandedGestureScrollIndicatorState remember blocks to their respective gesture configurations to avoid stale state.
Restore onVisibilityChanged check on interactive button inside OneHandedGestureScreen so off-screen buttons do not intercept one-handed gestures over scrollable list containers.
Specify priority = OneHandedGesturePriority.Scrollable in list gesture configurations across ScrollGestureSnippet and ScrollGestureHintSnippet so clickable child items take precedence over list scrolling.
Align OneHandedGestureScreen with official Wear Compose M3 samples by moving the interactive Play/Pause button into EdgeButton inside ScreenScaffold, conditionally enabling gesture capture only when the list cannot scroll forward. Remove unused sample tags and snippets to match documentation usage.
Align Wear Compose M3 one-handed gesture samples with official
conventions:
- Make ButtonGestureSnippet self-contained without external parameters.
- Use lowercase verb phrases ("pause"/"play", "scroll") for gesture
accessibility labels across snippets and app demo screen.
- Move buttonInteractionSource to outer screen scope in demo screen.
- Use plain Text items instead of cards in transforming list demo.
Use a standard Button in ButtonGestureHintSnippet and remove unused imports from OneHandedGestures.kt per review feedback.
Isolate OneHandedGestures.kt compilation behind property wearGesturesVersionOverride so snapshot dependencies are used strictly when enabled and standard builds compile cleanly. Update CI workflows and KDoc documentation to use new flag.
ithinkihaveacat
marked this pull request as ready for review
August 10, 2026 17:48
|
Here is the summary of changes. You are about to add 3 region tags.
This comment is generated by snippet-bot.
|
ithinkihaveacat
enabled auto-merge (squash)
August 10, 2026 17:54
Contributor
|
Hi Michael! Since this module isn't needed long-term, is it possible to keep this code on a branch in the snippets repo? (and point to that branch from the DAC page)? |
kul3r4
approved these changes
Aug 10, 2026
Contributor
|
@kkuan2011 we intend to update to beta on the 12th upon API availability, as for now we just need to push to propagate the changes so that those will be available on DAC |
ithinkihaveacat
changed the base branch from
main
to
wear-m3-one-handed-gestures
August 10, 2026 19:50
ithinkihaveacat
merged commit Aug 10, 2026
982f669
into
android:wear-m3-one-handed-gestures
10 checks passed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds standalone, self-contained documentation snippets for Wear OS One-Handed Gestures (Wear OS 7+, API 37+) using Wear Compose Material 3. It demonstrates scrollable container gestures and interactive button click gestures (Double Pinch and Wrist Turn).
Important
Subproject Addition (
:wear:snapshot): This PR introduces a new subproject:wear:snapshot(wear/snapshot/) specifically to house the gestures snippet.:wear:snapshot? Building this snippet currently requires1.7.0-SNAPSHOT. Creating a dedicated subproject isolates1.7.0-SNAPSHOTfrom the main:wearmodule, protecting the rest of the:wearcodebase from potential snapshot build breakages.1.7.0beta release, at which pointOneHandedGestures.ktwill be merged back into the main:wearmodule.Implementation
:wear:snapshot)::wear:snapshotinsettings.gradle.kts.wear/snapshot/build.gradle.ktsenforcing1.7.0-SNAPSHOTforwear-compose-material3andcompose-foundation.OneHandedGestures.ktunderwear/snapshot/src/main/java/com/example/wear/snippets/m3/gestures/OneHandedGestures.kt.:wearModule:libs.wear.compose.material3).How to Test
:wear:snapshotsubproject locally: