diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla27731.cs b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla27731.cs
index 63b58bb8b..835ac5a27 100644
--- a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla27731.cs
+++ b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla27731.cs
@@ -43,6 +43,7 @@ namespace Xamarin.Forms.Controls.Issues
[Test]
public void Bugzilla27731Test()
{
+ RunningApp.WaitForElement("Click");
RunningApp.WaitForNoElement(_pageTitle);
}
#endif
diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue7111.cs b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue7111.cs
new file mode 100644
index 000000000..2b3744dbd
--- /dev/null
+++ b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue7111.cs
@@ -0,0 +1,58 @@
+using Xamarin.Forms.CustomAttributes;
+using Xamarin.Forms.Internals;
+
+namespace Xamarin.Forms.Controls.Issues
+{
+ [Preserve(AllMembers = true)]
+ [Issue(IssueTracker.Github, 7111, "[Bug] [WPF] Label with a predefined FontSize value throws an exception", PlatformAffected.WPF)]
+ public class Issue7111 : TestContentPage
+ {
+
+ protected override void Init()
+ {
+ var stack = new StackLayout
+ {
+ VerticalOptions = LayoutOptions.Center,
+ HorizontalOptions = LayoutOptions.Center
+ };
+
+ var labelBody = new Label
+ {
+ Text = "If you see this, things didn't crash and it worked",
+ FontSize = Device.GetNamedSize(NamedSize.Body, typeof(Label))
+ };
+
+ var labelCaption = new Label
+ {
+ Text = "If you see this, things didn't crash and it worked",
+ FontSize = Device.GetNamedSize(NamedSize.Caption, typeof(Label))
+ };
+
+ var labelHeader = new Label
+ {
+ Text = "If you see this, things didn't crash and it worked",
+ FontSize = Device.GetNamedSize(NamedSize.Header, typeof(Label))
+ };
+
+ var labelSubtitle = new Label
+ {
+ Text = "If you see this, things didn't crash and it worked",
+ FontSize = Device.GetNamedSize(NamedSize.Subtitle, typeof(Label))
+ };
+
+ var labelTitle = new Label
+ {
+ Text = "If you see this, things didn't crash and it worked",
+ FontSize = Device.GetNamedSize(NamedSize.Title, typeof(Label))
+ };
+
+ stack.Children.Add(labelBody);
+ stack.Children.Add(labelCaption);
+ stack.Children.Add(labelHeader);
+ stack.Children.Add(labelSubtitle);
+ stack.Children.Add(labelTitle);
+
+ Content = stack;
+ }
+ }
+}
\ No newline at end of file
diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems
index d83c8747a..599c400f6 100644
--- a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems
+++ b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems
@@ -24,6 +24,7 @@
+
diff --git a/Xamarin.Forms.Platform.Android/AndroidTicker.cs b/Xamarin.Forms.Platform.Android/AndroidTicker.cs
index 343a6002e..6640d934b 100644
--- a/Xamarin.Forms.Platform.Android/AndroidTicker.cs
+++ b/Xamarin.Forms.Platform.Android/AndroidTicker.cs
@@ -9,7 +9,8 @@ namespace Xamarin.Forms.Platform.Android
internal class AndroidTicker : Ticker, IDisposable
{
ValueAnimator _val;
- bool _systemEnabled;
+ bool _energySaveModeDisabled;
+ readonly bool _animatorEnabled;
public AndroidTicker()
{
@@ -17,10 +18,11 @@ namespace Xamarin.Forms.Platform.Android
_val.SetIntValues(0, 100); // avoid crash
_val.RepeatCount = ValueAnimator.Infinite;
_val.Update += OnValOnUpdate;
+ _animatorEnabled = IsAnimatorEnabled();
CheckPowerSaveModeStatus();
}
- public override bool SystemEnabled => _systemEnabled;
+ public override bool SystemEnabled => _energySaveModeDisabled && _animatorEnabled;
internal void CheckPowerSaveModeStatus()
{
@@ -31,7 +33,7 @@ namespace Xamarin.Forms.Platform.Android
if (!Forms.IsLollipopOrNewer)
{
- _systemEnabled = true;
+ _energySaveModeDisabled = true;
return;
}
@@ -40,12 +42,24 @@ namespace Xamarin.Forms.Platform.Android
var powerSaveOn = powerManager.IsPowerSaveMode;
// If power saver is active, then animations will not run
- _systemEnabled = !powerSaveOn;
+ _energySaveModeDisabled = !powerSaveOn;
// Notify the ticker that this value has changed, so it can manage animations in progress
OnSystemEnabledChanged();
}
+ static bool IsAnimatorEnabled()
+ {
+ var resolver = global::Android.App.Application.Context?.ContentResolver;
+ if (resolver == null)
+ {
+ return false;
+ }
+
+ var scale = global::Android.Provider.Settings.Global.GetFloat(resolver, global::Android.Provider.Settings.Global.AnimatorDurationScale, 0);
+ return scale > 0;
+ }
+
public void Dispose()
{
if (_val != null)
diff --git a/Xamarin.Forms.Platform.WPF/WPFPlatformServices.cs b/Xamarin.Forms.Platform.WPF/WPFPlatformServices.cs
index ae53ab816..5047bf14b 100644
--- a/Xamarin.Forms.Platform.WPF/WPFPlatformServices.cs
+++ b/Xamarin.Forms.Platform.WPF/WPFPlatformServices.cs
@@ -85,6 +85,16 @@ namespace Xamarin.Forms.Platform.WPF
return (double)System.Windows.Application.Current.Resources["FontSizeMedium"];
case NamedSize.Large:
return (double)System.Windows.Application.Current.Resources["FontSizeLarge"];
+ case NamedSize.Body:
+ return (double)System.Windows.Application.Current.Resources["FontSizeBody"];
+ case NamedSize.Caption:
+ return (double)System.Windows.Application.Current.Resources["FontSizeCaption"];
+ case NamedSize.Header:
+ return (double)System.Windows.Application.Current.Resources["FontSizeHeader"];
+ case NamedSize.Subtitle:
+ return (double)System.Windows.Application.Current.Resources["FontSizeSubtitle"];
+ case NamedSize.Title:
+ return (double)System.Windows.Application.Current.Resources["FontSizeTitle"];
default:
throw new ArgumentOutOfRangeException("size");
}
diff --git a/Xamarin.Forms.Platform.WPF/WPFResources.xaml b/Xamarin.Forms.Platform.WPF/WPFResources.xaml
index caf898512..a355e9e7a 100644
--- a/Xamarin.Forms.Platform.WPF/WPFResources.xaml
+++ b/Xamarin.Forms.Platform.WPF/WPFResources.xaml
@@ -29,9 +29,14 @@
32
42
72
- 186
+ 186
+ 14
+ 12
+ 46
+ 20
+ 24
- Segoe UI
+ Segoe UI
Segoe UI