diff --git a/src/Controls/tests/TestCases.Android.Tests/snapshots/android/CanvasShouldHonorBlur.png b/src/Controls/tests/TestCases.Android.Tests/snapshots/android/CanvasShouldHonorBlur.png index 08ffcdef5234..4bf538cd21fc 100644 Binary files a/src/Controls/tests/TestCases.Android.Tests/snapshots/android/CanvasShouldHonorBlur.png and b/src/Controls/tests/TestCases.Android.Tests/snapshots/android/CanvasShouldHonorBlur.png differ diff --git a/src/Controls/tests/TestCases.Android.Tests/snapshots/android/IndicatorViewWithTemplatedIcon.png b/src/Controls/tests/TestCases.Android.Tests/snapshots/android/IndicatorViewWithTemplatedIcon.png index b6d61ae69ccb..54ece567b5b9 100644 Binary files a/src/Controls/tests/TestCases.Android.Tests/snapshots/android/IndicatorViewWithTemplatedIcon.png and b/src/Controls/tests/TestCases.Android.Tests/snapshots/android/IndicatorViewWithTemplatedIcon.png differ diff --git a/src/Controls/tests/TestCases.Android.Tests/snapshots/android/LabelShouldSizeCorrectlyOnHorizontalCenterLayoutOptions.png b/src/Controls/tests/TestCases.Android.Tests/snapshots/android/LabelShouldSizeCorrectlyOnHorizontalCenterLayoutOptions.png deleted file mode 100644 index c03a622dc216..000000000000 Binary files a/src/Controls/tests/TestCases.Android.Tests/snapshots/android/LabelShouldSizeCorrectlyOnHorizontalCenterLayoutOptions.png and /dev/null differ diff --git a/src/Controls/tests/TestCases.Android.Tests/snapshots/android/LabelShouldSizeCorrectlyOnHorizontalEndLayoutOptions.png b/src/Controls/tests/TestCases.Android.Tests/snapshots/android/LabelShouldSizeCorrectlyOnHorizontalEndLayoutOptions.png deleted file mode 100644 index 5fe6a68c551a..000000000000 Binary files a/src/Controls/tests/TestCases.Android.Tests/snapshots/android/LabelShouldSizeCorrectlyOnHorizontalEndLayoutOptions.png and /dev/null differ diff --git a/src/Controls/tests/TestCases.Android.Tests/snapshots/android/LabelShouldSizeCorrectlyOnHorizontalStartLayoutOptions.png b/src/Controls/tests/TestCases.Android.Tests/snapshots/android/LabelShouldSizeCorrectlyOnHorizontalStartLayoutOptions.png deleted file mode 100644 index f47e1a7f855b..000000000000 Binary files a/src/Controls/tests/TestCases.Android.Tests/snapshots/android/LabelShouldSizeCorrectlyOnHorizontalStartLayoutOptions.png and /dev/null differ diff --git a/src/Controls/tests/TestCases.Android.Tests/snapshots/android/LabelShouldSizeProperlyOnCollectionView.png b/src/Controls/tests/TestCases.Android.Tests/snapshots/android/LabelShouldSizeProperlyOnCollectionView.png new file mode 100644 index 000000000000..c727aa793eae Binary files /dev/null and b/src/Controls/tests/TestCases.Android.Tests/snapshots/android/LabelShouldSizeProperlyOnCollectionView.png differ diff --git a/src/Controls/tests/TestCases.Android.Tests/snapshots/android/VerifyCarouselLayoutOrientationChange.png b/src/Controls/tests/TestCases.Android.Tests/snapshots/android/VerifyCarouselLayoutOrientationChange.png index 2cbe08888f18..2b53b166dee6 100644 Binary files a/src/Controls/tests/TestCases.Android.Tests/snapshots/android/VerifyCarouselLayoutOrientationChange.png and b/src/Controls/tests/TestCases.Android.Tests/snapshots/android/VerifyCarouselLayoutOrientationChange.png differ diff --git a/src/Controls/tests/TestCases.Android.Tests/snapshots/android/VerifyCarouselViewItemsSourceClearedDynamically.png b/src/Controls/tests/TestCases.Android.Tests/snapshots/android/VerifyCarouselViewItemsSourceClearedDynamically.png index de3846443d8e..adde792cef58 100644 Binary files a/src/Controls/tests/TestCases.Android.Tests/snapshots/android/VerifyCarouselViewItemsSourceClearedDynamically.png and b/src/Controls/tests/TestCases.Android.Tests/snapshots/android/VerifyCarouselViewItemsSourceClearedDynamically.png differ diff --git a/src/Controls/tests/TestCases.Android.Tests/snapshots/android/WordWrapLineBreakModeNoExtraSpace.png b/src/Controls/tests/TestCases.Android.Tests/snapshots/android/WordWrapLineBreakModeNoExtraSpace.png index 4be947230ad1..043b5348f47e 100644 Binary files a/src/Controls/tests/TestCases.Android.Tests/snapshots/android/WordWrapLineBreakModeNoExtraSpace.png and b/src/Controls/tests/TestCases.Android.Tests/snapshots/android/WordWrapLineBreakModeNoExtraSpace.png differ diff --git a/src/Controls/tests/TestCases.HostApp/Issues/Issue27614.cs b/src/Controls/tests/TestCases.HostApp/Issues/Issue27614.cs deleted file mode 100644 index 9008d5fb43eb..000000000000 --- a/src/Controls/tests/TestCases.HostApp/Issues/Issue27614.cs +++ /dev/null @@ -1,61 +0,0 @@ -namespace Maui.Controls.Sample.Issues -{ - [Issue(IssueTracker.Github, 27614, "Label not sized correctly on Android", PlatformAffected.Android)] - public class Issue27614 : ContentPage - { - public Issue27614() - { - - var singleLineLabel = new Label - { - HorizontalOptions = LayoutOptions.Start, - AutomationId = "Label", - Margin = new Thickness(5, 5), - Text = "Hello World", - BackgroundColor = Colors.Blue, - TextColor = Colors.Black, - FontSize = 20 - }; - - var multiLineLabel = new Label - { - HorizontalOptions = LayoutOptions.Start, - Margin = new Thickness(5, 5), - Text = "NET MAUI is a framework used to build native, cross-platform desktop and mobile apps from a single C# codebase for Android, iOS, Mac, and Windows", - BackgroundColor = Colors.Orchid, - TextColor = Colors.Black, - FontSize = 20 - }; - - var button = new Button - { - Text = "Change Label HorizontalOptions to Center", - AutomationId = "CenterButton", - Margin = new Thickness(5, 5) - - }; - button.Clicked += (s, e) => - { - singleLineLabel.HorizontalOptions = LayoutOptions.Center; - multiLineLabel.HorizontalOptions = LayoutOptions.Center; - }; - var button1 = new Button - { - Text = "Change Label HorizontalOptions to End", - AutomationId = "EndButton", - Margin = new Thickness(5, 5) - }; - button1.Clicked += (s, e) => - { - singleLineLabel.HorizontalOptions = LayoutOptions.End; - multiLineLabel.HorizontalOptions = LayoutOptions.End; - }; - var layout = new VerticalStackLayout - { - Children = { singleLineLabel, multiLineLabel, button, button1 } - }; - - Content = layout; - } - } -} \ No newline at end of file diff --git a/src/Controls/tests/TestCases.HostApp/Issues/Issue29542.cs b/src/Controls/tests/TestCases.HostApp/Issues/Issue29542.cs new file mode 100644 index 000000000000..eeeccb49b799 --- /dev/null +++ b/src/Controls/tests/TestCases.HostApp/Issues/Issue29542.cs @@ -0,0 +1,124 @@ +namespace Maui.Controls.Sample.Issues; + +[Issue(IssueTracker.Github, 29542, "I1_Vertical_list_for_Multiple_Rows - Rotating the emulator would cause clipping on the description text.", PlatformAffected.Android)] +public class Issue29542 : ContentPage +{ + public Issue29542() + { + var grid = new Grid + { + Margin = 20, + RowDefinitions = + { + new RowDefinition { Height = GridLength.Auto }, + new RowDefinition { Height = GridLength.Auto }, + new RowDefinition { Height = GridLength.Star }, + + } + }; + + // Top text description + var headerLabel = new Label + { + Text = "1. The test passes if resizing or rotating without clipping or elements disappearing in multiple rows.", + }; + + var button = new Button + { + Text = "Scroll Down", + AutomationId = "ScrollToDownButton", + BackgroundColor = Colors.Red, + HorizontalOptions = LayoutOptions.Center, + VerticalOptions = LayoutOptions.Center, + }; + + var verticalHeaderLayout = new VerticalStackLayout() + { + Children = + { + headerLabel + }, + }; + Grid.SetRow(verticalHeaderLayout, 0); + Grid.SetRow(button, 1); + var items = new List(); + for (int i = 1; i <= 21; i++) + { + items.Add(i.ToString()); + } + var myCollection = new CollectionView + { + AutomationId = "TestCollectionView", + ItemsSource = items, + ItemsLayout = new GridItemsLayout(1, ItemsLayoutOrientation.Vertical) + { + VerticalItemSpacing = 5 + }, + Header = new Label + { + Text = "Header", + FontSize = 32, + TextColor = Color.FromArgb("#3B3A39") + }, + ItemTemplate = new DataTemplate(CreateItemTemplate) + }; + + Grid.SetRow(myCollection, 2); + button.Clicked += (s, e) => + { + + myCollection.ScrollTo(15, position: ScrollToPosition.End, animate: true); + }; + + // Add to grid + grid.Children.Add(verticalHeaderLayout); + grid.Children.Add(button); + + grid.Children.Add(myCollection); + Content = grid; + } + + private View CreateItemTemplate() + { + var label = new Label + { + MaxLines = 3, + LineBreakMode = LineBreakMode.TailTruncation, + Text = @"DescriptionDescriptionDescriptionDescriptionDescriptionDescriptionDescriptionDescriptionDescriptionDescriptionDescriptionDescription DescriptionDescriptionDescriptionDescriptionDescriptionDescriptionDescriptionDescription + DescriptionDescriptionDescriptionDescriptionDescriptionDescription DescriptionDescriptionDescriptionDescriptionDescriptionDescriptionDescriptionDescriptionDescriptionDescriptionDescriptionDescriptionDescriptionDescriptionDescription + DescriptionDescriptionDescription + DescriptionDescriptionDescription", + BackgroundColor = Colors.Green, + HorizontalOptions = LayoutOptions.Start + }; + + var image = new Image + { + Aspect = Aspect.AspectFit, + BackgroundColor = Colors.Transparent, + VerticalOptions = LayoutOptions.Center, + HorizontalOptions = LayoutOptions.Center, + HeightRequest = 24, + Source = "dotnet_bot.png", + Margin = new Thickness(0, 0, 20, 0) + }; + + var layout = new Grid + { + ColumnDefinitions = + { + new ColumnDefinition { Width = GridLength.Star }, + new ColumnDefinition { Width = GridLength.Auto } + }, + BackgroundColor = Colors.AliceBlue, + Padding = 5 + }; + + layout.Children.Add(label); + layout.Children.Add(image); + Grid.SetColumn(label, 0); + Grid.SetColumn(image, 1); + + return layout; + } +} \ No newline at end of file diff --git a/src/Controls/tests/TestCases.Mac.Tests/snapshots/mac/LabelShouldSizeCorrectlyOnHorizontalCenterLayoutOptions.png b/src/Controls/tests/TestCases.Mac.Tests/snapshots/mac/LabelShouldSizeCorrectlyOnHorizontalCenterLayoutOptions.png deleted file mode 100644 index ff7713ab7d56..000000000000 Binary files a/src/Controls/tests/TestCases.Mac.Tests/snapshots/mac/LabelShouldSizeCorrectlyOnHorizontalCenterLayoutOptions.png and /dev/null differ diff --git a/src/Controls/tests/TestCases.Mac.Tests/snapshots/mac/LabelShouldSizeCorrectlyOnHorizontalEndLayoutOptions.png b/src/Controls/tests/TestCases.Mac.Tests/snapshots/mac/LabelShouldSizeCorrectlyOnHorizontalEndLayoutOptions.png deleted file mode 100644 index ab0f20130c2e..000000000000 Binary files a/src/Controls/tests/TestCases.Mac.Tests/snapshots/mac/LabelShouldSizeCorrectlyOnHorizontalEndLayoutOptions.png and /dev/null differ diff --git a/src/Controls/tests/TestCases.Mac.Tests/snapshots/mac/LabelShouldSizeCorrectlyOnHorizontalStartLayoutOptions.png b/src/Controls/tests/TestCases.Mac.Tests/snapshots/mac/LabelShouldSizeCorrectlyOnHorizontalStartLayoutOptions.png deleted file mode 100644 index 5a5096aff505..000000000000 Binary files a/src/Controls/tests/TestCases.Mac.Tests/snapshots/mac/LabelShouldSizeCorrectlyOnHorizontalStartLayoutOptions.png and /dev/null differ diff --git a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue27614.cs b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue27614.cs deleted file mode 100644 index 3096ef571dae..000000000000 --- a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue27614.cs +++ /dev/null @@ -1,41 +0,0 @@ -using NUnit.Framework; -using UITest.Appium; -using UITest.Core; - -namespace Microsoft.Maui.TestCases.Tests.Issues -{ - public class Issue27614 : _IssuesUITest - { - public Issue27614(TestDevice testDevice) : base(testDevice) - { - } - - public override string Issue => "Label not sized correctly on Android"; - - [Test, Order(1)] - [Category(UITestCategories.Label)] - public void LabelShouldSizeCorrectlyOnHorizontalStartLayoutOptions() - { - App.WaitForElement("Label"); - VerifyScreenshot(); - } - - [Test, Order(2)] - [Category(UITestCategories.Label)] - public void LabelShouldSizeCorrectlyOnHorizontalCenterLayoutOptions() - { - App.WaitForElement("CenterButton"); - App.Tap("CenterButton"); - VerifyScreenshot(); - } - - [Test, Order(3)] - [Category(UITestCategories.Label)] - public void LabelShouldSizeCorrectlyOnHorizontalEndLayoutOptions() - { - App.WaitForElement("EndButton"); - App.Tap("EndButton"); - VerifyScreenshot(); - } - } -} \ No newline at end of file diff --git a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue29542.cs b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue29542.cs new file mode 100644 index 000000000000..1c65f3494519 --- /dev/null +++ b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue29542.cs @@ -0,0 +1,31 @@ +#if TEST_FAILS_ON_CATALYST && TEST_FAILS_ON_WINDOWS //The test fails on Windows and MacCatalyst because the SetOrientation method, which is intended to change the device orientation, is only supported on mobile platforms iOS and Android. +using NUnit.Framework; +using UITest.Appium; +using UITest.Core; + +namespace Microsoft.Maui.TestCases.Tests.Issues; + +public class Issue29542 : _IssuesUITest +{ + public Issue29542(TestDevice device) : base(device) { } + + public override string Issue => "I1_Vertical_list_for_Multiple_Rows - Rotating the emulator would cause clipping on the description text."; + + [Test] + [Category(UITestCategories.Label)] + public void LabelShouldSizeProperlyOnCollectionView() + { + App.WaitForElement("TestCollectionView"); + App.Tap("ScrollToDownButton"); + App.SetOrientationLandscape(); + App.WaitForElement("TestCollectionView"); + VerifyScreenshot(); + } + + [TearDown] + public void TearDown() + { + App.SetOrientationPortrait(); + } +} +#endif \ No newline at end of file diff --git a/src/Controls/tests/TestCases.WinUI.Tests/snapshots/windows/LabelShouldSizeCorrectlyOnHorizontalCenterLayoutOptions.png b/src/Controls/tests/TestCases.WinUI.Tests/snapshots/windows/LabelShouldSizeCorrectlyOnHorizontalCenterLayoutOptions.png deleted file mode 100644 index 8aa5849ccd46..000000000000 Binary files a/src/Controls/tests/TestCases.WinUI.Tests/snapshots/windows/LabelShouldSizeCorrectlyOnHorizontalCenterLayoutOptions.png and /dev/null differ diff --git a/src/Controls/tests/TestCases.WinUI.Tests/snapshots/windows/LabelShouldSizeCorrectlyOnHorizontalEndLayoutOptions.png b/src/Controls/tests/TestCases.WinUI.Tests/snapshots/windows/LabelShouldSizeCorrectlyOnHorizontalEndLayoutOptions.png deleted file mode 100644 index c3d95f5ac107..000000000000 Binary files a/src/Controls/tests/TestCases.WinUI.Tests/snapshots/windows/LabelShouldSizeCorrectlyOnHorizontalEndLayoutOptions.png and /dev/null differ diff --git a/src/Controls/tests/TestCases.WinUI.Tests/snapshots/windows/LabelShouldSizeCorrectlyOnHorizontalStartLayoutOptions.png b/src/Controls/tests/TestCases.WinUI.Tests/snapshots/windows/LabelShouldSizeCorrectlyOnHorizontalStartLayoutOptions.png deleted file mode 100644 index 075f8db451f2..000000000000 Binary files a/src/Controls/tests/TestCases.WinUI.Tests/snapshots/windows/LabelShouldSizeCorrectlyOnHorizontalStartLayoutOptions.png and /dev/null differ diff --git a/src/Controls/tests/TestCases.iOS.Tests/snapshots/ios/LabelShouldSizeCorrectlyOnHorizontalCenterLayoutOptions.png b/src/Controls/tests/TestCases.iOS.Tests/snapshots/ios/LabelShouldSizeCorrectlyOnHorizontalCenterLayoutOptions.png deleted file mode 100644 index b198dc9cd43c..000000000000 Binary files a/src/Controls/tests/TestCases.iOS.Tests/snapshots/ios/LabelShouldSizeCorrectlyOnHorizontalCenterLayoutOptions.png and /dev/null differ diff --git a/src/Controls/tests/TestCases.iOS.Tests/snapshots/ios/LabelShouldSizeCorrectlyOnHorizontalEndLayoutOptions.png b/src/Controls/tests/TestCases.iOS.Tests/snapshots/ios/LabelShouldSizeCorrectlyOnHorizontalEndLayoutOptions.png deleted file mode 100644 index 0c56578d340d..000000000000 Binary files a/src/Controls/tests/TestCases.iOS.Tests/snapshots/ios/LabelShouldSizeCorrectlyOnHorizontalEndLayoutOptions.png and /dev/null differ diff --git a/src/Controls/tests/TestCases.iOS.Tests/snapshots/ios/LabelShouldSizeCorrectlyOnHorizontalStartLayoutOptions.png b/src/Controls/tests/TestCases.iOS.Tests/snapshots/ios/LabelShouldSizeCorrectlyOnHorizontalStartLayoutOptions.png deleted file mode 100644 index 108a3a0cd047..000000000000 Binary files a/src/Controls/tests/TestCases.iOS.Tests/snapshots/ios/LabelShouldSizeCorrectlyOnHorizontalStartLayoutOptions.png and /dev/null differ diff --git a/src/Controls/tests/TestCases.iOS.Tests/snapshots/ios/LabelShouldSizeProperlyOnCollectionView.png b/src/Controls/tests/TestCases.iOS.Tests/snapshots/ios/LabelShouldSizeProperlyOnCollectionView.png new file mode 100644 index 000000000000..7316fe0f80e7 Binary files /dev/null and b/src/Controls/tests/TestCases.iOS.Tests/snapshots/ios/LabelShouldSizeProperlyOnCollectionView.png differ diff --git a/src/Core/src/Platform/Android/MauiTextView.cs b/src/Core/src/Platform/Android/MauiTextView.cs index 5d866f0a9fb3..4ef5e45cd821 100644 --- a/src/Core/src/Platform/Android/MauiTextView.cs +++ b/src/Core/src/Platform/Android/MauiTextView.cs @@ -1,7 +1,5 @@ using System; using Android.Content; -using Android.Text; -using Android.Views; using AndroidX.AppCompat.Widget; namespace Microsoft.Maui.Platform @@ -18,37 +16,6 @@ internal override void OnLayoutFormatted(bool changed, int l, int t, int r, int { LayoutChanged?.Invoke(this, new LayoutChangedEventArgs(l, t, r, b)); } - protected override void OnMeasure(int widthMeasureSpec, int heightMeasureSpec) - { - if (MeasureSpec.GetMode(widthMeasureSpec) == MeasureSpecMode.AtMost && Layout is not null) - { - // Ensure the Layout is valid and measured before reading LineCount or GetLineWidth(i) to avoid unnecessary calculations. - if (Layout.Width > 0) - { - // Calculate the total width needed based on text content plus padding - int contentWidth = (int)Math.Ceiling(GetMaxLineWidth(Layout)); - int totalPadding = CompoundPaddingLeft + CompoundPaddingRight; - int requiredWidth = contentWidth + totalPadding; - - // Constrain to maximum available width from original spec - int availableWidth = MeasureSpec.GetSize(widthMeasureSpec); - int desiredWidth = Math.Min(requiredWidth, availableWidth); - widthMeasureSpec = MeasureSpec.MakeMeasureSpec(desiredWidth, MeasureSpecMode.AtMost); - } - } - base.OnMeasure(widthMeasureSpec, heightMeasureSpec); - } - - static float GetMaxLineWidth(Layout layout) - { - float maxWidth = 0; - //Calculates the maximum width needed to display the content based on the widest line." - for (int i = 0, count = layout.LineCount; i < count; i++) - { - maxWidth = Math.Max(maxWidth, layout.GetLineWidth(i)); - } - return maxWidth; - } } public class LayoutChangedEventArgs : EventArgs diff --git a/src/Core/src/PublicAPI/net-android/PublicAPI.Unshipped.txt b/src/Core/src/PublicAPI/net-android/PublicAPI.Unshipped.txt index 99976a0a61d1..e8d6b4cdd5d4 100644 --- a/src/Core/src/PublicAPI/net-android/PublicAPI.Unshipped.txt +++ b/src/Core/src/PublicAPI/net-android/PublicAPI.Unshipped.txt @@ -5,4 +5,5 @@ *REMOVED*override Microsoft.Maui.Platform.MauiPicker.OnTouchEvent(Android.Views.MotionEvent? e) -> bool override Microsoft.Maui.Platform.MauiDatePicker.DefaultMovementMethod.get -> Android.Text.Method.IMovementMethod? override Microsoft.Maui.Platform.MauiPickerBase.DefaultMovementMethod.get -> Android.Text.Method.IMovementMethod? -override Microsoft.Maui.Platform.MauiTimePicker.DefaultMovementMethod.get -> Android.Text.Method.IMovementMethod? \ No newline at end of file +override Microsoft.Maui.Platform.MauiTimePicker.DefaultMovementMethod.get -> Android.Text.Method.IMovementMethod? +*REMOVED*override Microsoft.Maui.Platform.MauiTextView.OnMeasure(int widthMeasureSpec, int heightMeasureSpec) -> void