Skip to content

Commit

Permalink
Enable Entry.IsTextPredicationEnabled property on Tizen
Browse files Browse the repository at this point in the history
  • Loading branch information
myroot committed Mar 22, 2018
1 parent 5917ae1 commit 8de76f4
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
12 changes: 6 additions & 6 deletions Xamarin.Forms.Platform.Tizen/Extensions/KeyboardExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,16 +54,16 @@ public static AutoCapital ToAutoCapital(this KeyboardFlags keyboardFlags)
}
}

public static InputHints ToInputHints(this Keyboard keyboard, bool isSpellCheckEnabled)
public static InputHints ToInputHints(this Keyboard keyboard, bool isSpellCheckEnabled, bool isTextPredictionEnabled)
{
if (keyboard is CustomKeyboard customKeyboard && customKeyboard.Flags.HasFlag(KeyboardFlags.Suggestions))
if (keyboard is CustomKeyboard customKeyboard)
{
return InputHints.AutoComplete;
return customKeyboard.Flags.HasFlag(KeyboardFlags.Suggestions) || customKeyboard.Flags.HasFlag(KeyboardFlags.Spellcheck) ? InputHints.AutoComplete : InputHints.None;
}
return isSpellCheckEnabled ? InputHints.AutoComplete : InputHints.None;
return isSpellCheckEnabled && isTextPredictionEnabled ? InputHints.AutoComplete : InputHints.None;
}

public static void UpdateKeyboard(this Native.Entry control, Keyboard keyboard, bool isSpellCheckEnabled)
public static void UpdateKeyboard(this Native.Entry control, Keyboard keyboard, bool isSpellCheckEnabled, bool isTextPredictionEnabled)
{
control.Keyboard = keyboard.ToNative();
if (keyboard is CustomKeyboard customKeyboard)
Expand All @@ -74,7 +74,7 @@ public static void UpdateKeyboard(this Native.Entry control, Keyboard keyboard,
{
control.AutoCapital = AutoCapital.None;
}
control.InputHint = keyboard.ToInputHints(isSpellCheckEnabled);
control.InputHint = keyboard.ToInputHints(isSpellCheckEnabled, isTextPredictionEnabled);
}
}
}
4 changes: 2 additions & 2 deletions Xamarin.Forms.Platform.Tizen/Renderers/EditorRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,12 @@ void UpdateKeyboard(bool initialize)
{
if (initialize && Element.Keyboard == Keyboard.Default)
return;
Control.UpdateKeyboard(Element.Keyboard, Element.IsSpellCheckEnabled);
Control.UpdateKeyboard(Element.Keyboard, Element.IsSpellCheckEnabled, true);
}

void UpdateIsSpellCheckEnabled()
{
Control.InputHint = Element.Keyboard.ToInputHints(Element.IsSpellCheckEnabled);
Control.InputHint = Element.Keyboard.ToInputHints(Element.IsSpellCheckEnabled, true);
}

void UpdateMaxLength()
Expand Down
5 changes: 3 additions & 2 deletions Xamarin.Forms.Platform.Tizen/Renderers/EntryRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public EntryRenderer()
RegisterPropertyHandler(InputView.MaxLengthProperty, UpdateMaxLength);
RegisterPropertyHandler(Entry.ReturnTypeProperty, UpdateReturnType);
RegisterPropertyHandler(InputView.IsSpellCheckEnabledProperty, UpdateIsSpellCheckEnabled);
RegisterPropertyHandler(Entry.IsTextPredictionEnabledProperty, UpdateIsSpellCheckEnabled);

if (TizenPlatformServices.AppDomain.IsTizenSpecificAvailable)
{
Expand Down Expand Up @@ -121,12 +122,12 @@ void UpdateKeyboard(bool initialize)
{
if (initialize && Element.Keyboard == Keyboard.Default)
return;
Control.UpdateKeyboard(Element.Keyboard, Element.IsSpellCheckEnabled);
Control.UpdateKeyboard(Element.Keyboard, Element.IsSpellCheckEnabled, Element.IsTextPredictionEnabled);
}

void UpdateIsSpellCheckEnabled()
{
Control.InputHint = Element.Keyboard.ToInputHints(Element.IsSpellCheckEnabled);
Control.InputHint = Element.Keyboard.ToInputHints(Element.IsSpellCheckEnabled, Element.IsTextPredictionEnabled);
}

void UpdatePlaceholder()
Expand Down

0 comments on commit 8de76f4

Please sign in to comment.