Add androidx.compose.material3.adaptive bindings#1463
Conversation
Co-authored-by: jonathanpeppers <840039+jonathanpeppers@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR adds new .NET for Android bindings for the androidx.compose.material3.adaptive family (plus material3-adaptive-navigation-suite), enabling use of Material3 adaptive scaffolds/navigation and WindowAdaptiveInfo APIs from .NET.
Changes:
- Adds 8 new Maven→NuGet entries in
config.json(including requiredextraDependenciesand awindow-core-androiddependencyOnlymapping). - Introduces new binding source folders with Transforms/Metadata for common (stripped) and
-android(real types) variants, including managed-name overrides to avoid Kotlin value-class overload collisions. - Updates generated/public surface tracking docs (
published-namespaces.txt,docs/artifact-list.md) and adds PublicAPI shipped/unshipped baselines for the new bindings.
Reviewed changes
Copilot reviewed 26 out of 28 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| source/androidx.compose.material3/material3-adaptive-navigation-suite/Transforms/Metadata.xml | Strips common KMP variant (remove-node) to keep it metadata-only. |
| source/androidx.compose.material3/material3-adaptive-navigation-suite/PublicAPI/PublicAPI.Unshipped.txt | PublicAPI baseline placeholder for the stripped common variant. |
| source/androidx.compose.material3/material3-adaptive-navigation-suite/PublicAPI/PublicAPI.Shipped.txt | PublicAPI baseline placeholder for the stripped common variant. |
| source/androidx.compose.material3/material3-adaptive-navigation-suite-android/Transforms/Metadata.xml | Transform file for the Android variant (currently empty; candidate location for namespace casing fix). |
| source/androidx.compose.material3/material3-adaptive-navigation-suite-android/PublicAPI/PublicAPI.Unshipped.txt | PublicAPI baseline for the actual material3-adaptive-navigation-suite-android surface. |
| source/androidx.compose.material3/material3-adaptive-navigation-suite-android/PublicAPI/PublicAPI.Shipped.txt | Initial shipped baseline marker for the Android variant. |
| source/androidx.compose.material3.adaptive/adaptive/Transforms/Metadata.xml | Strips common KMP adaptive variant (remove-node). |
| source/androidx.compose.material3.adaptive/adaptive/PublicAPI/PublicAPI.Unshipped.txt | PublicAPI baseline placeholder for stripped common variant. |
| source/androidx.compose.material3.adaptive/adaptive/PublicAPI/PublicAPI.Shipped.txt | PublicAPI baseline placeholder for stripped common variant. |
| source/androidx.compose.material3.adaptive/adaptive-navigation/Transforms/Metadata.xml | Strips common KMP adaptive-navigation variant (remove-node). |
| source/androidx.compose.material3.adaptive/adaptive-navigation/PublicAPI/PublicAPI.Unshipped.txt | PublicAPI baseline placeholder for stripped common variant. |
| source/androidx.compose.material3.adaptive/adaptive-navigation/PublicAPI/PublicAPI.Shipped.txt | PublicAPI baseline placeholder for stripped common variant. |
| source/androidx.compose.material3.adaptive/adaptive-navigation-android/Transforms/Metadata.xml | Transform file for the Android variant (currently empty). |
| source/androidx.compose.material3.adaptive/adaptive-navigation-android/PublicAPI/PublicAPI.Unshipped.txt | PublicAPI baseline for adaptive navigation Android APIs (navigator + predictive back handler helpers). |
| source/androidx.compose.material3.adaptive/adaptive-navigation-android/PublicAPI/PublicAPI.Shipped.txt | Initial shipped baseline marker for the Android variant. |
| source/androidx.compose.material3.adaptive/adaptive-layout/Transforms/Metadata.xml | Strips common KMP adaptive-layout variant (remove-node). |
| source/androidx.compose.material3.adaptive/adaptive-layout/PublicAPI/PublicAPI.Unshipped.txt | PublicAPI baseline placeholder for stripped common variant. |
| source/androidx.compose.material3.adaptive/adaptive-layout/PublicAPI/PublicAPI.Shipped.txt | PublicAPI baseline placeholder for stripped common variant. |
| source/androidx.compose.material3.adaptive/adaptive-layout-android/Transforms/Metadata.xml | Adds managedName overrides to prevent CS0111 collisions from Kotlin inline value-class overloads. |
| source/androidx.compose.material3.adaptive/adaptive-layout-android/PublicAPI/PublicAPI.Unshipped.txt | Large PublicAPI baseline for adaptive layout Android APIs (scaffolds, directives, motions, etc.). |
| source/androidx.compose.material3.adaptive/adaptive-layout-android/PublicAPI/PublicAPI.Shipped.txt | Initial shipped baseline marker for the Android variant. |
| source/androidx.compose.material3.adaptive/adaptive-android/Transforms/Metadata.xml | Transform file for the Android variant (currently empty). |
| source/androidx.compose.material3.adaptive/adaptive-android/PublicAPI/PublicAPI.Unshipped.txt | PublicAPI baseline for WindowAdaptiveInfo / posture / hinge APIs and helpers. |
| source/androidx.compose.material3.adaptive/adaptive-android/PublicAPI/PublicAPI.Shipped.txt | Initial shipped baseline marker for the Android variant. |
| published-namespaces.txt | Adds the new published namespaces for the adaptive bindings. |
| docs/artifact-list.md | Adds the new Maven→NuGet mappings to the generated artifact list. |
| config.json | Adds new artifact entries + extra dependencies and window-core-android dependencyOnly mapping. |
Co-authored-by: jonathanpeppers <840039+jonathanpeppers@users.noreply.github.com>
|
@copilot namespaces not updated! |
…pace Co-authored-by: jonathanpeppers <840039+jonathanpeppers@users.noreply.github.com>
... Added the missing |
|
@copilot fix merge conflicts |
…inding-material3-adaptive # Conflicts: # docs/artifact-list-with-versions.md # docs/artifact-list.md Co-authored-by: jonathanpeppers <840039+jonathanpeppers@users.noreply.github.com>
Merged latest |
Adds composer.CurrentWindowAdaptiveInfo() as a thin wrapper over the newly-bound WindowAdaptiveInfoKt.CurrentWindowAdaptiveInfo from Xamarin.AndroidX.Compose.Material3.Adaptive 1.2.0 (shipped via dotnet/android-libraries#1463). Returns the bound WindowAdaptiveInfo directly, exposing: - AndroidX.Window.Core.Layout.WindowSizeClass.IsWidthAtLeastBreakpoint / IsHeightAtLeastBreakpoint + the standard 600/840/480/900 dp constants - Posture/HingeInfo for foldable + tabletop detection Aligns Xamarin.AndroidX.Core / .Core.Core.Ktx at 1.19.0 to avoid an R8 duplicate-class error from the transitive 1.19 / 1.18 mismatch the Adaptive package surfaces. Bumps Foundation pin to 1.11.2.2 as required by Adaptive 1.2.0. Adds a Gallery demo under LocalsMisc/ that shows MinWidthDp / MinHeightDp, the four breakpoint predicates, Posture state, and a Phone/Tablet/Desktop label that flips at the 600 / 840 dp breakpoints. Closes #143. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Adds composer.CurrentWindowAdaptiveInfo() as a thin wrapper over the newly-bound WindowAdaptiveInfoKt.CurrentWindowAdaptiveInfo from Xamarin.AndroidX.Compose.Material3.Adaptive 1.2.0 (shipped via dotnet/android-libraries#1463). Returns the bound WindowAdaptiveInfo directly, exposing: - AndroidX.Window.Core.Layout.WindowSizeClass.IsWidthAtLeastBreakpoint / IsHeightAtLeastBreakpoint + the standard 600/840/480/900 dp constants - Posture/HingeInfo for foldable + tabletop detection Aligns Xamarin.AndroidX.Core / .Core.Core.Ktx at 1.19.0 to avoid an R8 duplicate-class error from the transitive 1.19 / 1.18 mismatch the Adaptive package surfaces. Bumps Foundation pin to 1.11.2.2 as required by Adaptive 1.2.0. Adds a Gallery demo under LocalsMisc/ that shows MinWidthDp / MinHeightDp, the four breakpoint predicates, Posture state, and a Phone/Tablet/Desktop label that flips at the 600 / 840 dp breakpoints. Closes #143. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…ts (#192) Closes #143. Adds `composer.CurrentWindowAdaptiveInfo()` — a one-method extension that forwards to the newly-bound `WindowAdaptiveInfoKt.CurrentWindowAdaptiveInfo` from `Xamarin.AndroidX.Compose.Material3.Adaptive` **1.2.0** (shipped via dotnet/android-libraries#1463). Returns the bound `AndroidX.Compose.Material3.Adaptive.WindowAdaptiveInfo` directly, so callers get everything for free: - `info.WindowSizeClass` — `AndroidX.Window.Core.Layout.WindowSizeClass` with: - `IsWidthAtLeastBreakpoint(int)` / `IsHeightAtLeastBreakpoint(int)` (the recommended-by-upstream way to branch on size buckets). - Standard `WidthDpMediumLowerBound = 600`, `WidthDpExpandedLowerBound = 840`, `HeightDpMediumLowerBound = 480`, `HeightDpExpandedLowerBound = 900` constants (plus large/extra-large). - `info.WindowPosture` — bound `Posture` + `HingeInfo` for foldable / tabletop detection. (Originally deferred — exposed transitively for free now that the binding ships.) ```csharp var info = composer.CurrentWindowAdaptiveInfo(); if (info.WindowSizeClass.IsWidthAtLeastBreakpoint( AndroidX.Window.Core.Layout.WindowSizeClass.WidthDpMediumLowerBound)) return ListDetailScreen.Build(...); else return PhoneScreen.Build(...); ``` ## Gallery demo `LocalsMisc → WindowAdaptiveInfo & WindowSizeClass` (in `Demos/LocalsMisc/WindowSizeClassDemo.cs`) — live readout of `MinWidthDp` / `MinHeightDp`, the four width/height predicates at the standard breakpoints, `Posture.IsTabletop` + hinge count, and a 📱 Phone / 📟 Tablet / 🖥️ Desktop indicator that flips at `IsWidthAtLeastBreakpoint(600)` and `(840)`. Rotate the device or resize the split-screen window to see all values update live. ## Package changes - `Xamarin.AndroidX.Compose.Material3.Adaptive` / `.AdaptiveAndroid` 1.2.0 — new direct refs from the facade. - `Xamarin.AndroidX.Compose.Foundation` / `.Android` bumped 1.11.2.1 → 1.11.2.2 (required by Adaptive 1.2.0). - `Xamarin.AndroidX.Core` / `.Core.Core.Ktx` pinned at 1.19.0 to align them and avoid an R8 duplicate-class error (`androidx.core.animation.AnimatorKt$addListener$1`) caused by the transitive 1.19 / 1.18 mismatch the Adaptive package surfaces. ## Sample docs The C# ports of **Reply** and **JetNews** still don't use any adaptive branching — both READMEs previously listed #143 as the blocker, but the real outstanding blockers are other unbound APIs. Status corrected in this PR: - `samples/README.md` — #143 row moved from "API gaps" to "Closed gaps", with a note that `NavigationSuiteScaffold`, `SharedTransitionLayout`, and `ListDetailScene` bindings are still outstanding. - `samples/Reply/README.md` + `samples/Reply/ReplyApp.cs` — re-attributed the dropped `NavigationSuiteScaffold` and rail/drawer rows to the missing `Xamarin.AndroidX.Compose.Material3.Adaptive.NavigationSuite` package + #163. - `samples/JetNews/README.md` — re-attributed the list-detail blocker to the missing `SharedTransitionLayout` / `ListDetailScene` bindings. Actually wiring Reply (manual rail / drawer switchover) or JetNews (list-detail) to use the new API is left to follow-up PRs per sample — both need additional bindings beyond what #143 delivers. ## What this replaces The earlier shape of this PR was a pure-C# polyfill that read `Locals.LocalConfiguration` — accurate on a normal `Activity`, but not actually wired into any Kotlin Compose API and divergent in embedded `ComposeView` / dialog hosts. With Adaptive 1.2.0 on NuGet, the real Kotlin-side `currentWindowAdaptiveInfo()` is one bound call away — the polyfill types (`WindowAdaptiveInfo`, `WindowSizeClass`, `WindowWidthSizeClass`, `WindowHeightSizeClass`) are gone; their behaviour is now provided by the bound upstream types instead. Note: the bound `WindowSizeClass.WindowWidthSizeClass` / `WindowHeightSizeClass` getters carry `[Obsolete("deprecated")]` upstream in favor of the breakpoint predicates, so the demo uses the predicates exclusively (which is what Google's docs recommend anyway). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The
androidx.compose.material3.adaptivefamily — Google's recommended Compose surface for adaptive (phone/foldable/tablet/large-screen) layouts — had noXamarin.AndroidX.Compose.*binding, leaving .NET for Android apps unable to use adaptive scaffolds, navigation-suite, orWindowAdaptiveInfo.Bindings added
Eight packages (each KMP artifact gets a metadata-only common variant + a real
-androidvariant):androidx.compose.material3.adaptive:adaptiveXamarin.AndroidX.Compose.Material3.Adaptive…:adaptive-layoutXamarin.AndroidX.Compose.Material3.Adaptive.Layout…:adaptive-navigationXamarin.AndroidX.Compose.Material3.Adaptive.Navigationandroidx.compose.material3:material3-adaptive-navigation-suiteXamarin.AndroidX.Compose.Material3.Adaptive.NavigationSuiteExposes
WindowAdaptiveInfo/Posture/HingeInfo,currentWindowAdaptiveInfo()/currentWindowSize(),ListDetailPaneScaffold/SupportingPaneScaffold/ThreePaneScaffold+ navigators, andNavigationSuiteScaffold.Changes
config.json— 8 artifact entries;extraDependenciesto pull in the Composeruntime/ui/foundation/ui-unit-androidreferences the POMs only declare transitively; awindow-core-androiddependencyOnlymapping to the existingXamarin.AndroidX.Window.WindowCorebinding to satisfy the KMP dependency.remove-node;-androidvariants carry the classes.managedName— resolves Kotlin value-class (Dp) overload collisions that otherwise emit CS0111; also corrects the auto-generatednavigationsuitepackage segment to the properly-casedAndroidX.Compose.Material3.Adaptive.NavigationSuitenamespace:PublicAPI.{Shipped,Unshipped}.txtper binding; regeneratedpublished-namespaces.txt(addsAndroidX.Compose.Material3.Adaptive[.Layout|.Navigation|.NavigationSuite]) anddocs/artifact-list*.md.Notes for reviewers
proportion-basedpreferredWidth(Float)overload keeps the default managed name; the renamed*2methods are theDpvariants.