From 96dbc4599d88b1ca4805bbfbc977ff75a0d0fb09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20Su=C3=A1rez?= Date: Wed, 22 Mar 2023 21:19:16 +0100 Subject: [PATCH] Implement Entry IsSpellCheckEnabled property (#7442) * Implement Entry IsSpellCheckEnabled property * Fix build errors * Updated public APIs * Updated Tizen public apis * Fix build errors * move this back * Updated publicAPIs * Auto-format source code * Fix build errors --------- Co-authored-by: Rui Marinho Co-authored-by: Matthew Leibowitz Co-authored-by: GitHub Actions Autoformatter --- .../Core/src/Windows/EntryRenderer.cs | 1 + .../Core/src/iOS/Renderers/EntryRenderer.cs | 1 + src/Core/src/Core/ITextInput.cs | 5 +++++ .../src/Handlers/Entry/EntryHandler.Android.cs | 3 +++ .../Handlers/Entry/EntryHandler.Standard.cs | 1 + .../src/Handlers/Entry/EntryHandler.Tizen.cs | 2 ++ .../src/Handlers/Entry/EntryHandler.Windows.cs | 3 +++ src/Core/src/Handlers/Entry/EntryHandler.cs | 1 + .../src/Handlers/Entry/EntryHandler.iOS.cs | 3 +++ .../src/Platform/Android/EditTextExtensions.cs | 17 +++++++++++++++-- .../src/Platform/Windows/TextBoxExtensions.cs | 5 +++++ .../src/Platform/iOS/TextFieldExtensions.cs | 18 ++++++++++++++---- .../net-android/PublicAPI.Unshipped.txt | 3 +++ .../PublicAPI/net-ios/PublicAPI.Unshipped.txt | 3 +++ .../net-maccatalyst/PublicAPI.Unshipped.txt | 3 +++ .../net-tizen/PublicAPI.Unshipped.txt | 4 +++- .../net-windows/PublicAPI.Unshipped.txt | 3 +++ .../src/PublicAPI/net/PublicAPI.Unshipped.txt | 2 ++ .../netstandard/PublicAPI.Unshipped.txt | 2 ++ .../netstandard2.0/PublicAPI.Unshipped.txt | 2 ++ .../Entry/EntryHandlerTests.Android.cs | 6 +++--- .../Entry/EntryHandlerTests.Windows.cs | 5 ++++- .../Handlers/Entry/EntryHandlerTests.cs | 17 +++++++++++++++-- .../Handlers/Entry/EntryHandlerTests.iOS.cs | 3 +++ src/Core/tests/DeviceTests/Stubs/EditorStub.cs | 2 ++ src/Core/tests/DeviceTests/Stubs/EntryStub.cs | 2 ++ .../tests/DeviceTests/Stubs/SearchBarStub.cs | 2 ++ 27 files changed, 106 insertions(+), 13 deletions(-) diff --git a/src/Compatibility/Core/src/Windows/EntryRenderer.cs b/src/Compatibility/Core/src/Windows/EntryRenderer.cs index 42ecc9180776..484f6fc61d69 100644 --- a/src/Compatibility/Core/src/Windows/EntryRenderer.cs +++ b/src/Compatibility/Core/src/Windows/EntryRenderer.cs @@ -260,6 +260,7 @@ void UpdateClearButtonVisibility() Control.ClearButtonVisible = Element.ClearButtonVisibility == ClearButtonVisibility.WhileEditing; } + [PortHandler] void UpdateInputScope() { Entry entry = Element; diff --git a/src/Compatibility/Core/src/iOS/Renderers/EntryRenderer.cs b/src/Compatibility/Core/src/iOS/Renderers/EntryRenderer.cs index 167dc6c4862f..19128095036e 100644 --- a/src/Compatibility/Core/src/iOS/Renderers/EntryRenderer.cs +++ b/src/Compatibility/Core/src/iOS/Renderers/EntryRenderer.cs @@ -306,6 +306,7 @@ protected virtual void UpdateFont() Control.Font = Element.ToUIFont(); } + [PortHandler] void UpdateKeyboard() { var keyboard = Element.Keyboard; diff --git a/src/Core/src/Core/ITextInput.cs b/src/Core/src/Core/ITextInput.cs index 53c6a76ce1c8..d930ad34fd3d 100644 --- a/src/Core/src/Core/ITextInput.cs +++ b/src/Core/src/Core/ITextInput.cs @@ -15,6 +15,11 @@ public interface ITextInput : IText, IPlaceholder /// bool IsTextPredictionEnabled { get; } + /// + /// Gets a value that controls whether spell checking is enabled. + /// + bool IsSpellCheckEnabled { get; } + /// /// Gets a value indicating whether or not the view is read-only. /// diff --git a/src/Core/src/Handlers/Entry/EntryHandler.Android.cs b/src/Core/src/Handlers/Entry/EntryHandler.Android.cs index 96e2971321a9..b8d7dbfe6c9a 100644 --- a/src/Core/src/Handlers/Entry/EntryHandler.Android.cs +++ b/src/Core/src/Handlers/Entry/EntryHandler.Android.cs @@ -89,6 +89,9 @@ public static void MapVerticalTextAlignment(IEntryHandler handler, IEntry entry) public static void MapIsTextPredictionEnabled(IEntryHandler handler, IEntry entry) => handler.PlatformView?.UpdateIsTextPredictionEnabled(entry); + public static void MapIsSpellCheckEnabled(IEntryHandler handler, IEntry entry) => + handler.PlatformView?.UpdateIsSpellCheckEnabled(entry); + public static void MapMaxLength(IEntryHandler handler, IEntry entry) => handler.PlatformView?.UpdateMaxLength(entry); diff --git a/src/Core/src/Handlers/Entry/EntryHandler.Standard.cs b/src/Core/src/Handlers/Entry/EntryHandler.Standard.cs index a3c379f96b60..3553baa5da98 100644 --- a/src/Core/src/Handlers/Entry/EntryHandler.Standard.cs +++ b/src/Core/src/Handlers/Entry/EntryHandler.Standard.cs @@ -12,6 +12,7 @@ public static void MapIsPassword(IEntryHandler handler, IEntry entry) { } public static void MapHorizontalTextAlignment(IEntryHandler handler, IEntry entry) { } public static void MapVerticalTextAlignment(IEntryHandler handler, IEntry entry) { } public static void MapIsTextPredictionEnabled(IEntryHandler handler, IEntry entry) { } + public static void MapIsSpellCheckEnabled(IEntryHandler handler, IEntry entry) { } public static void MapMaxLength(IEntryHandler handler, IEntry entry) { } public static void MapPlaceholder(IEntryHandler handler, IEntry entry) { } public static void MapPlaceholderColor(IEntryHandler handler, IEntry entry) { } diff --git a/src/Core/src/Handlers/Entry/EntryHandler.Tizen.cs b/src/Core/src/Handlers/Entry/EntryHandler.Tizen.cs index 523fc0cba767..e22a26dfa93a 100644 --- a/src/Core/src/Handlers/Entry/EntryHandler.Tizen.cs +++ b/src/Core/src/Handlers/Entry/EntryHandler.Tizen.cs @@ -100,6 +100,8 @@ public static void MapPlaceholder(IEntryHandler handler, IEntry entry) => public static void MapPlaceholderColor(IEntryHandler handler, IEntry entry) => handler.PlatformView?.UpdatePlaceholderColor(entry); + public static void MapIsSpellCheckEnabled(IEntryHandler handler, IEntry entry) { } + public static void MapFont(IEntryHandler handler, IEntry entry) => handler.PlatformView?.UpdateFont(entry, handler.GetRequiredService()); diff --git a/src/Core/src/Handlers/Entry/EntryHandler.Windows.cs b/src/Core/src/Handlers/Entry/EntryHandler.Windows.cs index 382474af8280..b015eab027c7 100644 --- a/src/Core/src/Handlers/Entry/EntryHandler.Windows.cs +++ b/src/Core/src/Handlers/Entry/EntryHandler.Windows.cs @@ -70,6 +70,9 @@ public static void MapVerticalTextAlignment(IEntryHandler handler, IEntry entry) public static void MapIsTextPredictionEnabled(IEntryHandler handler, IEntry entry) => handler.PlatformView?.UpdateIsTextPredictionEnabled(entry); + public static void MapIsSpellCheckEnabled(IEntryHandler handler, IEntry entry) => + handler.PlatformView?.UpdateIsSpellCheckEnabled(entry); + public static void MapMaxLength(IEntryHandler handler, IEntry entry) => handler.PlatformView?.UpdateMaxLength(entry); diff --git a/src/Core/src/Handlers/Entry/EntryHandler.cs b/src/Core/src/Handlers/Entry/EntryHandler.cs index 38f0b20ef605..3d4d666adffc 100644 --- a/src/Core/src/Handlers/Entry/EntryHandler.cs +++ b/src/Core/src/Handlers/Entry/EntryHandler.cs @@ -28,6 +28,7 @@ public partial class EntryHandler : IEntryHandler [nameof(IEntry.VerticalTextAlignment)] = MapVerticalTextAlignment, [nameof(IEntry.IsReadOnly)] = MapIsReadOnly, [nameof(IEntry.IsTextPredictionEnabled)] = MapIsTextPredictionEnabled, + [nameof(IEntry.IsSpellCheckEnabled)] = MapIsSpellCheckEnabled, [nameof(IEntry.Keyboard)] = MapKeyboard, [nameof(IEntry.MaxLength)] = MapMaxLength, [nameof(IEntry.Placeholder)] = MapPlaceholder, diff --git a/src/Core/src/Handlers/Entry/EntryHandler.iOS.cs b/src/Core/src/Handlers/Entry/EntryHandler.iOS.cs index 85b41ee428f6..94a523ee30ea 100644 --- a/src/Core/src/Handlers/Entry/EntryHandler.iOS.cs +++ b/src/Core/src/Handlers/Entry/EntryHandler.iOS.cs @@ -76,6 +76,9 @@ public static void MapVerticalTextAlignment(IEntryHandler handler, IEntry entry) public static void MapIsTextPredictionEnabled(IEntryHandler handler, IEntry entry) => handler.PlatformView?.UpdateIsTextPredictionEnabled(entry); + public static void MapIsSpellCheckEnabled(IEntryHandler handler, IEntry entry) => + handler.PlatformView?.UpdateIsSpellCheckEnabled(entry); + public static void MapMaxLength(IEntryHandler handler, IEntry entry) => handler.PlatformView?.UpdateMaxLength(entry); diff --git a/src/Core/src/Platform/Android/EditTextExtensions.cs b/src/Core/src/Platform/Android/EditTextExtensions.cs index bb0a19fa20e8..dfa9f94a9b3f 100644 --- a/src/Core/src/Platform/Android/EditTextExtensions.cs +++ b/src/Core/src/Platform/Android/EditTextExtensions.cs @@ -68,6 +68,11 @@ public static void UpdateIsTextPredictionEnabled(this EditText editText, IEntry editText.SetInputType(entry); } + public static void UpdateIsSpellCheckEnabled(this EditText editText, IEntry entry) + { + editText.SetInputType(entry); + } + public static void UpdateIsTextPredictionEnabled(this EditText editText, IEditor editor) { if (editor.IsTextPredictionEnabled) @@ -288,8 +293,16 @@ internal static void SetInputType(this EditText editText, ITextInput textInput) if ((nativeInputTypeToUpdate & InputTypes.TextFlagNoSuggestions) != InputTypes.TextFlagNoSuggestions) { - if (!textInput.IsTextPredictionEnabled) - nativeInputTypeToUpdate |= InputTypes.TextFlagNoSuggestions; + if (!nativeInputTypeToUpdate.HasFlag(InputTypes.TextFlagNoSuggestions)) + { + if (!textInput.IsSpellCheckEnabled) + nativeInputTypeToUpdate |= InputTypes.TextFlagNoSuggestions; + } + if (!nativeInputTypeToUpdate.HasFlag(InputTypes.TextFlagNoSuggestions)) + { + if (!textInput.IsTextPredictionEnabled) + nativeInputTypeToUpdate |= InputTypes.TextFlagNoSuggestions; + } } } diff --git a/src/Core/src/Platform/Windows/TextBoxExtensions.cs b/src/Core/src/Platform/Windows/TextBoxExtensions.cs index 7ad9099248b5..2ca3692b0812 100644 --- a/src/Core/src/Platform/Windows/TextBoxExtensions.cs +++ b/src/Core/src/Platform/Windows/TextBoxExtensions.cs @@ -154,6 +154,11 @@ public static void UpdateIsTextPredictionEnabled(this TextBox textBox, ITextInpu textBox.UpdateInputScope(textInput); } + public static void UpdateIsSpellCheckEnabled(this TextBox textBox, ITextInput textInput) + { + textBox.UpdateInputScope(textInput); + } + public static void UpdateKeyboard(this TextBox textBox, ITextInput textInput) { textBox.UpdateInputScope(textInput); diff --git a/src/Core/src/Platform/iOS/TextFieldExtensions.cs b/src/Core/src/Platform/iOS/TextFieldExtensions.cs index 6d839bb367c8..a20c8f9f35d7 100644 --- a/src/Core/src/Platform/iOS/TextFieldExtensions.cs +++ b/src/Core/src/Platform/iOS/TextFieldExtensions.cs @@ -46,10 +46,12 @@ public static void UpdateVerticalTextAlignment(this UITextField textField, IText public static void UpdateIsTextPredictionEnabled(this UITextField textField, IEntry entry) { - if (entry.IsTextPredictionEnabled) - textField.AutocorrectionType = UITextAutocorrectionType.Yes; - else - textField.AutocorrectionType = UITextAutocorrectionType.No; + textField.UpdateKeyboard(entry); + } + + public static void UpdateIsSpellCheckEnabled(this UITextField textField, IEntry entry) + { + textField.UpdateKeyboard(entry); } public static void UpdateMaxLength(this UITextField textField, IEntry entry) @@ -112,8 +114,16 @@ public static void UpdateKeyboard(this UITextField textField, IEntry entry) textField.ApplyKeyboard(keyboard); if (keyboard is not CustomKeyboard) + { textField.UpdateIsTextPredictionEnabled(entry); + if (!entry.IsSpellCheckEnabled) + textField.SpellCheckingType = UITextSpellCheckingType.No; + + if (!entry.IsTextPredictionEnabled) + textField.AutocorrectionType = UITextAutocorrectionType.No; + } + textField.ReloadInputViews(); } diff --git a/src/Core/src/PublicAPI/net-android/PublicAPI.Unshipped.txt b/src/Core/src/PublicAPI/net-android/PublicAPI.Unshipped.txt index a440b184d5f6..29c09b8faa92 100644 --- a/src/Core/src/PublicAPI/net-android/PublicAPI.Unshipped.txt +++ b/src/Core/src/PublicAPI/net-android/PublicAPI.Unshipped.txt @@ -2,6 +2,7 @@ Microsoft.Maui.FontSize.Equals(Microsoft.Maui.FontSize other) -> bool Microsoft.Maui.IApplication.UserAppTheme.get -> Microsoft.Maui.ApplicationModel.AppTheme Microsoft.Maui.Hosting.MauiApp.DisposeAsync() -> System.Threading.Tasks.ValueTask +Microsoft.Maui.ITextInput.IsSpellCheckEnabled.get -> bool Microsoft.Maui.Layouts.FlexBasis.Equals(Microsoft.Maui.Layouts.FlexBasis other) -> bool Microsoft.Maui.SizeRequest.Equals(Microsoft.Maui.SizeRequest other) -> bool override Microsoft.Maui.FontSize.Equals(object? obj) -> bool @@ -18,11 +19,13 @@ static Microsoft.Maui.FontSize.operator !=(Microsoft.Maui.FontSize left, Microso static Microsoft.Maui.FontSize.operator ==(Microsoft.Maui.FontSize left, Microsoft.Maui.FontSize right) -> bool static Microsoft.Maui.GridLength.operator !=(Microsoft.Maui.GridLength left, Microsoft.Maui.GridLength right) -> bool static Microsoft.Maui.GridLength.operator ==(Microsoft.Maui.GridLength left, Microsoft.Maui.GridLength right) -> bool +static Microsoft.Maui.Handlers.EntryHandler.MapIsSpellCheckEnabled(Microsoft.Maui.Handlers.IEntryHandler! handler, Microsoft.Maui.IEntry! entry) -> void static Microsoft.Maui.Handlers.StepperHandler.MapIsEnabled(Microsoft.Maui.Handlers.IStepperHandler! handler, Microsoft.Maui.IStepper! stepper) -> void static Microsoft.Maui.Layouts.FlexBasis.operator !=(Microsoft.Maui.Layouts.FlexBasis left, Microsoft.Maui.Layouts.FlexBasis right) -> bool static Microsoft.Maui.Layouts.FlexBasis.operator ==(Microsoft.Maui.Layouts.FlexBasis left, Microsoft.Maui.Layouts.FlexBasis right) -> bool static Microsoft.Maui.Layouts.LayoutExtensions.ArrangeContentUnbounded(this Microsoft.Maui.IContentView! contentView, Microsoft.Maui.Graphics.Rect bounds) -> Microsoft.Maui.Graphics.Size static Microsoft.Maui.Handlers.SearchBarHandler.MapKeyboard(Microsoft.Maui.Handlers.ISearchBarHandler! handler, Microsoft.Maui.ISearchBar! searchBar) -> void +static Microsoft.Maui.Platform.EditTextExtensions.UpdateIsSpellCheckEnabled(this Android.Widget.EditText! editText, Microsoft.Maui.IEntry! entry) -> void static Microsoft.Maui.Platform.SearchViewExtensions.UpdateKeyboard(this AndroidX.AppCompat.Widget.SearchView! searchView, Microsoft.Maui.ISearchBar! searchBar) -> void Microsoft.Maui.IWebView.UserAgent.get -> string? Microsoft.Maui.IWebView.UserAgent.set -> void diff --git a/src/Core/src/PublicAPI/net-ios/PublicAPI.Unshipped.txt b/src/Core/src/PublicAPI/net-ios/PublicAPI.Unshipped.txt index 704635f81aac..cbb5a1a94056 100644 --- a/src/Core/src/PublicAPI/net-ios/PublicAPI.Unshipped.txt +++ b/src/Core/src/PublicAPI/net-ios/PublicAPI.Unshipped.txt @@ -4,6 +4,7 @@ Microsoft.Maui.Handlers.SwipeItemButton.FrameChanged -> System.EventHandler? Microsoft.Maui.Handlers.SwipeItemButton.SwipeItemButton() -> void Microsoft.Maui.IApplication.UserAppTheme.get -> Microsoft.Maui.ApplicationModel.AppTheme Microsoft.Maui.Hosting.MauiApp.DisposeAsync() -> System.Threading.Tasks.ValueTask +Microsoft.Maui.ITextInput.IsSpellCheckEnabled.get -> bool Microsoft.Maui.Layouts.FlexBasis.Equals(Microsoft.Maui.Layouts.FlexBasis other) -> bool Microsoft.Maui.LifecycleEvents.iOSLifecycle.PerformFetch Microsoft.Maui.SizeRequest.Equals(Microsoft.Maui.SizeRequest other) -> bool @@ -25,6 +26,7 @@ override Microsoft.Maui.SizeRequest.Equals(object? obj) -> bool override Microsoft.Maui.SizeRequest.GetHashCode() -> int static Microsoft.Maui.GridLength.operator !=(Microsoft.Maui.GridLength left, Microsoft.Maui.GridLength right) -> bool static Microsoft.Maui.GridLength.operator ==(Microsoft.Maui.GridLength left, Microsoft.Maui.GridLength right) -> bool +static Microsoft.Maui.Handlers.EntryHandler.MapIsSpellCheckEnabled(Microsoft.Maui.Handlers.IEntryHandler! handler, Microsoft.Maui.IEntry! entry) -> void static Microsoft.Maui.Layouts.FlexBasis.operator !=(Microsoft.Maui.Layouts.FlexBasis left, Microsoft.Maui.Layouts.FlexBasis right) -> bool static Microsoft.Maui.Layouts.FlexBasis.operator ==(Microsoft.Maui.Layouts.FlexBasis left, Microsoft.Maui.Layouts.FlexBasis right) -> bool static Microsoft.Maui.Layouts.LayoutExtensions.ArrangeContentUnbounded(this Microsoft.Maui.IContentView! contentView, Microsoft.Maui.Graphics.Rect bounds) -> Microsoft.Maui.Graphics.Size @@ -39,6 +41,7 @@ Microsoft.Maui.IWebView.UserAgent.get -> string? Microsoft.Maui.IWebView.UserAgent.set -> void static Microsoft.Maui.Handlers.WebViewHandler.MapUserAgent(Microsoft.Maui.Handlers.IWebViewHandler! handler, Microsoft.Maui.IWebView! webView) -> void static Microsoft.Maui.Platform.ApplicationExtensions.UpdateUserInterfaceStyle(this Microsoft.Maui.IApplication! application) -> void +static Microsoft.Maui.Platform.TextFieldExtensions.UpdateIsSpellCheckEnabled(this UIKit.UITextField! textField, Microsoft.Maui.IEntry! entry) -> void static Microsoft.Maui.Platform.WebViewExtensions.UpdateUserAgent(this WebKit.WKWebView! platformWebView, Microsoft.Maui.IWebView! webView) -> void *REMOVED*Microsoft.Maui.WeakEventManager.HandleEvent(object! sender, object! args, string! eventName) -> void Microsoft.Maui.WeakEventManager.HandleEvent(object? sender, object? args, string! eventName) -> void diff --git a/src/Core/src/PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt b/src/Core/src/PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt index 1edd64241b4f..2f6dd9fc1a60 100644 --- a/src/Core/src/PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt +++ b/src/Core/src/PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt @@ -4,6 +4,7 @@ Microsoft.Maui.Handlers.SwipeItemButton.FrameChanged -> System.EventHandler? Microsoft.Maui.Handlers.SwipeItemButton.SwipeItemButton() -> void Microsoft.Maui.IApplication.UserAppTheme.get -> Microsoft.Maui.ApplicationModel.AppTheme Microsoft.Maui.Hosting.MauiApp.DisposeAsync() -> System.Threading.Tasks.ValueTask +Microsoft.Maui.ITextInput.IsSpellCheckEnabled.get -> bool Microsoft.Maui.Layouts.FlexBasis.Equals(Microsoft.Maui.Layouts.FlexBasis other) -> bool Microsoft.Maui.SizeRequest.Equals(Microsoft.Maui.SizeRequest other) -> bool Microsoft.Maui.Platform.MauiScrollView @@ -24,6 +25,7 @@ override Microsoft.Maui.SizeRequest.Equals(object? obj) -> bool override Microsoft.Maui.SizeRequest.GetHashCode() -> int static Microsoft.Maui.GridLength.operator !=(Microsoft.Maui.GridLength left, Microsoft.Maui.GridLength right) -> bool static Microsoft.Maui.GridLength.operator ==(Microsoft.Maui.GridLength left, Microsoft.Maui.GridLength right) -> bool +static Microsoft.Maui.Handlers.EntryHandler.MapIsSpellCheckEnabled(Microsoft.Maui.Handlers.IEntryHandler! handler, Microsoft.Maui.IEntry! entry) -> void static Microsoft.Maui.Layouts.FlexBasis.operator !=(Microsoft.Maui.Layouts.FlexBasis left, Microsoft.Maui.Layouts.FlexBasis right) -> bool static Microsoft.Maui.Layouts.FlexBasis.operator ==(Microsoft.Maui.Layouts.FlexBasis left, Microsoft.Maui.Layouts.FlexBasis right) -> bool static Microsoft.Maui.Layouts.LayoutExtensions.ArrangeContentUnbounded(this Microsoft.Maui.IContentView! contentView, Microsoft.Maui.Graphics.Rect bounds) -> Microsoft.Maui.Graphics.Size @@ -38,6 +40,7 @@ Microsoft.Maui.IWebView.UserAgent.get -> string? Microsoft.Maui.IWebView.UserAgent.set -> void static Microsoft.Maui.Handlers.WebViewHandler.MapUserAgent(Microsoft.Maui.Handlers.IWebViewHandler! handler, Microsoft.Maui.IWebView! webView) -> void static Microsoft.Maui.Platform.ApplicationExtensions.UpdateUserInterfaceStyle(this Microsoft.Maui.IApplication! application) -> void +static Microsoft.Maui.Platform.TextFieldExtensions.UpdateIsSpellCheckEnabled(this UIKit.UITextField! textField, Microsoft.Maui.IEntry! entry) -> void static Microsoft.Maui.Platform.WebViewExtensions.UpdateUserAgent(this WebKit.WKWebView! platformWebView, Microsoft.Maui.IWebView! webView) -> void *REMOVED*Microsoft.Maui.WeakEventManager.HandleEvent(object! sender, object! args, string! eventName) -> void Microsoft.Maui.WeakEventManager.HandleEvent(object? sender, object? args, string! eventName) -> void diff --git a/src/Core/src/PublicAPI/net-tizen/PublicAPI.Unshipped.txt b/src/Core/src/PublicAPI/net-tizen/PublicAPI.Unshipped.txt index 96ac11228270..e7ae941e5590 100644 --- a/src/Core/src/PublicAPI/net-tizen/PublicAPI.Unshipped.txt +++ b/src/Core/src/PublicAPI/net-tizen/PublicAPI.Unshipped.txt @@ -19,4 +19,6 @@ static Microsoft.Maui.Layouts.LayoutExtensions.ArrangeContentUnbounded(this Micr *REMOVED*Microsoft.Maui.WeakEventManager.HandleEvent(object! sender, object! args, string! eventName) -> void Microsoft.Maui.WeakEventManager.HandleEvent(object? sender, object? args, string! eventName) -> void static Microsoft.Maui.SizeRequest.operator !=(Microsoft.Maui.SizeRequest left, Microsoft.Maui.SizeRequest right) -> bool -static Microsoft.Maui.SizeRequest.operator ==(Microsoft.Maui.SizeRequest left, Microsoft.Maui.SizeRequest right) -> bool \ No newline at end of file +static Microsoft.Maui.SizeRequest.operator ==(Microsoft.Maui.SizeRequest left, Microsoft.Maui.SizeRequest right) -> bool +Microsoft.Maui.ITextInput.IsSpellCheckEnabled.get -> bool +static Microsoft.Maui.Handlers.EntryHandler.MapIsSpellCheckEnabled(Microsoft.Maui.Handlers.IEntryHandler! handler, Microsoft.Maui.IEntry! entry) -> void \ No newline at end of file diff --git a/src/Core/src/PublicAPI/net-windows/PublicAPI.Unshipped.txt b/src/Core/src/PublicAPI/net-windows/PublicAPI.Unshipped.txt index f7e7b81f6a37..6b0be5aa8c16 100644 --- a/src/Core/src/PublicAPI/net-windows/PublicAPI.Unshipped.txt +++ b/src/Core/src/PublicAPI/net-windows/PublicAPI.Unshipped.txt @@ -1,6 +1,7 @@ #nullable enable Microsoft.Maui.IApplication.UserAppTheme.get -> Microsoft.Maui.ApplicationModel.AppTheme Microsoft.Maui.Hosting.MauiApp.DisposeAsync() -> System.Threading.Tasks.ValueTask +Microsoft.Maui.ITextInput.IsSpellCheckEnabled.get -> bool Microsoft.Maui.Layouts.FlexBasis.Equals(Microsoft.Maui.Layouts.FlexBasis other) -> bool Microsoft.Maui.Platform.MauiWebView.MauiWebView(Microsoft.Maui.Handlers.WebViewHandler! handler) -> void Microsoft.Maui.SizeRequest.Equals(Microsoft.Maui.SizeRequest other) -> bool @@ -11,6 +12,7 @@ override Microsoft.Maui.SizeRequest.Equals(object? obj) -> bool override Microsoft.Maui.SizeRequest.GetHashCode() -> int static Microsoft.Maui.GridLength.operator !=(Microsoft.Maui.GridLength left, Microsoft.Maui.GridLength right) -> bool static Microsoft.Maui.GridLength.operator ==(Microsoft.Maui.GridLength left, Microsoft.Maui.GridLength right) -> bool +static Microsoft.Maui.Handlers.EntryHandler.MapIsSpellCheckEnabled(Microsoft.Maui.Handlers.IEntryHandler! handler, Microsoft.Maui.IEntry! entry) -> void static Microsoft.Maui.Layouts.FlexBasis.operator !=(Microsoft.Maui.Layouts.FlexBasis left, Microsoft.Maui.Layouts.FlexBasis right) -> bool static Microsoft.Maui.Layouts.FlexBasis.operator ==(Microsoft.Maui.Layouts.FlexBasis left, Microsoft.Maui.Layouts.FlexBasis right) -> bool static Microsoft.Maui.Layouts.LayoutExtensions.ArrangeContentUnbounded(this Microsoft.Maui.IContentView! contentView, Microsoft.Maui.Graphics.Rect bounds) -> Microsoft.Maui.Graphics.Size @@ -19,6 +21,7 @@ static Microsoft.Maui.Platform.SearchBarExtensions.UpdateKeyboard(this Microsoft Microsoft.Maui.IWebView.UserAgent.get -> string? Microsoft.Maui.IWebView.UserAgent.set -> void static Microsoft.Maui.Handlers.WebViewHandler.MapUserAgent(Microsoft.Maui.Handlers.IWebViewHandler! handler, Microsoft.Maui.IWebView! webView) -> void +static Microsoft.Maui.Platform.TextBoxExtensions.UpdateIsSpellCheckEnabled(this Microsoft.UI.Xaml.Controls.TextBox! textBox, Microsoft.Maui.ITextInput! textInput) -> void static Microsoft.Maui.Platform.WebViewExtensions.UpdateUserAgent(this Microsoft.UI.Xaml.Controls.WebView2! platformWebView, Microsoft.Maui.IWebView! webView) -> void *REMOVED*Microsoft.Maui.WeakEventManager.HandleEvent(object! sender, object! args, string! eventName) -> void Microsoft.Maui.WeakEventManager.HandleEvent(object? sender, object? args, string! eventName) -> void diff --git a/src/Core/src/PublicAPI/net/PublicAPI.Unshipped.txt b/src/Core/src/PublicAPI/net/PublicAPI.Unshipped.txt index 97edf1e46179..9e70dd8462df 100644 --- a/src/Core/src/PublicAPI/net/PublicAPI.Unshipped.txt +++ b/src/Core/src/PublicAPI/net/PublicAPI.Unshipped.txt @@ -1,6 +1,7 @@ #nullable enable Microsoft.Maui.IApplication.UserAppTheme.get -> Microsoft.Maui.ApplicationModel.AppTheme Microsoft.Maui.Hosting.MauiApp.DisposeAsync() -> System.Threading.Tasks.ValueTask +Microsoft.Maui.ITextInput.IsSpellCheckEnabled.get -> bool Microsoft.Maui.Layouts.FlexBasis.Equals(Microsoft.Maui.Layouts.FlexBasis other) -> bool Microsoft.Maui.SizeRequest.Equals(Microsoft.Maui.SizeRequest other) -> bool override Microsoft.Maui.Layouts.FlexBasis.Equals(object? obj) -> bool @@ -9,6 +10,7 @@ override Microsoft.Maui.SizeRequest.Equals(object? obj) -> bool override Microsoft.Maui.SizeRequest.GetHashCode() -> int static Microsoft.Maui.GridLength.operator !=(Microsoft.Maui.GridLength left, Microsoft.Maui.GridLength right) -> bool static Microsoft.Maui.GridLength.operator ==(Microsoft.Maui.GridLength left, Microsoft.Maui.GridLength right) -> bool +static Microsoft.Maui.Handlers.EntryHandler.MapIsSpellCheckEnabled(Microsoft.Maui.Handlers.IEntryHandler! handler, Microsoft.Maui.IEntry! entry) -> void static Microsoft.Maui.Layouts.FlexBasis.operator !=(Microsoft.Maui.Layouts.FlexBasis left, Microsoft.Maui.Layouts.FlexBasis right) -> bool static Microsoft.Maui.Layouts.FlexBasis.operator ==(Microsoft.Maui.Layouts.FlexBasis left, Microsoft.Maui.Layouts.FlexBasis right) -> bool static Microsoft.Maui.Layouts.LayoutExtensions.ArrangeContentUnbounded(this Microsoft.Maui.IContentView! contentView, Microsoft.Maui.Graphics.Rect bounds) -> Microsoft.Maui.Graphics.Size diff --git a/src/Core/src/PublicAPI/netstandard/PublicAPI.Unshipped.txt b/src/Core/src/PublicAPI/netstandard/PublicAPI.Unshipped.txt index b53159a7dd99..4eb9c427c89d 100644 --- a/src/Core/src/PublicAPI/netstandard/PublicAPI.Unshipped.txt +++ b/src/Core/src/PublicAPI/netstandard/PublicAPI.Unshipped.txt @@ -1,6 +1,7 @@ #nullable enable Microsoft.Maui.IApplication.UserAppTheme.get -> Microsoft.Maui.ApplicationModel.AppTheme Microsoft.Maui.Hosting.MauiApp.DisposeAsync() -> System.Threading.Tasks.ValueTask +Microsoft.Maui.ITextInput.IsSpellCheckEnabled.get -> bool Microsoft.Maui.Layouts.FlexBasis.Equals(Microsoft.Maui.Layouts.FlexBasis other) -> bool Microsoft.Maui.SizeRequest.Equals(Microsoft.Maui.SizeRequest other) -> bool override Microsoft.Maui.Layouts.FlexBasis.Equals(object? obj) -> bool @@ -9,6 +10,7 @@ override Microsoft.Maui.SizeRequest.Equals(object? obj) -> bool override Microsoft.Maui.SizeRequest.GetHashCode() -> int static Microsoft.Maui.GridLength.operator !=(Microsoft.Maui.GridLength left, Microsoft.Maui.GridLength right) -> bool static Microsoft.Maui.GridLength.operator ==(Microsoft.Maui.GridLength left, Microsoft.Maui.GridLength right) -> bool +static Microsoft.Maui.Handlers.EntryHandler.MapIsSpellCheckEnabled(Microsoft.Maui.Handlers.IEntryHandler! handler, Microsoft.Maui.IEntry! entry) -> void static Microsoft.Maui.Layouts.FlexBasis.operator !=(Microsoft.Maui.Layouts.FlexBasis left, Microsoft.Maui.Layouts.FlexBasis right) -> bool static Microsoft.Maui.Layouts.FlexBasis.operator ==(Microsoft.Maui.Layouts.FlexBasis left, Microsoft.Maui.Layouts.FlexBasis right) -> bool static Microsoft.Maui.Layouts.LayoutExtensions.ArrangeContentUnbounded(this Microsoft.Maui.IContentView! contentView, Microsoft.Maui.Graphics.Rect bounds) -> Microsoft.Maui.Graphics.Size diff --git a/src/Core/src/PublicAPI/netstandard2.0/PublicAPI.Unshipped.txt b/src/Core/src/PublicAPI/netstandard2.0/PublicAPI.Unshipped.txt index 97edf1e46179..9e70dd8462df 100644 --- a/src/Core/src/PublicAPI/netstandard2.0/PublicAPI.Unshipped.txt +++ b/src/Core/src/PublicAPI/netstandard2.0/PublicAPI.Unshipped.txt @@ -1,6 +1,7 @@ #nullable enable Microsoft.Maui.IApplication.UserAppTheme.get -> Microsoft.Maui.ApplicationModel.AppTheme Microsoft.Maui.Hosting.MauiApp.DisposeAsync() -> System.Threading.Tasks.ValueTask +Microsoft.Maui.ITextInput.IsSpellCheckEnabled.get -> bool Microsoft.Maui.Layouts.FlexBasis.Equals(Microsoft.Maui.Layouts.FlexBasis other) -> bool Microsoft.Maui.SizeRequest.Equals(Microsoft.Maui.SizeRequest other) -> bool override Microsoft.Maui.Layouts.FlexBasis.Equals(object? obj) -> bool @@ -9,6 +10,7 @@ override Microsoft.Maui.SizeRequest.Equals(object? obj) -> bool override Microsoft.Maui.SizeRequest.GetHashCode() -> int static Microsoft.Maui.GridLength.operator !=(Microsoft.Maui.GridLength left, Microsoft.Maui.GridLength right) -> bool static Microsoft.Maui.GridLength.operator ==(Microsoft.Maui.GridLength left, Microsoft.Maui.GridLength right) -> bool +static Microsoft.Maui.Handlers.EntryHandler.MapIsSpellCheckEnabled(Microsoft.Maui.Handlers.IEntryHandler! handler, Microsoft.Maui.IEntry! entry) -> void static Microsoft.Maui.Layouts.FlexBasis.operator !=(Microsoft.Maui.Layouts.FlexBasis left, Microsoft.Maui.Layouts.FlexBasis right) -> bool static Microsoft.Maui.Layouts.FlexBasis.operator ==(Microsoft.Maui.Layouts.FlexBasis left, Microsoft.Maui.Layouts.FlexBasis right) -> bool static Microsoft.Maui.Layouts.LayoutExtensions.ArrangeContentUnbounded(this Microsoft.Maui.IContentView! contentView, Microsoft.Maui.Graphics.Rect bounds) -> Microsoft.Maui.Graphics.Size diff --git a/src/Core/tests/DeviceTests/Handlers/Entry/EntryHandlerTests.Android.cs b/src/Core/tests/DeviceTests/Handlers/Entry/EntryHandlerTests.Android.cs index fc1f456d9b54..324b612ca561 100644 --- a/src/Core/tests/DeviceTests/Handlers/Entry/EntryHandlerTests.Android.cs +++ b/src/Core/tests/DeviceTests/Handlers/Entry/EntryHandlerTests.Android.cs @@ -4,10 +4,7 @@ using Android.Text.Method; using Android.Views.InputMethods; using AndroidX.AppCompat.Widget; -using Microsoft.Extensions.DependencyInjection; using Microsoft.Maui.DeviceTests.Stubs; -using Microsoft.Maui.Graphics; -using Microsoft.Maui.Handlers; using Xunit; using AColor = Android.Graphics.Color; @@ -326,5 +323,8 @@ int GetNativeSelectionLength(EntryHandler entryHandler) return -1; } + + bool GetNativeIsSpellCheckEnabled(EntryHandler entryHandler) => + !GetNativeEntry(entryHandler).InputType.HasFlag(InputTypes.TextFlagNoSuggestions); } } diff --git a/src/Core/tests/DeviceTests/Handlers/Entry/EntryHandlerTests.Windows.cs b/src/Core/tests/DeviceTests/Handlers/Entry/EntryHandlerTests.Windows.cs index 746b87d76963..157911e58b4a 100644 --- a/src/Core/tests/DeviceTests/Handlers/Entry/EntryHandlerTests.Windows.cs +++ b/src/Core/tests/DeviceTests/Handlers/Entry/EntryHandlerTests.Windows.cs @@ -1,4 +1,4 @@ -using System.Threading.Tasks; +using System.Threading.Tasks; using Microsoft.Extensions.DependencyInjection; using Microsoft.Maui.DeviceTests.Stubs; using Microsoft.Maui.Graphics; @@ -187,5 +187,8 @@ Task PerformClick(IButton button) ip?.Invoke(); }); } + + bool GetNativeIsSpellCheckEnabled(EntryHandler entryHandler) => + GetNativeEntry(entryHandler).IsTextPredictionEnabled; } } \ No newline at end of file diff --git a/src/Core/tests/DeviceTests/Handlers/Entry/EntryHandlerTests.cs b/src/Core/tests/DeviceTests/Handlers/Entry/EntryHandlerTests.cs index 8a1360f4fe61..e74061faadf0 100644 --- a/src/Core/tests/DeviceTests/Handlers/Entry/EntryHandlerTests.cs +++ b/src/Core/tests/DeviceTests/Handlers/Entry/EntryHandlerTests.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Threading.Tasks; using Microsoft.Maui.Controls; using Microsoft.Maui.DeviceTests.Stubs; @@ -495,6 +495,19 @@ await ValidateUnrelatedPropertyUnaffected( () => entry.CharacterSpacing = newSize); } + [Theory(DisplayName = "Is Spell Check Enabled")] + [InlineData(true)] + [InlineData(false)] + public async Task IsSpellCheckEnabledCorrectly(bool isSpellCheckEnabled) + { + var entry = new EntryStub() + { + IsSpellCheckEnabled = isSpellCheckEnabled + }; + + await ValidatePropertyInitValue(entry, () => entry.IsSpellCheckEnabled, GetNativeIsSpellCheckEnabled, isSpellCheckEnabled); + } + [Theory(DisplayName = "Vertical TextAlignment Initializes Correctly")] [InlineData(TextAlignment.Start)] [InlineData(TextAlignment.Center)] @@ -615,4 +628,4 @@ public class EntryTextStyleTests : TextStyleHandlerTests + GetNativeEntry(entryHandler).SpellCheckingType == UITextSpellCheckingType.Yes; } } \ No newline at end of file diff --git a/src/Core/tests/DeviceTests/Stubs/EditorStub.cs b/src/Core/tests/DeviceTests/Stubs/EditorStub.cs index 860a6789c0db..575362405cbe 100644 --- a/src/Core/tests/DeviceTests/Stubs/EditorStub.cs +++ b/src/Core/tests/DeviceTests/Stubs/EditorStub.cs @@ -29,6 +29,8 @@ public string Text public bool IsTextPredictionEnabled { get; set; } = true; + public bool IsSpellCheckEnabled { get; set; } = true; + public Keyboard Keyboard { get; set; } = Keyboard.Default; public TextAlignment HorizontalTextAlignment { get; set; } diff --git a/src/Core/tests/DeviceTests/Stubs/EntryStub.cs b/src/Core/tests/DeviceTests/Stubs/EntryStub.cs index 2589c8bc9e82..4960c6836780 100644 --- a/src/Core/tests/DeviceTests/Stubs/EntryStub.cs +++ b/src/Core/tests/DeviceTests/Stubs/EntryStub.cs @@ -21,6 +21,8 @@ public string Text public bool IsTextPredictionEnabled { get; set; } = true; + public bool IsSpellCheckEnabled { get; set; } = true; + public string Placeholder { get; set; } public Color PlaceholderColor { get; set; } diff --git a/src/Core/tests/DeviceTests/Stubs/SearchBarStub.cs b/src/Core/tests/DeviceTests/Stubs/SearchBarStub.cs index d486897f1137..3ef8f8b4b8c7 100644 --- a/src/Core/tests/DeviceTests/Stubs/SearchBarStub.cs +++ b/src/Core/tests/DeviceTests/Stubs/SearchBarStub.cs @@ -41,6 +41,8 @@ void OnTextChanged(string oldValue, string newValue) => public bool IsTextPredictionEnabled { get; set; } = true; + public bool IsSpellCheckEnabled { get; set; } = true; + public bool IsReadOnly { get; set; } public int MaxLength { get; set; } = int.MaxValue;