diff --git a/src/Android/Avalonia.Android/Platform/SkiaPlatform/TopLevelImpl.cs b/src/Android/Avalonia.Android/Platform/SkiaPlatform/TopLevelImpl.cs index 0d0d9db252..71706676d6 100644 --- a/src/Android/Avalonia.Android/Platform/SkiaPlatform/TopLevelImpl.cs +++ b/src/Android/Avalonia.Android/Platform/SkiaPlatform/TopLevelImpl.cs @@ -15,10 +15,10 @@ using Avalonia.Rendering; namespace Avalonia.Android.Platform.SkiaPlatform { class TopLevelImpl : IAndroidView, ITopLevelImpl, IFramebufferPlatformSurface - { private readonly AndroidKeyboardEventsHelper _keyboardHelper; private readonly AndroidTouchEventsHelper _touchHelper; + private ViewImpl _view; public TopLevelImpl(Context context, bool placeOnTop = false) @@ -28,6 +28,8 @@ namespace Avalonia.Android.Platform.SkiaPlatform _touchHelper = new AndroidTouchEventsHelper(this, () => InputRoot, p => GetAvaloniaPointFromEvent(p)); + Surfaces = new object[] { this }; + MaxClientSize = new Size(_view.Resources.DisplayMetrics.WidthPixels, _view.Resources.DisplayMetrics.HeightPixels); } @@ -82,7 +84,7 @@ namespace Avalonia.Android.Platform.SkiaPlatform public IPlatformHandle Handle => _view; - public IEnumerable Surfaces => new object[] {this}; + public IEnumerable Surfaces { get; } public IRenderer CreateRenderer(IRenderRoot root) { diff --git a/src/Avalonia.Base/Platform/Interop/Utf8Buffer.cs b/src/Avalonia.Base/Platform/Interop/Utf8Buffer.cs index dc7a3e5634..7117576b3b 100644 --- a/src/Avalonia.Base/Platform/Interop/Utf8Buffer.cs +++ b/src/Avalonia.Base/Platform/Interop/Utf8Buffer.cs @@ -1,4 +1,5 @@ using System; +using System.Buffers; using System.Runtime.InteropServices; using System.Text; @@ -6,7 +7,7 @@ namespace Avalonia.Platform.Interop { public class Utf8Buffer : SafeHandle { - private GCHandle _gchandle; + private GCHandle _gcHandle; private byte[] _data; public Utf8Buffer(string s) : base(IntPtr.Zero, true) @@ -14,8 +15,8 @@ namespace Avalonia.Platform.Interop if (s == null) return; _data = Encoding.UTF8.GetBytes(s); - _gchandle = GCHandle.Alloc(_data, GCHandleType.Pinned); - handle = _gchandle.AddrOfPinnedObject(); + _gcHandle = GCHandle.Alloc(_data, GCHandleType.Pinned); + handle = _gcHandle.AddrOfPinnedObject(); } public int ByteLen => _data.Length; @@ -26,7 +27,7 @@ namespace Avalonia.Platform.Interop { handle = IntPtr.Zero; _data = null; - _gchandle.Free(); + _gcHandle.Free(); } return true; } @@ -40,10 +41,18 @@ namespace Avalonia.Platform.Interop return null; int len; for (len = 0; pstr[len] != 0; len++) ; - var bytes = new byte[len]; - Marshal.Copy(s, bytes, 0, len); - return Encoding.UTF8.GetString(bytes, 0, len); + var bytes = ArrayPool.Shared.Rent(len); + + try + { + Marshal.Copy(s, bytes, 0, len); + return Encoding.UTF8.GetString(bytes, 0, len); + } + finally + { + ArrayPool.Shared.Return(bytes); + } } } } diff --git a/src/Avalonia.Controls/Button.cs b/src/Avalonia.Controls/Button.cs index b09d3bddff..d39ea73828 100644 --- a/src/Avalonia.Controls/Button.cs +++ b/src/Avalonia.Controls/Button.cs @@ -64,6 +64,12 @@ namespace Avalonia.Controls public static readonly StyledProperty IsDefaultProperty = AvaloniaProperty.Register(nameof(IsDefault)); + /// + /// Defines the property. + /// + public static readonly StyledProperty IsCancelProperty = + AvaloniaProperty.Register(nameof(IsCancel)); + /// /// Defines the event. /// @@ -84,6 +90,7 @@ namespace Avalonia.Controls FocusableProperty.OverrideDefaultValue(typeof(Button), true); CommandProperty.Changed.Subscribe(CommandChanged); IsDefaultProperty.Changed.Subscribe(IsDefaultChanged); + IsCancelProperty.Changed.Subscribe(IsCancelChanged); PseudoClass