summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorE.Z. Hart <hartez@users.noreply.github.com>2016-12-14 17:13:17 -0700
committerGitHub <noreply@github.com>2016-12-14 17:13:17 -0700
commit8f1bb7b4b2ae8fd182c3874f208a12d549d230dd (patch)
treeab5f5c4b784065827248d2b4ea40dde23571f90b
parent1c5de535739e92d0c6dca335c024503b08d1a2af (diff)
downloadxamarin-forms-8f1bb7b4b2ae8fd182c3874f208a12d549d230dd.tar.gz
xamarin-forms-8f1bb7b4b2ae8fd182c3874f208a12d549d230dd.tar.bz2
xamarin-forms-8f1bb7b4b2ae8fd182c3874f208a12d549d230dd.zip
Fix potential NRE in ConditionalFocusLayout (#587)2.3.3.175
-rw-r--r--Xamarin.Forms.ControlGallery.Android/Resources/layout/Layout38989.axml13
-rw-r--r--Xamarin.Forms.ControlGallery.Android/Xamarin.Forms.ControlGallery.Android.csproj8
-rw-r--r--Xamarin.Forms.ControlGallery.Android/_38989CustomRenderer.cs35
-rw-r--r--Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla38989.cs52
-rw-r--r--Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems1
-rw-r--r--Xamarin.Forms.Platform.Android/Renderers/ConditionalFocusLayout.cs9
6 files changed, 109 insertions, 9 deletions
diff --git a/Xamarin.Forms.ControlGallery.Android/Resources/layout/Layout38989.axml b/Xamarin.Forms.ControlGallery.Android/Resources/layout/Layout38989.axml
new file mode 100644
index 00000000..82d895ab
--- /dev/null
+++ b/Xamarin.Forms.ControlGallery.Android/Resources/layout/Layout38989.axml
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="utf-8"?>
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:padding="8dp">
+ <ImageView
+ android:id="@+id/coffee"
+ android:layout_width="48dp"
+ android:layout_height="48dp"
+ android:padding="5dp"
+ android:src="@drawable/icon"
+ android:layout_alignParentLeft="true" />
+</RelativeLayout> \ 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 32f92ecc..9a907004 100644
--- a/Xamarin.Forms.ControlGallery.Android/Xamarin.Forms.ControlGallery.Android.csproj
+++ b/Xamarin.Forms.ControlGallery.Android/Xamarin.Forms.ControlGallery.Android.csproj
@@ -53,9 +53,7 @@
</CustomCommands>
</CustomCommands>
<AndroidCreatePackagePerAbi>False</AndroidCreatePackagePerAbi>
- <AndroidSupportedAbis>armeabi,armeabi-v7a,x86</AndroidSupportedAbis>
- <AndroidStoreUncompressedFileExtensions />
- <MandroidI18n />
+ <AndroidSupportedAbis>armeabi;armeabi-v7a;x86</AndroidSupportedAbis>
<Debugger>Xamarin</Debugger>
<AndroidEnableMultiDex>False</AndroidEnableMultiDex>
<DevInstrumentationEnabled>True</DevInstrumentationEnabled>
@@ -176,6 +174,7 @@
<Compile Include="Resources\Resource.Designer.cs" />
<Compile Include="CustomRenderers.cs" />
<Compile Include="ColorPicker.cs" />
+ <Compile Include="_38989CustomRenderer.cs" />
</ItemGroup>
<ItemGroup>
<AndroidAsset Include="Assets\default.css" />
@@ -256,6 +255,9 @@
<AndroidResource Include="Resources\layout\Tabbar.axml">
<SubType>Designer</SubType>
</AndroidResource>
+ <AndroidResource Include="Resources\layout\Layout38989.axml">
+ <SubType>Designer</SubType>
+ </AndroidResource>
</ItemGroup>
<ItemGroup>
<TransformFile Include="Properties\AndroidManifest.xml" />
diff --git a/Xamarin.Forms.ControlGallery.Android/_38989CustomRenderer.cs b/Xamarin.Forms.ControlGallery.Android/_38989CustomRenderer.cs
new file mode 100644
index 00000000..1cde98a8
--- /dev/null
+++ b/Xamarin.Forms.ControlGallery.Android/_38989CustomRenderer.cs
@@ -0,0 +1,35 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+using Android.App;
+using Android.Content;
+using Android.OS;
+using Android.Runtime;
+using Android.Views;
+using Android.Widget;
+using Xamarin.Forms;
+using Xamarin.Forms.ControlGallery.Android;
+using Xamarin.Forms.Controls.Issues;
+using AView = Android.Views.View;
+
+[assembly: ExportRenderer(typeof(Bugzilla38989._38989CustomViewCell), typeof(_38989CustomViewCellRenderer))]
+
+namespace Xamarin.Forms.ControlGallery.Android
+{
+ public class _38989CustomViewCellRenderer : Xamarin.Forms.Platform.Android.ViewCellRenderer
+ {
+ protected override AView GetCellCore(Cell item, AView convertView, ViewGroup parent, Context context)
+ {
+ var nativeView = convertView;
+
+ if (nativeView == null)
+ nativeView = (context as Activity).LayoutInflater.Inflate(Resource.Layout.Layout38989, null);
+
+ return nativeView;
+ }
+ }
+
+
+} \ No newline at end of file
diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla38989.cs b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla38989.cs
new file mode 100644
index 00000000..a16f1adf
--- /dev/null
+++ b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla38989.cs
@@ -0,0 +1,52 @@
+using System.Collections.Generic;
+using Xamarin.Forms.CustomAttributes;
+using Xamarin.Forms.Internals;
+#if UITEST
+using NUnit.Framework;
+
+#endif
+
+namespace Xamarin.Forms.Controls.Issues
+{
+ [Preserve(AllMembers = true)]
+ [Issue(IssueTracker.Bugzilla, 38989, "[Android] NullReferenceException when using a custom ViewCellRenderer ",
+ PlatformAffected.Android)]
+ public class Bugzilla38989 : TestContentPage
+ {
+ const string Success = "If you can see this, the test passed.";
+
+#if UITEST && __ANDROID__
+ [Test]
+ public void Bugzilla38989Test()
+ {
+ RunningApp.WaitForElement(q => q.Marked(Success));
+ }
+#endif
+
+ protected override void Init()
+ {
+ var successLabel = new Label { Text = Success };
+
+ var lv = new ListView();
+ var items = new List<string> { "data", "does not", "matter" };
+
+ lv.ItemTemplate = new DataTemplate(typeof(_38989CustomViewCell));
+
+ lv.ItemsSource = items;
+
+ Content = new StackLayout { Children = { successLabel, lv } };
+ }
+
+ [Preserve(AllMembers = true)]
+ public class _38989CustomViewCell : ViewCell
+ {
+ public _38989CustomViewCell()
+ {
+ var label = new Label();
+ label.SetBinding(Label.TextProperty, ".");
+
+ View = label;
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems
index 290835a2..76c721f1 100644
--- a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems
+++ b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems
@@ -85,6 +85,7 @@
<DependentUpon>Bugzilla38827.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
+ <Compile Include="$(MSBuildThisFileDirectory)Bugzilla38989.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Bugzilla39395.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Bugzilla39461.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Bugzilla39483.xaml.cs">
diff --git a/Xamarin.Forms.Platform.Android/Renderers/ConditionalFocusLayout.cs b/Xamarin.Forms.Platform.Android/Renderers/ConditionalFocusLayout.cs
index 6368d023..311db6b8 100644
--- a/Xamarin.Forms.Platform.Android/Renderers/ConditionalFocusLayout.cs
+++ b/Xamarin.Forms.Platform.Android/Renderers/ConditionalFocusLayout.cs
@@ -26,12 +26,11 @@ namespace Xamarin.Forms.Platform.Android
(aView as EntryCellView)?.EditText.SetOnTouchListener(this);
var viewCell = item as ViewCell;
- if (viewCell == null || viewCell?.View == null)
+ if (viewCell?.View == null)
return;
IVisualElementRenderer renderer = Platform.GetRenderer(viewCell.View);
- if (renderer?.ViewGroup?.ChildCount != 0)
- (renderer.ViewGroup.GetChildAt(0) as EditText)?.SetOnTouchListener(this);
+ (renderer?.ViewGroup?.GetChildAt(0) as EditText)?.SetOnTouchListener(this);
foreach (Element descendant in viewCell.View.Descendants())
{
@@ -39,9 +38,7 @@ namespace Xamarin.Forms.Platform.Android
if (element == null)
continue;
renderer = Platform.GetRenderer(element);
- if (renderer?.ViewGroup?.ChildCount == 0)
- continue;
- (renderer.ViewGroup.GetChildAt(0) as EditText)?.SetOnTouchListener(this);
+ (renderer?.ViewGroup?.GetChildAt(0) as EditText)?.SetOnTouchListener(this);
}
}
}