This commit is contained in:
ShaneN 2019-08-13 11:27:43 -06:00
Родитель 26d63d6af6 a91f149c42
Коммит bb8d19aa7e
6 изменённых файлов: 95 добавлений и 6 удалений

Просмотреть файл

@ -43,6 +43,7 @@ namespace Xamarin.Forms.Controls.Issues
[Test]
public void Bugzilla27731Test()
{
RunningApp.WaitForElement("Click");
RunningApp.WaitForNoElement(_pageTitle);
}
#endif

Просмотреть файл

@ -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;
}
}
}

Просмотреть файл

@ -24,6 +24,7 @@
</Compile>
<Compile Include="$(MSBuildThisFileDirectory)Issue7049.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Issue7061.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Issue7111.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ShellGestures.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ShellInsets.cs" />
<Compile Include="$(MSBuildThisFileDirectory)CollectionViewGrouping.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)

Просмотреть файл

@ -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");
}

Просмотреть файл

@ -29,9 +29,14 @@
<system:Double x:Key="FontSizeLarge">32</system:Double>
<system:Double x:Key="FontSizeExtraLarge">42</system:Double>
<system:Double x:Key="FontSizeExtraExtraLarge">72</system:Double>
<system:Double x:Key="FontSizeHuge">186</system:Double>
<system:Double x:Key="FontSizeHuge">186</system:Double>
<system:Double x:Key="FontSizeBody">14</system:Double>
<system:Double x:Key="FontSizeCaption">12</system:Double>
<system:Double x:Key="FontSizeHeader">46</system:Double>
<system:Double x:Key="FontSizeSubtitle">20</system:Double>
<system:Double x:Key="FontSizeTitle">24</system:Double>
<FontFamily x:Key="FontFamilyNormal">Segoe UI</FontFamily>
<FontFamily x:Key="FontFamilyNormal">Segoe UI</FontFamily>
<FontFamily x:Key="FontFamilySemiBold">Segoe UI</FontFamily>
<wpf:HeightConverter x:Key="HeightConverter" />