Merge branch '4.4.0' into 4.5.0

This commit is contained in:
Rui Marinho 2020-03-09 14:39:32 +00:00
Родитель 515c4553db 59a8d4d7ea
Коммит 0a84286656
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 924E81B5DB553385
15 изменённых файлов: 599 добавлений и 137 удалений

Просмотреть файл

@ -57,6 +57,7 @@ using Android.Support.V4.Content;
[assembly: ExportRenderer(typeof(Issue7249Switch), typeof(Issue7249SwitchRenderer))]
[assembly: ExportRenderer(typeof(Issue9360.Issue9360NavigationPage), typeof(Issue9360NavigationPageRenderer))]
[assembly: ExportRenderer(typeof(Xamarin.Forms.Controls.GalleryPages.TwoPaneViewGalleries.HingeAngleLabel), typeof(HingeAngleLabelRenderer))]
[assembly: ExportRenderer(typeof(Issue8801.PopupStackLayout), typeof(CustomStackLayoutRenderer))]
#if PRE_APPLICATION_CLASS
#elif FORMS_APPLICATION_ACTIVITY
@ -115,6 +116,24 @@ namespace Xamarin.Forms.ControlGallery.Android
}
}
public class CustomStackLayoutRenderer : VisualElementRenderer<StackLayout>
{
public CustomStackLayoutRenderer(Context context) : base(context)
{
}
public override void AddView(global::Android.Views.View child)
{
if (child is global::Android.Widget.Button head && (head.Text == "Show" || head.Text == "Hide"))
{
base.AddView(child);
}
}
}
public class Issue9360NavigationPageRenderer : Xamarin.Forms.Platform.Android.AppCompat.NavigationPageRenderer
{
public Issue9360NavigationPageRenderer(Context context) : base(context)
@ -145,7 +164,7 @@ namespace Xamarin.Forms.ControlGallery.Android
menuItem.SetIcon(drawable);
}
else
{
{
var drawable = Context.GetDrawable(name);
menuItem.SetIcon(drawable);
}

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 490 B

Просмотреть файл

@ -395,6 +395,12 @@
<ItemGroup>
<LinkDescription Include="LinkDescription.xml" />
</ItemGroup>
<ItemGroup>
<AndroidResource Include="Resources\drawable\coffee2.png">
<Generator>MSBuild:UpdateGeneratedFiles</Generator>
<SubType>Designer</SubType>
</AndroidResource>
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.CSharp.targets" />
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
<Target Name="BeforeBuild">

Просмотреть файл

@ -0,0 +1,312 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
using Xamarin.Forms.CustomAttributes;
using Xamarin.Forms.Internals;
#if UITEST
using Xamarin.UITest;
using NUnit.Framework;
using Xamarin.Forms.Core.UITests;
#endif
namespace Xamarin.Forms.Controls.Issues
{
[Preserve(AllMembers = true)]
[Issue(IssueTracker.Github, 8801, "[Android] Attempt to read from field 'int android.view.ViewGroup$LayoutParams.width' on a null object reference",
PlatformAffected.Android, navigationBehavior: NavigationBehavior.SetApplicationRoot)]
public class Issue8801 : TestContentPage
{
View[] _elements = null;
protected override void Init()
{
_elements = new View[]
{
new Button() { Text = "Edit", HorizontalOptions = LayoutOptions.End, VerticalOptions = LayoutOptions.Start },
new Button() { Text = "Save" , HorizontalOptions = LayoutOptions.End, VerticalOptions = LayoutOptions.Start},
new Button() { Text = "Cancel", HorizontalOptions = LayoutOptions.End, VerticalOptions = LayoutOptions.Start },
new Label() { Text = "Some Label", HorizontalOptions = LayoutOptions.End, VerticalOptions = LayoutOptions.Start },
new Label() { Text = "Success", HorizontalOptions = LayoutOptions.End, VerticalOptions = LayoutOptions.Start },
};
var layout = new PopupStackLayout()
{
};
foreach (View element in _elements)
layout.Children.Add(element);
var grid = new Grid()
{
Children = {
layout
}
};
grid.AddChild(new Label() { Text = "Success" }, 0, 0);
grid.AddChild(layout, 0, 1);
Content = grid;
}
protected override void OnAppearing()
{
base.OnAppearing();
Device.BeginInvokeOnMainThread(() =>
{
foreach (var button in _elements.OfType<Button>())
{
button.Text += "changed";
}
foreach (var label in _elements.OfType<Label>())
{
if (label.Text != "Success")
label.Text += "changed";
}
});
}
public interface IViewPositionService
{
Point GetRelativePosition(VisualElement subView, VisualElement parent);
}
public class PopupStackLayout : StackLayout, INotifyPropertyChanged
{
private static readonly Guid PageRootGridId = Guid.NewGuid();
private readonly Guid ShowButtonId = Guid.NewGuid();
private readonly IViewPositionService viewPositionService;
private readonly StackLayout popupStack;
private ContentPage rootPage;
private Button showButton;
public PopupStackLayout()
{
this.viewPositionService = DependencyService.Get<IViewPositionService>();
this.BackgroundColor = Color.Red;
showButton = new Button()
{
Text = "Show",
AutomationId = ShowButtonId.ToString(),
Command = new Command(ImageButtonCommandAsync)
};
popupStack = new StackLayout()
{
BindingContext = this.BindingContext,
AutomationId = Guid.NewGuid().ToString(),
BackgroundColor = Color.Blue,
IsVisible = false,
Margin = this.Margin,
HorizontalOptions = LayoutOptions.Start,
VerticalOptions = LayoutOptions.Start,
Orientation = this.Orientation,
WidthRequest = Device.RuntimePlatform == Device.UWP ? 20 : 50,
};
this.SetBinding(HeightRequestProperty, new Binding(nameof(Height), BindingMode.OneWay, source: showButton));
this.SetBinding(WidthRequestProperty, new Binding(nameof(Width), BindingMode.OneWay, source: showButton));
this.Children.Insert(0, showButton);
}
private bool isOpen = false;
public bool IsOpen
{
get
{
return this.isOpen;
}
set
{
if (value != this.isOpen)
{
this.isOpen = value;
NotifyPropertyChanged();
}
}
}
public async Task CloseAsync()
{
if (popupStack.IsVisible)
{
await popupStack.FadeTo(0, 100, Easing.Linear);
popupStack.IsVisible = false;
IsOpen = false;
}
}
protected override SizeRequest OnMeasure(double widthConstraint, double heightConstraint)
{
var sizeRequest = base.OnMeasure(widthConstraint, heightConstraint);
PositionStack();
return sizeRequest;
}
protected override void OnChildAdded(Element child)
{
if (child != showButton && child is Button button)
{
if (Device.RuntimePlatform == Device.Android)
{
button.Clicked -= PopupStackLayout_Clicked;
button.Clicked += PopupStackLayout_Clicked;
}
popupStack.Children.Add((View)child);
}
else
{
base.OnChildAdded(child);
}
}
private async void PopupStackLayout_Clicked(object sender, EventArgs e)
{
await popupStack.FadeTo(0, 50, Easing.Linear);
popupStack.IsVisible = false;
popupStack.IsVisible = true;
await popupStack.FadeTo(1, 50, Easing.Linear);
}
protected override void LayoutChildren(double x, double y, double width, double height)
{
if (rootPage == null)
{
var page = Navigation.NavigationStack.LastOrDefault();
rootPage = GetRootPage(page);
}
if (rootPage != null)
{
if (rootPage.Content.AutomationId != PageRootGridId.ToString())
{
var rootGrid = new Grid() { AutomationId = PageRootGridId.ToString() };
var content = rootPage.Content;
rootPage.Content = null;
rootGrid.Children.Add(content);
content.Parent = rootGrid;
rootGrid.Children.Add(popupStack);
popupStack.Parent = rootGrid;
rootPage.Content = rootGrid;
rootGrid.Parent = rootPage;
rootGrid.RaiseChild(popupStack);
}
else
{
var rootGrid = rootPage.Content as Grid;
popupStack.Layout(new Rectangle(x, y, popupStack.WidthRequest, height));
rootGrid.Children.Add(popupStack);
popupStack.Parent = rootGrid;
rootGrid.RaiseChild(popupStack);
}
}
base.LayoutChildren(x, y, width, height);
}
private async void ImageButtonCommandAsync()
{
if (popupStack.IsVisible)
{
showButton.Text = "Show";
await CloseAsync();
}
else
{
// ((Grid)popupStack.Parent).Children[0].IsVisible = false;
showButton.Text = "Hide";
PositionStack();
popupStack.Opacity = 0;
popupStack.IsVisible = true;
IsOpen = true;
await popupStack.FadeTo(1, 100, Easing.Linear);
}
}
private void PositionStack()
{
if (rootPage == null)
{
var page = Navigation.NavigationStack.LastOrDefault();
if (page == null)
{
page = Application.Current.MainPage;
}
rootPage = GetRootPage(page);
}
if (rootPage != null)
{
var newPos = viewPositionService.GetRelativePosition(this, rootPage);
popupStack.TranslateTo(newPos.X - popupStack.WidthRequest, newPos.Y, 1, null);
}
}
private ContentPage GetRootPage(Page page)
{
if (page is MasterDetailPage mdPage)
{
return GetRootPage(mdPage.Detail);
}
else if (page is NavigationPage navPage)
{
return GetRootPage(navPage.CurrentPage);
}
else if (page is TabbedPage tabPage)
{
return GetRootPage(tabPage.CurrentPage);
}
else if (page is CarouselPage carouselPage)
{
return GetRootPage(carouselPage.CurrentPage);
}
if (page is ContentPage cPage)
{
return cPage;
}
return null;
}
public new event PropertyChangedEventHandler PropertyChanged;
private void NotifyPropertyChanged([CallerMemberName] String propertyName = "")
{
if (PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
}
}
#if UITEST && __ANDROID__
[Test]
public void NotAddingElementsNativelyDoesntCrashAndroid()
{
RunningApp.WaitForElement("Success");
}
#endif
}
}

Просмотреть файл

@ -0,0 +1,57 @@
using Xamarin.Forms.CustomAttributes;
using Xamarin.Forms.Internals;
#if UITEST
using Xamarin.UITest;
using NUnit.Framework;
using Xamarin.Forms.Core.UITests;
#endif
namespace Xamarin.Forms.Controls.Issues
{
[Preserve(AllMembers = true)]
[Issue(IssueTracker.Github, 9054, "[Bug] ImageButton.Aspect Property is always Fill",
PlatformAffected.iOS)]
#if UITEST
[NUnit.Framework.Category(UITestCategories.ImageButton)]
[NUnit.Framework.Category(UITestCategories.ManualReview)]
#endif
public class Issue9054 : TestContentPage
{
protected override void Init()
{
StackLayout stackLayout = new StackLayout();
string imageSource = "coffee.png";
ImageButton imageButton1 = new ImageButton()
{
Source = imageSource,
Aspect = Aspect.AspectFill,
AutomationId = "TestImage"
};
ImageButton imageButton2 = new ImageButton()
{
Source = imageSource,
Aspect = Aspect.AspectFit,
AutomationId = "TestImage"
};
ImageButton imageButton3 = new ImageButton()
{
Source = imageSource,
Aspect = Aspect.Fill,
AutomationId = "TestImage"
};
stackLayout.Children.Add(new Label() { Text = $"Verify Image Button Aspects Are Working" });
stackLayout.Children.Add(new Label() { Text = $"{imageButton1.Aspect}" });
stackLayout.Children.Add(imageButton1);
stackLayout.Children.Add(new Label() { Text = $"{imageButton2.Aspect}" });
stackLayout.Children.Add(imageButton2);
stackLayout.Children.Add(new Label() { Text = $"{imageButton3.Aspect}" });
stackLayout.Children.Add(imageButton3);
Content = stackLayout;
}
}
}

Просмотреть файл

@ -0,0 +1,85 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Text;
using Xamarin.Forms.CustomAttributes;
using Xamarin.Forms.Internals;
#if UITEST
using Xamarin.UITest;
using NUnit.Framework;
using Xamarin.Forms.Core.UITests;
#endif
namespace Xamarin.Forms.Controls.Issues
{
[Preserve(AllMembers = true)]
[Issue(IssueTracker.Github, 9428, "[Android] Swapping out Image on ImageButton can cause measuring issues",
PlatformAffected.Android)]
#if UITEST
[NUnit.Framework.Category(UITestCategories.ListView)]
[NUnit.Framework.Category(UITestCategories.ManualReview)]
#endif
public class Issue9428 : TestContentPage
{
protected override void Init()
{
ImageButton imageButton = new ImageButton()
{
HeightRequest = 200,
WidthRequest = 200,
VerticalOptions = LayoutOptions.CenterAndExpand,
HorizontalOptions = LayoutOptions.CenterAndExpand,
BackgroundColor = Color.Transparent,
AutomationId = "Coffee"
};
VisualStateGroup vsg = new VisualStateGroup()
{
Name = "button",
States =
{
new VisualState()
{
Name = "Normal",
Setters =
{
new Setter()
{
Property = ImageButton.SourceProperty,
Value = "coffee.png"
}
}
},
new VisualState()
{
Name = "Pressed",
Setters =
{
new Setter()
{
Property = ImageButton.SourceProperty,
Value = "coffee2.jpg"
}
}
}
}
};
VisualStateManager.SetVisualStateGroups(imageButton, new VisualStateGroupList()
{
vsg
});
Content = new StackLayout()
{
Children =
{
new Label(){ Text = "Click on the image and it should stay the same size"},
imageButton
}
};
}
}
}

Просмотреть файл

@ -14,6 +14,8 @@
<DependentUpon>Issue3228.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Compile Include="$(MSBuildThisFileDirectory)Issue8801.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Issue9428.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Issue9419.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Issue8262.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Issue8899.cs" />
@ -1270,6 +1272,7 @@
<Compile Include="$(MSBuildThisFileDirectory)Issue9329.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Issue9305.xaml.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Issue9767.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Issue9054.cs" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="$(MSBuildThisFileDirectory)Bugzilla22229.xaml">
@ -1839,4 +1842,4 @@
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
</EmbeddedResource>
</ItemGroup>
</Project>
</Project>

Просмотреть файл

@ -195,13 +195,11 @@ namespace Xamarin.Forms.Platform.Android
{
ElementChanged?.Invoke(this, new VisualElementChangedEventArgs(e.OldElement, e.NewElement));
}
public override void Draw(Canvas canvas)
{
if (Element == null)
return;
var backgroundDrawable = _backgroundTracker?.BackgroundDrawable;
RectF drawableBounds = null;
@ -210,12 +208,11 @@ namespace Xamarin.Forms.Platform.Android
if ((int)Forms.SdkInt >= 18 && backgroundDrawable != null)
{
var outlineBounds = backgroundDrawable.GetPaddingBounds(canvas.Width, canvas.Height);
var width = (float)MeasuredWidth;
var height = (float)MeasuredHeight;
var width = (float)canvas.Width;
var height = (float)canvas.Height;
var widthRatio = 1f;
var heightRatio = 1f;
if (Element.Aspect == Aspect.AspectFill && OnThisPlatform().GetIsShadowEnabled())
Internals.Log.Warning(nameof(ImageButtonRenderer), "AspectFill isn't fully supported when using shadows. Image may be clipped incorrectly to Border");

Просмотреть файл

@ -257,7 +257,7 @@ namespace Xamarin.Forms.Platform.Android
bool UpdateTextAndImage()
{
if (_disposed || _renderer == null || _element == null)
if (_disposed || _renderer == null || _element == null || View?.LayoutParameters == null)
return false;
AppCompatButton view = View;

Просмотреть файл

@ -87,7 +87,7 @@ namespace Xamarin.Forms.Platform.Android.FastRenderers
{
((IElementController)Button).SetValueFromRenderer(VisualElement.IsFocusedPropertyKey, hasFocus);
}
SizeRequest IVisualElementRenderer.GetDesiredSize(int widthConstraint, int heightConstraint)
{
if (_isDisposed)
@ -96,15 +96,17 @@ namespace Xamarin.Forms.Platform.Android.FastRenderers
}
var hint = Control.Hint;
bool setHint = Control.LayoutParameters != null;
if (!string.IsNullOrWhiteSpace(hint))
if (!string.IsNullOrWhiteSpace(hint) && setHint)
{
Control.Hint = string.Empty;
}
var result = _buttonLayoutManager.GetDesiredSize(widthConstraint, heightConstraint);
Control.Hint = hint;
if(setHint)
Control.Hint = hint;
return result;
}
@ -243,6 +245,12 @@ namespace Xamarin.Forms.Platform.Android.FastRenderers
protected virtual void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
{
if(Control?.LayoutParameters == null)
{
ElementPropertyChanged?.Invoke(this, e);
return;
}
if (e.PropertyName == Button.TextColorProperty.PropertyName)
{
UpdateTextColor();

Просмотреть файл

@ -230,6 +230,12 @@ namespace Xamarin.Forms.Platform.Android.FastRenderers
{
ElementPropertyChanged?.Invoke(this, e);
if (Control?.LayoutParameters == null)
{
return;
}
if (e.PropertyName == Frame.HasShadowProperty.PropertyName)
UpdateShadow();
else if (e.PropertyName == VisualElement.BackgroundColorProperty.PropertyName)

Просмотреть файл

@ -13,53 +13,53 @@ using AViewCompat = Android.Support.V4.View.ViewCompat;
namespace Xamarin.Forms.Platform.Android.FastRenderers
{
public static class ImageElementManager
{
public static void Init(IVisualElementRenderer renderer)
{
renderer.ElementPropertyChanged += OnElementPropertyChanged;
renderer.ElementChanged += OnElementChanged;
public static class ImageElementManager
{
public static void Init(IVisualElementRenderer renderer)
{
renderer.ElementPropertyChanged += OnElementPropertyChanged;
renderer.ElementChanged += OnElementChanged;
if (renderer is ILayoutChanges layoutChanges)
layoutChanges.LayoutChange += OnLayoutChange;
}
if (renderer is ILayoutChanges layoutChanges)
layoutChanges.LayoutChange += OnLayoutChange;
}
static void OnLayoutChange(object sender, global::Android.Views.View.LayoutChangeEventArgs e)
{
if (sender is IVisualElementRenderer renderer && renderer.View is ImageView imageView)
AViewCompat.SetClipBounds(imageView, imageView.GetScaleType() == AScaleType.CenterCrop ? new ARect(0, 0, e.Right - e.Left, e.Bottom - e.Top) : null);
}
static void OnLayoutChange(object sender, global::Android.Views.View.LayoutChangeEventArgs e)
{
if (sender is IVisualElementRenderer renderer && renderer.View is ImageView imageView)
AViewCompat.SetClipBounds(imageView, imageView.GetScaleType() == AScaleType.CenterCrop ? new ARect(0, 0, e.Right - e.Left, e.Bottom - e.Top) : null);
}
public static void Dispose(IVisualElementRenderer renderer)
{
renderer.ElementPropertyChanged -= OnElementPropertyChanged;
renderer.ElementChanged -= OnElementChanged;
if (renderer is ILayoutChanges layoutChanges)
layoutChanges.LayoutChange -= OnLayoutChange;
public static void Dispose(IVisualElementRenderer renderer)
{
renderer.ElementPropertyChanged -= OnElementPropertyChanged;
renderer.ElementChanged -= OnElementChanged;
if (renderer is ILayoutChanges layoutChanges)
layoutChanges.LayoutChange -= OnLayoutChange;
if (renderer is IImageRendererController imageRenderer)
imageRenderer.SetFormsAnimationDrawable(null);
if (renderer is IImageRendererController imageRenderer)
imageRenderer.SetFormsAnimationDrawable(null);
if (renderer.View is ImageView imageView)
{
imageView.SetImageDrawable(null);
imageView.Reset();
}
}
if (renderer.View is ImageView imageView)
{
imageView.SetImageDrawable(null);
imageView.Reset();
}
}
async static void OnElementChanged(object sender, VisualElementChangedEventArgs e)
{
var renderer = (sender as IVisualElementRenderer);
var view = renderer.View as ImageView;
var newImageElementManager = e.NewElement as IImageElement;
var oldImageElementManager = e.OldElement as IImageElement;
var rendererController = renderer as IImageRendererController;
async static void OnElementChanged(object sender, VisualElementChangedEventArgs e)
{
var renderer = (sender as IVisualElementRenderer);
var view = renderer.View as ImageView;
var newImageElementManager = e.NewElement as IImageElement;
var oldImageElementManager = e.OldElement as IImageElement;
var rendererController = renderer as IImageRendererController;
if (rendererController.IsDisposed)
return;
await TryUpdateBitmap(rendererController, view, newImageElementManager, oldImageElementManager);
if (rendererController.IsDisposed)
return;
@ -68,25 +68,31 @@ namespace Xamarin.Forms.Platform.Android.FastRenderers
if (rendererController.IsDisposed)
return;
ElevationHelper.SetElevation(view, renderer.Element);
}
ElevationHelper.SetElevation(view, renderer.Element);
}
async static void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
async static void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
{
var renderer = (sender as IVisualElementRenderer);
var ImageElementManager = (IImageElement)renderer.Element;
var imageController = (IImageController)renderer.Element;
if (e.IsOneOf(Image.SourceProperty, Button.ImageSourceProperty))
{
await TryUpdateBitmap(renderer as IImageRendererController, (ImageView)renderer.View, (IImageElement)renderer.Element).ConfigureAwait(false);
}
else if (e.Is(Image.AspectProperty))
{
UpdateAspect(renderer as IImageRendererController, (ImageView)renderer.View, (IImageElement)renderer.Element);
}
else if (e.Is(Image.IsAnimationPlayingProperty))
if (renderer?.View?.LayoutParameters == null)
{
return;
}
if (e.IsOneOf(Image.SourceProperty, Button.ImageSourceProperty))
{
await TryUpdateBitmap(renderer as IImageRendererController, (ImageView)renderer.View, (IImageElement)renderer.Element).ConfigureAwait(false);
}
else if (e.Is(Image.AspectProperty))
{
UpdateAspect(renderer as IImageRendererController, (ImageView)renderer.View, (IImageElement)renderer.Element);
}
else if (e.Is(Image.IsAnimationPlayingProperty))
await StartStopAnimation(renderer, imageController, ImageElementManager).ConfigureAwait(false);
}
@ -116,12 +122,12 @@ namespace Xamarin.Forms.Platform.Android.FastRenderers
}
async static Task TryUpdateBitmap(IImageRendererController rendererController, ImageView Control, IImageElement newImage, IImageElement previous = null)
{
if (newImage == null || rendererController.IsDisposed)
{
return;
}
async static Task TryUpdateBitmap(IImageRendererController rendererController, ImageView Control, IImageElement newImage, IImageElement previous = null)
{
if (newImage == null || rendererController.IsDisposed)
{
return;
}
if (Control.Drawable is FormsAnimationDrawable currentAnimation)
{
@ -133,23 +139,23 @@ namespace Xamarin.Forms.Platform.Android.FastRenderers
rendererController.SetFormsAnimationDrawable(null);
}
try
{
await Control.UpdateBitmap(newImage, previous).ConfigureAwait(false);
}
catch (Exception ex)
{
Log.Warning(nameof(ImageElementManager), "Error loading image: {0}", ex);
}
finally
{
if (newImage is IImageController imageController)
imageController.SetIsLoading(false);
}
try
{
await Control.UpdateBitmap(newImage, previous).ConfigureAwait(false);
}
catch (Exception ex)
{
Log.Warning(nameof(ImageElementManager), "Error loading image: {0}", ex);
}
finally
{
if (newImage is IImageController imageController)
imageController.SetIsLoading(false);
}
if (rendererController.IsDisposed)
return;
if (Control.Drawable is FormsAnimationDrawable updatedAnimation)
{
rendererController.SetFormsAnimationDrawable(updatedAnimation);
@ -166,14 +172,14 @@ namespace Xamarin.Forms.Platform.Android.FastRenderers
}
static void UpdateAspect(IImageRendererController rendererController, ImageView Control, IImageElement newImage, IImageElement previous = null)
{
if (newImage == null || rendererController.IsDisposed)
{
return;
}
{
if (newImage == null || rendererController.IsDisposed)
{
return;
}
ImageView.ScaleType type = newImage.Aspect.ToScaleType();
Control.SetScaleType(type);
}
}
ImageView.ScaleType type = newImage.Aspect.ToScaleType();
Control.SetScaleType(type);
}
}
}

Просмотреть файл

@ -121,14 +121,16 @@ namespace Xamarin.Forms.Platform.Android.FastRenderers
//We need to clear the Hint or else it will interfere with the sizing of the Label
var hint = Control.Hint;
if (!string.IsNullOrEmpty(hint))
bool setHint = Control.LayoutParameters != null;
if (!string.IsNullOrEmpty(hint) && setHint)
Control.Hint = string.Empty;
Measure(widthConstraint, heightConstraint);
var result = new SizeRequest(new Size(MeasuredWidth, MeasuredHeight), new Size());
//Set Hint back after sizing
Control.Hint = hint;
if(setHint)
Control.Hint = hint;
result.Minimum = new Size(Math.Min(Context.ToPixels(10), result.Request.Width), result.Request.Height);
@ -274,6 +276,9 @@ namespace Xamarin.Forms.Platform.Android.FastRenderers
{
ElementPropertyChanged?.Invoke(this, e);
if (Control?.LayoutParameters == null)
return;
if (e.PropertyName == Label.HorizontalTextAlignmentProperty.PropertyName || e.PropertyName == Label.VerticalTextAlignmentProperty.PropertyName)
UpdateGravity();
else if (e.PropertyName == Label.TextColorProperty.PropertyName ||

Просмотреть файл

@ -115,50 +115,7 @@ namespace Xamarin.Forms.Platform.iOS
protected override UIButton CreateNativeControl()
{
return new FormsButton();
}
class FormsButton : UIButton
{
UIImageView _imageView;
public FormsButton() : base()
{
}
public override void LayoutSubviews()
{
base.LayoutSubviews();
}
public override void AddSubview(UIView view)
{
base.AddSubview(view);
}
public override void InsertSubview(UIView view, nint atIndex)
{
base.InsertSubview(view, atIndex);
}
public override UIImageView ImageView
{
get
{
if (_imageView == null)
{
_imageView = new FormsUIImageView();
}
return _imageView;
}
}
//[Export("imageViewClass")]
//public static ObjCRuntime.Class imageViewClass()
//{
// return new ObjCRuntime.Class(typeof(FormsUIImageView));
//}
return new UIButton();
}
protected override void SetAccessibilityLabel()

Просмотреть файл

@ -203,12 +203,13 @@ Global
Xamarin.Forms.Controls.Issues\Xamarin.Forms.Controls.Issues.Shared\Xamarin.Forms.Controls.Issues.Shared.projitems*{0a39a74b-6f7a-4d41-84f2-b0ccdce899df}*SharedItemsImports = 4
Xamarin.Forms.Core.UITests.Shared\Xamarin.Forms.Core.UITests.projitems*{0a39a74b-6f7a-4d41-84f2-b0ccdce899df}*SharedItemsImports = 4
Xamarin.Forms.Controls.Issues\Xamarin.Forms.Controls.Issues.Shared\Xamarin.Forms.Controls.Issues.Shared.projitems*{0f0db9cc-ea65-429c-9363-38624bf8f49c}*SharedItemsImports = 13
Xamarin.Flex\Xamarin.Flex.projitems*{57b8b73d-c3b5-4c42-869e-7b2f17d354ac}*SharedItemsImports = 5
Xamarin.Forms.Controls.Issues\Xamarin.Forms.Controls.Issues.Shared\Xamarin.Forms.Controls.Issues.Shared.projitems*{9db0cabb-24cc-4538-88ec-6e0a0fe40248}*SharedItemsImports = 4
Xamarin.Forms.Core.UITests.Shared\Xamarin.Forms.Core.UITests.projitems*{9db0cabb-24cc-4538-88ec-6e0a0fe40248}*SharedItemsImports = 4
Xamarin.Forms.Controls.Issues\Xamarin.Forms.Controls.Issues.Shared\Xamarin.Forms.Controls.Issues.Shared.projitems*{a34ebe01-25bf-4e69-a2dc-2288dc625541}*SharedItemsImports = 4
Xamarin.Forms.Core.UITests.Shared\Xamarin.Forms.Core.UITests.projitems*{a34ebe01-25bf-4e69-a2dc-2288dc625541}*SharedItemsImports = 4
Xamarin.Flex\Xamarin.Flex.projitems*{a6703c7d-d362-452a-a7a5-73771194d38c}*SharedItemsImports = 13
Xamarin.Forms.Controls.Issues\Xamarin.Forms.Controls.Issues.Shared\Xamarin.Forms.Controls.Issues.Shared.projitems*{cb9c96ce-125c-4a68-b6a1-c3ff1fbf93e1}*SharedItemsImports = 4
Xamarin.Forms.Controls.Issues\Xamarin.Forms.Controls.Issues.Shared\Xamarin.Forms.Controls.Issues.Shared.projitems*{cb9c96ce-125c-4a68-b6a1-c3ff1fbf93e1}*SharedItemsImports = 5
Xamarin.Forms.Core.UITests.Shared\Xamarin.Forms.Core.UITests.projitems*{e175485b-3c8c-47d7-8dd5-f7fed627eb25}*SharedItemsImports = 13
Xamarin.Forms.Controls.Issues\Xamarin.Forms.Controls.Issues.Shared\Xamarin.Forms.Controls.Issues.Shared.projitems*{eadd8100-b3ae-4a31-92c4-267a64a1c6eb}*SharedItemsImports = 4
Xamarin.Forms.Core.UITests.Shared\Xamarin.Forms.Core.UITests.projitems*{eadd8100-b3ae-4a31-92c4-267a64a1c6eb}*SharedItemsImports = 4