Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

Android fastrenderers #845

Merged
merged 34 commits into from Apr 6, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
1a6bb39
Obsolete IVisualElementRenderer.ViewGroup in favor of .View
hartez Feb 27, 2017
9a1279f
Fix NRE
hartez Feb 27, 2017
f2f8f1b
Changing TContainer in PlatformEffect to View
hartez Feb 28, 2017
685e5f2
Fix "View" type
hartez Feb 28, 2017
99fbac1
new VisualElementRenderer
samhouts Mar 1, 2017
d8aa8d7
Fast Label Renderer
samhouts Mar 1, 2017
ff6219c
Let's try that again. Behold: Label Fast Renderer
samhouts Mar 1, 2017
6ed0018
First attempt at a fast(er) button renderer
hartez Feb 28, 2017
03ea4f3
Move FrameRenderer into Fast Renderers
hartez Mar 1, 2017
5588ae4
Fix Disposable on VisualElementRenderer
hartez Mar 1, 2017
e35e3c6
Simplify touch and click handlers
hartez Mar 1, 2017
4edc909
Drop empty if clause
hartez Mar 1, 2017
50d915f
[Android] Add initial Image fast renderer
rmarinho Mar 2, 2017
24f2032
[Android] Small fixes to VisualElementRenderer
rmarinho Mar 2, 2017
99374db
Split accessibility out to a separate helper class; fix tapgesture bu…
hartez Mar 2, 2017
2d6ec16
Move accessiblity stuff to a separate class (which needs a good name)
hartez Mar 2, 2017
66fbb50
[Android] ImageRenderer refactoring
rmarinho Mar 2, 2017
2c1d21e
Prevent query from looking to parent for fast renderers
hartez Mar 2, 2017
32d7892
Fix elevation/z-index bugs with Button (e.g., 40173)
hartez Mar 2, 2017
385b356
Move SetLabeledBy to Accessibilitizer
hartez Mar 3, 2017
a30dd5f
Un-break automation IDs for Labels
hartez Mar 3, 2017
2e61843
Move gesture handling to its own class
hartez Mar 3, 2017
83c8ac1
Split gesture and effect management into separate classes
hartez Mar 3, 2017
1936dfa
Remove unneeded packager from LabelRenderer
hartez Mar 4, 2017
92e6cd0
LabelRenderer inherits from FormsTextView
samhouts Mar 6, 2017
45c19f0
Batch updates to View
hartez Mar 6, 2017
3940325
Fix isOnParentRenderer check for non-Android platforms
hartez Mar 23, 2017
004b28f
[Controls] Update Xamarin.Forms.ControlGallery.iOS.csproj
rmarinho Mar 29, 2017
a56c573
[Android,IOS] Small fixes to rebase and use of Internals
rmarinho Mar 30, 2017
0dba203
[Android] Ignroe warning for now
rmarinho Mar 30, 2017
4039200
Fast renderers now passing InputTransparent and IsEnabled tests
hartez Mar 31, 2017
83253c5
Fast and legacy renderers now pass the Enabled and InputTransparent t…
hartez Apr 3, 2017
50e54be
Change PlatformEffect back, default container to null
hartez Apr 3, 2017
cb85d14
Fix mangled using directives
hartez Apr 3, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -93,4 +93,134 @@ public void sendBatchUpdate (
setTranslationX (translationX);
setTranslationY (translationY);
}

package com.xamarin.forms.platform.android;

import android.content.Context;
import android.util.AttributeSet;
import android.view.ViewGroup;
import android.view.*;


public class FormsViewGroup extends ViewGroup {

public FormsViewGroup(Context context) {
super(context);
// TODO Auto-generated constructor stub
}

public FormsViewGroup(Context context, AttributeSet attrs) {
super(context, attrs);
// TODO Auto-generated constructor stub
}

public FormsViewGroup(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
// TODO Auto-generated constructor stub
}

public void measureAndLayout (int widthMeasureSpec, int heightMeasureSpec, int l, int t, int r, int b)
{
measure (widthMeasureSpec, heightMeasureSpec);
layout (l, t, r, b);
}

@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
}

boolean inputTransparent;

protected void setInputTransparent (boolean value)
{
inputTransparent = value;
}

protected boolean getInputTransparent ()
{
return inputTransparent;
}

@Override
public boolean onInterceptTouchEvent (MotionEvent ev)
{
if (inputTransparent)
return false;

return super.onInterceptTouchEvent(ev);
}

