Skip to content
This repository has been archived by the owner on May 15, 2024. It is now read-only.

API Fixes #590

Merged
merged 59 commits into from
Nov 28, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
db12561
Rename AppInfo.OpenSettings -> ShowSettingsUI
Redth Nov 2, 2018
34c262b
Missed one docs rename
Redth Nov 2, 2018
0a46328
Added back a missing using.
mattleibow Nov 2, 2018
d393957
Fixed up Clipboard API! Updated everything SetTextAsync.
jamesmontemagno Nov 2, 2018
32e0d14
Updates Connectivity APIs from the review! got rid of Other made it u…
jamesmontemagno Nov 2, 2018
07962c5
Change MapKey to Platform.MapServiceToken only for UWP
jamesmontemagno Nov 2, 2018
7367dae
Dropping the version of the device runner until we can figure out wha…
mattleibow Nov 2, 2018
881ba54
Merge branch 'dev/api-fix' into dev/api-fix-569
jamesmontemagno Nov 2, 2018
68155eb
Update docs/en/FrameworksIndex/xamarin-essentials-uwp.xml
mattleibow Nov 2, 2018
49db077
Fix spacing
jamesmontemagno Nov 2, 2018
1f093d9
Merge pull request #597 from jamesmontemagno/dev/api-fix-573
mattleibow Nov 2, 2018
2fe4bed
Merge pull request #595 from jamesmontemagno/dev/api-fix-570
mattleibow Nov 2, 2018
36c53af
Updated DOCS!
mattleibow Nov 2, 2018
4599c20
Added Default and set it to Medium
jamesmontemagno Nov 2, 2018
1f04307
Merge pull request #594 from jamesmontemagno/dev/api-fix-569
mattleibow Nov 2, 2018
de6bf49
[Platform] Remove the Platform for .net standard since it does nothin…
mattleibow Nov 2, 2018
98c4a9e
GH-583: [api-fix] Power / Battery (#591)
mattleibow Nov 2, 2018
3219cc6
Merged the PR
mattleibow Nov 2, 2018
7e980ad
Merge pull request #598 from jamesmontemagno/dev/api-fix-574
mattleibow Nov 2, 2018
b639765
GH-568: [api-fix] Browser (#589)
Redth Nov 2, 2018
f24a7f2
re-gen docs
mattleibow Nov 2, 2018
da77177
Merge pull request #1 from xamarin/dev/api-fix
jamesmontemagno Nov 2, 2018
6f5b46f
Generated docs
mattleibow Nov 2, 2018
a1d7038
Revert this to avoid conflicts
mattleibow Nov 2, 2018
e3a7860
Add in DeviceIdiom and DevicePlatform
jamesmontemagno Nov 3, 2018
c2fdf1b
Merge pull request #600 from jamesmontemagno/dev/api-fix-572
mattleibow Nov 3, 2018
2d55930
Updated the docs and added a .gitattributes to control the line endings
mattleibow Nov 3, 2018
3a5ecb7
Renamed SpeakSettings to SpeechOptions. Closes #580
mattleibow Nov 3, 2018
06f6e2b
Add docs about HTML emails not supported on UWP. Closes #578
mattleibow Nov 3, 2018
1f412f2
[Map] Fixed the type names and enum values. Closes #576
mattleibow Nov 4, 2018
69571e6
Merge pull request #2 from xamarin/dev/api-fix
jamesmontemagno Nov 5, 2018
fcfa6fb
Refactor display info and keep screen on.
jamesmontemagno Nov 5, 2018
7fc2ff9
Add device display.
jamesmontemagno Nov 5, 2018
e78a8c9
Change to BatteryInfoChanged and BatteryInfoChangedEventArgs
jamesmontemagno Nov 5, 2018
8fd2f9a
Revert back battery intent
jamesmontemagno Nov 5, 2018
0739610
If we can't unwrap the key, then tear down everything and start over …
jamesmontemagno Nov 5, 2018
ba23b0f
Change back to "DisplayInfoChangedEventArgs"
jamesmontemagno Nov 5, 2018
fb8b851
Update Battery.android.cs
jamesmontemagno Nov 5, 2018
fcb0228
change to valid key
jamesmontemagno Nov 5, 2018
895ed8b
Update Battery.android.cs
jamesmontemagno Nov 5, 2018
3c917b5
Add docs
jamesmontemagno Nov 5, 2018
fa97147
Rename file correctly for docs!
jamesmontemagno Nov 5, 2018
8d1eaeb
Cleanup docs
jamesmontemagno Nov 5, 2018
b2ab4b7
Catch only specific exceptions. some code cleanup
jamesmontemagno Nov 5, 2018
d9cfb77
Merge pull request #606 from jamesmontemagno/dev/api-fix-571
mattleibow Nov 5, 2018
f935973
Updated the sensors to adhere to guidelines. #582
mattleibow Nov 5, 2018
5f20db6
Catch invalid key exception.
jamesmontemagno Nov 5, 2018
6cbf633
Merge pull request #610 from xamarin/dev/api-fix-sensors
mattleibow Nov 5, 2018
2eb20b0
Merge branch 'pr/607' into dev/api-fix
mattleibow Nov 5, 2018
8d0712a
Merge pull request #609 from jamesmontemagno/dev/bug-fix-564
mattleibow Nov 5, 2018
dc5e8b9
If there is no main window, then there is no UI thread. Closes 510
mattleibow Nov 5, 2018
9161aa2
Merge pull request #611 from xamarin/dev/api-fix-510
mattleibow Nov 7, 2018
a945d51
Merge branch 'master' into dev/api-fix
jamesmontemagno Nov 7, 2018
5801de3
Fixes #612
jamesmontemagno Nov 8, 2018
9076ac4
Merge pull request #615 from xamarin/dev/api-fix-612
mattleibow Nov 8, 2018
e0b392e
Integrate html option into sample for email. (#623)
jamesmontemagno Nov 17, 2018
ffe9400
Add Unknown to DeviceType. Update .net standard to return unknown for…
jamesmontemagno Nov 20, 2018
1099789
Update nugetreadme.txt (#625)
jamesmontemagno Nov 26, 2018
6ebb9fe
Merge branch 'master' into dev/api-fix
Redth Nov 28, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions DeviceTests/DeviceTests.Android/DeviceTests.Android.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Xamarin.Forms" Version="3.3.0.912540" />
<PackageReference Include="Xamarin.Forms" Version="3.3.0.967583" />
<PackageReference Include="Xamarin.Android.Support.Design" Version="27.0.2.1" />
<PackageReference Include="Xamarin.Android.Support.v7.AppCompat" Version="27.0.2.1" />
<PackageReference Include="Xamarin.Android.Support.v4" Version="27.0.2.1" />
Expand All @@ -74,8 +74,8 @@
<PackageReference Include="Xamarin.Android.Support.CustomTabs" Version="27.0.2.1" />
<PackageReference Include="Xamarin.Android.Support.Core.Utils" Version="27.0.2.1" />
<PackageReference Include="System.Numerics.Vectors" Version="4.5.0" />
<PackageReference Include="xunit" Version="2.4.0" />
<PackageReference Include="xunit.runner.devices" Version="2.4.48" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.devices" Version="2.5.20" />
<PackageReference Include="UnitTests.HeadlessRunner" Version="2.0.0" />
</ItemGroup>
<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion DeviceTests/DeviceTests.Shared/Barometer_Shared.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ void Barometer_ReadingChanged(object sender, BarometerChangedEventArgs e)

var d = await tcs.Task;

Assert.True(d.Pressure >= 0);
Assert.True(d.PressureInHectopascals >= 0);
Barometer.Stop();
Barometer.ReadingChanged -= Barometer_ReadingChanged;
}
Expand Down
6 changes: 6 additions & 0 deletions DeviceTests/DeviceTests.Shared/Battery_Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,11 @@ public void Charge_Power()

Assert.NotEqual(BatteryPowerSource.Unknown, Battery.PowerSource);
}

[Fact]
public void App_Is_Not_Lower_Power_mode()
{
Assert.Equal(EnergySaverStatus.Off, Battery.EnergySaverStatus);
}
}
}
7 changes: 2 additions & 5 deletions DeviceTests/DeviceTests.Shared/Clipboard_Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,7 @@ public Task Set_Clipboard_Values(string text)
{
return Utils.OnMainThread(async () =>
{
Clipboard.SetText(text);

await Task.Delay(100);

await Clipboard.SetTextAsync(text);
Assert.True(Clipboard.HasText);
});
}
Expand All @@ -28,7 +25,7 @@ public Task Get_Clipboard_Values(string text)
{
return Utils.OnMainThread(async () =>
{
Clipboard.SetText(text);
await Clipboard.SetTextAsync(text);
var clipText = await Clipboard.GetTextAsync();

Assert.NotNull(clipText);
Expand Down
4 changes: 2 additions & 2 deletions DeviceTests/DeviceTests.Shared/Connectivity_Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public void Network_Access() =>
Assert.Equal(NetworkAccess.Internet, Connectivity.NetworkAccess);

[Fact]
public void Profiles() =>
Assert.True(Connectivity.Profiles.Count() > 0);
public void ConnectionProfiles() =>
Assert.True(Connectivity.ConnectionProfiles.Count() > 0);
}
}
52 changes: 48 additions & 4 deletions DeviceTests/DeviceTests.Shared/DeviceInfo_Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,11 @@ public void AppPackageName_Is_Correct()
public void Platform_Is_Correct()
{
#if WINDOWS_UWP
Assert.Equal(DeviceInfo.Platforms.UWP, DeviceInfo.Platform);
Assert.Equal(DevicePlatform.UWP, DeviceInfo.Platform);
#elif __IOS__
Assert.Equal(DeviceInfo.Platforms.iOS, DeviceInfo.Platform);
Assert.Equal(DevicePlatform.iOS, DeviceInfo.Platform);
#elif __ANDROID__
Assert.Equal(DeviceInfo.Platforms.Android, DeviceInfo.Platform);
Assert.Equal(DevicePlatform.Android, DeviceInfo.Platform);
#else
throw new PlatformNotSupportedException();
#endif
Expand All @@ -96,12 +96,56 @@ public Task Screen_Metrics_Are_Not_Null()
{
return Utils.OnMainThread(() =>
{
var metrics = DeviceDisplay.ScreenMetrics;
var metrics = DeviceDisplay.MainDisplayInfo;

Assert.True(metrics.Width > 0);
Assert.True(metrics.Height > 0);
Assert.True(metrics.Density > 0);
});
}

[Fact]
public Task ScreenLock_Locks()
{
return Utils.OnMainThread(() =>
{
Assert.False(DeviceDisplay.KeepScreenOn);

DeviceDisplay.KeepScreenOn = true;
Assert.True(DeviceDisplay.KeepScreenOn);

DeviceDisplay.KeepScreenOn = false;
Assert.False(DeviceDisplay.KeepScreenOn);
});
}

[Fact]
public Task ScreenLock_Unlocks_Without_Locking()
{
return Utils.OnMainThread(() =>
{
Assert.False(DeviceDisplay.KeepScreenOn);

DeviceDisplay.KeepScreenOn = false;
Assert.False(DeviceDisplay.KeepScreenOn);
});
}

[Fact]
public Task ScreenLock_Locks_Only_Once()
{
return Utils.OnMainThread(() =>
{
Assert.False(DeviceDisplay.KeepScreenOn);

DeviceDisplay.KeepScreenOn = true;
Assert.True(DeviceDisplay.KeepScreenOn);
DeviceDisplay.KeepScreenOn = true;
Assert.True(DeviceDisplay.KeepScreenOn);

DeviceDisplay.KeepScreenOn = false;
Assert.False(DeviceDisplay.KeepScreenOn);
});
}
}
}
10 changes: 5 additions & 5 deletions DeviceTests/DeviceTests.Shared/DeviceTests.Shared.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,17 @@
<DebugType>pdbonly</DebugType>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="MSBuild.Sdk.Extras" Version="1.6.55" PrivateAssets="All" />
<PackageReference Include="MSBuild.Sdk.Extras" Version="1.6.60" PrivateAssets="All" />
<PackageReference Include="System.Numerics.Vectors" Version="4.5.0" />
<PackageReference Include="Xamarin.Forms" Version="3.3.0.912540" />
<PackageReference Include="xunit" Version="2.4.0" />
<PackageReference Include="xunit.runner.devices" Version="2.4.48" />
<PackageReference Include="Xamarin.Forms" Version="3.3.0.967583" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.devices" Version="2.3.3" />
<PackageReference Include="UnitTests.HeadlessRunner" Version="2.0.0" />
<PackageReference Include="System.Numerics.Vectors" Version="4.5.0" />
<ProjectReference Include="..\..\Xamarin.Essentials\Xamarin.Essentials.csproj" />
</ItemGroup>
<ItemGroup Condition=" $(TargetFramework.StartsWith('uap10.0')) ">
<PackageReference Include="Microsoft.NETCore.UniversalWindowsPlatform" Version="6.1.5" />
<PackageReference Include="Microsoft.NETCore.UniversalWindowsPlatform" Version="6.1.9" />
<SDKReference Include="WindowsMobile, Version=10.0.16299.0">
<Name>Windows Mobile Extensions for the UWP</Name>
</SDKReference>
Expand Down
4 changes: 3 additions & 1 deletion DeviceTests/DeviceTests.Shared/Geocoding_Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ public class Geocoding_Tests
{
public Geocoding_Tests()
{
Geocoding.MapKey = "RJHqIE53Onrqons5CNOx~FrDr3XhjDTyEXEjng-CRoA~Aj69MhNManYUKxo6QcwZ0wmXBtyva0zwuHB04rFYAPf7qqGJ5cHb03RCDw1jIW8l";
#if WINDOWS_UWP
Platform.MapServiceToken = "RJHqIE53Onrqons5CNOx~FrDr3XhjDTyEXEjng-CRoA~Aj69MhNManYUKxo6QcwZ0wmXBtyva0zwuHB04rFYAPf7qqGJ5cHb03RCDw1jIW8l";
#endif
}

[Theory]
Expand Down
12 changes: 6 additions & 6 deletions DeviceTests/DeviceTests.Shared/Maps_Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public class Maps_Tests
[Trait(Traits.InteractionType, Traits.InteractionTypes.Human)]
public async Task LaunchMap_CoordinatesDisplayCorrectPlace()
{
await Maps.OpenAsync(testLatitude, testLongitude, new MapsLaunchOptions { Name = mapName });
await Map.OpenAsync(testLatitude, testLongitude, new MapLaunchOptions { Name = mapName });
}

[Fact]
Expand All @@ -29,28 +29,28 @@ public async Task LaunchMap_PlacemarkDisplayCorrectPlace()
Thoroughfare = "Microsoft Building 25",
Locality = "Redmond"
};
await Maps.OpenAsync(placemark, new MapsLaunchOptions { Name = mapName });
await Map.OpenAsync(placemark, new MapLaunchOptions { Name = mapName });
}

