|
@@ -4,14 +4,16 @@ using Android.Content;
|
|
|
using Android.Graphics;
|
|
|
using Android.Runtime;
|
|
|
using Android.Views;
|
|
|
-
|
|
|
+using Android.Views.InputMethods;
|
|
|
using Avalonia.Android.OpenGL;
|
|
|
using Avalonia.Android.Platform.Specific;
|
|
|
using Avalonia.Android.Platform.Specific.Helpers;
|
|
|
using Avalonia.Controls;
|
|
|
+using Avalonia.Controls.Platform;
|
|
|
using Avalonia.Controls.Platform.Surfaces;
|
|
|
using Avalonia.Input;
|
|
|
using Avalonia.Input.Raw;
|
|
|
+using Avalonia.Input.TextInput;
|
|
|
using Avalonia.OpenGL.Egl;
|
|
|
using Avalonia.OpenGL.Surfaces;
|
|
|
using Avalonia.Platform;
|
|
@@ -19,19 +21,20 @@ using Avalonia.Rendering;
|
|
|
|
|
|
namespace Avalonia.Android.Platform.SkiaPlatform
|
|
|
{
|
|
|
- class TopLevelImpl : IAndroidView, ITopLevelImpl, EglGlPlatformSurfaceBase.IEglWindowGlPlatformSurfaceInfo
|
|
|
+ class TopLevelImpl : IAndroidView, ITopLevelImpl, EglGlPlatformSurfaceBase.IEglWindowGlPlatformSurfaceInfo, ITopLevelImplWithTextInputMethod
|
|
|
{
|
|
|
private readonly IGlPlatformSurface _gl;
|
|
|
private readonly IFramebufferPlatformSurface _framebuffer;
|
|
|
|
|
|
private readonly AndroidKeyboardEventsHelper<TopLevelImpl> _keyboardHelper;
|
|
|
private readonly AndroidTouchEventsHelper<TopLevelImpl> _touchHelper;
|
|
|
-
|
|
|
+ private readonly ITextInputMethodImpl _textInputMethod;
|
|
|
private ViewImpl _view;
|
|
|
|
|
|
public TopLevelImpl(Context context, bool placeOnTop = false)
|
|
|
{
|
|
|
_view = new ViewImpl(context, this, placeOnTop);
|
|
|
+ _textInputMethod = new AndroidInputMethod<ViewImpl>(_view);
|
|
|
_keyboardHelper = new AndroidKeyboardEventsHelper<TopLevelImpl>(this);
|
|
|
_touchHelper = new AndroidTouchEventsHelper<TopLevelImpl>(this, () => InputRoot,
|
|
|
GetAvaloniaPointFromEvent);
|
|
@@ -45,18 +48,6 @@ namespace Avalonia.Android.Platform.SkiaPlatform
|
|
|
_view.Resources.DisplayMetrics.HeightPixels).ToSize(RenderScaling);
|
|
|
}
|
|
|
|
|
|
- private bool _handleEvents;
|
|
|
-
|
|
|
- public bool HandleEvents
|
|
|
- {
|
|
|
- get { return _handleEvents; }
|
|
|
- set
|
|
|
- {
|
|
|
- _handleEvents = value;
|
|
|
- _keyboardHelper.HandleEvents = _handleEvents;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
public virtual Point GetAvaloniaPointFromEvent(MotionEvent e, int pointerIndex) =>
|
|
|
new Point(e.GetX(pointerIndex), e.GetY(pointerIndex)) / RenderScaling;
|
|
|
|
|
@@ -144,7 +135,7 @@ namespace Avalonia.Android.Platform.SkiaPlatform
|
|
|
Resized?.Invoke(size);
|
|
|
}
|
|
|
|
|
|
- class ViewImpl : InvalidationAwareSurfaceView, ISurfaceHolderCallback
|
|
|
+ class ViewImpl : InvalidationAwareSurfaceView, ISurfaceHolderCallback, IInitEditorInfo
|
|
|
{
|
|
|
private readonly TopLevelImpl _tl;
|
|
|
private Size _oldSize;
|
|
@@ -191,6 +182,27 @@ namespace Avalonia.Android.Platform.SkiaPlatform
|
|
|
|
|
|
base.SurfaceChanged(holder, format, width, height);
|
|
|
}
|
|
|
+
|
|
|
+ public sealed override bool OnCheckIsTextEditor()
|
|
|
+ {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ private Action<EditorInfo> _initEditorInfo;
|
|
|
+
|
|
|
+ public void InitEditorInfo(Action<EditorInfo> init)
|
|
|
+ {
|
|
|
+ _initEditorInfo = init;
|
|
|
+ }
|
|
|
+
|
|
|
+ public sealed override IInputConnection OnCreateInputConnection(EditorInfo outAttrs)
|
|
|
+ {
|
|
|
+ if (_initEditorInfo != null)
|
|
|
+ _initEditorInfo(outAttrs);
|
|
|
+
|
|
|
+ return base.OnCreateInputConnection(outAttrs);
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
public IPopupImpl CreatePopup() => null;
|
|
@@ -209,6 +221,8 @@ namespace Avalonia.Android.Platform.SkiaPlatform
|
|
|
|
|
|
public double Scaling => RenderScaling;
|
|
|
|
|
|
+ public ITextInputMethodImpl TextInputMethod => _textInputMethod;
|
|
|
+
|
|
|
public void SetTransparencyLevelHint(WindowTransparencyLevel transparencyLevel)
|
|
|
{
|
|
|
throw new NotImplementedException();
|