-
Notifications
You must be signed in to change notification settings - Fork 1.9k
[Android] Fixed Label Overlapped by Android Status Bar When Using SafeAreaEdges="Container" in .NET MAUI #33014
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
6b0ac22
sandbox sample
NirmalKumarYuvaraj 6f64068
minor change
NirmalKumarYuvaraj 3296a25
fix
NirmalKumarYuvaraj 0d2c84f
added test case
NirmalKumarYuvaraj cdf9b23
added snapshots
NirmalKumarYuvaraj e2beb37
Fix SafeAreaExtensions full-screen detection and improve Issue32941 test
PureWeen f1052a2
Replace 95% threshold with parent-based detection in SafeAreaExtensions
PureWeen 6dc61b0
Add ISafeAreaIgnoredContainer to disable safe area for ListView/Table…
PureWeen f9fd9e7
Remove all ISafeAreaIgnoredContainer PublicAPI entries
PureWeen 967d469
Fix ISafeAreaIgnoredContainer logic to check parent hierarchy
PureWeen 7e11c0e
Fix ISafeAreaIgnoredContainer to not skip view tracking
PureWeen a6afe09
Remove ISafeAreaIgnoredContainer from ViewCell
PureWeen 70d85e5
Add SafeAreaEdges.Container to pages with ListView/TableView as root …
PureWeen 0c66629
Consolidate redundant parent check in SafeAreaExtensions
PureWeen 367e5c9
Delete src/Core/AndroidNative/build/reports/problems/problems-report.…
PureWeen bb7567c
Fix Issue5924 and ShellInsets ListViewPage with SafeAreaEdges.Container
PureWeen 9178e56
Fix Issue1658 and Issue6258 with SafeAreaEdges.Container
PureWeen ddde512
Refactor: Move ISafeAreaIgnoredContainer check to FindListenerForView
PureWeen 6ee203c
Remove ISafeAreaIgnoredContainer logic from SafeAreaExtensions
PureWeen a8909e0
Add Issue33034 test and fix SafeArea for ListView/TableView children
PureWeen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
Binary file modified
BIN
+1.29 KB
(100%)
...Cases.Android.Tests/snapshots/android/ImageDoesNotDisappearWhenSwitchingTab.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
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
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
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,84 @@ | ||
| namespace Maui.Controls.Sample.Issues; | ||
|
|
||
| [Issue(IssueTracker.Github, 32941, "Label Overlapped by Android Status Bar When Using SafeAreaEdges=Container in .NET MAUI", PlatformAffected.Android)] | ||
| public class Issue32941 : TestShell | ||
| { | ||
| protected override void Init() | ||
| { | ||
| var shellContent1 = new ShellContent | ||
| { | ||
| Title = "Home", | ||
| Route = "MainPage", | ||
| Content = new Issue32941_MainPage() | ||
| }; | ||
| var shellContent2 = new ShellContent | ||
| { | ||
| Title = "SignOut", | ||
| Route = "SignOutPage", | ||
| Content = new Issue32941_SignOutPage() | ||
| }; | ||
| Items.Add(shellContent1); | ||
| Items.Add(shellContent2); | ||
| } | ||
| } | ||
|
|
||
| public class Issue32941_MainPage : ContentPage | ||
| { | ||
| public Issue32941_MainPage() | ||
| { | ||
| var goToSignOutButton = new Button | ||
| { | ||
| Text = "Go to SignOut", | ||
| AutomationId = "GoToSignOutButton" | ||
| }; | ||
| goToSignOutButton.Clicked += async (s, e) => await Shell.Current.GoToAsync("//SignOutPage", false); | ||
|
|
||
| Content = new VerticalStackLayout | ||
| { | ||
| Spacing = 20, | ||
| Padding = new Thickness(20), | ||
| Children = | ||
| { | ||
| new Label | ||
| { | ||
| Text = "Main Page", | ||
| FontSize = 24, | ||
| AutomationId = "MainPageLabel" | ||
| }, | ||
| goToSignOutButton | ||
| } | ||
| }; | ||
| } | ||
| } | ||
|
|
||
| public class Issue32941_SignOutPage : ContentPage | ||
| { | ||
| public Issue32941_SignOutPage() | ||
| { | ||
| Shell.SetNavBarIsVisible(this, false); | ||
| SafeAreaEdges = new SafeAreaEdges(SafeAreaRegions.Container); | ||
|
|
||
| var backButton = new Button | ||
| { | ||
| Text = "Back to Main", | ||
| AutomationId = "BackButton" | ||
| }; | ||
| backButton.Clicked += async (s, e) => await Shell.Current.GoToAsync("//MainPage", true); | ||
|
|
||
| Content = new VerticalStackLayout | ||
| { | ||
| BackgroundColor = Colors.White, | ||
| Children = | ||
| { | ||
| new Label | ||
| { | ||
| Text = "SignOut / Session Expiry Page", | ||
| FontSize = 24, | ||
| BackgroundColor = Colors.Yellow, | ||
| AutomationId = "SignOutLabel" | ||
| }, | ||
| backButton | ||
| } | ||
| }; | ||
| } | ||
| } |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| <?xml version="1.0" encoding="utf-8" ?> | ||
| <local:TestShell xmlns="http://schemas.microsoft.com/dotnet/2021/maui" | ||
| xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" | ||
| xmlns:local="clr-namespace:Maui.Controls.Sample.Issues" | ||
| x:Class="Maui.Controls.Sample.Issues.Issue33034" | ||
| Title="Issue 33034"> | ||
| </local:TestShell> |
41 changes: 41 additions & 0 deletions
41
src/Controls/tests/TestCases.HostApp/Issues/Issue33034.xaml.cs
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| using Microsoft.Maui.Controls; | ||
| using Microsoft.Maui.Controls.Xaml; | ||
|
|
||
| namespace Maui.Controls.Sample.Issues; | ||
|
|
||
| [XamlCompilation(XamlCompilationOptions.Compile)] | ||
| [Issue(IssueTracker.Github, 33034, "SafeAreaEdges works correctly only on the first tab in Shell. Other tabs have content colliding with the display cutout in the landscape mode.", PlatformAffected.Android)] | ||
| public partial class Issue33034 : TestShell | ||
| { | ||
| public Issue33034() | ||
| { | ||
| InitializeComponent(); | ||
| } | ||
|
|
||
| protected override void Init() | ||
| { | ||
| // Create TabBar with two tabs using the same content page | ||
| var tabBar = new TabBar(); | ||
|
|
||
| var tab = new Tab { Title = "Tabs" }; | ||
|
|
||
| tab.Items.Add(new ShellContent | ||
| { | ||
| Title = "First Tab", | ||
| AutomationId = "FirstTab", | ||
| ContentTemplate = new DataTemplate(typeof(Issue33034TabContent)), | ||
| Route = "tab1" | ||
| }); | ||
|
|
||
| tab.Items.Add(new ShellContent | ||
| { | ||
| Title = "Second Tab", | ||
| AutomationId = "SecondTab", | ||
| ContentTemplate = new DataTemplate(typeof(Issue33034TabContent)), | ||
| Route = "tab2" | ||
| }); | ||
|
|
||
| tabBar.Items.Add(tab); | ||
| Items.Add(tabBar); | ||
| } | ||
| } |
41 changes: 41 additions & 0 deletions
41
src/Controls/tests/TestCases.HostApp/Issues/Issue33034TabContent.xaml
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| <?xml version="1.0" encoding="utf-8" ?> | ||
| <ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui" | ||
| xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" | ||
| x:Class="Maui.Controls.Sample.Issues.Issue33034TabContent" | ||
| Title="Tab Content"> | ||
|
|
||
| <ScrollView> | ||
| <VerticalStackLayout Spacing="10" Padding="10"> | ||
| <!-- Label positioned at the left edge to test safe area --> | ||
| <Label | ||
| x:Name="LeftEdgeLabel" | ||
| AutomationId="LeftEdgeLabel" | ||
| Text="LEFT EDGE - Should have safe area padding" | ||
| FontSize="18" | ||
| FontAttributes="Bold" | ||
| BackgroundColor="Red" | ||
| TextColor="White" | ||
| Padding="10" | ||
| HorizontalOptions="Start"/> | ||
|
|
||
| <!-- Some content to fill the page --> | ||
| <BoxView | ||
| AutomationId="ContentBox" | ||
| Color="Blue" | ||
| HeightRequest="100" | ||
| HorizontalOptions="Fill"/> | ||
|
|
||
| <Label | ||
| Text="This content should respect safe area on ALL tabs in landscape mode." | ||
| FontSize="14" | ||
| TextColor="Gray" | ||
| HorizontalTextAlignment="Center"/> | ||
|
|
||
| <Label | ||
| Text="Bug: On second tab, content collides with display cutout/notch in landscape." | ||
| FontSize="12" | ||
| TextColor="DarkRed" | ||
| HorizontalTextAlignment="Center"/> | ||
| </VerticalStackLayout> | ||
| </ScrollView> | ||
| </ContentPage> |
13 changes: 13 additions & 0 deletions
13
src/Controls/tests/TestCases.HostApp/Issues/Issue33034TabContent.xaml.cs
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| using Microsoft.Maui.Controls; | ||
| using Microsoft.Maui.Controls.Xaml; | ||
|
|
||
| namespace Maui.Controls.Sample.Issues; | ||
|
|
||
| [XamlCompilation(XamlCompilationOptions.Compile)] | ||
| public partial class Issue33034TabContent : ContentPage | ||
| { | ||
| public Issue33034TabContent() | ||
| { | ||
| InitializeComponent(); | ||
| } | ||
| } |
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
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
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
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
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
38 changes: 38 additions & 0 deletions
38
src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue32941.cs
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| #if TEST_FAILS_ON_CATALYST && TEST_FAILS_ON_WINDOWS // SafeAreaEdges not supported on Catalyst and Windows | ||
| using NUnit.Framework; | ||
| using UITest.Appium; | ||
| using UITest.Core; | ||
|
|
||
| namespace Microsoft.Maui.TestCases.Tests.Issues; | ||
|
|
||
| public class Issue32941 : _IssuesUITest | ||
| { | ||
| public Issue32941(TestDevice testDevice) : base(testDevice) | ||
| { | ||
| } | ||
|
|
||
| public override string Issue => "Label Overlapped by Android Status Bar When Using SafeAreaEdges=Container in .NET MAUI"; | ||
|
|
||
| [Test] | ||
| [Category(UITestCategories.SafeAreaEdges)] | ||
| public void ShellContentShouldRespectSafeAreaEdges_After_Navigation() | ||
| { | ||
| App.WaitForElement("MainPageLabel"); | ||
| App.Tap("GoToSignOutButton"); | ||
| App.WaitForElement("SignOutLabel"); | ||
|
|
||
| // Get the position of the label | ||
| var labelRect = App.FindElement("SignOutLabel").GetRect(); | ||
|
|
||
| // The label should be positioned below the status bar (Y coordinate should be > 0) | ||
| // On Android with notch, status bar is typically 24-88dp depending on device | ||
| // The label should have adequate top padding from SafeAreaEdges=Container | ||
| Assert.That(labelRect.Y, Is.GreaterThan(0), "Label should not be at Y=0 (would be under status bar)"); | ||
|
|
||
| // Verify the label is not overlapped by checking it has reasonable top spacing | ||
| // A label at Y < 20 is likely overlapped by the status bar | ||
| Assert.That(labelRect.Y, Is.GreaterThanOrEqualTo(20), | ||
| "Label Y position should be at least 20 pixels from top to avoid status bar overlap"); | ||
| } | ||
| } | ||
| #endif |
30 changes: 30 additions & 0 deletions
30
src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue33034.cs
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| using NUnit.Framework; | ||
| using UITest.Appium; | ||
| using UITest.Core; | ||
|
|
||
| namespace Microsoft.Maui.TestCases.Tests.Issues | ||
| { | ||
| public class Issue33034 : _IssuesUITest | ||
| { | ||
| public override string Issue => "SafeAreaEdges works correctly only on the first tab in Shell. Other tabs have content colliding with the display cutout in the landscape mode."; | ||
|
|
||
| public Issue33034(TestDevice device) : base(device) { } | ||
|
|
||
| [Test] | ||
| [Category(UITestCategories.SafeAreaEdges)] | ||
| public void SafeAreaShouldWorkOnAllShellTabs() | ||
| { | ||
| // Wait for the first tab to load | ||
| App.WaitForElement("LeftEdgeLabel"); | ||
|
|
||
| // Get the X position of the left edge label on the first tab | ||
| var firstTabLabelRect = App.FindElement("LeftEdgeLabel").GetRect(); | ||
| var firstTabLeftPosition = firstTabLabelRect.X; | ||
|
|
||
| // The label should have proper left padding (safe area inset) | ||
| // With our SafeArea fix, it should be > 0 | ||
| Assert.That(firstTabLeftPosition, Is.GreaterThan(0), | ||
| $"Left edge label should have safe area inset on first tab. Position: {firstTabLeftPosition}"); | ||
| } | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@NirmalKumarYuvaraj can you evaluate if this is a regression or an expected visual change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@PureWeen , This is a regression. I will check and update