summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.ControlGallery.Android
diff options
context:
space:
mode:
authorE.Z. Hart <hartez@users.noreply.github.com>2017-08-10 17:35:27 (GMT)
committerJason Smith <jason.smith@xamarin.com>2017-08-10 17:35:27 (GMT)
commit1aab6ff4893935fb3bb91187d2d3fa796576198a (patch)
tree99a4adc0b178cc5619496d17c7feeb2a8f55607d /Xamarin.Forms.ControlGallery.Android
parentec10a37ff125fd920616649ec9ffde2f51d77a37 (diff)
downloadxamarin-forms-1aab6ff4893935fb3bb91187d2d3fa796576198a.zip
xamarin-forms-1aab6ff4893935fb3bb91187d2d3fa796576198a.tar.gz
xamarin-forms-1aab6ff4893935fb3bb91187d2d3fa796576198a.tar.bz2
Repro 58406; apply effects to fast renderers on Android (#1077)
Diffstat (limited to 'Xamarin.Forms.ControlGallery.Android')
-rw-r--r--Xamarin.Forms.ControlGallery.Android/Properties/AssemblyInfo.cs7
-rw-r--r--Xamarin.Forms.ControlGallery.Android/Xamarin.Forms.ControlGallery.Android.csproj1
-rw-r--r--Xamarin.Forms.ControlGallery.Android/_58406EffectRenderer.cs67
3 files changed, 73 insertions, 2 deletions
diff --git a/Xamarin.Forms.ControlGallery.Android/Properties/AssemblyInfo.cs b/Xamarin.Forms.ControlGallery.Android/Properties/AssemblyInfo.cs
index 82e7252..ee551d2 100644
--- a/Xamarin.Forms.ControlGallery.Android/Properties/AssemblyInfo.cs
+++ b/Xamarin.Forms.ControlGallery.Android/Properties/AssemblyInfo.cs
@@ -6,7 +6,8 @@ using Xamarin.Forms.Controls;
using Xamarin.Forms.Platform.Android;
using Xamarin.Forms;
using Xamarin.Forms.ControlGallery.Android;
-
+using Xamarin.Forms.Controls.Issues;
+
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
@@ -37,8 +38,10 @@ using Xamarin.Forms.ControlGallery.Android;
[assembly: UsesPermission (Android.Manifest.Permission.Internet)]
[assembly: UsesPermission (Android.Manifest.Permission.WriteExternalStorage)]
+
+
[assembly: Android.App.MetaData("com.google.android.maps.v2.API_KEY", Value = "AIzaSyAdstcJQswxEjzX5YjLaMcu2aRVEBJw39Y")]
-[assembly: Xamarin.Forms.ResolutionGroupName ("XamControl")]
+[assembly: Xamarin.Forms.ResolutionGroupName (Xamarin.Forms.Controls.Issues.Effects.ResolutionGroupName)]
// Deliberately broken image source and handler so we can test handling of image loading errors
[assembly: ExportImageSourceHandler(typeof(FailImageSource), typeof(BrokenImageSourceHandler))]
diff --git a/Xamarin.Forms.ControlGallery.Android/Xamarin.Forms.ControlGallery.Android.csproj b/Xamarin.Forms.ControlGallery.Android/Xamarin.Forms.ControlGallery.Android.csproj
index ccf16fe..31ef91c 100644
--- a/Xamarin.Forms.ControlGallery.Android/Xamarin.Forms.ControlGallery.Android.csproj
+++ b/Xamarin.Forms.ControlGallery.Android/Xamarin.Forms.ControlGallery.Android.csproj
@@ -191,6 +191,7 @@
<Compile Include="_38989CustomRenderer.cs" />
<Compile Include="BrokenImageSourceHandler.cs" />
<Compile Include="_57114CustomRenderer.cs" />
+ <Compile Include="_58406EffectRenderer.cs" />
</ItemGroup>
<ItemGroup>
<AndroidAsset Include="Assets\default.css" />
diff --git a/Xamarin.Forms.ControlGallery.Android/_58406EffectRenderer.cs b/Xamarin.Forms.ControlGallery.Android/_58406EffectRenderer.cs
new file mode 100644
index 0000000..b34b38a
--- /dev/null
+++ b/Xamarin.Forms.ControlGallery.Android/_58406EffectRenderer.cs
@@ -0,0 +1,67 @@
+using System;
+using System.Diagnostics;
+using System.Linq;
+using Android.Widget;
+using Xamarin.Forms;
+using Xamarin.Forms.Controls.Issues;
+using Xamarin.Forms.Platform.Android;
+
+[assembly: ExportEffect(typeof(Xamarin.Forms.ControlGallery.Android._58406EffectRenderer), Bugzilla58406.EffectName)]
+
+namespace Xamarin.Forms.ControlGallery.Android
+{
+ public class _58406EffectRenderer : PlatformEffect
+ {
+ protected override void OnAttached()
+ {
+ var tv = Control as TextView;
+
+ if (tv == null)
+ {
+ return;
+ }
+
+ ReverseText(tv, tv.Text);
+ tv.TextChanged += OnTextChanged;
+ }
+
+ bool _ignoreNextTextChange;
+
+ void OnTextChanged(object sender, global::Android.Text.TextChangedEventArgs textChangedEventArgs)
+ {
+ var tv = sender as TextView;
+
+ if (tv == null)
+ {
+ return;
+ }
+
+ if (_ignoreNextTextChange)
+ {
+ _ignoreNextTextChange = false;
+ return;
+ }
+
+ _ignoreNextTextChange = true;
+
+ ReverseText(tv, textChangedEventArgs.Text.ToString());
+ }
+
+ static void ReverseText(TextView tv, string text)
+ {
+ var rev = new string(text.Reverse().ToArray());
+ tv.Text = rev;
+ }
+
+ protected override void OnDetached()
+ {
+ var tv = Control as TextView;
+ if (tv == null)
+ {
+ return;
+ }
+
+ tv.TextChanged -= OnTextChanged;
+ }
+ }
+} \ No newline at end of file