Repository navigation
[Android] Don't leave a background tint on the toolbar for a solid BarBackground - #40550
Conversation
…rBackground UpdateBarBackground applied a solid BarBackground as a view background tint (PorterDuff.Mode.Src). The tint stays on the toolbar, so a background drawable set later, such as the gradient a custom IShellToolbarAppearanceTracker sets with SetBackgroundResource, was painted over with the solid color. Tint the current background drawable instead. The tint goes away with that drawable, so a replaced background shows as set. The drawable's fill color is not changed, so ShellToolbarAppearanceTracker.CaptureNativeColors still reads the native color under Material 3. Fixes dotnet#40372
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
Hey there @marcelomoresco! Thank you so much for your PR! Someone from the team will get assigned to your PR shortly and we'll get it reviewed. |
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Expert Review — 0 findings
Reviewed commit b04cf29.
Keep only comments that follow the conventions of the surrounding code. Co-authored-by: OpenBot <335604065+openbotgit[bot]@users.noreply.github.com>
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Expert Review — 0 findings
Reviewed commit eade114.
|
/review run-tests |
This comment has been minimized.
This comment has been minimized.
|
/review run-tests |
This comment has been minimized.
This comment has been minimized.
kubaflo
left a comment
There was a problem hiding this comment.
Some tests failed - could you please check?
…PR (#40612) ### Description of Change `/review run-tests` builds run on a `run-tests/*` dispatch commit, so Azure Pipelines reports their jobs on that commit and the PR's checks panel only shows the `maui-pr-uitests (selected run)` / `maui-pr-devicetests (selected run)` summary checks. `Update-RunTestsResults.ps1` now mirrors every job of the selected build as its own check on the PR head, e.g. - `maui-pr-uitests (Android UITests CoreClr Controls (API 30) Shell1)` ✅ - `maui-pr-devicetests (net11.0 CoreCLR ios/catalyst/android Helix Tests Build Device Tests (CoreCLR))` ❌ Each check links to the job's log and follows it (queued → in progress → success / failure / cancelled) on every results sweep. Checks are tagged `external_id: job:<build id>`; when a later `/review` run on the same commit builds something else, the previous build's job checks that are no longer part of it are marked neutral ("Superseded"). ### Testing - New Pester test for `New-RunTestsJobChecks`; `RunTests.Tests.ps1` passes (76). - Generated the checks from the live build 1698101 (#40550) — the 8 Android UITests jobs with their results. - Creating check runs needs the GitHub App token, so the end-to-end check happens in the workflow after merge. Co-authored-by: Copilot CI <copilot-ci@microsoft.com>
Inside the Microsoft.Maui namespace, Android.Graphics resolves to Microsoft.Android, which has no Graphics namespace, so the device test project failed to build (CS0234). Use the GradientDrawable type from the Android.Graphics.Drawables using directive that the file already has. Co-authored-by: OpenBot <335604065+openbotgit[bot]@users.noreply.github.com>
|
Resolved #ceca39ae — was a CS0234 (Android.Graphics.Drawables resolving ambiguously inside a Microsoft.* namespace, missing global::), not an actual test failure. Fixed, CI should be green now. |
This comment has been minimized.
This comment has been minimized.
A solid BarBackground is applied as a tint on the toolbar's background drawable. When the color is cleared and BarBackground becomes null, only the view tint was cleared, so the drawable could keep the old color. Clear the drawable tint on that path too, and test that clearing BarBackgroundColor removes the previous color. Co-authored-by: OpenBot <335604065+openbotgit[bot]@users.noreply.github.com>
This comment has been minimized.
This comment has been minimized.
291d2b6 to
627689d
Compare
Setting the view background tint to null still marks the tint as configured, and Android then reapplies that empty tint to the background drawable. Only clear the view tint and tint mode when they are set, so a solid color applied to the drawable later is never cleared by a leftover view tint.
627689d to
8733b74
Compare
…nchanged (#40615) ### Description of Change Follow-up to #40612. Running `review-run-tests-results.yml` with `head_sha` for #40550 found the two run-tests comments but published no job checks: the builds had already finished, the comment text did not change, and the loop skipped everything after the `$updated -ceq $comment.body` check — including the check updates. - The comment is only patched when it changed, but the `(selected run)` check and the per-job checks are synced for every refreshed section. - Comments are processed oldest first, so for one commit the newest build's job checks win and the older build's extra jobs are marked superseded. ### Testing `RunTests.Tests.ps1` passes (76). After merge: re-dispatch `review-run-tests-results.yml` with #40550's head SHA.
…PR (dotnet#40612) ### Description of Change `/review run-tests` builds run on a `run-tests/*` dispatch commit, so Azure Pipelines reports their jobs on that commit and the PR's checks panel only shows the `maui-pr-uitests (selected run)` / `maui-pr-devicetests (selected run)` summary checks. `Update-RunTestsResults.ps1` now mirrors every job of the selected build as its own check on the PR head, e.g. - `maui-pr-uitests (Android UITests CoreClr Controls (API 30) Shell1)` ✅ - `maui-pr-devicetests (net11.0 CoreCLR ios/catalyst/android Helix Tests Build Device Tests (CoreCLR))` ❌ Each check links to the job's log and follows it (queued → in progress → success / failure / cancelled) on every results sweep. Checks are tagged `external_id: job:<build id>`; when a later `/review` run on the same commit builds something else, the previous build's job checks that are no longer part of it are marked neutral ("Superseded"). ### Testing - New Pester test for `New-RunTestsJobChecks`; `RunTests.Tests.ps1` passes (76). - Generated the checks from the live build 1698101 (dotnet#40550) — the 8 Android UITests jobs with their results. - Creating check runs needs the GitHub App token, so the end-to-end check happens in the workflow after merge. Co-authored-by: Copilot CI <copilot-ci@microsoft.com>
…nchanged (dotnet#40615) ### Description of Change Follow-up to dotnet#40612. Running `review-run-tests-results.yml` with `head_sha` for dotnet#40550 found the two run-tests comments but published no job checks: the builds had already finished, the comment text did not change, and the loop skipped everything after the `$updated -ceq $comment.body` check — including the check updates. - The comment is only patched when it changed, but the `(selected run)` check and the per-job checks are synced for every refreshed section. - Comments are processed oldest first, so for one commit the newest build's job checks win and the older build's extra jobs are marked superseded. ### Testing `RunTests.Tests.ps1` passes (76). After merge: re-dispatch `review-run-tests-results.yml` with dotnet#40550's head SHA.
This comment has been minimized.
This comment has been minimized.
Selected Tests
🧪 Test selection — click to expand
🧪 UI tests —
|
| Platform | Categories |
|---|---|
| Android | Navigation, Shell1, Shell2, Material3 |
📊 Results — succeeded: 8 passed, 0 failed of 8 jobs
🔗 All test results · Build logs
| Job | Result |
|---|---|
| Android UITests CoreClr Controls (API 30) Navigation | ✅ succeeded |
| Android UITests CoreClr Controls (API 30) Shell1 | ✅ succeeded |
| Android UITests CoreClr Controls (API 30) Shell2 | ✅ succeeded |
| Android UITests Material3 Controls Material3 (API 36) | ✅ succeeded |
| Android UITests Shell Renderer Controls Shell Renderer (API 30) Shell1 | ✅ succeeded |
| Android UITests Shell Renderer Controls Shell Renderer (API 30) Shell2 | ✅ succeeded |
| Build UITests CoreCLR Sample App Build Sample App | ✅ succeeded |
| Build UITests Material3 Sample App Build Sample App (Material3) | ✅ succeeded |
🧪 Device tests — Controls.Modal, Controls.NavigationPage, Controls.Shell, Controls.Toolbar on Android
✅ maui-pr-devicetests #1701020 passed.
GPT-6.2 Sol: Run Android NavigationPage, Shell, and Toolbar device tests for drawable tinting and background replacement.
MAI Code 2: Android toolbar tint behavior and its navigation and Shell call sites; runs focused Controls device tests on Android.
🧪 Ran — 4 categories on Android
| Platform | Categories |
|---|---|
| Android | Controls.Modal, Controls.NavigationPage, Controls.Shell, Controls.Toolbar |
📊 Results — succeeded: 2 passed, 0 failed of 2 jobs
🔗 All test results · Build logs
| Job | Result |
|---|---|
| net11.0 CoreCLR Android Helix Tests Run DeviceTests Android (CoreCLR) | ✅ succeeded |
| net11.0 CoreCLR ios/catalyst/android Helix Tests Build Device Tests (CoreCLR) | ✅ succeeded |
⏭️ Skipped — what neither suite runs
UI tests — 73 categories, 3 platforms
Platforms not run: iOS, MacCatalyst, Windows
Categories not run: Accessibility, ActionSheet, ActivityIndicator, Animation, AppLinks, Border, BoxView, Brush, Button, CarouselView, CollectionView1, CollectionView2, CollectionView3, CollectionView4, CollectionView5, CollectionView6, CollectionView7, Cells, CheckBox, ContextActions, CustomRenderers, DatePicker, Dispatcher, DisplayAlert, DisplayPrompt, DragAndDrop, Entry, Editor, Effects, Essentials, FlyoutPage, Focus, Fonts, Frame, Gestures, GraphicsView, Image, ImageButton, IndicatorView, InputTransparent, IsEnabled, IsVisible, Label, Layout, Lifecycle, ManualReview, Maps, Page, Performance, Picker, ProgressBar, RadioButton, RefreshView, SafeAreaEdges, Shadow, ScrollView, SearchBar, Shape, Slider, SoftInput, Stepper, Switch, SwipeView, TabbedPage, TableView, TimePicker, TitleView, ToolbarItem, Triggers, ViewBaseTests, VisualStateManager, Window, WebView
Each skipped platform and category is listed as a maui-pr-uitests (skipped) … status on this commit. Use /azp run maui-pr-uitests for the full suite.
Device tests — 101 categories, 3 platforms
Platforms not run: iOS, MacCatalyst, Windows
Categories not run: Controls.Accessibility, Controls.Animations, Controls.Application, Controls.Behavior, Controls.Border, Controls.BoxView, Controls.Button, Controls.CarouselView, Controls.CheckBox, Controls.CollectionView, Controls.Compatibility, Controls.ContentView, Controls.DatePicker, Controls.Dispatcher, Controls.Editor, Controls.Element, Controls.Entry, Controls.FlexLayout, Controls.FlyoutPage, Controls.Frame, Controls.Gesture, Controls.HybridWebView, Controls.Image, Controls.Label, Controls.Layout, Controls.Lifecycle, Controls.Map, Controls.Mapper, Controls.Memory, Controls.MenuFlyout, Controls.Page, Controls.PageTransitions, Controls.Path, Controls.Picker, Controls.RadioButton, Controls.RefreshView, Controls.ScrollView, Controls.SearchBar, Controls.Shape, Controls.Slider, Controls.SwipeView, Controls.Switch, Controls.TabbedPage, Controls.TemplatedView, Controls.TextInput, Controls.View, Controls.VisualElement, Controls.VisualElementTree, Controls.WebView, Controls.Window, Controls.WindowOverlay, Controls.Xaml, Core.ActivityIndicator, Core.Animation, Core.Application, Core.Border, Core.BoxView, Core.Button, Core.CheckBox, Core.ContentView, Core.DatePicker, Core.Dispatcher, Core.Editor, Core.Element, Core.Entry, Core.FlowDirection, Core.FlyoutView, Core.Fonts, Core.Formatting, Core.Graphics, Core.GraphicsView, Core.Image, Core.ImageButton, Core.ImageSource, Core.IndicatorView, Core.Label, Core.Layout, Core.Lifecycle, Core.MauiContext, Core.Memory, Core.NavigationPage, Core.Page, Core.Picker, Core.ProgressBar, Core.RadioButton, Core.RefreshView, Core.ScrollView, Core.SearchBar, Core.ShapeView, Core.Slider, Core.Stepper, Core.SwipeView, Core.Switch, Core.TimePicker, Core.View, Core.WebView, Core.Window, Core.WindowOverlay, Graphics, Essentials, BlazorWebView
Each skipped platform and project is listed as a maui-pr-devicetests (skipped) … status on this commit. Use /azp run maui-pr-devicetests for the full suite.
🤖 Why these tests — AI rationale (GPT-6.2 Sol + MAI Code 2)
UI tests
Each model chose independently; every test that runs was selected by at least one of them.
| Platform | GPT-6.2 Sol | MAI Code 2 |
|---|---|---|
| Android | Shell1, Shell2, Navigation, Material3 |
Shell1, Shell2, Navigation |
| iOS | — | — |
| MacCatalyst | — | — |
| Windows | — | — |
GPT-6.2 Sol — Run Android Shell, Navigation, and Material3 UI tests for the toolbar background tint fix.
- ToolbarExtensions.cs changes BarBackground rendering for Shell and NavigationPage on Android.
- Material3 covers Shell’s native toolbar color capture.
- No toolbar-item, navigation-stack, or non-Android changes.
MAI Code 2 — Android-only toolbar background tint fix; runs Shell and Navigation UI tests on Android.
ToolbarExtensions.cschanges Android toolbar tint application used by Shell, so runShellon Android.- The same toolbar path controls
NavigationPage.BarBackground, so runNavigationon Android. - The code is Android-specific and narrowly scoped; omit iOS, Mac Catalyst, Windows, and unrelated UI categories.
- This is not a base layout or app-infrastructure change, so no full run is needed.
Device tests
Each model chose independently; every test that runs was selected by at least one of them.
| Platform | GPT-6.2 Sol | MAI Code 2 |
|---|---|---|
| Android | Controls.NavigationPage, Controls.Shell, Controls.Toolbar |
Controls.NavigationPage, Controls.Modal, Controls.Shell |
| iOS | — | — |
| MacCatalyst | — | — |
| Windows | — | — |
GPT-6.2 Sol — Run Android NavigationPage, Shell, and Toolbar device tests for drawable tinting and background replacement.
- NavigationPageTests.Android.cs adds regressions for replacing a tinted background and clearing BarBackgroundColor.
- Controls.Shell and Controls.Toolbar cover consumers of the changed Android toolbar rendering.
- No Core handler, modal-stack, or non-Android changes.
MAI Code 2 — Android toolbar tint behavior and its navigation and Shell call sites; runs focused Controls device tests on Android.
ToolbarExtensions.cschanges AndroidNavigationPage/Shell toolbar background handling, selectingControls.NavigationPageandControls.Shell.- Navigation styling is coupled to modal toolbar behavior, so include
Controls.Modal. - The modified device tests target Android
NavigationPagebackground tint regressions. - No shared base class, app startup, Core handler, or other platform is affected; no full device run is needed.
Generated by /review run-tests. A targeted run is a fast signal, not full-suite certification.
aa55172
into
dotnet:candidate/11.0.1xx-sr3
Target Branch
mainnet11, for reviewFor .NET 11 fixes, only a maintainer retargets the approved PR to the active
inflight lane and merges it after CI validates that final base. Do not merge
individual fixes directly into
net11; agents must not retarget or merge.Note: the issue was confirmed reproducing on .NET MAUI 10.0.110, and the same
code path is unchanged on
net11, so this targetsnet11as the currentservicing line; please redirect if a 10.0.1xx backport is the intended route
instead.
Description of Change
On Android, Shell's toolbar
UpdateBarBackgroundapplied a solidBarBackgroundas a view background tint (BackgroundTintListwithPorterDuff.Mode.Src) instead of coloring the background drawable itself.That tint stays on the toolbar view, so when a custom
IShellToolbarAppearanceTracker.SetAppearancelater callstoolbar.SetBackgroundResource(...)with a gradient drawable, the tint paintsover it and the gradient renders as the last solid color instead.
The fix tints the current background drawable (
Mutate()+SetTintList/SetTintMode) instead of the view. The tint goes away togetherwith that drawable when the background is replaced, so a later gradient (or
any other custom background) shows correctly. The drawable's own fill color
is untouched, so
ShellToolbarAppearanceTracker.CaptureNativeColorsunderMaterial 3 keeps reading the native color correctly. The existing gradient
BarBackgroundcode path (theelsebranch) is unchanged.Added a device test,
SolidBarBackgroundDoesNotLeaveViewBackgroundTint, inNavigationPageTests.Android.cs.Local verification (Android)
Checked by hand on an Android emulator (API 36) with a small .NET 10 test app
containing an exact copy of the corrected method
(the MAUI repo's own
main/net11build requires .NET 11, not available onthis machine):
white; with the fix, the red→blue gradient renders. Screenshot below
(left: without the fix, right: with the fix).
BarBackgroundcolor change atruntime (orange → green): identical pixels with and without the fix
(
#FFA500→#008000), so solid backgrounds keep working.NavigationPage.BarBackgroundorange →LinearGradientBrush→ green:without the fix the gradient never shows (stays
#FFA500); with the fixthe gradient shows (
#F1000E…#0E00F1) before returning to green. This isan additional improvement beyond the reported Shell case, worth noting.
Not verified
main/net11branchesrequire .NET 11, this machine has .NET 10), and the new device test
(
SolidBarBackgroundDoesNotLeaveViewBackgroundTint) was not executed.UseMauiAndroidSystemBarBackgroundsenabled was notchecked — that path doesn't go through this code.
Shell.Backgroundwith a brush (MAUI 11-only) was not checked.Issues Fixed
Fixes #40372