summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Platform.Android/FastRenderers
diff options
context:
space:
mode:
authorSamantha Houts <samhouts@users.noreply.github.com>2017-06-22 11:19:26 -0700
committerRui Marinho <me@ruimarinho.net>2017-06-22 19:19:26 +0100
commitf80a5e05de0d1a6d8f1c1d81bced85cb468e7813 (patch)
tree35b0f625df314b4a44aeb6298a189cf3f58b3489 /Xamarin.Forms.Platform.Android/FastRenderers
parent5a87b84e866f01411fb8c167ced1fa7e5e5f3261 (diff)
downloadxamarin-forms-f80a5e05de0d1a6d8f1c1d81bced85cb468e7813.tar.gz
xamarin-forms-f80a5e05de0d1a6d8f1c1d81bced85cb468e7813.tar.bz2
xamarin-forms-f80a5e05de0d1a6d8f1c1d81bced85cb468e7813.zip
[Android] Remove the ". " on empty labels (Accessibility) on Fastrenderers (#915)
* [Android] Concatenate Name/HelpText better Also remove some parameters that were added to workaround an issue that no longer exists. * Add repro * Listen to Stephane he's usually right * oops, didn't save
Diffstat (limited to 'Xamarin.Forms.Platform.Android/FastRenderers')
-rw-r--r--Xamarin.Forms.Platform.Android/FastRenderers/AutomationPropertiesProvider.cs44
1 files changed, 21 insertions, 23 deletions
diff --git a/Xamarin.Forms.Platform.Android/FastRenderers/AutomationPropertiesProvider.cs b/Xamarin.Forms.Platform.Android/FastRenderers/AutomationPropertiesProvider.cs
index 6d34c6b5..6cd158ff 100644
--- a/Xamarin.Forms.Platform.Android/FastRenderers/AutomationPropertiesProvider.cs
+++ b/Xamarin.Forms.Platform.Android/FastRenderers/AutomationPropertiesProvider.cs
@@ -6,7 +6,6 @@ namespace Xamarin.Forms.Platform.Android.FastRenderers
{
internal class AutomationPropertiesProvider : IDisposable
{
- const string GetFromElement = "GetValueFromElement";
string _defaultContentDescription;
bool? _defaultFocusable;
string _defaultHint;
@@ -49,18 +48,14 @@ namespace Xamarin.Forms.Platform.Android.FastRenderers
}
}
- void SetAutomationId(string id = GetFromElement)
+ void SetAutomationId()
{
if (Element == null || Control == null)
{
return;
}
- string value = id;
- if (value == GetFromElement)
- {
- value = Element.AutomationId;
- }
+ string value = Element.AutomationId;
if (!string.IsNullOrEmpty(value))
{
@@ -68,7 +63,7 @@ namespace Xamarin.Forms.Platform.Android.FastRenderers
}
}
- void SetContentDescription(string contentDescription = GetFromElement)
+ void SetContentDescription()
{
if (Element == null || Control == null)
{
@@ -85,12 +80,7 @@ namespace Xamarin.Forms.Platform.Android.FastRenderers
_defaultContentDescription = Control.ContentDescription;
}
- string value = contentDescription;
- if (value == GetFromElement)
- {
- value = string.Join(" ", (string)Element.GetValue(AutomationProperties.NameProperty),
- (string)Element.GetValue(AutomationProperties.HelpTextProperty));
- }
+ string value = ConcatenateNameAndHelpText(Element);
if (!string.IsNullOrWhiteSpace(value))
{
@@ -102,7 +92,7 @@ namespace Xamarin.Forms.Platform.Android.FastRenderers
}
}
- void SetFocusable(bool? value = null)
+ void SetFocusable()
{
if (Element == null || Control == null)
{
@@ -115,10 +105,10 @@ namespace Xamarin.Forms.Platform.Android.FastRenderers
}
Control.Focusable =
- (bool)(value ?? (bool?)Element.GetValue(AutomationProperties.IsInAccessibleTreeProperty) ?? _defaultFocusable);
+ (bool)((bool?)Element.GetValue(AutomationProperties.IsInAccessibleTreeProperty) ?? _defaultFocusable);
}
- bool SetHint(string hint = GetFromElement)
+ bool SetHint()
{
if (Element == null || Control == null)
{
@@ -142,18 +132,26 @@ namespace Xamarin.Forms.Platform.Android.FastRenderers
_defaultHint = textView.Hint;
}
- string value = hint;
- if (value == GetFromElement)
- {
- value = string.Join(". ", (string)Element.GetValue(AutomationProperties.NameProperty),
- (string)Element.GetValue(AutomationProperties.HelpTextProperty));
- }
+ string value = ConcatenateNameAndHelpText(Element);
textView.Hint = !string.IsNullOrWhiteSpace(value) ? value : _defaultHint;
return true;
}
+ internal static string ConcatenateNameAndHelpText(Element Element)
+ {
+ var name = (string)Element.GetValue(AutomationProperties.NameProperty);
+ var helpText = (string)Element.GetValue(AutomationProperties.HelpTextProperty);
+
+ if (string.IsNullOrWhiteSpace(name))
+ return helpText;
+ if (string.IsNullOrWhiteSpace(helpText))
+ return name;
+
+ return $"{name}. {helpText}";
+ }
+
void SetLabeledBy()
{
if (Element == null || Control == null)