Skip to content

Add androidx.compose.material3.adaptive bindings#1463

Merged
jonathanpeppers merged 5 commits into
mainfrom
copilot/fix-missing-binding-material3-adaptive
Jun 9, 2026
Merged

Add androidx.compose.material3.adaptive bindings#1463
jonathanpeppers merged 5 commits into
mainfrom
copilot/fix-missing-binding-material3-adaptive

Conversation

Copilot AI commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

The androidx.compose.material3.adaptive family — Google's recommended Compose surface for adaptive (phone/foldable/tablet/large-screen) layouts — had no Xamarin.AndroidX.Compose.* binding, leaving .NET for Android apps unable to use adaptive scaffolds, navigation-suite, or WindowAdaptiveInfo.

Bindings added

Eight packages (each KMP artifact gets a metadata-only common variant + a real -android variant):

Kotlin artifact NuGet ID Version
androidx.compose.material3.adaptive:adaptive Xamarin.AndroidX.Compose.Material3.Adaptive 1.2.0
…:adaptive-layout Xamarin.AndroidX.Compose.Material3.Adaptive.Layout 1.2.0
…:adaptive-navigation Xamarin.AndroidX.Compose.Material3.Adaptive.Navigation 1.2.0
androidx.compose.material3:material3-adaptive-navigation-suite Xamarin.AndroidX.Compose.Material3.Adaptive.NavigationSuite 1.4.0

Exposes WindowAdaptiveInfo / Posture / HingeInfo, currentWindowAdaptiveInfo() / currentWindowSize(), ListDetailPaneScaffold / SupportingPaneScaffold / ThreePaneScaffold + navigators, and NavigationSuiteScaffold.

Changes

  • config.json — 8 artifact entries; extraDependencies to pull in the Compose runtime/ui/foundation/ui-unit -android references the POMs only declare transitively; a window-core-android dependencyOnly mapping to the existing Xamarin.AndroidX.Window.WindowCore binding to satisfy the KMP dependency.
  • Transforms — common KMP variants stripped via remove-node; -android variants carry the classes.
  • Metadata managedName — resolves Kotlin value-class (Dp) overload collisions that otherwise emit CS0111; also corrects the auto-generated navigationsuite package segment to the properly-cased AndroidX.Compose.Material3.Adaptive.NavigationSuite namespace:
    <attr path="/api/package[@name='androidx.compose.material3.adaptive.navigationsuite']" name="managedName">AndroidX.Compose.Material3.Adaptive.NavigationSuite</attr>
  • GeneratedPublicAPI.{Shipped,Unshipped}.txt per binding; regenerated published-namespaces.txt (adds AndroidX.Compose.Material3.Adaptive[.Layout|.Navigation|.NavigationSuite]) and docs/artifact-list*.md.

Notes for reviewers

  • No existing package content changed, so no version bumps were applied.
  • The proportion-based preferredWidth(Float) overload keeps the default managed name; the renamed *2 methods are the Dp variants.

Co-authored-by: jonathanpeppers <840039+jonathanpeppers@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix missing binding for androidx.compose.material3.adaptive in Xamarin.AndroidX Add androidx.compose.material3.adaptive bindings Jun 8, 2026
Copilot AI requested a review from jonathanpeppers June 8, 2026 19:07
@jonathanpeppers jonathanpeppers marked this pull request as ready for review June 8, 2026 19:24
Copilot AI review requested due to automatic review settings June 8, 2026 19:24

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 required extraDependencies and a window-core-android dependencyOnly mapping).
  • 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>
@jonathanpeppers

Copy link
Copy Markdown
Member

@copilot namespaces not updated!

----------------------------------------
Setup
----------------------------------------

========================================
verify-namespace-file
========================================
New Namespaces
--------------
AndroidX.Compose.Material3.Adaptive.Layout.Internal

An error occurred when executing task 'verify-namespace-file'.

----------------------------------------
TearDown
----------------------------------------
     #TimingDataStopwatch,  20260608-224507.78,                   verify-namespace-file,         00:00:04.5430123
          #TimingDataCake,  20260608-224507.78,                   verify-namespace-file,         00:00:04.5426872
Error: Namespaces were added or removed.
please run:
    dotnet cake utilities.cake -t=generate-namespace-file

##[error]PowerShell exited with code '1'.
Finishing: Verify published namespaces

…pace

Co-authored-by: jonathanpeppers <840039+jonathanpeppers@users.noreply.github.com>

Copilot AI commented Jun 9, 2026

Copy link
Copy Markdown
Contributor Author

@copilot namespaces not updated!

----------------------------------------

...

Added the missing AndroidX.Compose.Material3.Adaptive.Layout.Internal namespace to published-namespaces.txt (kept Ordinal sort order). This resolves the verify-namespace-file failure. Commit Add missing AndroidX.Compose.Material3.Adaptive.Layout.Internal namespace.

@jonathanpeppers

Copy link
Copy Markdown
Member

@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>

Copilot AI commented Jun 9, 2026

Copy link
Copy Markdown
Contributor Author

@copilot fix merge conflicts

Merged latest origin/main and resolved the conflicts in docs/artifact-list.md and docs/artifact-list-with-versions.md by regenerating both deterministically from the merged config.json. Content changes are limited to the 8 new adaptive rows plus the versions already current in config.json (foundation 1.11.2.2, connect-client 1.1.0.3). Commit 2d6933f9.

@jonathanpeppers jonathanpeppers merged commit 52f9800 into main Jun 9, 2026
2 checks passed
@jonathanpeppers jonathanpeppers deleted the copilot/fix-missing-binding-material3-adaptive branch June 9, 2026 23:08
jonathanpeppers added a commit to jonathanpeppers/Microsoft.AndroidX.Compose that referenced this pull request Jun 10, 2026
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>
jonathanpeppers added a commit to jonathanpeppers/Microsoft.AndroidX.Compose that referenced this pull request Jun 10, 2026
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>
jonathanpeppers added a commit to jonathanpeppers/Microsoft.AndroidX.Compose that referenced this pull request Jun 10, 2026
…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>
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.

Compose Material3: missing binding for androidx.compose.material3.adaptive (WindowAdaptiveInfo, ListDetailPaneScaffold, NavigationSuiteScaffold, ...)

3 participants