summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Platform.Android
diff options
context:
space:
mode:
Diffstat (limited to 'Xamarin.Forms.Platform.Android')
-rw-r--r--Xamarin.Forms.Platform.Android/AppCompat/ButtonRenderer.cs38
-rw-r--r--Xamarin.Forms.Platform.Android/AppCompat/FormsAppCompatActivity.cs1
-rw-r--r--Xamarin.Forms.Platform.Android/AppCompat/FrameRenderer.cs9
-rw-r--r--Xamarin.Forms.Platform.Android/AppCompat/MasterDetailPageRenderer.cs4
-rw-r--r--Xamarin.Forms.Platform.Android/AppCompat/NavigationPageRenderer.cs4
-rw-r--r--Xamarin.Forms.Platform.Android/FormsApplicationActivity.cs1
-rw-r--r--Xamarin.Forms.Platform.Android/IVisualElementRenderer.cs3
-rw-r--r--Xamarin.Forms.Platform.Android/Renderers/ButtonRenderer.cs26
-rw-r--r--Xamarin.Forms.Platform.Android/Renderers/EditorEditText.cs13
-rw-r--r--Xamarin.Forms.Platform.Android/Renderers/EntryEditText.cs13
-rw-r--r--Xamarin.Forms.Platform.Android/Renderers/MasterDetailRenderer.cs4
-rw-r--r--Xamarin.Forms.Platform.Android/Renderers/NavigationRenderer.cs4
-rw-r--r--Xamarin.Forms.Platform.Android/Renderers/ScrollViewRenderer.cs4
-rw-r--r--Xamarin.Forms.Platform.Android/Renderers/SearchBarRenderer.cs20
-rw-r--r--Xamarin.Forms.Platform.Android/ViewRenderer.cs99
-rw-r--r--Xamarin.Forms.Platform.Android/VisualElementExtensions.cs12
-rw-r--r--Xamarin.Forms.Platform.Android/VisualElementRenderer.cs77
17 files changed, 28 insertions, 304 deletions
diff --git a/Xamarin.Forms.Platform.Android/AppCompat/ButtonRenderer.cs b/Xamarin.Forms.Platform.Android/AppCompat/ButtonRenderer.cs
index aef56e11..4c33df85 100644
--- a/Xamarin.Forms.Platform.Android/AppCompat/ButtonRenderer.cs
+++ b/Xamarin.Forms.Platform.Android/AppCompat/ButtonRenderer.cs
@@ -9,14 +9,11 @@ using Android.Support.V7.Widget;
using Android.Util;
using GlobalResource = Android.Resource;
using Object = Java.Lang.Object;
-using AView = Android.Views.View;
-using AMotionEvent = Android.Views.MotionEvent;
-using AMotionEventActions = Android.Views.MotionEventActions;
using static System.String;
namespace Xamarin.Forms.Platform.Android.AppCompat
{
- public class ButtonRenderer : ViewRenderer<Button, AppCompatButton>, AView.IOnAttachStateChangeListener
+ public class ButtonRenderer : ViewRenderer<Button, AppCompatButton>, global::Android.Views.View.IOnAttachStateChangeListener
{
TextColorSwitcher _textColorSwitcher;
float _defaultFontSize;
@@ -31,12 +28,12 @@ namespace Xamarin.Forms.Platform.Android.AppCompat
global::Android.Widget.Button NativeButton => Control;
- void IOnAttachStateChangeListener.OnViewAttachedToWindow(AView attachedView)
+ void IOnAttachStateChangeListener.OnViewAttachedToWindow(global::Android.Views.View attachedView)
{
UpdateText();
}
- void IOnAttachStateChangeListener.OnViewDetachedFromWindow(AView detachedView)
+ void IOnAttachStateChangeListener.OnViewDetachedFromWindow(global::Android.Views.View detachedView)
{
}
@@ -77,7 +74,6 @@ namespace Xamarin.Forms.Platform.Android.AppCompat
if (Control != null)
{
Control.SetOnClickListener(null);
- Control.SetOnTouchListener(null);
Control.RemoveOnAttachStateChangeListener(this);
Control.Tag = null;
_textColorSwitcher = null;
@@ -102,7 +98,6 @@ namespace Xamarin.Forms.Platform.Android.AppCompat
AppCompatButton button = CreateNativeControl();
button.SetOnClickListener(ButtonClickListener.Instance.Value);
- button.SetOnTouchListener(ButtonTouchListener.Instance.Value);
button.Tag = this;
_textColorSwitcher = new TextColorSwitcher(button.TextColors);
SetNativeControl(button);
@@ -297,34 +292,11 @@ namespace Xamarin.Forms.Platform.Android.AppCompat
#endregion
- public void OnClick(AView v)
+ public void OnClick(global::Android.Views.View v)
{
var renderer = v.Tag as ButtonRenderer;
((IButtonController)renderer?.Element)?.SendClicked();
}
}
-
- class ButtonTouchListener : Object, IOnTouchListener
- {
- public static readonly Lazy<ButtonTouchListener> Instance = new Lazy<ButtonTouchListener>(() => new ButtonTouchListener());
-
- public bool OnTouch(AView v, AMotionEvent e)
- {
- var renderer = v.Tag as ButtonRenderer;
- if (renderer != null)
- {
- var buttonController = renderer.Element as IButtonController;
- if (e.Action == AMotionEventActions.Down)
- {
- buttonController?.SendPressed();
- }
- else if (e.Action == AMotionEventActions.Up)
- {
- buttonController?.SendReleased();
- }
- }
- return false;
- }
- }
}
-}
+} \ No newline at end of file
diff --git a/Xamarin.Forms.Platform.Android/AppCompat/FormsAppCompatActivity.cs b/Xamarin.Forms.Platform.Android/AppCompat/FormsAppCompatActivity.cs
index 223d3a83..2fe5d5d9 100644
--- a/Xamarin.Forms.Platform.Android/AppCompat/FormsAppCompatActivity.cs
+++ b/Xamarin.Forms.Platform.Android/AppCompat/FormsAppCompatActivity.cs
@@ -1,7 +1,6 @@
#region
using System;
-using System.Collections.Concurrent;
using System.ComponentModel;
using System.Linq;
using Android.App;
diff --git a/Xamarin.Forms.Platform.Android/AppCompat/FrameRenderer.cs b/Xamarin.Forms.Platform.Android/AppCompat/FrameRenderer.cs
index 7c40ea80..2b657b5e 100644
--- a/Xamarin.Forms.Platform.Android/AppCompat/FrameRenderer.cs
+++ b/Xamarin.Forms.Platform.Android/AppCompat/FrameRenderer.cs
@@ -21,7 +21,6 @@ namespace Xamarin.Forms.Platform.Android.AppCompat
float _defaultElevation = -1f;
float _defaultCornerRadius = -1f;
- int? _defaultLabelFor;
bool _clickable;
bool _disposed;
@@ -114,14 +113,6 @@ namespace Xamarin.Forms.Platform.Android.AppCompat
ContentDescription = Element.AutomationId;
}
- void IVisualElementRenderer.SetLabelFor(int? id)
- {
- if (_defaultLabelFor == null)
- _defaultLabelFor = LabelFor;
-
- LabelFor = (int)(id ?? _defaultLabelFor);
- }
-
VisualElementTracker IVisualElementRenderer.Tracker => _visualElementTracker;
void IVisualElementRenderer.UpdateLayout()
diff --git a/Xamarin.Forms.Platform.Android/AppCompat/MasterDetailPageRenderer.cs b/Xamarin.Forms.Platform.Android/AppCompat/MasterDetailPageRenderer.cs
index 85ab6b73..757a98b4 100644
--- a/Xamarin.Forms.Platform.Android/AppCompat/MasterDetailPageRenderer.cs
+++ b/Xamarin.Forms.Platform.Android/AppCompat/MasterDetailPageRenderer.cs
@@ -165,10 +165,6 @@ namespace Xamarin.Forms.Platform.Android.AppCompat
_tracker = new VisualElementTracker(this);
}
- void IVisualElementRenderer.SetLabelFor(int? id)
- {
- }
-
VisualElementTracker IVisualElementRenderer.Tracker => _tracker;
void IVisualElementRenderer.UpdateLayout()
diff --git a/Xamarin.Forms.Platform.Android/AppCompat/NavigationPageRenderer.cs b/Xamarin.Forms.Platform.Android/AppCompat/NavigationPageRenderer.cs
index cc474293..cab4d561 100644
--- a/Xamarin.Forms.Platform.Android/AppCompat/NavigationPageRenderer.cs
+++ b/Xamarin.Forms.Platform.Android/AppCompat/NavigationPageRenderer.cs
@@ -268,7 +268,7 @@ namespace Xamarin.Forms.Platform.Android.AppCompat
navController.RemovePageRequested += OnRemovePageRequested;
// If there is already stuff on the stack we need to push it
- foreach (Page page in navController.Pages)
+ foreach (Page page in navController.StackCopy.Reverse())
{
PushViewAsync(page, false);
}
@@ -461,7 +461,7 @@ namespace Xamarin.Forms.Platform.Android.AppCompat
Task<bool> OnPopViewAsync(Page page, bool animated)
{
- Page pageToShow = ((INavigationPageController)Element).Peek(1);
+ Page pageToShow = ((INavigationPageController)Element).StackCopy.Skip(1).FirstOrDefault();
if (pageToShow == null)
return Task.FromResult(false);
diff --git a/Xamarin.Forms.Platform.Android/FormsApplicationActivity.cs b/Xamarin.Forms.Platform.Android/FormsApplicationActivity.cs
index fb1fa174..0a2397d8 100644
--- a/Xamarin.Forms.Platform.Android/FormsApplicationActivity.cs
+++ b/Xamarin.Forms.Platform.Android/FormsApplicationActivity.cs
@@ -1,5 +1,4 @@
using System;
-using System.Collections.Concurrent;
using System.ComponentModel;
using System.Linq;
using Android.App;
diff --git a/Xamarin.Forms.Platform.Android/IVisualElementRenderer.cs b/Xamarin.Forms.Platform.Android/IVisualElementRenderer.cs
index da565ce2..99393516 100644
--- a/Xamarin.Forms.Platform.Android/IVisualElementRenderer.cs
+++ b/Xamarin.Forms.Platform.Android/IVisualElementRenderer.cs
@@ -17,9 +17,6 @@ namespace Xamarin.Forms.Platform.Android
SizeRequest GetDesiredSize(int widthConstraint, int heightConstraint);
void SetElement(VisualElement element);
-
- void SetLabelFor(int? id);
-
void UpdateLayout();
}
} \ No newline at end of file
diff --git a/Xamarin.Forms.Platform.Android/Renderers/ButtonRenderer.cs b/Xamarin.Forms.Platform.Android/Renderers/ButtonRenderer.cs
index e07a2be5..4f384b3b 100644
--- a/Xamarin.Forms.Platform.Android/Renderers/ButtonRenderer.cs
+++ b/Xamarin.Forms.Platform.Android/Renderers/ButtonRenderer.cs
@@ -7,8 +7,6 @@ using Android.Util;
using static System.String;
using AButton = Android.Widget.Button;
using AView = Android.Views.View;
-using AMotionEvent = Android.Views.MotionEvent;
-using AMotionEventActions = Android.Views.MotionEventActions;
using Object = Java.Lang.Object;
namespace Xamarin.Forms.Platform.Android
@@ -98,7 +96,6 @@ namespace Xamarin.Forms.Platform.Android
{
button = CreateNativeControl();
button.SetOnClickListener(ButtonClickListener.Instance.Value);
- button.SetOnTouchListener(ButtonTouchListener.Instance.Value);
button.Tag = this;
SetNativeControl(button);
_textColorSwitcher = new TextColorSwitcher(button.TextColors);
@@ -306,28 +303,5 @@ namespace Xamarin.Forms.Platform.Android
((IButtonController)renderer.Element).SendClicked();
}
}
-
- class ButtonTouchListener : Object, IOnTouchListener
- {
- public static readonly Lazy<ButtonTouchListener> Instance = new Lazy<ButtonTouchListener>(() => new ButtonTouchListener());
-
- public bool OnTouch(AView v, AMotionEvent e)
- {
- var renderer = v.Tag as ButtonRenderer;
- if (renderer != null)
- {
- var buttonController = renderer.Element as IButtonController;
- if (e.Action == AMotionEventActions.Down)
- {
- buttonController?.SendPressed();
- }
- else if (e.Action == AMotionEventActions.Up)
- {
- buttonController?.SendReleased();
- }
- }
- return false;
- }
- }
}
} \ No newline at end of file
diff --git a/Xamarin.Forms.Platform.Android/Renderers/EditorEditText.cs b/Xamarin.Forms.Platform.Android/Renderers/EditorEditText.cs
index 4a6428eb..24273121 100644
--- a/Xamarin.Forms.Platform.Android/Renderers/EditorEditText.cs
+++ b/Xamarin.Forms.Platform.Android/Renderers/EditorEditText.cs
@@ -23,12 +23,13 @@ namespace Xamarin.Forms.Platform.Android
public override bool OnKeyPreIme(Keycode keyCode, KeyEvent e)
{
- if (keyCode != Keycode.Back || e.Action != KeyEventActions.Down)
- return base.OnKeyPreIme(keyCode, e);
-
- this.HideKeyboard();
- OnBackKeyboardPressed?.Invoke(this, EventArgs.Empty);
- return true;
+ if (keyCode == Keycode.Back && e.Action == KeyEventActions.Down)
+ {
+ EventHandler handler = OnBackKeyboardPressed;
+ if (handler != null)
+ handler(this, EventArgs.Empty);
+ }
+ return base.OnKeyPreIme(keyCode, e);
}
public override bool RequestFocus(FocusSearchDirection direction, Rect previouslyFocusedRect)
diff --git a/Xamarin.Forms.Platform.Android/Renderers/EntryEditText.cs b/Xamarin.Forms.Platform.Android/Renderers/EntryEditText.cs
index 5c0b7c0e..de03a414 100644
--- a/Xamarin.Forms.Platform.Android/Renderers/EntryEditText.cs
+++ b/Xamarin.Forms.Platform.Android/Renderers/EntryEditText.cs
@@ -23,12 +23,13 @@ namespace Xamarin.Forms.Platform.Android
public override bool OnKeyPreIme(Keycode keyCode, KeyEvent e)
{
- if (keyCode != Keycode.Back || e.Action != KeyEventActions.Down)
- return base.OnKeyPreIme(keyCode, e);
-
- this.HideKeyboard();
- OnKeyboardBackPressed?.Invoke(this, EventArgs.Empty);
- return true;
+ if (keyCode == Keycode.Back && e.Action == KeyEventActions.Down)
+ {
+ EventHandler handler = OnKeyboardBackPressed;
+ if (handler != null)
+ handler(this, EventArgs.Empty);
+ }
+ return base.OnKeyPreIme(keyCode, e);
}
public override bool RequestFocus(FocusSearchDirection direction, Rect previouslyFocusedRect)
diff --git a/Xamarin.Forms.Platform.Android/Renderers/MasterDetailRenderer.cs b/Xamarin.Forms.Platform.Android/Renderers/MasterDetailRenderer.cs
index d18781a7..ec9c620e 100644
--- a/Xamarin.Forms.Platform.Android/Renderers/MasterDetailRenderer.cs
+++ b/Xamarin.Forms.Platform.Android/Renderers/MasterDetailRenderer.cs
@@ -287,10 +287,6 @@ namespace Xamarin.Forms.Platform.Android
SetDrawerLockMode(_page.IsGestureEnabled ? LockModeUnlocked : LockModeLockedClosed);
}
- void IVisualElementRenderer.SetLabelFor(int? id)
- {
- }
-
void SetLockMode(int lockMode)
{
if (_currentLockMode != lockMode)
diff --git a/Xamarin.Forms.Platform.Android/Renderers/NavigationRenderer.cs b/Xamarin.Forms.Platform.Android/Renderers/NavigationRenderer.cs
index bf6540b9..c02dc42b 100644
--- a/Xamarin.Forms.Platform.Android/Renderers/NavigationRenderer.cs
+++ b/Xamarin.Forms.Platform.Android/Renderers/NavigationRenderer.cs
@@ -109,7 +109,7 @@ namespace Xamarin.Forms.Platform.Android
newNavController.RemovePageRequested += OnRemovePageRequested;
// If there is already stuff on the stack we need to push it
- foreach (Page page in newNavController.Pages)
+ foreach(Page page in newNavController.StackCopy.Reverse())
{
PushViewAsync(page, false);
}
@@ -130,7 +130,7 @@ namespace Xamarin.Forms.Platform.Android
protected virtual Task<bool> OnPopViewAsync(Page page, bool animated)
{
- Page pageToShow = ((INavigationPageController)Element).Peek(1);
+ Page pageToShow = ((INavigationPageController)Element).StackCopy.Skip(1).FirstOrDefault();
if (pageToShow == null)
return Task.FromResult(false);
diff --git a/Xamarin.Forms.Platform.Android/Renderers/ScrollViewRenderer.cs b/Xamarin.Forms.Platform.Android/Renderers/ScrollViewRenderer.cs
index a2e3ddb3..6db51c23 100644
--- a/Xamarin.Forms.Platform.Android/Renderers/ScrollViewRenderer.cs
+++ b/Xamarin.Forms.Platform.Android/Renderers/ScrollViewRenderer.cs
@@ -328,10 +328,6 @@ namespace Xamarin.Forms.Platform.Android
}
}
- void IVisualElementRenderer.SetLabelFor(int? id)
- {
- }
-
void UpdateBackgroundColor()
{
SetBackgroundColor(Element.BackgroundColor.ToAndroid(Color.Transparent));
diff --git a/Xamarin.Forms.Platform.Android/Renderers/SearchBarRenderer.cs b/Xamarin.Forms.Platform.Android/Renderers/SearchBarRenderer.cs
index 48bcf576..468710ca 100644
--- a/Xamarin.Forms.Platform.Android/Renderers/SearchBarRenderer.cs
+++ b/Xamarin.Forms.Platform.Android/Renderers/SearchBarRenderer.cs
@@ -33,7 +33,7 @@ namespace Xamarin.Forms.Platform.Android
bool SearchView.IOnQueryTextListener.OnQueryTextSubmit(string query)
{
((ISearchBarController)Element).OnSearchButtonPressed();
- ClearFocus(Control);
+ Control.ClearFocus();
return true;
}
@@ -67,7 +67,7 @@ namespace Xamarin.Forms.Platform.Android
_inputType = InputTypes.ClassText | InputTypes.TextFlagAutoComplete | InputTypes.TextFlagNoSuggestions;
}
- ClearFocus(searchView);
+ searchView.ClearFocus();
UpdatePlaceholder();
UpdateText();
UpdateEnabled();
@@ -113,7 +113,7 @@ namespace Xamarin.Forms.Platform.Android
internal override void OnNativeFocusChanged(bool hasFocus)
{
if (hasFocus && !Element.IsEnabled)
- ClearFocus(Control);
+ Control.ClearFocus();
}
void UpdateAlignment()
@@ -148,7 +148,7 @@ namespace Xamarin.Forms.Platform.Android
SearchView control = Control;
if (!model.IsEnabled)
{
- ClearFocus(control);
+ control.ClearFocus();
// removes cursor in SearchView
control.SetInputType(InputTypes.Null);
}
@@ -156,18 +156,6 @@ namespace Xamarin.Forms.Platform.Android
control.SetInputType(_inputType);
}
- void ClearFocus(SearchView view)
- {
- try
- {
- view.ClearFocus();
- }
- catch (Java.Lang.UnsupportedOperationException)
- {
- // silently catch these as they happen in the previewer due to some bugs in upstread android
- }
- }
-
void UpdateFont()
{
_editText = _editText ?? Control.GetChildrenOfType<EditText>().FirstOrDefault();
diff --git a/Xamarin.Forms.Platform.Android/ViewRenderer.cs b/Xamarin.Forms.Platform.Android/ViewRenderer.cs
index 31a9c282..c4bd3fa0 100644
--- a/Xamarin.Forms.Platform.Android/ViewRenderer.cs
+++ b/Xamarin.Forms.Platform.Android/ViewRenderer.cs
@@ -19,9 +19,6 @@ namespace Xamarin.Forms.Platform.Android
}
ViewGroup _container;
- string _defaultContentDescription;
- bool? _defaultFocusable;
- string _defaultHint;
bool _disposed;
EventHandler<VisualElement.FocusRequestArgs> _focusChangeHandler;
@@ -69,7 +66,7 @@ namespace Xamarin.Forms.Platform.Android
{
if (Control == null)
return (base.GetDesiredSize(widthConstraint, heightConstraint));
-
+
AView view = _container == this ? (AView)Control : _container;
view.Measure(widthConstraint, heightConstraint);
@@ -127,8 +124,6 @@ namespace Xamarin.Forms.Platform.Android
if (e.PropertyName == VisualElement.IsEnabledProperty.PropertyName)
UpdateIsEnabled();
- else if (e.PropertyName == Accessibility.LabeledByProperty.PropertyName)
- SetLabeledBy();
}
protected override void OnLayout(bool changed, int l, int t, int r, int b)
@@ -160,79 +155,6 @@ namespace Xamarin.Forms.Platform.Android
}
}
- protected override void SetContentDescription()
- {
- if (Control == null)
- {
- base.SetContentDescription();
- return;
- }
-
- if (Element == null)
- return;
-
- if (SetHint())
- return;
-
- if (_defaultContentDescription == null)
- _defaultContentDescription = Control.ContentDescription;
-
- var elemValue = string.Join(" ", (string)Element.GetValue(Accessibility.NameProperty), (string)Element.GetValue(Accessibility.HintProperty));
-
- if (!string.IsNullOrWhiteSpace(elemValue))
- Control.ContentDescription = elemValue;
- else
- Control.ContentDescription = _defaultContentDescription;
- }
-
- protected override void SetFocusable()
- {
- if (Control == null)
- {
- base.SetFocusable();
- return;
- }
-
- if (Element == null)
- return;
-
- if (!_defaultFocusable.HasValue)
- _defaultFocusable = Control.Focusable;
-
- Control.Focusable = (bool)((bool?)Element.GetValue(Accessibility.IsInAccessibleTreeProperty) ?? _defaultFocusable);
- }
-
- protected override bool SetHint()
- {
- if (Control == null)
- {
- return base.SetHint();
- }
-
- if (Element == null)
- return false;
-
- var textView = Control as global::Android.Widget.TextView;
- if (textView == null)
- return false;
-
- // Let the specified Title/Placeholder take precedence, but don't set the ContentDescription (won't work anyway)
- if (((Element as Picker)?.Title ?? (Element as Entry)?.Placeholder ?? (Element as EntryCell)?.Placeholder) != null)
- return true;
-
- if (_defaultHint == null)
- _defaultHint = textView.Hint;
-
- var elemValue = string.Join(". ", (string)Element.GetValue(Accessibility.NameProperty), (string)Element.GetValue(Accessibility.HintProperty));
-
- if (!string.IsNullOrWhiteSpace(elemValue))
- textView.Hint = elemValue;
- else
- textView.Hint = _defaultHint;
-
- return true;
- }
-
protected void SetNativeControl(TNativeView control)
{
SetNativeControl(control, this);
@@ -297,25 +219,6 @@ namespace Xamarin.Forms.Platform.Android
Control.OnFocusChangeListener = this;
UpdateIsEnabled();
- SetLabeledBy();
- }
-
- void SetLabeledBy()
- {
- if (Element == null || Control == null)
- return;
-
- var elemValue = (VisualElement)Element.GetValue(Accessibility.LabeledByProperty);
-
- if (elemValue != null)
- {
- var id = Control.Id;
- if (id == -1)
- id = Control.Id = FormsAppCompatActivity.GetUniqueId();
-
- var renderer = elemValue?.GetRenderer();
- renderer?.SetLabelFor(id);
- }
}
void UpdateIsEnabled()
diff --git a/Xamarin.Forms.Platform.Android/VisualElementExtensions.cs b/Xamarin.Forms.Platform.Android/VisualElementExtensions.cs
index 800a967e..13f2fffa 100644
--- a/Xamarin.Forms.Platform.Android/VisualElementExtensions.cs
+++ b/Xamarin.Forms.Platform.Android/VisualElementExtensions.cs
@@ -1,19 +1,7 @@
-using System;
-
namespace Xamarin.Forms.Platform.Android
{
public static class VisualElementExtensions
{
- public static IVisualElementRenderer GetRenderer(this VisualElement self)
- {
- if (self == null)
- throw new ArgumentNullException("self");
-
- IVisualElementRenderer renderer = Platform.GetRenderer(self);
-
- return renderer;
- }
-
public static bool ShouldBeMadeClickable(this View view)
{
var shouldBeClickable = false;
diff --git a/Xamarin.Forms.Platform.Android/VisualElementRenderer.cs b/Xamarin.Forms.Platform.Android/VisualElementRenderer.cs
index 68f5d7d4..c2c96eac 100644
--- a/Xamarin.Forms.Platform.Android/VisualElementRenderer.cs
+++ b/Xamarin.Forms.Platform.Android/VisualElementRenderer.cs
@@ -23,10 +23,6 @@ namespace Xamarin.Forms.Platform.Android
VisualElementRendererFlags _flags = VisualElementRendererFlags.AutoPackage | VisualElementRendererFlags.AutoTrack;
- string _defaultContentDescription;
- bool? _defaultFocusable;
- string _defaultHint;
- int? _defaultLabelFor;
InnerGestureListener _gestureListener;
VisualElementPackager _packager;
PropertyChangedEventHandler _propertyChangeHandler;
@@ -213,9 +209,6 @@ namespace Xamarin.Forms.Platform.Android
if (element != null && !string.IsNullOrEmpty(element.AutomationId))
SetAutomationId(element.AutomationId);
- SetContentDescription();
- SetFocusable();
-
Performance.Stop();
}
@@ -307,12 +300,6 @@ namespace Xamarin.Forms.Platform.Android
UpdateBackgroundColor();
else if (e.PropertyName == VisualElement.InputTransparentProperty.PropertyName)
InputTransparent = Element.InputTransparent;
- else if (e.PropertyName == Accessibility.HintProperty.PropertyName)
- SetContentDescription();
- else if (e.PropertyName == Accessibility.NameProperty.PropertyName)
- SetContentDescription();
- else if (e.PropertyName == Accessibility.IsInAccessibleTreeProperty.PropertyName)
- SetFocusable();
}
protected override void OnLayout(bool changed, int l, int t, int r, int b)
@@ -342,62 +329,6 @@ namespace Xamarin.Forms.Platform.Android
ContentDescription = id;
}
- protected virtual void SetContentDescription()
- {
- if (Element == null)
- return;
-
- if (SetHint())
- return;
-
- if (_defaultContentDescription == null)
- _defaultContentDescription = ContentDescription;
-
- var elemValue = string.Join(" ", (string)Element.GetValue(Accessibility.NameProperty), (string)Element.GetValue(Accessibility.HintProperty));
-
- if (!string.IsNullOrWhiteSpace(elemValue))
- ContentDescription = elemValue;
- else
- ContentDescription = _defaultContentDescription;
- }
-
- protected virtual void SetFocusable()
- {
- if (Element == null)
- return;
-
- if (!_defaultFocusable.HasValue)
- _defaultFocusable = Focusable;
-
- Focusable = (bool)((bool?)Element.GetValue(Accessibility.IsInAccessibleTreeProperty) ?? _defaultFocusable);
- }
-
- protected virtual bool SetHint()
- {
- if (Element == null)
- return false;
-
- var textView = this as global::Android.Widget.TextView;
- if (textView == null)
- return false;
-
- // Let the specified Title/Placeholder take precedence, but don't set the ContentDescription (won't work anyway)
- if (((Element as Picker)?.Title ?? (Element as Entry)?.Placeholder ?? (Element as EntryCell)?.Placeholder) != null)
- return true;
-
- if (_defaultHint == null)
- _defaultHint = textView.Hint;
-
- var elemValue = string.Join(". ", (string)Element.GetValue(Accessibility.NameProperty), (string)Element.GetValue(Accessibility.HintProperty));
-
- if (!string.IsNullOrWhiteSpace(elemValue))
- textView.Hint = elemValue;
- else
- textView.Hint = _defaultHint;
-
- return true;
- }
-
protected void SetPackager(VisualElementPackager packager)
{
_packager = packager;
@@ -424,14 +355,6 @@ namespace Xamarin.Forms.Platform.Android
UpdateGestureRecognizers();
}
- void IVisualElementRenderer.SetLabelFor(int? id)
- {
- if (_defaultLabelFor == null)
- _defaultLabelFor = LabelFor;
-
- LabelFor = (int)(id ?? _defaultLabelFor);
- }
-
void SubscribeGestureRecognizers(VisualElement element)
{
var view = element as View;