@Override
public boolean onTouchEvent (MotionEvent ev)
{
if (inputTransparent)
return false;

return super.onTouchEvent(ev);
}

public void sendBatchUpdate (
float pivotX,
float pivotY,
int visibility,
boolean enabled,
float opacity,
float rotation,
float rotationX,
float rotationY,
float scale,
float translationX,
float translationY){
setPivotX (pivotX);
setPivotY (pivotY);

if (getVisibility () != visibility)
setVisibility (visibility);

if (isEnabled () != enabled)
setEnabled (enabled);

setAlpha (opacity);
setRotation (rotation);
setRotationX (rotationX);
setRotationY (rotationY);
setScaleX (scale);
setScaleY (scale);
setTranslationX (translationX);
setTranslationY (translationY);
}

public static void sendViewBatchUpdate (
View view,
float pivotX,
float pivotY,
int visibility,
boolean enabled,
float opacity,
float rotation,
float rotationX,
float rotationY,
float scale,
float translationX,
float translationY){
view.setPivotX (pivotX);
view.setPivotY (pivotY);

if (view.getVisibility () != visibility)
view.setVisibility (visibility);

if (view.isEnabled () != enabled)
view.setEnabled (enabled);

view.setAlpha (opacity);
view.setRotation (rotation);
view.setRotationX (rotationX);
view.setRotationY (rotationY);
view.setScaleX (scale);
view.setScaleY (scale);
view.setTranslationX (translationX);
view.setTranslationY (translationY);
}
}

}
9 changes: 8 additions & 1 deletion Stubs/Xamarin.Forms.Platform.cs
Expand Up @@ -34,11 +34,18 @@ internal class _EntryRenderer { }

[RenderWith (typeof (EditorRenderer))]
internal class _EditorRenderer { }

#if __ANDROID__
[RenderWith (typeof (Xamarin.Forms.Platform.Android.FastRenderers.LabelRenderer))]
#else
[RenderWith (typeof (LabelRenderer))]
#endif
internal class _LabelRenderer { }

#if __ANDROID__
[RenderWith(typeof(Xamarin.Forms.Platform.Android.FastRenderers.ImageRenderer))]
#else
[RenderWith (typeof (ImageRenderer))]
#endif
internal class _ImageRenderer { }

[RenderWith (typeof (ButtonRenderer))]
Expand Down
46 changes: 8 additions & 38 deletions Xamarin.Forms.ControlGallery.Android/Activity1.cs
@@ -1,28 +1,20 @@
using System;
using System.ComponentModel;
using System.Diagnostics;
using System.Reflection;

using System.Globalization;
using System.IO;
using System.IO.IsolatedStorage;
using Android.App;
using Android.Content;
using Android.Content.PM;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using Android.OS;
using Android.Widget;
using Java.Interop;
using Xamarin.Forms;
using Xamarin.Forms.ControlGallery.Android;
using Xamarin.Forms.Controls;
using Xamarin.Forms.Maps.Android;
using Xamarin.Forms.Controls.Issues;
using Xamarin.Forms.Platform.Android;
using Xamarin.Forms.Platform.Android.AppLinks;
using System.IO;
using System.IO.IsolatedStorage;

using Droid = Android;
using System.Globalization;
using Java.Interop;
using Xamarin.Forms.Controls.Issues;
using Android.Content;

[assembly: Dependency (typeof (CacheService))]
[assembly: Dependency (typeof (TestCloudService))]
Expand All @@ -34,29 +26,7 @@

