summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Smith <jason.smith@xamarin.com>2016-04-12 08:53:36 -0700
committerJason Smith <jason.smith@xamarin.com>2016-04-12 08:53:36 -0700
commitba2a434ec13370cc4814b54f6ce51d4d16594f97 (patch)
treece0d082e4e114fa689e7c5eee3da9d892b11f49c
parent0a20bdaa3c373ec303c9a94ae45ecaa144996ba5 (diff)
downloadxamarin-forms-ba2a434ec13370cc4814b54f6ce51d4d16594f97.tar.gz
xamarin-forms-ba2a434ec13370cc4814b54f6ce51d4d16594f97.tar.bz2
xamarin-forms-ba2a434ec13370cc4814b54f6ce51d4d16594f97.zip
Add compatibility shims to fix warnings; annotate warnings which require (#75)
more thought to fix; Fix a few more warnings VS didn't see fit to raise as errors Adding comments to `pragma warning disable` statements pragma comments Fix typo Set TabletMasterDetailRenderer back to previous version Fix incorrect config access in legacy activity
-rw-r--r--Xamarin.Forms.ControlGallery.Android/Activity1.cs2
-rw-r--r--Xamarin.Forms.Platform.Android/AppCompat/ButtonRenderer.cs6
-rw-r--r--Xamarin.Forms.Platform.Android/AppCompat/CarouselPageRenderer.cs9
-rw-r--r--Xamarin.Forms.Platform.Android/AppCompat/FormsAppCompatActivity.cs8
-rw-r--r--Xamarin.Forms.Platform.Android/AppCompat/FrameRenderer.cs7
-rw-r--r--Xamarin.Forms.Platform.Android/AppCompat/NavigationPageRenderer.cs10
-rw-r--r--Xamarin.Forms.Platform.Android/AppCompat/Platform.cs8
-rw-r--r--Xamarin.Forms.Platform.Android/Cells/BaseCellView.cs28
-rw-r--r--Xamarin.Forms.Platform.Android/Cells/EntryCellView.cs4
-rw-r--r--Xamarin.Forms.Platform.Android/ColorExtensions.cs6
-rw-r--r--Xamarin.Forms.Platform.Android/Forms.cs3
-rw-r--r--Xamarin.Forms.Platform.Android/Platform.cs24
-rw-r--r--Xamarin.Forms.Platform.Android/Renderers/BoxRenderer.cs2
-rw-r--r--Xamarin.Forms.Platform.Android/Renderers/ButtonRenderer.cs8
-rw-r--r--Xamarin.Forms.Platform.Android/Renderers/CarouselPageRenderer.cs8
-rw-r--r--Xamarin.Forms.Platform.Android/Renderers/CarouselViewRenderer.cs24
-rw-r--r--Xamarin.Forms.Platform.Android/Renderers/FormattedStringExtensions.cs2
-rw-r--r--Xamarin.Forms.Platform.Android/Renderers/FrameRenderer.cs4
-rw-r--r--Xamarin.Forms.Platform.Android/Renderers/ImageRenderer.cs3
-rw-r--r--Xamarin.Forms.Platform.Android/Renderers/LabelRenderer.cs4
-rw-r--r--Xamarin.Forms.Platform.Android/Renderers/ListViewAdapter.cs4
-rw-r--r--Xamarin.Forms.Platform.Android/Renderers/MasterDetailRenderer.cs4
-rw-r--r--Xamarin.Forms.Platform.Android/Renderers/NavigationMenuRenderer.cs8
-rw-r--r--Xamarin.Forms.Platform.Android/Renderers/NavigationRenderer.cs1
-rw-r--r--Xamarin.Forms.Platform.Android/Renderers/OpenGLViewRenderer.cs8
-rw-r--r--Xamarin.Forms.Platform.Android/Renderers/ScrollViewRenderer.cs2
-rw-r--r--Xamarin.Forms.Platform.Android/Renderers/TableViewModelRenderer.cs4
-rw-r--r--Xamarin.Forms.Platform.Android/Renderers/WebViewRenderer.cs12
-rw-r--r--Xamarin.Forms.Platform.Android/ResourceManager.cs5
-rw-r--r--Xamarin.Forms.Platform.Android/TextViewExtensions.cs21
-rw-r--r--Xamarin.Forms.Platform.Android/ViewExtensions.cs30
-rw-r--r--Xamarin.Forms.Platform.Android/VisualElementRenderer.cs4
-rw-r--r--Xamarin.Forms.Platform.Android/Xamarin.Forms.Platform.Android.csproj4
33 files changed, 124 insertions, 153 deletions
diff --git a/Xamarin.Forms.ControlGallery.Android/Activity1.cs b/Xamarin.Forms.ControlGallery.Android/Activity1.cs
index 4a96b800..4b36a548 100644
--- a/Xamarin.Forms.ControlGallery.Android/Activity1.cs
+++ b/Xamarin.Forms.ControlGallery.Android/Activity1.cs
@@ -188,7 +188,7 @@ namespace Xamarin.Forms.ControlGallery.Android
base.OnCreate(bundle);
if (!Debugger.IsAttached)
- Insights.Initialize(App.Secrets["InsightsApiKey"], this.ApplicationContext);
+ Insights.Initialize(App.Config["InsightsApiKey"], this.ApplicationContext);
Forms.Init(this, bundle);
FormsMaps.Init(this, bundle);
diff --git a/Xamarin.Forms.Platform.Android/AppCompat/ButtonRenderer.cs b/Xamarin.Forms.Platform.Android/AppCompat/ButtonRenderer.cs
index 817519c7..3260dbf1 100644
--- a/Xamarin.Forms.Platform.Android/AppCompat/ButtonRenderer.cs
+++ b/Xamarin.Forms.Platform.Android/AppCompat/ButtonRenderer.cs
@@ -4,6 +4,7 @@ using Android.Content;
using Android.Content.Res;
using Android.Graphics;
using Android.Graphics.Drawables;
+using Android.Support.V4.Content;
using Android.Support.V7.Widget;
using Android.Util;
using GlobalResource = Android.Resource;
@@ -127,14 +128,13 @@ namespace Xamarin.Forms.Platform.Android.AppCompat
{
Resources.Theme theme = context.Theme;
if (theme != null && theme.ResolveAttribute(id, value, true))
-#pragma warning disable 618
- Control.SupportBackgroundTintList = Resources.GetColorStateList(value.Data);
-#pragma warning restore 618
+ Control.SupportBackgroundTintList = ContextCompat.GetColorStateList(context, value.Data);
else
Control.SupportBackgroundTintList = new ColorStateList(States, new[] { (int)0xffd7d6d6, 0x7fd7d6d6 });
}
catch (Exception ex)
{
+ Log.Warning("Xamarin.Forms.Platform.Android.ButtonRenderer", "Could not retrieve button background resource: {0}", ex);
Control.SupportBackgroundTintList = new ColorStateList(States, new[] { (int)0xffd7d6d6, 0x7fd7d6d6 });
}
}
diff --git a/Xamarin.Forms.Platform.Android/AppCompat/CarouselPageRenderer.cs b/Xamarin.Forms.Platform.Android/AppCompat/CarouselPageRenderer.cs
index 5e8a1b8a..a42d2863 100644
--- a/Xamarin.Forms.Platform.Android/AppCompat/CarouselPageRenderer.cs
+++ b/Xamarin.Forms.Platform.Android/AppCompat/CarouselPageRenderer.cs
@@ -100,7 +100,6 @@ namespace Xamarin.Forms.Platform.Android.AppCompat
if (carouselPage.CurrentPage != null)
ScrollToCurrentPage();
- UpdateIgnoreContainerAreas();
carouselPage.InternalChildren.CollectionChanged += OnChildrenCollectionChanged;
}
}
@@ -137,19 +136,11 @@ namespace Xamarin.Forms.Platform.Android.AppCompat
((FormsFragmentPagerAdapter<ContentPage>)pager.Adapter).CountOverride = Element.Children.Count;
pager.Adapter.NotifyDataSetChanged();
-
- UpdateIgnoreContainerAreas();
}
void ScrollToCurrentPage()
{
_viewPager.SetCurrentItem(Element.Children.IndexOf(Element.CurrentPage), true);
}
-
- void UpdateIgnoreContainerAreas()
- {
- foreach (ContentPage child in Element.Children)
- child.IgnoresContainerArea = child is NavigationPage;
- }
}
} \ 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 ac9e091c..a8e05444 100644
--- a/Xamarin.Forms.Platform.Android/AppCompat/FormsAppCompatActivity.cs
+++ b/Xamarin.Forms.Platform.Android/AppCompat/FormsAppCompatActivity.cs
@@ -8,6 +8,7 @@ using Android.Content;
using Android.Content.Res;
using Android.OS;
using Android.Runtime;
+using Android.Support.V4.Content;
using Android.Support.V7.App;
using Android.Util;
using Android.Views;
@@ -110,6 +111,8 @@ namespace Xamarin.Forms.Platform.Android
RegisterHandlerForDefaultRenderer(typeof(Picker), typeof(AppCompat.PickerRenderer), typeof(PickerRenderer));
RegisterHandlerForDefaultRenderer(typeof(Frame), typeof(AppCompat.FrameRenderer), typeof(FrameRenderer));
RegisterHandlerForDefaultRenderer(typeof(CarouselPage), typeof(AppCompat.CarouselPageRenderer), typeof(CarouselPageRenderer));
+
+ _renderersAdded = true;
}
if (application == null)
@@ -303,13 +306,12 @@ namespace Xamarin.Forms.Platform.Android
if (value.Type >= DataType.FirstInt && value.Type <= DataType.LastInt)
return value.Data;
if (value.Type == DataType.String)
-#pragma warning disable 618
- return context.Resources.GetColor(value.ResourceId);
-#pragma warning restore 618
+ return ContextCompat.GetColor(context, value.ResourceId);
}
}
catch (Exception ex)
{
+ Log.Warning("Xamarin.Forms.Platform.Android.FormsAppCompatActivity", "Error retrieving color resource: {0}", ex);
}
return -1;
diff --git a/Xamarin.Forms.Platform.Android/AppCompat/FrameRenderer.cs b/Xamarin.Forms.Platform.Android/AppCompat/FrameRenderer.cs
index 232b6a6f..c2dd8e69 100644
--- a/Xamarin.Forms.Platform.Android/AppCompat/FrameRenderer.cs
+++ b/Xamarin.Forms.Platform.Android/AppCompat/FrameRenderer.cs
@@ -242,8 +242,11 @@ namespace Xamarin.Forms.Platform.Android.AppCompat
return;
bool newValue = view.ShouldBeMadeClickable();
- if (force || _clickable != newValue)
- Clickable = newValue;
+ if (force || _clickable != newValue)
+ {
+ Clickable = newValue;
+ _clickable = newValue;
+ }
}
void UpdateGestureRecognizers(bool forceClick = false)
diff --git a/Xamarin.Forms.Platform.Android/AppCompat/NavigationPageRenderer.cs b/Xamarin.Forms.Platform.Android/AppCompat/NavigationPageRenderer.cs
index dd1c033d..7fd4ed94 100644
--- a/Xamarin.Forms.Platform.Android/AppCompat/NavigationPageRenderer.cs
+++ b/Xamarin.Forms.Platform.Android/AppCompat/NavigationPageRenderer.cs
@@ -27,14 +27,6 @@ namespace Xamarin.Forms.Platform.Android.AppCompat
{
public class NavigationPageRenderer : VisualElementRenderer<NavigationPage>, IManageFragments
{
- #region Statics
-
- // All statics need to be made non-static/bound to platform
-
- static ViewPropertyAnimator s_currentAnimation;
-
- #endregion
-
readonly List<Fragment> _fragmentStack = new List<Fragment>();
Drawable _backgroundDrawable;
@@ -370,7 +362,7 @@ namespace Xamarin.Forms.Platform.Android.AppCompat
UpdateToolbar();
}
- async void DeviceInfoPropertyChanged(object sender, PropertyChangedEventArgs e)
+ void DeviceInfoPropertyChanged(object sender, PropertyChangedEventArgs e)
{
if (nameof(Device.Info.CurrentOrientation) == e.PropertyName)
ResetToolbar();
diff --git a/Xamarin.Forms.Platform.Android/AppCompat/Platform.cs b/Xamarin.Forms.Platform.Android/AppCompat/Platform.cs
index 6c5d86ff..01e8dcc1 100644
--- a/Xamarin.Forms.Platform.Android/AppCompat/Platform.cs
+++ b/Xamarin.Forms.Platform.Android/AppCompat/Platform.cs
@@ -245,9 +245,7 @@ namespace Xamarin.Forms.Platform.Android.AppCompat
return;
Android.Platform.SetPageContext(page, _context);
-#pragma warning disable 618
- IVisualElementRenderer renderView = RendererFactory.GetRenderer(page);
-#pragma warning restore 618
+ IVisualElementRenderer renderView = Android.Platform.CreateRenderer(page);
Android.Platform.SetRenderer(page, renderView);
if (layout)
@@ -332,9 +330,7 @@ namespace Xamarin.Forms.Platform.Android.AppCompat
AddView(_backgroundView);
Android.Platform.SetPageContext(modal, context);
-#pragma warning disable 618
- _renderer = RendererFactory.GetRenderer(modal);
-#pragma warning restore 618
+ _renderer = Android.Platform.CreateRenderer(modal);
Android.Platform.SetRenderer(modal, _renderer);
AddView(_renderer.ViewGroup);
diff --git a/Xamarin.Forms.Platform.Android/Cells/BaseCellView.cs b/Xamarin.Forms.Platform.Android/Cells/BaseCellView.cs
index 60267c3e..1457075b 100644
--- a/Xamarin.Forms.Platform.Android/Cells/BaseCellView.cs
+++ b/Xamarin.Forms.Platform.Android/Cells/BaseCellView.cs
@@ -2,6 +2,7 @@ using System.IO;
using System.Threading.Tasks;
using Android.Content;
using Android.Graphics;
+using Android.Support.V4.Content;
using Android.Text;
using Android.Views;
using Android.Widget;
@@ -39,9 +40,7 @@ namespace Xamarin.Forms.Platform.Android
SetPadding(padding, padding, padding, padding);
_imageView = new ImageView(context);
-#pragma warning disable 618
- var imageParams = new LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.FillParent)
-#pragma warning restore 618
+ var imageParams = new LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.MatchParent)
{
Width = (int)context.ToPixels(60),
Height = (int)context.ToPixels(60),
@@ -57,13 +56,9 @@ namespace Xamarin.Forms.Platform.Android
_mainText.SetSingleLine(true);
_mainText.Ellipsize = TextUtils.TruncateAt.End;
_mainText.SetPadding((int)context.ToPixels(15), padding, padding, padding);
-#pragma warning disable 618
- _mainText.SetTextAppearance(context, global::Android.Resource.Attribute.TextAppearanceListItem);
-#pragma warning restore 618
+ _mainText.SetTextAppearanceCompat(context, global::Android.Resource.Attribute.TextAppearanceListItem);
-#pragma warning disable 618
- using (var lp = new LayoutParams(ViewGroup.LayoutParams.FillParent, ViewGroup.LayoutParams.WrapContent))
-#pragma warning restore 618
+ using (var lp = new LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent))
textLayout.AddView(_mainText, lp);
_detailText = new TextView(context);
@@ -71,13 +66,9 @@ namespace Xamarin.Forms.Platform.Android
_detailText.Ellipsize = TextUtils.TruncateAt.End;
_detailText.SetPadding((int)context.ToPixels(15), padding, padding, padding);
_detailText.Visibility = ViewStates.Gone;
-#pragma warning disable 618
- _detailText.SetTextAppearance(context, global::Android.Resource.Attribute.TextAppearanceListItemSmall);
-#pragma warning restore 618
+ _detailText.SetTextAppearanceCompat(context, global::Android.Resource.Attribute.TextAppearanceListItemSmall);
-#pragma warning disable 618
- using (var lp = new LayoutParams(ViewGroup.LayoutParams.FillParent, ViewGroup.LayoutParams.WrapContent))
-#pragma warning restore 618
+ using (var lp = new LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent))
textLayout.AddView(_detailText, lp);
var layoutParams = new LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent) { Width = 0, Weight = 1, Gravity = GravityFlags.Center };
@@ -130,9 +121,7 @@ namespace Xamarin.Forms.Platform.Android
if (view != null)
{
-#pragma warning disable 618
- using (var layout = new LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.FillParent))
-#pragma warning restore 618
+ using (var layout = new LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.MatchParent))
AddView(view, layout);
AccessoryView = view;
@@ -209,8 +198,9 @@ namespace Xamarin.Forms.Platform.Android
catch (TaskCanceledException)
{
}
- catch (IOException e)
+ catch (IOException ex)
{
+ Log.Warning("Xamarin.Forms.Platform.Android.BaseCellView", "Error updating bitmap: {0}", ex);
}
}
diff --git a/Xamarin.Forms.Platform.Android/Cells/EntryCellView.cs b/Xamarin.Forms.Platform.Android/Cells/EntryCellView.cs
index c1ae1911..0380a31a 100644
--- a/Xamarin.Forms.Platform.Android/Cells/EntryCellView.cs
+++ b/Xamarin.Forms.Platform.Android/Cells/EntryCellView.cs
@@ -29,9 +29,7 @@ namespace Xamarin.Forms.Platform.Android
SetPadding((int)context.ToPixels(15), padding, padding, padding);
_label = new TextView(context);
-#pragma warning disable 618
- _label.SetTextAppearance(context, global::Android.Resource.Attribute.TextAppearanceListItem);
-#pragma warning restore 618
+ _label.SetTextAppearanceCompat(context, global::Android.Resource.Attribute.TextAppearanceListItem);
var layoutParams = new LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent) { Gravity = GravityFlags.CenterVertical };
using (layoutParams)
diff --git a/Xamarin.Forms.Platform.Android/ColorExtensions.cs b/Xamarin.Forms.Platform.Android/ColorExtensions.cs
index f6ac113b..2fee25a2 100644
--- a/Xamarin.Forms.Platform.Android/ColorExtensions.cs
+++ b/Xamarin.Forms.Platform.Android/ColorExtensions.cs
@@ -1,4 +1,5 @@
using Android.Content.Res;
+using Android.Support.V4.Content;
using AColor = Android.Graphics.Color;
namespace Xamarin.Forms.Platform.Android
@@ -16,10 +17,7 @@ namespace Xamarin.Forms.Platform.Android
{
if (self == Color.Default)
{
- using (Resources resources = Resources.System)
-#pragma warning disable 618
- return resources.GetColor(defaultColorResourceId);
-#pragma warning restore 618
+ return new AColor(ContextCompat.GetColor(Forms.Context, defaultColorResourceId));
}
return ToAndroid(self);
diff --git a/Xamarin.Forms.Platform.Android/Forms.cs b/Xamarin.Forms.Platform.Android/Forms.cs
index a089ea9a..398c1503 100644
--- a/Xamarin.Forms.Platform.Android/Forms.cs
+++ b/Xamarin.Forms.Platform.Android/Forms.cs
@@ -431,8 +431,7 @@ namespace Xamarin.Forms
}
catch (Exception ex)
{
- // Before you ask, yes, Exception. I know. But thats what android throws, new Exception... YAY BINDINGS
- // log exception using insights if possible
+ Log.Warning("Xamarin.Forms.Platform.Android.AndroidPlatformServices", "Error retrieving text appearance: {0}", ex);
}
return false;
}
diff --git a/Xamarin.Forms.Platform.Android/Platform.cs b/Xamarin.Forms.Platform.Android/Platform.cs
index 87bf5354..8c289ef4 100644
--- a/Xamarin.Forms.Platform.Android/Platform.cs
+++ b/Xamarin.Forms.Platform.Android/Platform.cs
@@ -144,7 +144,7 @@ namespace Xamarin.Forms.Platform.Android
}
}
-#pragma warning disable 618
+#pragma warning disable 618 // Eventually we will need to determine how to handle the v7 ActionBarDrawerToggle for AppCompat
ActionBarDrawerToggle MasterDetailPageToggle { get; set; }
#pragma warning restore 618
@@ -458,7 +458,7 @@ namespace Xamarin.Forms.Platform.Android
Color colorToUse = Color.Default;
if (CurrentNavigationPage != null)
{
-#pragma warning disable 618
+#pragma warning disable 618 // Make sure Tint still works
if (CurrentNavigationPage.Tint != Color.Default)
colorToUse = CurrentNavigationPage.Tint;
#pragma warning restore 618
@@ -526,16 +526,14 @@ namespace Xamarin.Forms.Platform.Android
_renderer.AddView(renderView.ViewGroup);
}
-#pragma warning disable 618
+#pragma warning disable 618 // This may need to be updated to work with TabLayout/AppCompat
ActionBar.Tab AddTab(Page page, int index)
#pragma warning restore 618
{
ActionBar actionBar = ((Activity)_context).ActionBar;
TabbedPage currentTabs = CurrentTabbedPage;
-#pragma warning disable 618
- ActionBar.Tab atab = actionBar.NewTab();
-#pragma warning restore 618
+ var atab = actionBar.NewTab();
atab.SetText(page.Title);
atab.TabSelected += (sender, e) =>
{
@@ -594,7 +592,7 @@ namespace Xamarin.Forms.Platform.Android
void CurrentNavigationPageOnPropertyChanged(object sender, PropertyChangedEventArgs e)
{
-#pragma warning disable 618
+#pragma warning disable 618 // Make sure Tint still works
if (e.PropertyName == NavigationPage.TintProperty.PropertyName)
#pragma warning restore 618
UpdateActionBarBackgroundColor();
@@ -688,9 +686,11 @@ namespace Xamarin.Forms.Platform.Android
var drawer = GetRenderer(CurrentMasterDetailPage) as MasterDetailRenderer;
if (drawer == null)
return;
-#pragma warning disable 618
+
+#pragma warning disable 618 // Eventually we will need to determine how to handle the v7 ActionBarDrawerToggle for AppCompat
MasterDetailPageToggle = new ActionBarDrawerToggle(_context as Activity, drawer, icon, 0, 0);
#pragma warning restore 618
+
MasterDetailPageToggle.SyncState();
}
@@ -741,9 +741,7 @@ namespace Xamarin.Forms.Platform.Android
return;
var page = sender as Page;
-#pragma warning disable 618
- ActionBar.Tab atab = actionBar.GetTabAt(currentTabs.Children.IndexOf(page));
-#pragma warning restore 618
+ var atab = actionBar.GetTabAt(currentTabs.Children.IndexOf(page));
atab.SetText(page.Title);
}
}
@@ -827,9 +825,7 @@ namespace Xamarin.Forms.Platform.Android
var i = 0;
foreach (Page tab in CurrentTabbedPage.Children.OfType<Page>())
{
-#pragma warning disable 618
- ActionBar.Tab realTab = AddTab(tab, i++);
-#pragma warning restore 618
+ var realTab = AddTab(tab, i++);
if (tab == CurrentTabbedPage.CurrentPage)
realTab.Select();
}
diff --git a/Xamarin.Forms.Platform.Android/Renderers/BoxRenderer.cs b/Xamarin.Forms.Platform.Android/Renderers/BoxRenderer.cs
index b29dd760..380d4018 100644
--- a/Xamarin.Forms.Platform.Android/Renderers/BoxRenderer.cs
+++ b/Xamarin.Forms.Platform.Android/Renderers/BoxRenderer.cs
@@ -48,7 +48,7 @@ namespace Xamarin.Forms.Platform.Android
UpdateBackgroundColor();
}
- void UpdateBackgroundColor()
+ protected override void UpdateBackgroundColor()
{
Color colorToSet = Element.Color;
diff --git a/Xamarin.Forms.Platform.Android/Renderers/ButtonRenderer.cs b/Xamarin.Forms.Platform.Android/Renderers/ButtonRenderer.cs
index 14046448..43f042b1 100644
--- a/Xamarin.Forms.Platform.Android/Renderers/ButtonRenderer.cs
+++ b/Xamarin.Forms.Platform.Android/Renderers/ButtonRenderer.cs
@@ -195,9 +195,7 @@ namespace Xamarin.Forms.Platform.Android
return;
if (_defaultDrawable != null)
-#pragma warning disable 618
- Control.SetBackgroundDrawable(_defaultDrawable);
-#pragma warning restore 618
+ Control.SetBackground(_defaultDrawable);
_drawableEnabled = false;
}
@@ -214,9 +212,7 @@ namespace Xamarin.Forms.Platform.Android
if (_defaultDrawable == null)
_defaultDrawable = Control.Background;
-#pragma warning disable 618
- Control.SetBackgroundDrawable(_backgroundDrawable);
-#pragma warning restore 618
+ Control.SetBackground(_backgroundDrawable);
_drawableEnabled = true;
}
diff --git a/Xamarin.Forms.Platform.Android/Renderers/CarouselPageRenderer.cs b/Xamarin.Forms.Platform.Android/Renderers/CarouselPageRenderer.cs
index 5053b698..859e78d2 100644
--- a/Xamarin.Forms.Platform.Android/Renderers/CarouselPageRenderer.cs
+++ b/Xamarin.Forms.Platform.Android/Renderers/CarouselPageRenderer.cs
@@ -30,9 +30,7 @@ namespace Xamarin.Forms.Platform.Android
base.OnAttachedToWindow();
var adapter = new CarouselPageAdapter(_viewPager, Element, Context);
_viewPager.Adapter = adapter;
-#pragma warning disable 618
- _viewPager.SetOnPageChangeListener(adapter);
-#pragma warning restore 618
+ _viewPager.AddOnPageChangeListener(adapter);
adapter.UpdateCurrentItem();
@@ -52,9 +50,7 @@ namespace Xamarin.Forms.Platform.Android
if (_viewPager != null)
{
RemoveView(_viewPager);
-#pragma warning disable 618
- _viewPager.SetOnPageChangeListener(null);
-#pragma warning restore 618
+ _viewPager.ClearOnPageChangeListeners();
_viewPager.Dispose();
}
diff --git a/Xamarin.Forms.Platform.Android/Renderers/CarouselViewRenderer.cs b/Xamarin.Forms.Platform.Android/Renderers/CarouselViewRenderer.cs
index 12a1157a..0056a1f8 100644
--- a/Xamarin.Forms.Platform.Android/Renderers/CarouselViewRenderer.cs
+++ b/Xamarin.Forms.Platform.Android/Renderers/CarouselViewRenderer.cs
@@ -364,13 +364,13 @@ namespace Xamarin.Forms.Platform.Android
public override void OnItemRangeInserted(int positionStart, int itemCount)
{
- // removal after the current position won't change current position
if (positionStart > _carouselView._position)
- ;
-
- // raise position changed
+ {
+ // removal after the current position won't change current position
+ }
else
{
+ // raise position changed
_carouselView._position += itemCount;
_carouselView.OnPositionChanged();
}
@@ -381,31 +381,26 @@ namespace Xamarin.Forms.Platform.Android
{
Assert(itemCount == 1);
- // removal after the current position won't change current position
if (positionStart > _carouselView._position)
- ;
-
- // raise item changed
+ {
+ // removal after the current position won't change current position
+ }
else if (positionStart == _carouselView._position &&
positionStart != _carouselView.Adapter.ItemCount)
{
+ // raise item changed
_carouselView.OnItemChanged();
return;
}
-
- // raise position changed
else
{
+ // raise position changed
_carouselView._position -= itemCount;
_carouselView.OnPositionChanged();
}
base.OnItemRangeRemoved(positionStart, itemCount);
}
- public override void OnItemRangeMoved(int fromPosition, int toPosition, int itemCount)
- {
- base.OnItemRangeMoved(fromPosition, toPosition, itemCount);
- }
}
#endregion
@@ -761,7 +756,6 @@ namespace Xamarin.Forms.Platform.Android
#region Static Fields
readonly static int s_samplesCount = 5;
- readonly static Func<int, int> s_fixPosition = o => o;
#endregion
#region Fields
diff --git a/Xamarin.Forms.Platform.Android/Renderers/FormattedStringExtensions.cs b/Xamarin.Forms.Platform.Android/Renderers/FormattedStringExtensions.cs
index f049cd0c..6eee5fee 100644
--- a/Xamarin.Forms.Platform.Android/Renderers/FormattedStringExtensions.cs
+++ b/Xamarin.Forms.Platform.Android/Renderers/FormattedStringExtensions.cs
@@ -50,7 +50,7 @@ namespace Xamarin.Forms.Platform.Android
}
if (!span.IsDefault())
-#pragma warning disable 618
+#pragma warning disable 618 // We will need to update this when .Font goes away
spannable.SetSpan(new FontSpan(span.Font, view), start, end, SpanTypes.InclusiveInclusive);
#pragma warning restore 618
else if (defaultFont != Font.Default)
diff --git a/Xamarin.Forms.Platform.Android/Renderers/FrameRenderer.cs b/Xamarin.Forms.Platform.Android/Renderers/FrameRenderer.cs
index 4e1881c4..f24c8d45 100644
--- a/Xamarin.Forms.Platform.Android/Renderers/FrameRenderer.cs
+++ b/Xamarin.Forms.Platform.Android/Renderers/FrameRenderer.cs
@@ -32,9 +32,7 @@ namespace Xamarin.Forms.Platform.Android
void UpdateBackground()
{
-#pragma warning disable 618
- SetBackgroundDrawable(new FrameDrawable(Element));
-#pragma warning restore 618
+ this.SetBackground(new FrameDrawable(Element));
}
class FrameDrawable : Drawable
diff --git a/Xamarin.Forms.Platform.Android/Renderers/ImageRenderer.cs b/Xamarin.Forms.Platform.Android/Renderers/ImageRenderer.cs
index a080e58b..be57b002 100644
--- a/Xamarin.Forms.Platform.Android/Renderers/ImageRenderer.cs
+++ b/Xamarin.Forms.Platform.Android/Renderers/ImageRenderer.cs
@@ -86,8 +86,9 @@ namespace Xamarin.Forms.Platform.Android
catch (TaskCanceledException)
{
}
- catch (IOException e)
+ catch (IOException ex)
{
+ Log.Warning("Xamarin.Forms.Platform.Android.ImageRenderer", "Error updating bitmap: {0}", ex);
}
}
diff --git a/Xamarin.Forms.Platform.Android/Renderers/LabelRenderer.cs b/Xamarin.Forms.Platform.Android/Renderers/LabelRenderer.cs
index 98406ca0..56880525 100644
--- a/Xamarin.Forms.Platform.Android/Renderers/LabelRenderer.cs
+++ b/Xamarin.Forms.Platform.Android/Renderers/LabelRenderer.cs
@@ -125,7 +125,7 @@ namespace Xamarin.Forms.Platform.Android
void UpdateFont()
{
-#pragma warning disable 618
+#pragma warning disable 618 // We will need to update this when .Font goes away
Font f = Element.Font;
#pragma warning restore 618
@@ -192,7 +192,7 @@ namespace Xamarin.Forms.Platform.Android
if (Element.FormattedText != null)
{
FormattedString formattedText = Element.FormattedText ?? Element.Text;
-#pragma warning disable 618
+#pragma warning disable 618 // We will need to update this when .Font goes away
_view.TextFormatted = formattedText.ToAttributed(Element.Font, Element.TextColor, _view);
#pragma warning restore 618
_wasFormatted = true;
diff --git a/Xamarin.Forms.Platform.Android/Renderers/ListViewAdapter.cs b/Xamarin.Forms.Platform.Android/Renderers/ListViewAdapter.cs
index ee1eba07..81214957 100644
--- a/Xamarin.Forms.Platform.Android/Renderers/ListViewAdapter.cs
+++ b/Xamarin.Forms.Platform.Android/Renderers/ListViewAdapter.cs
@@ -270,9 +270,7 @@ namespace Xamarin.Forms.Platform.Android
AView bline;
if (makeBline)
{
-#pragma warning disable 618
- bline = new AView(_context) { LayoutParameters = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.FillParent, 1) };
-#pragma warning restore 618
+ bline = new AView(_context) { LayoutParameters = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, 1) };
layout.AddView(bline);
}
diff --git a/Xamarin.Forms.Platform.Android/Renderers/MasterDetailRenderer.cs b/Xamarin.Forms.Platform.Android/Renderers/MasterDetailRenderer.cs
index 6f514aff..d00bca1a 100644
--- a/Xamarin.Forms.Platform.Android/Renderers/MasterDetailRenderer.cs
+++ b/Xamarin.Forms.Platform.Android/Renderers/MasterDetailRenderer.cs
@@ -305,9 +305,7 @@ namespace Xamarin.Forms.Platform.Android
void UpdateBackgroundImage(Page view)
{
if (!string.IsNullOrEmpty(view.BackgroundImage))
-#pragma warning disable 618
- SetBackgroundDrawable(Context.Resources.GetDrawable(view.BackgroundImage));
-#pragma warning restore 618
+ this.SetBackground(Context.Resources.GetDrawable(view.BackgroundImage));
}
void UpdateDetail()
diff --git a/Xamarin.Forms.Platform.Android/Renderers/NavigationMenuRenderer.cs b/Xamarin.Forms.Platform.Android/Renderers/NavigationMenuRenderer.cs
index 9678b9ca..92a65117 100644
--- a/Xamarin.Forms.Platform.Android/Renderers/NavigationMenuRenderer.cs
+++ b/Xamarin.Forms.Platform.Android/Renderers/NavigationMenuRenderer.cs
@@ -77,8 +77,8 @@ namespace Xamarin.Forms.Platform.Android
_image.SetScaleType(ImageView.ScaleType.FitCenter);
_image.Click += (object sender, EventArgs e) =>
{
- if (Selected != null)
- Selected();
+ if (OnSelected != null)
+ OnSelected();
};
AddView(_image, new LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent) { Gravity = GravityFlags.Center });
@@ -103,7 +103,7 @@ namespace Xamarin.Forms.Platform.Android
set { _label.Text = value; }
}
- public Action Selected { get; set; }
+ public Action OnSelected { get; set; }
}
class MenuAdapter : BaseAdapter<Page>
@@ -130,7 +130,7 @@ namespace Xamarin.Forms.Platform.Android
Page item = this[position];
menuItem.Icon = item.Icon;
menuItem.Name = item.Title;
- menuItem.Selected = () => _menu.SendTargetSelected(item);
+ menuItem.OnSelected = () => _menu.SendTargetSelected(item);
return menuItem;
}
diff --git a/Xamarin.Forms.Platform.Android/Renderers/NavigationRenderer.cs b/Xamarin.Forms.Platform.Android/Renderers/NavigationRenderer.cs
index f0e6dc73..91e052ca 100644
--- a/Xamarin.Forms.Platform.Android/Renderers/NavigationRenderer.cs
+++ b/Xamarin.Forms.Platform.Android/Renderers/NavigationRenderer.cs
@@ -13,7 +13,6 @@ namespace Xamarin.Forms.Platform.Android
static ViewPropertyAnimator s_currentAnimation;
Page _current;
- Page _exitingPage;
public NavigationRenderer()
{
diff --git a/Xamarin.Forms.Platform.Android/Renderers/OpenGLViewRenderer.cs b/Xamarin.Forms.Platform.Android/Renderers/OpenGLViewRenderer.cs
index 5c787b76..0bddfb58 100644
--- a/Xamarin.Forms.Platform.Android/Renderers/OpenGLViewRenderer.cs
+++ b/Xamarin.Forms.Platform.Android/Renderers/OpenGLViewRenderer.cs
@@ -23,7 +23,7 @@ namespace Xamarin.Forms.Platform.Android
_disposed = true;
if (Element != null)
- ((IOpenGlViewController)Element).DisplayRequested -= Display;
+ ((IOpenGlViewController)Element).DisplayRequested -= Render;
}
base.Dispose(disposing);
}
@@ -33,7 +33,7 @@ namespace Xamarin.Forms.Platform.Android
base.OnElementChanged(e);
if (e.OldElement != null)
- ((IOpenGlViewController)Element).DisplayRequested -= Display;
+ ((IOpenGlViewController)Element).DisplayRequested -= Render;
if (e.NewElement != null)
{
@@ -45,7 +45,7 @@ namespace Xamarin.Forms.Platform.Android
SetNativeControl(surfaceView);
}
- ((IOpenGlViewController)Element).DisplayRequested += Display;
+ ((IOpenGlViewController)Element).DisplayRequested += Render;
surfaceView.SetRenderer(new Renderer(Element));
SetRenderMode();
}
@@ -59,7 +59,7 @@ namespace Xamarin.Forms.Platform.Android
SetRenderMode();
}
- void Display(object sender, EventArgs eventArgs)
+ void Render(object sender, EventArgs eventArgs)
{
if (Element.HasRenderLoop)
return;
diff --git a/Xamarin.Forms.Platform.Android/Renderers/ScrollViewRenderer.cs b/Xamarin.Forms.Platform.Android/Renderers/ScrollViewRenderer.cs
index 15f04278..acad08c3 100644
--- a/Xamarin.Forms.Platform.Android/Renderers/ScrollViewRenderer.cs
+++ b/Xamarin.Forms.Platform.Android/Renderers/ScrollViewRenderer.cs
@@ -16,7 +16,6 @@ namespace Xamarin.Forms.Platform.Android
bool _isAttached;
bool _isBidirectional;
- ScrollToRequestedEventArgs _pendingScrollTo;
ScrollView _view;
public ScrollViewRenderer() : base(Forms.Context)
@@ -224,7 +223,6 @@ namespace Xamarin.Forms.Platform.Android
{
if (!_isAttached)
{
- _pendingScrollTo = e;
return;
}
diff --git a/Xamarin.Forms.Platform.Android/Renderers/TableViewModelRenderer.cs b/Xamarin.Forms.Platform.Android/Renderers/TableViewModelRenderer.cs
index c7ff2636..ef997d07 100644
--- a/Xamarin.Forms.Platform.Android/Renderers/TableViewModelRenderer.cs
+++ b/Xamarin.Forms.Platform.Android/Renderers/TableViewModelRenderer.cs
@@ -110,9 +110,7 @@ namespace Xamarin.Forms.Platform.Android
AView bline;
if (makeBline)
{
-#pragma warning disable 618
- bline = new AView(Context) { LayoutParameters = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.FillParent, 1) };
-#pragma warning restore 618
+ bline = new AView(Context) { LayoutParameters = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, 1) };
layout.AddView(bline);
}
diff --git a/Xamarin.Forms.Platform.Android/Renderers/WebViewRenderer.cs b/Xamarin.Forms.Platform.Android/Renderers/WebViewRenderer.cs
index 01c74b02..baa1e794 100644
--- a/Xamarin.Forms.Platform.Android/Renderers/WebViewRenderer.cs
+++ b/Xamarin.Forms.Platform.Android/Renderers/WebViewRenderer.cs
@@ -1,6 +1,7 @@
using System;
using System.ComponentModel;
using Android.Webkit;
+using Android.Widget;
using AWebView = Android.Webkit.WebView;
namespace Xamarin.Forms.Platform.Android
@@ -61,7 +62,7 @@ namespace Xamarin.Forms.Platform.Android
if (Control == null)
{
var webView = new AWebView(Context);
-#pragma warning disable 618
+#pragma warning disable 618 // This can probably be replaced with LinearLayout(LayoutParams.MatchParent, LayoutParams.MatchParent); just need to test that theory
webView.LayoutParameters = new global::Android.Widget.AbsoluteLayout.LayoutParams(LayoutParams.MatchParent, LayoutParams.MatchParent, 0, 0);
#pragma warning restore 618
webView.SetWebViewClient(new WebClient(this));
@@ -175,6 +176,7 @@ namespace Xamarin.Forms.Platform.Android
base.OnPageFinished(view, url);
}
+ [Obsolete("This method was deprecated in API level 23.")]
public override void OnReceivedError(AWebView view, ClientError errorCode, string description, string failingUrl)
{
_navigationResult = WebNavigationResult.Failure;
@@ -185,6 +187,14 @@ namespace Xamarin.Forms.Platform.Android
#pragma warning restore 618
}
+ public override void OnReceivedError(AWebView view, IWebResourceRequest request, WebResourceError error)
+ {
+ _navigationResult = WebNavigationResult.Failure;
+ if (error.ErrorCode == ClientError.Timeout)
+ _navigationResult = WebNavigationResult.Timeout;
+ base.OnReceivedError(view, request, error);
+ }
+
public override bool ShouldOverrideUrlLoading(AWebView view, string url)
{
if (_renderer.Element == null)
diff --git a/Xamarin.Forms.Platform.Android/ResourceManager.cs b/Xamarin.Forms.Platform.Android/ResourceManager.cs
index e7eb81bb..b8629026 100644
--- a/Xamarin.Forms.Platform.Android/ResourceManager.cs
+++ b/Xamarin.Forms.Platform.Android/ResourceManager.cs
@@ -5,6 +5,7 @@ using System.Threading.Tasks;
using Android.Content.Res;
using Android.Graphics;
using Android.Graphics.Drawables;
+using Android.Support.V4.Content;
using Path = System.IO.Path;
namespace Xamarin.Forms.Platform.Android
@@ -33,9 +34,7 @@ namespace Xamarin.Forms.Platform.Android
Log.Warning("Could not load image named: {0}", name);
return null;
}
-#pragma warning disable 618
- return resource.GetDrawable(id);
-#pragma warning restore 618
+ return ContextCompat.GetDrawable(Forms.Context, id);
}
public static int GetDrawableByName(string name)
diff --git a/Xamarin.Forms.Platform.Android/TextViewExtensions.cs b/Xamarin.Forms.Platform.Android/TextViewExtensions.cs
new file mode 100644
index 00000000..5b5c1dd8
--- /dev/null
+++ b/Xamarin.Forms.Platform.Android/TextViewExtensions.cs
@@ -0,0 +1,21 @@
+using Android.Content;
+using Android.OS;
+using Android.Widget;
+
+namespace Xamarin.Forms.Platform.Android
+{
+ internal static class TextViewExtensions
+ {
+ public static void SetTextAppearanceCompat(this TextView textView, Context context, int resId)
+ {
+ if ((int)Build.VERSION.SdkInt < 23)
+ {
+#pragma warning disable 618 // Using older version of SetTextAppearance for compatibility with API 15-22
+ textView.SetTextAppearance(context, resId);
+#pragma warning restore 618
+ }
+ else
+ textView.SetTextAppearance(resId);
+ }
+ }
+} \ No newline at end of file
diff --git a/Xamarin.Forms.Platform.Android/ViewExtensions.cs b/Xamarin.Forms.Platform.Android/ViewExtensions.cs
index db7c3d4a..6afcf5c2 100644
--- a/Xamarin.Forms.Platform.Android/ViewExtensions.cs
+++ b/Xamarin.Forms.Platform.Android/ViewExtensions.cs
@@ -1,15 +1,22 @@
using Android.Content;
using Android.Graphics.Drawables;
using Android.OS;
+using Android.Support.V4.Content;
using Android.Util;
using Android.Views;
using AView = Android.Views.View;
+using AColor = Android.Graphics.Color;
namespace Xamarin.Forms.Platform.Android
{
public static class ViewExtensions
{
- static int s_apiLevel;
+ static readonly int s_apiLevel;
+
+ static ViewExtensions()
+ {
+ s_apiLevel = (int)Build.VERSION.SdkInt;
+ }
public static void RemoveFromParent(this AView view)
{
@@ -22,17 +29,17 @@ namespace Xamarin.Forms.Platform.Android
public static void SetBackground(this AView view, Drawable drawable)
{
- if (s_apiLevel == 0)
- s_apiLevel = (int)Build.VERSION.SdkInt;
-
if (s_apiLevel < 16)
{
-#pragma warning disable 618
+#pragma warning disable 618 // Using older method for compatibility with API 15
view.SetBackgroundDrawable(drawable);
#pragma warning restore 618
}
else
+ {
view.Background = drawable;
+ }
+
}
public static void SetWindowBackground(this AView view)
@@ -46,19 +53,12 @@ namespace Xamarin.Forms.Platform.Android
switch (type)
{
case "color":
-#pragma warning disable 618
- global::Android.Graphics.Color color = context.Resources.GetColor(background.ResourceId);
-#pragma warning restore 618
+ var color = new AColor(ContextCompat.GetColor(context, background.ResourceId));
view.SetBackgroundColor(color);
break;
case "drawable":
-#pragma warning disable 618
- using (Drawable drawable = context.Resources.GetDrawable(background.ResourceId))
-#pragma warning restore 618
-
-#pragma warning disable 618
- view.SetBackgroundDrawable(drawable);
-#pragma warning restore 618
+ using (Drawable drawable = ContextCompat.GetDrawable(context, background.ResourceId))
+ view.SetBackground(drawable);
break;
}
}
diff --git a/Xamarin.Forms.Platform.Android/VisualElementRenderer.cs b/Xamarin.Forms.Platform.Android/VisualElementRenderer.cs
index 41c97b18..5abb809f 100644
--- a/Xamarin.Forms.Platform.Android/VisualElementRenderer.cs
+++ b/Xamarin.Forms.Platform.Android/VisualElementRenderer.cs
@@ -19,7 +19,6 @@ namespace Xamarin.Forms.Platform.Android
readonly TapGestureHandler _tapGestureHandler;
- bool _clickable;
NotifyCollectionChangedEventHandler _collectionChangeHandler;
VisualElementRendererFlags _flags = VisualElementRendererFlags.AutoPackage | VisualElementRendererFlags.AutoTrack;
@@ -28,7 +27,6 @@ namespace Xamarin.Forms.Platform.Android
VisualElementPackager _packager;
PropertyChangedEventHandler _propertyChangeHandler;
Lazy<ScaleGestureDetector> _scaleDetector;
- VelocityTracker _velocity;
protected VisualElementRenderer() : base(Forms.Context)
{
@@ -377,7 +375,7 @@ namespace Xamarin.Forms.Platform.Android
return;
bool newValue = view.ShouldBeMadeClickable();
- if (force || _clickable != newValue)
+ if (force || newValue)
Clickable = newValue;
}
diff --git a/Xamarin.Forms.Platform.Android/Xamarin.Forms.Platform.Android.csproj b/Xamarin.Forms.Platform.Android/Xamarin.Forms.Platform.Android.csproj
index 5b679ee0..2ec3cccb 100644
--- a/Xamarin.Forms.Platform.Android/Xamarin.Forms.Platform.Android.csproj
+++ b/Xamarin.Forms.Platform.Android/Xamarin.Forms.Platform.Android.csproj
@@ -28,7 +28,8 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
- <NoWarn>0642;0114;0108;0672;0168;0169;0184;0649;1998;0414</NoWarn>
+ <NoWarn>
+ </NoWarn>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
@@ -163,6 +164,7 @@
<Compile Include="Renderers\ToolbarImageButton.cs" />
<Compile Include="Renderers\ViewGroupExtensions.cs" />
<Compile Include="TapGestureHandler.cs" />
+ <Compile Include="TextViewExtensions.cs" />
<Compile Include="ViewInitializedEventArgs.cs" />
<Compile Include="VisualElementChangedEventArgs.cs" />
<Compile Include="RendererPool.cs" />