From f0f147d6c63705f980d22c744020a9f90283c3d7 Mon Sep 17 00:00:00 2001 From: Shane Neuville Date: Thu, 21 Mar 2019 10:46:55 -0600 Subject: [PATCH] [Android] Remove changes to IVisualElementRenderer so it remains backwards compatible (#5619) * [Android] Remove changes to IVisualElementRenderer so it remains backwards compatible (#5398) * return IVisualElementRenderer to previous state * set to internal * remove extra change * - ToUIBarButtonItem abi fix * - page gallery * - remove tizen from iphone configuration --- .../PagesGallery.iOS/PagesGallery.iOS.csproj | 48 +++------------ PagesGallery/PagesGallery.iOS/packages.config | 61 ------------------- ...amarin.Forms.ControlGallery.Android.csproj | 4 -- .../AppCompat/ImageButtonRenderer.cs | 3 +- .../FastRenderers/ImageElementManager.cs | 7 ++- .../FastRenderers/ImageRenderer.cs | 3 +- .../ILayoutChanges.cs | 10 +++ .../IVisualElementRenderer.cs | 2 - .../Xamarin.Forms.Platform.Android.csproj | 1 + .../Extensions/ToolbarItemExtensions.cs | 11 +++- Xamarin.Forms.sln | 31 +++++----- 11 files changed, 50 insertions(+), 131 deletions(-) delete mode 100644 PagesGallery/PagesGallery.iOS/packages.config create mode 100644 Xamarin.Forms.Platform.Android/ILayoutChanges.cs diff --git a/PagesGallery/PagesGallery.iOS/PagesGallery.iOS.csproj b/PagesGallery/PagesGallery.iOS/PagesGallery.iOS.csproj index 5d6c5071c..ee6341ec7 100644 --- a/PagesGallery/PagesGallery.iOS/PagesGallery.iOS.csproj +++ b/PagesGallery/PagesGallery.iOS/PagesGallery.iOS.csproj @@ -72,7 +72,6 @@ - @@ -104,6 +103,8 @@ {39B3457F-01D8-43D0-8E84-D8C4F73CF48D} Xamarin.Forms.Platform.iOS (Forwarders) + false + false @@ -124,54 +125,19 @@ - - ..\..\packages\Microsoft.Azure.Mobile.Client.4.0.2\lib\xamarinios10\Microsoft.Azure.Mobile.Client.dll - - - ..\..\packages\Newtonsoft.Json.10.0.3\lib\netstandard1.3\Newtonsoft.Json.dll - - - ..\..\packages\PCLCrypto.2.0.147\lib\xamarinios10\PCLCrypto.dll - - - ..\..\packages\PInvoke.BCrypt.0.3.2\lib\portable-net45+win+wpa81+MonoAndroid10+xamarinios10+MonoTouch10\PInvoke.BCrypt.dll - - - ..\..\packages\PInvoke.Kernel32.0.3.2\lib\portable-net45+win+wpa81+MonoAndroid10+xamarinios10+MonoTouch10\PInvoke.Kernel32.dll - - - ..\..\packages\PInvoke.NCrypt.0.3.2\lib\portable-net45+win+wpa81+MonoAndroid10+xamarinios10+MonoTouch10\PInvoke.NCrypt.dll - - - ..\..\packages\PInvoke.Windows.Core.0.3.2\lib\portable-net45+win+wpa81+MonoAndroid10+xamarinios10+MonoTouch10\PInvoke.Windows.Core.dll - - - ..\..\packages\Validation.2.2.8\lib\dotnet\Validation.dll - + + + + - - - - <__XFBuildTasksLocation>$(_XFBuildTasksLocation) - <__XFBuildTasksLocation Condition="'$(__XFBuildTasksLocation)' == '' AND '$(MSBuildRuntimeType)' == 'Core'">..\..\.nuspec\netstandard2.0\ - <__XFBuildTasksLocation Condition="'$(__XFBuildTasksLocation)' == ''">..\..\.nuspec\net46\ - - - - - - This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - - - + \ No newline at end of file diff --git a/PagesGallery/PagesGallery.iOS/packages.config b/PagesGallery/PagesGallery.iOS/packages.config deleted file mode 100644 index 88cce26d6..000000000 --- a/PagesGallery/PagesGallery.iOS/packages.config +++ /dev/null @@ -1,61 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Xamarin.Forms.ControlGallery.Android/Xamarin.Forms.ControlGallery.Android.csproj b/Xamarin.Forms.ControlGallery.Android/Xamarin.Forms.ControlGallery.Android.csproj index a6d882f51..2fd014ccb 100644 --- a/Xamarin.Forms.ControlGallery.Android/Xamarin.Forms.ControlGallery.Android.csproj +++ b/Xamarin.Forms.ControlGallery.Android/Xamarin.Forms.ControlGallery.Android.csproj @@ -154,10 +154,6 @@ - - {5EB6EB6B-A412-4F41-A89B-D7C9AAD237F2} - PagesGallery.Droid - {6e53feb1-1100-46ae-8013-17bba35cc197} Xamarin.Forms.Platform.Android (Forwarders) diff --git a/Xamarin.Forms.Platform.Android/AppCompat/ImageButtonRenderer.cs b/Xamarin.Forms.Platform.Android/AppCompat/ImageButtonRenderer.cs index 0bfcf6b29..a6096488e 100644 --- a/Xamarin.Forms.Platform.Android/AppCompat/ImageButtonRenderer.cs +++ b/Xamarin.Forms.Platform.Android/AppCompat/ImageButtonRenderer.cs @@ -21,7 +21,8 @@ namespace Xamarin.Forms.Platform.Android IImageRendererController, AView.IOnFocusChangeListener, AView.IOnClickListener, - AView.IOnTouchListener + AView.IOnTouchListener, + ILayoutChanges { bool _inputTransparent; bool _disposed; diff --git a/Xamarin.Forms.Platform.Android/FastRenderers/ImageElementManager.cs b/Xamarin.Forms.Platform.Android/FastRenderers/ImageElementManager.cs index c620c25fc..c8633f853 100644 --- a/Xamarin.Forms.Platform.Android/FastRenderers/ImageElementManager.cs +++ b/Xamarin.Forms.Platform.Android/FastRenderers/ImageElementManager.cs @@ -15,7 +15,9 @@ namespace Xamarin.Forms.Platform.Android.FastRenderers { renderer.ElementPropertyChanged += OnElementPropertyChanged; renderer.ElementChanged += OnElementChanged; - renderer.LayoutChange += OnLayoutChange; + + if(renderer is ILayoutChanges layoutChanges) + layoutChanges.LayoutChange += OnLayoutChange; } static void OnLayoutChange(object sender, global::Android.Views.View.LayoutChangeEventArgs e) @@ -28,7 +30,8 @@ namespace Xamarin.Forms.Platform.Android.FastRenderers { renderer.ElementPropertyChanged -= OnElementPropertyChanged; renderer.ElementChanged -= OnElementChanged; - renderer.LayoutChange -= OnLayoutChange; + if (renderer is ILayoutChanges layoutChanges) + layoutChanges.LayoutChange -= OnLayoutChange; } async static void OnElementChanged(object sender, VisualElementChangedEventArgs e) diff --git a/Xamarin.Forms.Platform.Android/FastRenderers/ImageRenderer.cs b/Xamarin.Forms.Platform.Android/FastRenderers/ImageRenderer.cs index ea22b1fe3..abc0a2506 100644 --- a/Xamarin.Forms.Platform.Android/FastRenderers/ImageRenderer.cs +++ b/Xamarin.Forms.Platform.Android/FastRenderers/ImageRenderer.cs @@ -10,7 +10,8 @@ using Xamarin.Forms.Internals; namespace Xamarin.Forms.Platform.Android.FastRenderers { - internal sealed class ImageRenderer : AImageView, IVisualElementRenderer, IImageRendererController, IViewRenderer, ITabStop + internal sealed class ImageRenderer : AImageView, IVisualElementRenderer, IImageRendererController, IViewRenderer, ITabStop, + ILayoutChanges { bool _disposed; Image _element; diff --git a/Xamarin.Forms.Platform.Android/ILayoutChanges.cs b/Xamarin.Forms.Platform.Android/ILayoutChanges.cs new file mode 100644 index 000000000..a2455a4df --- /dev/null +++ b/Xamarin.Forms.Platform.Android/ILayoutChanges.cs @@ -0,0 +1,10 @@ +using System; +using ALayoutChangeEventArgs = Android.Views.View.LayoutChangeEventArgs; + +namespace Xamarin.Forms.Platform.Android +{ + internal interface ILayoutChanges + { + event EventHandler LayoutChange; + } +} \ No newline at end of file diff --git a/Xamarin.Forms.Platform.Android/IVisualElementRenderer.cs b/Xamarin.Forms.Platform.Android/IVisualElementRenderer.cs index 195f0ef7c..306644046 100644 --- a/Xamarin.Forms.Platform.Android/IVisualElementRenderer.cs +++ b/Xamarin.Forms.Platform.Android/IVisualElementRenderer.cs @@ -28,7 +28,5 @@ namespace Xamarin.Forms.Platform.Android void SetLabelFor(int? id); void UpdateLayout(); - - event EventHandler LayoutChange; } } \ No newline at end of file diff --git a/Xamarin.Forms.Platform.Android/Xamarin.Forms.Platform.Android.csproj b/Xamarin.Forms.Platform.Android/Xamarin.Forms.Platform.Android.csproj index 162b6075c..1ca5c0950 100644 --- a/Xamarin.Forms.Platform.Android/Xamarin.Forms.Platform.Android.csproj +++ b/Xamarin.Forms.Platform.Android/Xamarin.Forms.Platform.Android.csproj @@ -113,6 +113,7 @@ + diff --git a/Xamarin.Forms.Platform.iOS/Extensions/ToolbarItemExtensions.cs b/Xamarin.Forms.Platform.iOS/Extensions/ToolbarItemExtensions.cs index 13c1148ef..63106570d 100644 --- a/Xamarin.Forms.Platform.iOS/Extensions/ToolbarItemExtensions.cs +++ b/Xamarin.Forms.Platform.iOS/Extensions/ToolbarItemExtensions.cs @@ -9,9 +9,16 @@ namespace Xamarin.Forms.Platform.iOS { public static class ToolbarItemExtensions { - public static UIBarButtonItem ToUIBarButtonItem(this ToolbarItem item, bool forceName = false) + public static UIKit.UIBarButtonItem ToUIBarButtonItem(this Xamarin.Forms.ToolbarItem item, bool forceName) { - return item.Order == ToolbarItemOrder.Secondary ? new SecondaryToolbarItem(item) : (UIBarButtonItem)new PrimaryToolbarItem(item, forceName); + return ToUIBarButtonItem(item, false, false); + } + + public static UIBarButtonItem ToUIBarButtonItem(this ToolbarItem item, bool forceName = false, bool forcePrimary = false) + { + if (item.Order == ToolbarItemOrder.Secondary && !forcePrimary) + return new SecondaryToolbarItem(item); + return new PrimaryToolbarItem(item, forceName); } sealed class PrimaryToolbarItem : UIBarButtonItem diff --git a/Xamarin.Forms.sln b/Xamarin.Forms.sln index 68051a49e..7aac1b0f5 100644 --- a/Xamarin.Forms.sln +++ b/Xamarin.Forms.sln @@ -172,7 +172,7 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Xamarin.Forms.Xaml.Design", EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "XFCorePostProcessor.Tasks", "XFCorePostProcessor.Tasks\XFCorePostProcessor.Tasks.csproj", "{5BBF4A3F-4AD1-47FD-B250-05EA793F939D}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Xamarin.Forms.Platform.Tizen (Forwarders)", "Stubs\Xamarin.Forms.Platform.Tizen\Xamarin.Forms.Platform.Tizen (Forwarders).csproj", "{39B3457F-01D8-43D0-8E84-D8C4F73CF48E}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Xamarin.Forms.Platform.Tizen (Forwarders)", "Stubs\Xamarin.Forms.Platform.Tizen\Xamarin.Forms.Platform.Tizen (Forwarders).csproj", "{39B3457F-01D8-43D0-8E84-D8C4F73CF48E}" ProjectSection(ProjectDependencies) = postProject {83790029-272E-45AF-A41D-E7716684E5B8} = {83790029-272E-45AF-A41D-E7716684E5B8} EndProjectSection @@ -316,6 +316,7 @@ Global {1346A7F1-4457-4BB4-A371-2C8E28BBD53E}.Release|x86.Build.0 = Release|Any CPU {1346A7F1-4457-4BB4-A371-2C8E28BBD53E}.Release|x86.Deploy.0 = Release|Any CPU {4B14D295-C09B-4C38-B880-7CC768E50585}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {4B14D295-C09B-4C38-B880-7CC768E50585}.Debug|Any CPU.Build.0 = Debug|Any CPU {4B14D295-C09B-4C38-B880-7CC768E50585}.Debug|ARM.ActiveCfg = Debug|Any CPU {4B14D295-C09B-4C38-B880-7CC768E50585}.Debug|ARM.Build.0 = Debug|Any CPU {4B14D295-C09B-4C38-B880-7CC768E50585}.Debug|iPhone.ActiveCfg = Debug|Any CPU @@ -337,7 +338,6 @@ Global {4B14D295-C09B-4C38-B880-7CC768E50585}.Release|x64.Build.0 = Release|Any CPU {4B14D295-C09B-4C38-B880-7CC768E50585}.Release|x86.ActiveCfg = Release|Any CPU {4B14D295-C09B-4C38-B880-7CC768E50585}.Release|x86.Build.0 = Release|Any CPU - {4B14D295-C09B-4C38-B880-7CC768E50585}.Debug|Any CPU.Build.0 = Debug|Any CPU {57B8B73D-C3B5-4C42-869E-7B2F17D354AC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {57B8B73D-C3B5-4C42-869E-7B2F17D354AC}.Debug|Any CPU.Build.0 = Debug|Any CPU {57B8B73D-C3B5-4C42-869E-7B2F17D354AC}.Debug|ARM.ActiveCfg = Debug|Any CPU @@ -1362,7 +1362,6 @@ Global {AFF3AD0D-7181-4551-A29C-8701FE3E6753}.Debug|ARM.ActiveCfg = Debug|Any CPU {AFF3AD0D-7181-4551-A29C-8701FE3E6753}.Debug|ARM.Build.0 = Debug|Any CPU {AFF3AD0D-7181-4551-A29C-8701FE3E6753}.Debug|iPhone.ActiveCfg = Debug|Any CPU - {AFF3AD0D-7181-4551-A29C-8701FE3E6753}.Debug|iPhone.Build.0 = Debug|Any CPU {AFF3AD0D-7181-4551-A29C-8701FE3E6753}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU {AFF3AD0D-7181-4551-A29C-8701FE3E6753}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU {AFF3AD0D-7181-4551-A29C-8701FE3E6753}.Debug|x64.ActiveCfg = Debug|Any CPU @@ -1384,7 +1383,6 @@ Global {8C7F0087-4031-4297-A651-6ED55F7B88BA}.Debug|ARM.ActiveCfg = Debug|Any CPU {8C7F0087-4031-4297-A651-6ED55F7B88BA}.Debug|ARM.Build.0 = Debug|Any CPU {8C7F0087-4031-4297-A651-6ED55F7B88BA}.Debug|iPhone.ActiveCfg = Debug|Any CPU - {8C7F0087-4031-4297-A651-6ED55F7B88BA}.Debug|iPhone.Build.0 = Debug|Any CPU {8C7F0087-4031-4297-A651-6ED55F7B88BA}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU {8C7F0087-4031-4297-A651-6ED55F7B88BA}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU {8C7F0087-4031-4297-A651-6ED55F7B88BA}.Debug|x64.ActiveCfg = Debug|Any CPU @@ -1406,7 +1404,6 @@ Global {C5C1D2BE-DB01-4B2E-BCA5-2C9A9691E3F1}.Debug|ARM.ActiveCfg = Debug|Any CPU {C5C1D2BE-DB01-4B2E-BCA5-2C9A9691E3F1}.Debug|ARM.Build.0 = Debug|Any CPU {C5C1D2BE-DB01-4B2E-BCA5-2C9A9691E3F1}.Debug|iPhone.ActiveCfg = Debug|Any CPU - {C5C1D2BE-DB01-4B2E-BCA5-2C9A9691E3F1}.Debug|iPhone.Build.0 = Debug|Any CPU {C5C1D2BE-DB01-4B2E-BCA5-2C9A9691E3F1}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU {C5C1D2BE-DB01-4B2E-BCA5-2C9A9691E3F1}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU {C5C1D2BE-DB01-4B2E-BCA5-2C9A9691E3F1}.Debug|x64.ActiveCfg = Debug|Any CPU @@ -1520,6 +1517,18 @@ Global {65BC4888-CC59-428A-9B75-540CF1C09480}.Release|x64.Build.0 = Release|Any CPU {65BC4888-CC59-428A-9B75-540CF1C09480}.Release|x86.ActiveCfg = Release|Any CPU {65BC4888-CC59-428A-9B75-540CF1C09480}.Release|x86.Build.0 = Release|Any CPU + {5BBF4A3F-4AD1-47FD-B250-05EA793F939D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {5BBF4A3F-4AD1-47FD-B250-05EA793F939D}.Debug|ARM.ActiveCfg = Debug|Any CPU + {5BBF4A3F-4AD1-47FD-B250-05EA793F939D}.Debug|iPhone.ActiveCfg = Debug|Any CPU + {5BBF4A3F-4AD1-47FD-B250-05EA793F939D}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU + {5BBF4A3F-4AD1-47FD-B250-05EA793F939D}.Debug|x64.ActiveCfg = Debug|Any CPU + {5BBF4A3F-4AD1-47FD-B250-05EA793F939D}.Debug|x86.ActiveCfg = Debug|Any CPU + {5BBF4A3F-4AD1-47FD-B250-05EA793F939D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {5BBF4A3F-4AD1-47FD-B250-05EA793F939D}.Release|ARM.ActiveCfg = Release|Any CPU + {5BBF4A3F-4AD1-47FD-B250-05EA793F939D}.Release|iPhone.ActiveCfg = Release|Any CPU + {5BBF4A3F-4AD1-47FD-B250-05EA793F939D}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU + {5BBF4A3F-4AD1-47FD-B250-05EA793F939D}.Release|x64.ActiveCfg = Release|Any CPU + {5BBF4A3F-4AD1-47FD-B250-05EA793F939D}.Release|x86.ActiveCfg = Release|Any CPU {39B3457F-01D8-43D0-8E84-D8C4F73CF48E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {39B3457F-01D8-43D0-8E84-D8C4F73CF48E}.Debug|Any CPU.Build.0 = Debug|Any CPU {39B3457F-01D8-43D0-8E84-D8C4F73CF48E}.Debug|ARM.ActiveCfg = Debug|Any CPU @@ -1544,18 +1553,6 @@ Global {39B3457F-01D8-43D0-8E84-D8C4F73CF48E}.Release|x64.Build.0 = Release|Any CPU {39B3457F-01D8-43D0-8E84-D8C4F73CF48E}.Release|x86.ActiveCfg = Release|Any CPU {39B3457F-01D8-43D0-8E84-D8C4F73CF48E}.Release|x86.Build.0 = Release|Any CPU - {5BBF4A3F-4AD1-47FD-B250-05EA793F939D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {5BBF4A3F-4AD1-47FD-B250-05EA793F939D}.Debug|ARM.ActiveCfg = Debug|Any CPU - {5BBF4A3F-4AD1-47FD-B250-05EA793F939D}.Debug|iPhone.ActiveCfg = Debug|Any CPU - {5BBF4A3F-4AD1-47FD-B250-05EA793F939D}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU - {5BBF4A3F-4AD1-47FD-B250-05EA793F939D}.Debug|x64.ActiveCfg = Debug|Any CPU - {5BBF4A3F-4AD1-47FD-B250-05EA793F939D}.Debug|x86.ActiveCfg = Debug|Any CPU - {5BBF4A3F-4AD1-47FD-B250-05EA793F939D}.Release|Any CPU.ActiveCfg = Release|Any CPU - {5BBF4A3F-4AD1-47FD-B250-05EA793F939D}.Release|ARM.ActiveCfg = Release|Any CPU - {5BBF4A3F-4AD1-47FD-B250-05EA793F939D}.Release|iPhone.ActiveCfg = Release|Any CPU - {5BBF4A3F-4AD1-47FD-B250-05EA793F939D}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU - {5BBF4A3F-4AD1-47FD-B250-05EA793F939D}.Release|x64.ActiveCfg = Release|Any CPU - {5BBF4A3F-4AD1-47FD-B250-05EA793F939D}.Release|x86.ActiveCfg = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE