Skip to content
This repository has been archived by the owner on Feb 4, 2022. It is now read-only.

Commit

Permalink
Fixed cell properties bug from last commit, updated readme
Browse files Browse the repository at this point in the history
- Found issue with last commit with applying background color after
  background gradient if all props are being updated
- Updated README.MD to describe more inconsistent behavior in
  Android API 21
  • Loading branch information
tbaggett committed Aug 28, 2016
1 parent ec78d50 commit 7c1e072
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 22 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,9 @@ CellGloss.SetAccessoryType(cell, CellGlossAccessoryType.DisclosureIndicator);

Allows a color value to be specified as a cell's background color. Possible values are either named colors or numeric color values.

**KNOWN ISSUE:** The *BackgroundColor* property does not consistently operate as expected on Android API 21 (Lollipop) when it is applied to a touch enabled element. The material design ripple effect is expected when a user touches the element on API 21 and higher. The effect occurs as expected sometime but not others. In the other cases, the pre-21 highlighting of the entire element occurs instead of the ripple effect. The behavior works as expected (ripple on API 22 and higher, element highlighting on API 20 and lower) on all the other supported Android APIs (16 - 23).


**Xaml Example:**
```
<TextCell Text="Red" xfg:CellGloss.BackgroundColor="Red" />
Expand All @@ -155,6 +158,9 @@ CellGloss.SetBackgroundColor(cell, Color.Red);

Allows a multiple-color linear gradient to be specified as a content page or cells' background. You can specify as many colors as you like and control their distribution across the fill at any angle. Convenience properties and constructors also make it easy to create two-color horizontal or vertical fills.


**KNOWN ISSUE:** The *BackgroundGradient* property does not consistently operate as expected on Android API 21 (Lollipop) when it is applied to a touch enabled element. The material design ripple effect is expected when a user touches the element on API 21 and higher. The effect occurs as expected sometime but not others. In the other cases, the pre-21 highlighting of the entire element occurs instead of the ripple effect. The behavior works as expected (ripple on API 22 and higher, element highlighting on API 20 and lower) on all the other supported Android APIs (16 - 23).

**Xaml Example:**
```
<TextCell Text="Red" TextColor="White">
Expand Down Expand Up @@ -565,6 +571,8 @@ The XFGloss renderer classes require their overridden versions of OnElementChang

- An Android.Content.Res.Resources+NotFoundException is thrown on Android API 16 (Jelly Bean) with a message that reads "Unable to find resource ID #0x404" when you switch between tabs multiple times in any of the example pages. I believe this is an issue with either Android API 16 or Xamarin.Forms v2.3.1.114, as the exception doesn't occur on any of the other tested Android APIs (17 through 23). However, I will investigate further if other users aren't seeing the issue with other Xamarin.Forms apps running on API 16.

- The *BackgroundColor* and *BackgroundGradient* properties do not consistently operate as expected on Android API 21 (Lollipop) when they are applied to a touch enabled element. The material design ripple effect is expected when a user touches the element on API 21 and higher. The effect occurs as expected sometime but not others. In the other cases, the pre-21 highlighting of the entire element occurs instead of the ripple effect. The behavior works as expected (ripple on API 22 and higher, element highlighting on API 20 and lower) on all the other supported Android APIs (16 - 23).

- The *MaxTrackTintColor* and *MinTrackTintColor* properties do not operate as expected on Android API 21 (Lollipop). A new tinting technique was introduced in API 21. The initial implementation was broken, but was fixed in the next release. See the documentation for the *MaxTrackTintColor* and *MinTrackTintColor* properties for more details.

---
Expand Down
46 changes: 24 additions & 22 deletions XFGloss.Droid/Renderers/XFGlossCellRenderers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@
using Android.Content;
using Android.Content.Res;
using Android.Graphics.Drawables;
using System.Collections.Generic;
using XFGloss.Droid.Utils;
using Android.Graphics.Drawables.Shapes;
using System;
using Android.Views;

Expand Down Expand Up @@ -70,9 +67,9 @@ public void CreateNativeElement<TElement>(string propertyName, TElement element)
nativeCell.SetOnTouchListener(ripple);
nativeCell.Background = ripple;
}
// Otherwise we just darken/lighten the cell background depending on how dark the background is
else
{
// Otherwise we just darken/lighten the cell background depending on how dark the background is
nativeCell.Background =
BackgroundStateListDrawable.Create(new XFGlossPaintDrawable(element as Gradient),
(element as Gradient).AverageColor.ToAndroid());
Expand Down Expand Up @@ -232,25 +229,30 @@ protected override void UpdateProperties(Cell cell, AView nativeCell, string pro
var bk = nativeCell.Background;

Color bkgrndColor = (Color)cell.GetValue(CellGloss.BackgroundColorProperty);
AColor aBkColor = (bkgrndColor != Color.Default) ? bkgrndColor.ToAndroid() : AColor.Transparent;

// The material design ripple effect was introduced in Lollipop. Use it if we're running on that or newer
if (Android.OS.Build.VERSION.SdkInt >= Android.OS.BuildVersionCodes.Lollipop)
{
var ripple = BackgroundRippleDrawable.Create(aBkColor);
nativeCell.SetOnTouchListener(ripple);
nativeCell.Background = ripple;
}
else
// We don't want to assign a background color if the default color is specified
// and we're updating all properties.
if (propertyName != null || bkgrndColor != Color.Default)
{
// Pre-lollipop means no ripple available
// See FAQ at bottom of http://android-developers.blogspot.com/2014/10/appcompat-v21-material-design-for-pre.html
// Q: Why are there no ripples on pre-Lollipop?
// A: A lot of what allows RippleDrawable to run smoothly is Android 5.0’s new RenderThread.
// To optimize for performance on previous versions of Android, we've left RippleDrawable out
// for now.

nativeCell.Background = BackgroundStateListDrawable.Create(aBkColor);
AColor aBkColor = (bkgrndColor != Color.Default) ? bkgrndColor.ToAndroid() : AColor.Transparent;

// The material design ripple effect was introduced in Lollipop. Use it if we're running on that or newer
if (Android.OS.Build.VERSION.SdkInt >= Android.OS.BuildVersionCodes.Lollipop)
{
var ripple = BackgroundRippleDrawable.Create(aBkColor);
nativeCell.SetOnTouchListener(ripple);
nativeCell.Background = ripple;
}
else
{
// Pre-lollipop means no ripple available
// See FAQ at bottom of http://android-developers.blogspot.com/2014/10/appcompat-v21-material-design-for-pre.html
// Q: Why are there no ripples on pre-Lollipop?
// A: A lot of what allows RippleDrawable to run smoothly is Android 5.0’s new RenderThread.
// To optimize for performance on previous versions of Android, we've left RippleDrawable out
// for now.

nativeCell.Background = BackgroundStateListDrawable.Create(aBkColor);
}
}
}
}
Expand Down

0 comments on commit 7c1e072

Please sign in to comment.