[Fact]
public async Task LaunchMap_NullLocation()
{
Location location = null;
await Assert.ThrowsAsync<ArgumentNullException>(() => Maps.OpenAsync(location));
await Assert.ThrowsAsync<ArgumentNullException>(() => Map.OpenAsync(location));
}

[Fact]
public async Task LaunchMap_NullOptionsLocation()
{
var location = new Location(testLatitude, testLongitude);
await Assert.ThrowsAsync<ArgumentNullException>(() => Maps.OpenAsync(location, null));
await Assert.ThrowsAsync<ArgumentNullException>(() => Map.OpenAsync(location, null));
}

[Fact]
public async Task LaunchMap_NullPlacemark()
{
Placemark location = null;
await Assert.ThrowsAsync<ArgumentNullException>(() => Maps.OpenAsync(location));
await Assert.ThrowsAsync<ArgumentNullException>(() => Map.OpenAsync(location));
}

[Fact]
Expand All @@ -63,7 +63,7 @@ public async Task LaunchMap_NullOptionsPlacemark()
Thoroughfare = "Microsoft Building 25",
Locality = "Redmond"
};
await Assert.ThrowsAsync<ArgumentNullException>(() => Maps.OpenAsync(placemark, null));
await Assert.ThrowsAsync<ArgumentNullException>(() => Map.OpenAsync(placemark, null));
}
}
}
14 changes: 0 additions & 14 deletions DeviceTests/DeviceTests.Shared/Power_Tests.cs