namespace Xamarin.Forms.ControlGallery.Android
{
public class BorderEffect : PlatformEffect
{
protected override void OnAttached ()
{
Control.SetBackgroundColor (global::Android.Graphics.Color.Aqua);

var childLabel = (Element as ScrollView)?.Content as Label;
if (childLabel != null)
childLabel.Text = "Success";
}

protected override void OnDetached ()
{
Control.SetBackgroundColor(global::Android.Graphics.Color.Beige);
}

protected override void OnElementPropertyChanged (PropertyChangedEventArgs args)
{
base.OnElementPropertyChanged (args);
}
}

public class CacheService : ICacheService
public class CacheService : ICacheService
{
public void ClearImageCache ()
{
Expand Down
21 changes: 21 additions & 0 deletions Xamarin.Forms.ControlGallery.Android/BorderEffect.cs
@@ -0,0 +1,21 @@
using Xamarin.Forms.Platform.Android;

namespace Xamarin.Forms.ControlGallery.Android
{
public class BorderEffect : PlatformEffect
{
protected override void OnAttached ()
{
Control.SetBackgroundColor (global::Android.Graphics.Color.Aqua);

var childLabel = (Element as ScrollView)?.Content as Label;
if (childLabel != null)
childLabel.Text = "Success";
}

protected override void OnDetached ()
{
Control.SetBackgroundColor(global::Android.Graphics.Color.Beige);
}
}
}
Expand Up @@ -2,6 +2,7 @@
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using Android.App;
using Xamarin.Forms;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
Expand Down Expand Up @@ -35,3 +36,10 @@

[assembly: Android.App.MetaData("com.google.android.maps.v2.API_KEY", Value = "AIzaSyAdstcJQswxEjzX5YjLaMcu2aRVEBJw39Y")]
[assembly: Xamarin.Forms.ResolutionGroupName ("XamControl")]

#if TEST_LEGACY_RENDERERS
[assembly: ExportRenderer(typeof(Button), typeof(Xamarin.Forms.Platform.Android.AppCompat.ButtonRenderer))]
[assembly: ExportRenderer(typeof(Image), typeof(Xamarin.Forms.Platform.Android.ImageRenderer))]
[assembly: ExportRenderer(typeof(Label), typeof(Xamarin.Forms.Platform.Android.LabelRenderer))]
[assembly: ExportRenderer(typeof(Frame), typeof(Xamarin.Forms.Platform.Android.AppCompat.FrameRenderer))]
#endif
Expand Up @@ -168,6 +168,7 @@
</ItemGroup>
<ItemGroup>
<Compile Include="Activity1.cs" />
<Compile Include="BorderEffect.cs" />
<Compile Include="BrokenNativeControl.cs" />
<Compile Include="Properties\MapsKey.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
Expand Down
3 changes: 1 addition & 2 deletions Xamarin.Forms.ControlGallery.iOS/AppDelegate.cs
Expand Up @@ -2,7 +2,6 @@
using System.Drawing;
using System.Globalization;
using System.IO;
using AdvancedColorPicker;
using CoreGraphics;
using Foundation;
using UIKit;
Expand Down Expand Up @@ -328,7 +327,7 @@ void AddNativeBindings(NativeBindingGalleryPage page)
uiView.Add(uilabel);
sl?.Children.Add(uiView);
sl?.Children.Add(uibuttonColor.ToView());
var colorPicker = new ColorPickerView(new CGRect(0, 0, width, 300));
var colorPicker = new AdvancedColorPicker.ColorPickerView(new CGRect(0, 0, width, 300));
colorPicker.SetBinding("SelectedColor", new Binding("NativeLabelColor", BindingMode.TwoWay, nativeColorConverter), "ColorPicked");
sl?.Children.Add(colorPicker);
page.NativeControlsAdded = true;
Expand Down
Expand Up @@ -193,7 +193,7 @@
<IsAppExtension>false</IsAppExtension>
</ProjectReference>
<ProjectReference Include="..\Stubs\Xamarin.Forms.Platform.iOS\Xamarin.Forms.Platform.iOS %28Forwarders%29.csproj">
<Project>{39B3457F-01D8-43D0-8E84-D8C4F73CF48D}</Project>
<Project>{39b3457f-01d8-43d0-8e84-d8c4f73cf48d}</Project>
<Name>Xamarin.Forms.Platform.iOS (Forwarders)</Name>
</ProjectReference>
</ItemGroup>
Expand Down Expand Up @@ -295,6 +295,10 @@
<BundleResource Include="coffee.png" />
</ItemGroup>
<ItemGroup>
<Reference Include="AdvancedColorPicker, Version=2.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\AdvancedColorPicker.2.0.1\lib\Xamarin.iOS\AdvancedColorPicker.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Xml" />
<Reference Include="System.Core" />
Expand All @@ -308,9 +312,6 @@
<Reference Include="Calabash">
<HintPath>..\packages\Xamarin.TestCloud.Agent.0.20.3\lib\Xamarin.iOS10\Calabash.dll</HintPath>
</Reference>
<Reference Include="AdvancedColorPicker">
<HintPath>..\packages\AdvancedColorPicker.2.0.1\lib\Xamarin.iOS\AdvancedColorPicker.dll</HintPath>
</Reference>
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath)\Xamarin\iOS\Xamarin.iOS.CSharp.targets" />
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
Expand All @@ -320,8 +321,6 @@
</PropertyGroup>
<Error Condition="!Exists('$(SolutionDir)\.nuget\NuGet.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)\.nuget\NuGet.targets'))" />
</Target>
<ItemGroup>
<Folder Include="Resources\" />
</ItemGroup>
<ItemGroup />
<Import Project="..\packages\Xamarin.Insights.1.12.3\build\Xamarin.iOS10\Xamarin.Insights.targets" Condition="Exists('..\packages\Xamarin.Insights.1.12.3\build\Xamarin.iOS10\Xamarin.Insights.targets')" />
</Project>
Expand Up @@ -125,10 +125,16 @@ public T GetProperty<T>(BindableProperty formProperty)
bool isOnParentRenderer = property.Item2;

var query = ViewQuery;
if (isOnParentRenderer &&
PlatformViewType != PlatformViews.BoxView &&
PlatformViewType != PlatformViews.Frame)
{
if (isOnParentRenderer &&
PlatformViewType != PlatformViews.BoxView &&
PlatformViewType != PlatformViews.Frame
#if __ANDROID__
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hartez is this correct or did i screw the rebase ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That looks correct. The UI tests will catch it if not.

&&
PlatformViewType != PlatformViews.Button &&
PlatformViewType != PlatformViews.Label &&
PlatformViewType != PlatformViews.Image
#endif
) {
query = query + " parent * index:0";
}

Expand Down
Binary file not shown.
2 changes: 1 addition & 1 deletion Xamarin.Forms.Platform.Android/AppCompat/ButtonRenderer.cs
Expand Up @@ -17,7 +17,7 @@

namespace Xamarin.Forms.Platform.Android.AppCompat
{
public class ButtonRenderer : ViewRenderer<Button, AppCompatButton>, AView.IOnAttachStateChangeListener
public class ButtonRenderer : ViewRenderer<Button, AppCompatButton>, AView.IOnAttachStateChangeListener
{
TextColorSwitcher _textColorSwitcher;
float _defaultFontSize;
Expand Down
Expand Up @@ -42,7 +42,7 @@ protected override void Dispose(bool disposing)
IVisualElementRenderer pageRenderer = Android.Platform.GetRenderer(pageToRemove);
if (pageRenderer != null)
{
pageRenderer.ViewGroup.RemoveFromParent();
pageRenderer.View.RemoveFromParent();
pageRenderer.Dispose();
}
pageToRemove.ClearValue(Android.Platform.RendererProperty);
Expand Down
Expand Up @@ -115,8 +115,8 @@ protected void LoadApplication(Application application)
RegisterHandlerForDefaultRenderer(typeof(NavigationPage), typeof(NavigationPageRenderer), typeof(NavigationRenderer));
RegisterHandlerForDefaultRenderer(typeof(TabbedPage), typeof(TabbedPageRenderer), typeof(TabbedRenderer));
RegisterHandlerForDefaultRenderer(typeof(MasterDetailPage), typeof(MasterDetailPageRenderer), typeof(MasterDetailRenderer));
RegisterHandlerForDefaultRenderer(typeof(Button), typeof(AppCompat.ButtonRenderer), typeof(ButtonRenderer));
RegisterHandlerForDefaultRenderer(typeof(Switch), typeof(AppCompat.SwitchRenderer), typeof(SwitchRenderer));
RegisterHandlerForDefaultRenderer(typeof(Button), typeof(FastRenderers.ButtonRenderer), typeof(ButtonRenderer));
RegisterHandlerForDefaultRenderer(typeof(Switch), typeof(AppCompat.SwitchRenderer), typeof(SwitchRenderer));
RegisterHandlerForDefaultRenderer(typeof(Picker), typeof(AppCompat.PickerRenderer), typeof(PickerRenderer));
RegisterHandlerForDefaultRenderer(typeof(Frame), typeof(AppCompat.FrameRenderer), typeof(FrameRenderer));
RegisterHandlerForDefaultRenderer(typeof(CarouselPage), typeof(AppCompat.CarouselPageRenderer), typeof(CarouselPageRenderer));
Expand Down
4 changes: 2 additions & 2 deletions Xamarin.Forms.Platform.Android/AppCompat/FragmentContainer.cs
Expand Up @@ -83,9 +83,9 @@ public override void OnDestroyView()
{
if (_visualElementRenderer != null)
{
if (_visualElementRenderer.ViewGroup.Handle != IntPtr.Zero)
if (_visualElementRenderer.View.Handle != IntPtr.Zero)
{
_visualElementRenderer.ViewGroup.RemoveFromParent();
_visualElementRenderer.View.RemoveFromParent();
}

_visualElementRenderer.Dispose();
Expand Down