From 2bb25cd7efdaa1ca61deb4c5d801e8b8e94a443d Mon Sep 17 00:00:00 2001 From: Dan Walmsley Date: Thu, 15 Sep 2022 22:24:21 +0100 Subject: [PATCH] basic implementation of android return key type. --- .../Avalonia.Android/AndroidInputMethod.cs | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/Android/Avalonia.Android/AndroidInputMethod.cs b/src/Android/Avalonia.Android/AndroidInputMethod.cs index 81b1e91285..5293759586 100644 --- a/src/Android/Avalonia.Android/AndroidInputMethod.cs +++ b/src/Android/Avalonia.Android/AndroidInputMethod.cs @@ -19,6 +19,17 @@ namespace Avalonia.Android public bool IsActive { get; } } + enum CustomImeFlags + { + ActionNone = 0x00000001, + ActionGo = 0x00000002, + ActionSearch = 0x00000003, + ActionSend = 0x00000004, + ActionNext = 0x00000005, + ActionDone = 0x00000006, + ActionPrevious = 0x00000007, + } + class AndroidInputMethod : ITextInputMethodImpl, IAndroidInputMethod where TView : View, IInitEditorInfo { @@ -120,6 +131,17 @@ namespace Avalonia.Android if (options.Multiline) outAttrs.InputType |= global::Android.Text.InputTypes.TextFlagMultiLine; + outAttrs.ImeOptions = options.ReturnKeyType switch + { + TextInputReturnKeyType.Return => ImeFlags.NoEnterAction, + TextInputReturnKeyType.Go => (ImeFlags)CustomImeFlags.ActionGo, + TextInputReturnKeyType.Send => (ImeFlags)CustomImeFlags.ActionSend, + TextInputReturnKeyType.Search => (ImeFlags)CustomImeFlags.ActionSearch, + TextInputReturnKeyType.Next => (ImeFlags)CustomImeFlags.ActionNext, + TextInputReturnKeyType.Previous => (ImeFlags)CustomImeFlags.ActionPrevious, + _ => (ImeFlags)CustomImeFlags.ActionDone + }; + outAttrs.ImeOptions |= ImeFlags.NoFullscreen | ImeFlags.NoExtractUi; return _inputConnection;