зеркало из https://github.com/DeGsoft/maui-linux.git
Makes it easier for users to disable text prediction/autocomplete/autosuggest. Fixes #1677.
This commit is contained in:
Родитель
4d9a5bf370
Коммит
99f6d30be7
|
@ -0,0 +1,45 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using Xamarin.Forms.CustomAttributes;
|
||||
using Xamarin.Forms.Internals;
|
||||
|
||||
namespace Xamarin.Forms.Controls
|
||||
{
|
||||
[Preserve (AllMembers=true)]
|
||||
[Issue (IssueTracker.Github, 1677, "[Enhancement] Entry: Control over text-prediction", PlatformAffected.All)]
|
||||
public class Issue1677
|
||||
: TestContentPage
|
||||
{
|
||||
protected override void Init()
|
||||
{
|
||||
var entryDefaults = new Entry();
|
||||
var entryNoTextPrediction = new Entry { IsTextPredictionEnabled = false };
|
||||
// IsTextPredictionEnabled should be ignored for email Entry
|
||||
var entryEmail = new Entry { Text = "foo@example.com", Keyboard = Keyboard.Email, IsTextPredictionEnabled = true };
|
||||
// IsTextPredictionEnabled should be ignored for numeric Entry
|
||||
var entryNumeric = new Entry { Text = "01234", Keyboard = Keyboard.Numeric, IsTextPredictionEnabled = true };
|
||||
// On Android disabling either spell checking or text prediction both turn off text suggestions so this Entry
|
||||
// should behave the same as entryNoTextPrediction above
|
||||
var entryNoSpellChecking = new Entry { IsSpellCheckEnabled = false };
|
||||
|
||||
var stackLayout = new StackLayout();
|
||||
stackLayout.Children.Add(new Label { Text = "Defaults" });
|
||||
stackLayout.Children.Add(entryDefaults);
|
||||
stackLayout.Children.Add(new Label { Text = "Text prediction disabled" });
|
||||
stackLayout.Children.Add(entryNoTextPrediction);
|
||||
stackLayout.Children.Add(new Label { Text = "Spell checking disabled" });
|
||||
stackLayout.Children.Add(entryNoSpellChecking);
|
||||
stackLayout.Children.Add(new Label { Text = "Email" });
|
||||
stackLayout.Children.Add(entryEmail);
|
||||
stackLayout.Children.Add(new Label { Text = "Numeric" });
|
||||
stackLayout.Children.Add(entryNumeric);
|
||||
|
||||
stackLayout.Padding = new Thickness(0, 20, 0, 0);
|
||||
Content = stackLayout;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -238,6 +238,7 @@
|
|||
<Compile Include="$(MSBuildThisFileDirectory)Bugzilla59457.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Bugzilla59580.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)GitHub1878.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Issue1677.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Issue1683.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Issue1705_2.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Issue1601.cs" />
|
||||
|
|
|
@ -33,6 +33,8 @@ namespace Xamarin.Forms
|
|||
|
||||
public static readonly BindableProperty FontAttributesProperty = FontElement.FontAttributesProperty;
|
||||
|
||||
public static readonly BindableProperty IsTextPredictionEnabledProperty = BindableProperty.Create(nameof(IsTextPredictionEnabled), typeof(bool), typeof(Entry), true, BindingMode.OneTime);
|
||||
|
||||
readonly Lazy<PlatformConfigurationRegistry<Entry>> _platformConfigurationRegistry;
|
||||
|
||||
public Entry()
|
||||
|
@ -95,6 +97,12 @@ namespace Xamarin.Forms
|
|||
set { SetValue(FontSizeProperty, value); }
|
||||
}
|
||||
|
||||
public bool IsTextPredictionEnabled
|
||||
{
|
||||
get { return (bool)GetValue(IsTextPredictionEnabledProperty); }
|
||||
set { SetValue(IsTextPredictionEnabledProperty, value); }
|
||||
}
|
||||
|
||||
public ReturnType ReturnType
|
||||
{
|
||||
get => (ReturnType)GetValue(ReturnTypeProperty);
|
||||
|
|
|
@ -144,6 +144,8 @@ namespace Xamarin.Forms.Platform.Android
|
|||
UpdateInputType();
|
||||
else if (e.PropertyName == InputView.IsSpellCheckEnabledProperty.PropertyName)
|
||||
UpdateInputType();
|
||||
else if (e.PropertyName == Entry.IsTextPredictionEnabledProperty.PropertyName)
|
||||
UpdateInputType();
|
||||
else if (e.PropertyName == Entry.HorizontalTextAlignmentProperty.PropertyName)
|
||||
UpdateAlignment();
|
||||
else if (e.PropertyName == Entry.FontAttributesProperty.PropertyName)
|
||||
|
@ -205,12 +207,23 @@ namespace Xamarin.Forms.Platform.Android
|
|||
var keyboard = model.Keyboard;
|
||||
|
||||
Control.InputType = keyboard.ToInputType();
|
||||
if (!(keyboard is Internals.CustomKeyboard) && model.IsSet(InputView.IsSpellCheckEnabledProperty))
|
||||
if (!(keyboard is Internals.CustomKeyboard))
|
||||
{
|
||||
if ((Control.InputType & InputTypes.TextFlagNoSuggestions) != InputTypes.TextFlagNoSuggestions)
|
||||
if (model.IsSet(InputView.IsSpellCheckEnabledProperty))
|
||||
{
|
||||
if (!model.IsSpellCheckEnabled)
|
||||
Control.InputType = Control.InputType | InputTypes.TextFlagNoSuggestions;
|
||||
if ((Control.InputType & InputTypes.TextFlagNoSuggestions) != InputTypes.TextFlagNoSuggestions)
|
||||
{
|
||||
if (!model.IsSpellCheckEnabled)
|
||||
Control.InputType = Control.InputType | InputTypes.TextFlagNoSuggestions;
|
||||
}
|
||||
}
|
||||
if (model.IsSet(Entry.IsTextPredictionEnabledProperty))
|
||||
{
|
||||
if ((Control.InputType & InputTypes.TextFlagNoSuggestions) != InputTypes.TextFlagNoSuggestions)
|
||||
{
|
||||
if (!model.IsTextPredictionEnabled)
|
||||
Control.InputType = Control.InputType | InputTypes.TextFlagNoSuggestions;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -80,6 +80,8 @@ namespace Xamarin.Forms.Platform.UWP
|
|||
UpdateInputScope();
|
||||
else if (e.PropertyName == InputView.IsSpellCheckEnabledProperty.PropertyName)
|
||||
UpdateInputScope();
|
||||
else if (e.PropertyName == Entry.IsTextPredictionEnabledProperty.PropertyName)
|
||||
UpdateInputScope();
|
||||
else if (e.PropertyName == Entry.FontAttributesProperty.PropertyName)
|
||||
UpdateFont();
|
||||
else if (e.PropertyName == Entry.FontFamilyProperty.PropertyName)
|
||||
|
@ -181,7 +183,10 @@ namespace Xamarin.Forms.Platform.UWP
|
|||
}
|
||||
else
|
||||
{
|
||||
Control.ClearValue(TextBox.IsTextPredictionEnabledProperty);
|
||||
if (entry.IsSet(Entry.IsTextPredictionEnabledProperty))
|
||||
Control.IsTextPredictionEnabled = entry.IsTextPredictionEnabled;
|
||||
else
|
||||
Control.ClearValue(TextBox.IsTextPredictionEnabledProperty);
|
||||
if (entry.IsSet(InputView.IsSpellCheckEnabledProperty))
|
||||
Control.IsSpellCheckEnabled = entry.IsSpellCheckEnabled;
|
||||
else
|
||||
|
|
|
@ -125,6 +125,8 @@ namespace Xamarin.Forms.Platform.iOS
|
|||
UpdateKeyboard();
|
||||
else if (e.PropertyName == Xamarin.Forms.InputView.IsSpellCheckEnabledProperty.PropertyName)
|
||||
UpdateKeyboard();
|
||||
else if (e.PropertyName == Entry.IsTextPredictionEnabledProperty.PropertyName)
|
||||
UpdateKeyboard();
|
||||
else if (e.PropertyName == Entry.HorizontalTextAlignmentProperty.PropertyName)
|
||||
UpdateAlignment();
|
||||
else if (e.PropertyName == Entry.FontAttributesProperty.PropertyName)
|
||||
|
@ -215,12 +217,23 @@ namespace Xamarin.Forms.Platform.iOS
|
|||
|
||||
void UpdateKeyboard()
|
||||
{
|
||||
Control.ApplyKeyboard(Element.Keyboard);
|
||||
if (!(Element.Keyboard is Internals.CustomKeyboard) && Element.IsSet(Xamarin.Forms.InputView.IsSpellCheckEnabledProperty))
|
||||
var keyboard = Element.Keyboard;
|
||||
Control.ApplyKeyboard(keyboard);
|
||||
if (!(keyboard is Internals.CustomKeyboard))
|
||||
{
|
||||
if (!Element.IsSpellCheckEnabled)
|
||||
if (Element.IsSet(Xamarin.Forms.InputView.IsSpellCheckEnabledProperty))
|
||||
{
|
||||
Control.SpellCheckingType = UITextSpellCheckingType.No;
|
||||
if (!Element.IsSpellCheckEnabled)
|
||||
{
|
||||
Control.SpellCheckingType = UITextSpellCheckingType.No;
|
||||
}
|
||||
}
|
||||
if (Element.IsSet(Xamarin.Forms.Entry.IsTextPredictionEnabledProperty))
|
||||
{
|
||||
if (!Element.IsTextPredictionEnabled)
|
||||
{
|
||||
Control.AutocorrectionType = UITextAutocorrectionType.No;
|
||||
}
|
||||
}
|
||||
}
|
||||
Control.ReloadInputViews();
|
||||
|
|
|
@ -314,6 +314,37 @@ View CreateLoginForm ()
|
|||
</remarks>
|
||||
</Docs>
|
||||
</Member>
|
||||
<Member MemberName="IsTextPredictionEnabled">
|
||||
<MemberSignature Language="C#" Value="public bool IsTextPredictionEnabled { get; set; }" />
|
||||
<MemberSignature Language="ILAsm" Value=".property instance bool IsTextPredictionEnabled" />
|
||||
<MemberType>Property</MemberType>
|
||||
<AssemblyInfo>
|
||||
<AssemblyVersion>2.0.0.0</AssemblyVersion>
|
||||
</AssemblyInfo>
|
||||
<ReturnValue>
|
||||
<ReturnType>System.Boolean</ReturnType>
|
||||
</ReturnValue>
|
||||
<Docs>
|
||||
<summary>To be added.</summary>
|
||||
<value>To be added.</value>
|
||||
<remarks>To be added.</remarks>
|
||||
</Docs>
|
||||
</Member>
|
||||
<Member MemberName="IsTextPredictionEnabledProperty">
|
||||
<MemberSignature Language="C#" Value="public static readonly Xamarin.Forms.BindableProperty IsTextPredictionEnabledProperty;" />
|
||||
<MemberSignature Language="ILAsm" Value=".field public static initonly class Xamarin.Forms.BindableProperty IsTextPredictionEnabledProperty" />
|
||||
<MemberType>Field</MemberType>
|
||||
<AssemblyInfo>
|
||||
<AssemblyVersion>2.0.0.0</AssemblyVersion>
|
||||
</AssemblyInfo>
|
||||
<ReturnValue>
|
||||
<ReturnType>Xamarin.Forms.BindableProperty</ReturnType>
|
||||
</ReturnValue>
|
||||
<Docs>
|
||||
<summary>To be added.</summary>
|
||||
<remarks>To be added.</remarks>
|
||||
</Docs>
|
||||
</Member>
|
||||
<Member MemberName="On<T>">
|
||||
<MemberSignature Language="C#" Value="public Xamarin.Forms.IPlatformElementConfiguration<T,Xamarin.Forms.Entry> On<T> () where T : Xamarin.Forms.IConfigPlatform;" />
|
||||
<MemberSignature Language="ILAsm" Value=".method public hidebysig newslot virtual instance class Xamarin.Forms.IPlatformElementConfiguration`2<!!T, class Xamarin.Forms.Entry> On<(class Xamarin.Forms.IConfigPlatform) T>() cil managed" />
|
||||
|
|
Загрузка…
Ссылка в новой задаче