This file was deleted.

53 changes: 0 additions & 53 deletions DeviceTests/DeviceTests.Shared/ScreenLock_Tests.cs

This file was deleted.

31 changes: 31 additions & 0 deletions DeviceTests/DeviceTests.Shared/SecureStorage_Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ namespace DeviceTests
{
public class SecureStorage_Tests
{
public SecureStorage_Tests()
{
SecureStorage.RemoveAll();
}

[Theory]
[InlineData("test.txt", "data", true, true)]
[InlineData("noextension", "data2", true, false)]
Expand Down Expand Up @@ -40,6 +45,32 @@ public async Task Saves_And_Loads(string key, string data, bool emulatePreApi23,
Assert.Equal(data, c);
}

#if __ANDROID__
[Theory]
[InlineData("test.txt", "data")]
public async Task Fix_Corrupt_Key(string key, string data)
{
// set a valid key
SecureStorage.AlwaysUseAsymmetricKeyStorage = true;
await SecureStorage.SetAsync(key, data);

// simulate corrupt the key
var prefKey = "SecureStorageKey";
var mainKey = "A2PfJSNdEDjM+422tpu7FqFcVQQbO3ti/DvnDnIqrq9CFwaBi6NdXYcicjvMW6nF7X/Clpto5xerM41U1H4qtWJDO0Ijc5QNTHGZl9tDSbXJ6yDCDDnEDryj2uTa8DiHoNcNX68QtcV3at4kkJKXXAwZXSC88a73/xDdh1u5gUdCeXJzVc5vOY6QpAGUH0bjR5NHrqEQNNGDdquFGN9n2ZJPsEK6C9fx0QwCIL+uldpAYSWrpmUIr+/0X7Y0mJpN84ldygEVxHLBuVrzB4Bbu5XGLUN/0Sr2plWcKm7XhM6wp3JRW6Eae2ozys42p1YLeM0HXWrhTqP6FRPkS6mOtw==";

Preferences.Set(prefKey, mainKey, SecureStorage.Alias);

var c = await SecureStorage.GetAsync(key);
Assert.Null(c);

// try to reset and get again
await SecureStorage.SetAsync(key, data);
c = await SecureStorage.GetAsync(key);

Assert.Equal(data, c);
}
#endif

[Theory]
[InlineData(true)]
[InlineData(false)]
Expand Down
4 changes: 2 additions & 2 deletions DeviceTests/DeviceTests.Shared/Vibration_Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public void Vibrate()
#elif __IOS__
// TODO: remove this as soon as the test harness can filter
// the iOS simulator does not emulate a flashlight
if (DeviceInfo.DeviceType == DeviceType.Virtual && DeviceInfo.Platform == DeviceInfo.Platforms.iOS)
if (DeviceInfo.DeviceType == DeviceType.Virtual && DeviceInfo.Platform == DevicePlatform.iOS)
return;
#endif

Expand All @@ -35,7 +35,7 @@ public void Vibrate_Cancel()
#elif __IOS__
// TODO: remove this as soon as the test harness can filter
// the iOS simulator does not emulate a flashlight
if (DeviceInfo.DeviceType == DeviceType.Virtual && DeviceInfo.Platform == DeviceInfo.Platforms.iOS)
if (DeviceInfo.DeviceType == DeviceType.Virtual && DeviceInfo.Platform == DevicePlatform.iOS)
return;
#endif

Expand Down
8 changes: 4 additions & 4 deletions DeviceTests/DeviceTests.UWP/DeviceTests.UWP.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,10 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="UnitTests.HeadlessRunner" Version="2.0.0" />
<PackageReference Include="Xamarin.Forms" Version="3.3.0.912540" />
<PackageReference Include="Microsoft.NETCore.UniversalWindowsPlatform" Version="6.1.5" />
<PackageReference Include="xunit" Version="2.4.0" />
<PackageReference Include="xunit.runner.devices" Version="2.4.48" />
<PackageReference Include="Xamarin.Forms" Version="3.3.0.967583" />
<PackageReference Include="Microsoft.NETCore.UniversalWindowsPlatform" Version="6.1.9" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.devices" Version="2.3.3" />
<PackageReference Include="System.Numerics.Vectors" Version="4.5.0" />
</ItemGroup>
<ItemGroup>
Expand Down
6 changes: 3 additions & 3 deletions DeviceTests/DeviceTests.iOS/DeviceTests.iOS.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,9 @@
<Reference Include="Xamarin.iOS" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Xamarin.Forms" Version="3.3.0.912540" />
<PackageReference Include="xunit" Version="2.4.0" />
<PackageReference Include="xunit.runner.devices" Version="2.4.48" />
<PackageReference Include="Xamarin.Forms" Version="3.3.0.967583" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.devices" Version="2.5.20" />
<PackageReference Include="UnitTests.HeadlessRunner" Version="2.0.0" />
<PackageReference Include="System.Numerics.Vectors" Version="4.5.0" />
</ItemGroup>
Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ The following cross-platform APIs are available in Xamarin.Essentials:
* [Open Browser](https://docs.microsoft.com/xamarin/essentials/open-browser)
* [Orientation Sensor](https://docs.microsoft.com/en-us/xamarin/essentials/orientation-sensor)
* [Phone Dialer](https://docs.microsoft.com/xamarin/essentials/phone-dialer)
* [Power](https://docs.microsoft.com/en-us/xamarin/essentials/power)
* [Preferences](https://docs.microsoft.com/xamarin/essentials/preferences)
* [Screen Lock](https://docs.microsoft.com/xamarin/essentials/screen-lock)
* [Secure Storage](https://docs.microsoft.com/xamarin/essentials/secure-storage)
Expand Down
Loading