}
}
- public class AttachedStateEffectLabelRenderer : LabelRenderer
+ public class AttachedStateEffectLabelRenderer :
+#if TEST_EXPERIMENTAL_RENDERERS
+ Platform.Android.FastRenderers.LabelRenderer
+#else
+ LabelRenderer
+#endif
{
public AttachedStateEffectLabelRenderer(Context context) : base(context)
{
}
+#if TEST_EXPERIMENTAL_RENDERERS
protected override void Dispose(bool disposing)
{
+ foreach (var effect in Element.Effects.OfType<Controls.Effects.AttachedStateEffect>())
+ {
+ effect.Detached(Element);
+ }
+
base.Dispose(disposing);
}
+#endif
}
public class NativeDroidMasterDetail : Xamarin.Forms.Platform.Android.AppCompat.MasterDetailPageRenderer
protected override void Dispose(bool disposing)
{
- if(disposing)
+ if (disposing)
{
ViewGroup.ViewTreeObserver.RemoveOnGlobalLayoutListener(this);
_gridChild.SetOnTouchListener(null);
namespace Xamarin.Forms.ControlGallery.Android
{
#pragma warning disable 618
- public class DisposeLabelRenderer : LabelRenderer
+ public class DisposeLabelRenderer :
+#if TEST_EXPERIMENTAL_RENDERERS
+ Platform.Android.FastRenderers.LabelRenderer
+#else
+ LabelRenderer
+#endif
#pragma warning restore 618
{
protected override void Dispose (bool disposing)
base.OnCreate(bundle);
#if TEST_EXPERIMENTAL_RENDERERS
- // CollectionView lets us test CollectionView stuff until it's officially released
- Forms.SetFlags("FastRenderers_Experimental"/*, "CollectionView_Experimental", "Shell_Experimental"*/);
-#else
// Fake_Flag is here so we can test for flag initialization issues
- // CollectionView lets us test CollectionView stuff until it's officially released
- Forms.SetFlags("Fake_Flag"/*, "CollectionView_Experimental", "Shell_Experimental" */);
+ Forms.SetFlags("Fake_Flag"/*, "CollectionView_Experimental", "Shell_Experimental"*/);
+#else
+ Forms.SetFlags("UseLegacyRenderers"/*, "CollectionView_Experimental", "Shell_Experimental" */);
#endif
Forms.Init(this, bundle);
[assembly: ExportRenderer(typeof(Issue1909.FlatButton), typeof(FlatButtonRenderer))]
namespace Xamarin.Forms.ControlGallery.Android
{
- public class FlatButtonRenderer : ButtonRenderer
- {
+ public class FlatButtonRenderer :
+#if TEST_EXPERIMENTAL_RENDERERS
+ Platform.Android.FastRenderers.ButtonRenderer
+#else
+ ButtonRenderer
+#endif
+ {
public FlatButtonRenderer(Context context) : base(context)
{
}
--- /dev/null
+using Android.Content;
+using System;
+using System.Linq;
+using Xamarin.Forms;
+using Xamarin.Forms.ControlGallery.Android;
+using Xamarin.Forms.Platform.Android.AppCompat;
+using Xamarin.Forms.Controls.Issues;
+using System.ComponentModel;
+
+[assembly: ExportRenderer(typeof(Issue5724.CustomButton), typeof(CustomButtonRenderer5724))]
+namespace Xamarin.Forms.ControlGallery.Android
+{
+ public class CustomButtonRenderer5724 :
+#if TEST_EXPERIMENTAL_RENDERERS
+ Platform.Android.FastRenderers.ButtonRenderer
+#else
+ ButtonRenderer
+#endif
+ {
+ public CustomButtonRenderer5724(Context context) : base(context)
+ {
+ }
+
+ protected override void OnElementChanged(Platform.Android.ElementChangedEventArgs<Button> e)
+ {
+ base.OnElementChanged(e);
+ }
+ protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
+ {
+ base.OnElementPropertyChanged(sender, e);
+ }
+ }
+
+ public class CustomImageRenderer5724 :
+#if TEST_EXPERIMENTAL_RENDERERS
+ Platform.Android.FastRenderers.ImageRenderer
+#else
+ ImageRenderer
+#endif
+ {
+ public CustomImageRenderer5724(Context context) : base(context)
+ {
+ }
+
+ protected override void OnElementChanged(Platform.Android.ElementChangedEventArgs<Image> e)
+ {
+ base.OnElementChanged(e);
+ }
+ protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
+ {
+ base.OnElementPropertyChanged(sender, e);
+ }
+ }
+
+ public class CustomFrameRenderer5724 :
+#if TEST_EXPERIMENTAL_RENDERERS
+ Platform.Android.FastRenderers.FrameRenderer
+#else
+ FrameRenderer
+#endif
+ {
+ public CustomFrameRenderer5724(Context context) : base(context)
+ {
+ }
+
+ protected override void OnElementChanged(Platform.Android.ElementChangedEventArgs<Frame> e)
+ {
+ base.OnElementChanged(e);
+ }
+
+ protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
+ {
+ base.OnElementPropertyChanged(sender, e);
+ }
+
+ }
+
+ public class CustomLabelRenderer5724 :
+#if TEST_EXPERIMENTAL_RENDERERS
+ Platform.Android.FastRenderers.LabelRenderer
+#else
+ LabelRenderer
+#endif
+ {
+ public CustomLabelRenderer5724(Context context) : base(context)
+ {
+ }
+
+ protected override void OnElementChanged(Platform.Android.ElementChangedEventArgs<Label> e)
+ {
+ base.OnElementChanged(e);
+ }
+ protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
+ {
+ base.OnElementPropertyChanged(sender, e);
+ }
+ }
+}
\ No newline at end of file
namespace Xamarin.Forms.ControlGallery.Android
{
- public class _60122ImageRenderer : ImageRenderer
+ public class _60122ImageRenderer :
+#if TEST_EXPERIMENTAL_RENDERERS
+ Platform.Android.FastRenderers.ImageRenderer
+#else
+ ImageRenderer
+#endif
+
{
public _60122ImageRenderer(Context context) : base(context)
{
if (e.NewElement != null)
{
_customControl = e.NewElement as Bugzilla60122._60122Image;
-
+
LongClick += LongPressGestureRecognizerImageRenderer_LongClick;
}
else
--- /dev/null
+using Xamarin.Forms.CustomAttributes;
+using Xamarin.Forms.Internals;
+
+namespace Xamarin.Forms.Controls.Issues
+{
+ [Preserve(AllMembers = true)]
+ [Issue(IssueTracker.Github, 5724, "Use Android Fast Renderers by Default", PlatformAffected.Android)]
+ public class Issue5724 : TestContentPage
+ {
+ public class CustomButton : Button { }
+ public class CustomImage : Image { }
+ public class CustomLabel : Label { }
+ public class CustomFrame : Frame { }
+
+ protected override void Init()
+ {
+ Content = new StackLayout
+ {
+ Children =
+ {
+ new CustomLabel
+ {
+ Text = "See if I'm here"
+ },
+ new CustomButton
+ {
+ Text = "See if I'm here"
+ },
+ new CustomFrame
+ {
+ },
+ new CustomImage
+ {
+ Source = "coffee.png"
+ },
+ }
+ };
+ }
+ }
+}
\ No newline at end of file
<DependentUpon>VisualControlsPage.xaml</DependentUpon>
</Compile>
<Compile Include="$(MSBuildThisFileDirectory)Issue5470.cs" />
+ <Compile Include="$(MSBuildThisFileDirectory)Issue5724.cs" />
<Compile Include="$(MSBuildThisFileDirectory)_Template.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Bugzilla56298.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Bugzilla42620.cs" />
RegisterHandler(typeof(Picker), typeof(AppCompat.PickerRenderer), typeof(PickerRenderer));
RegisterHandler(typeof(CarouselPage), typeof(AppCompat.CarouselPageRenderer), typeof(CarouselPageRenderer));
- if (Forms.Flags.Contains(Flags.FastRenderersExperimental))
+ if (Forms.Flags.Contains(Flags.UseLegacyRenderers))
+ {
+ RegisterHandler(typeof(Button), typeof(AppCompat.ButtonRenderer), typeof(ButtonRenderer));
+ RegisterHandler(typeof(Frame), typeof(AppCompat.FrameRenderer), typeof(FrameRenderer));
+ }
+ else
{
RegisterHandler(typeof(Button), typeof(FastRenderers.ButtonRenderer), typeof(ButtonRenderer));
RegisterHandler(typeof(Label), typeof(FastRenderers.LabelRenderer), typeof(LabelRenderer));
RegisterHandler(typeof(Image), typeof(FastRenderers.ImageRenderer), typeof(ImageRenderer));
RegisterHandler(typeof(Frame), typeof(FastRenderers.FrameRenderer), typeof(FrameRenderer));
}
- else
- {
- RegisterHandler(typeof(Button), typeof(AppCompat.ButtonRenderer), typeof(ButtonRenderer));
- RegisterHandler(typeof(Frame), typeof(AppCompat.FrameRenderer), typeof(FrameRenderer));
- }
}
protected void LoadApplication(Application application)
namespace Xamarin.Forms.Platform.Android.FastRenderers
{
- internal sealed class ButtonRenderer : AppCompatButton,
+ public class ButtonRenderer : AppCompatButton,
IBorderVisualElementRenderer, IButtonLayoutRenderer, IVisualElementRenderer, IViewRenderer, ITabStop,
AView.IOnAttachStateChangeListener, AView.IOnFocusChangeListener, AView.IOnClickListener, AView.IOnTouchListener
{
Initialize();
}
- public VisualElement Element => Button;
+ protected Button Element => Button;
+ protected AppCompatButton Control => this;
+
+ VisualElement IBorderVisualElementRenderer.Element => Element;
+
+ VisualElement IVisualElementRenderer.Element => Element;
AView IVisualElementRenderer.View => this;
ViewGroup IVisualElementRenderer.ViewGroup => null;
VisualElementTracker IVisualElementRenderer.Tracker => _tracker;
return new Size();
}
- void OnElementChanged(ElementChangedEventArgs<Button> e)
+ protected virtual void OnElementChanged(ElementChangedEventArgs<Button> e)
{
if (e.NewElement != null && !_isDisposed)
{
ElementChanged?.Invoke(this, new VisualElementChangedEventArgs(e.OldElement, e.NewElement));
}
- void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
+ protected virtual void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
{
if (e.PropertyName == Button.TextColorProperty.PropertyName)
{
namespace Xamarin.Forms.Platform.Android.FastRenderers
{
- internal sealed class ImageRenderer : AImageView, IVisualElementRenderer, IImageRendererController, IViewRenderer, ITabStop,
+ public class ImageRenderer : AImageView, IVisualElementRenderer, IImageRendererController, IViewRenderer, ITabStop,
ILayoutChanges
{
bool _disposed;
base.Invalidate();
}
- void OnElementChanged(ElementChangedEventArgs<Image> e)
+ protected virtual void OnElementChanged(ElementChangedEventArgs<Image> e)
{
this.EnsureId();
ElementChanged?.Invoke(this, new VisualElementChangedEventArgs(e.OldElement, e.NewElement));
void IImageRendererController.SkipInvalidate() => _skipInvalidate = true;
- AImageView Control => this;
+ protected AImageView Control => this;
+ protected Image Element => _element;
public event EventHandler<VisualElementChangedEventArgs> ElementChanged;
public event EventHandler<PropertyChangedEventArgs> ElementPropertyChanged;
{
}
- void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
+ protected virtual void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
{
ElementPropertyChanged?.Invoke(this, e);
}
namespace Xamarin.Forms.Platform.Android.FastRenderers
{
- internal sealed class LabelRenderer : FormsTextView, IVisualElementRenderer, IViewRenderer, ITabStop
+ public class LabelRenderer : FormsTextView, IVisualElementRenderer, IViewRenderer, ITabStop
{
int? _defaultLabelFor;
bool _disposed;
ViewGroup IVisualElementRenderer.ViewGroup => null;
- Label Element
+ protected Label Element
{
get { return _element; }
set
_element?.SendViewInitialized(this);
}
}
+ protected global::Android.Widget.TextView Control => this;
SizeRequest IVisualElementRenderer.GetDesiredSize(int widthConstraint, int heightConstraint)
{
return _motionEventHelper.HandleMotionEvent(Parent, e);
}
- void OnElementChanged(ElementChangedEventArgs<Label> e)
+ protected virtual void OnElementChanged(ElementChangedEventArgs<Label> e)
{
ElementChanged?.Invoke(this, new VisualElementChangedEventArgs(e.OldElement, e.NewElement));
}
}
- void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
+ protected virtual void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
{
ElementPropertyChanged?.Invoke(this, e);
{
internal static class Flags
{
- internal const string FastRenderersExperimental = "FastRenderers_Experimental";
+ internal const string UseLegacyRenderers = "UseLegacyRenderers";
}
}
\ No newline at end of file