Merge in 1.3.0 (#870)
* GH-23: Added Tizen backend (#555) * Adding the initial work to get Tizen started. #23 * Adding the initial work to get Tizen started. #23 * Use the overloads properly. * Use the overloads properly. * Tizen needs to have a background explicitly set * Added the Vibration API * Added the Vibration API * Refactoring a little bit * Refactoring a little bit * Added the Browser API and some basic permissions checking * Added the Browser API and some basic permissions checking * Added the Battery API * Added the Battery API * Added the Acceleromerter API * Added the Acceleromerter API * Added the Filesystem API * Added the Filesystem API * Update Accelerometer Initialize using GetDefaultSensor * Update Accelerometer Initialize using GetDefaultSensor * Added the Gyroscope API * Added the Gyroscope API * Added the Magnetometer API * Added the Magnetometer API * Added the Compass API * Added the Compass API * Added the Connectivity API * Added the Connectivity API * Added the Flashlight API * Added the Flashlight API * Added the SecureStorage API * Added the SecureStorage API * Added the Vibration API * Added the Vibration API * Fixed build break * Fixed build break * Added the OrientationSensor API * Fixed build break * Initialized Maps/Launcher for Tizen * Added the Permissions API * Added the Geolocation API * Added the Geocoding API * Fixed build break * Initialize Barometer API * Added the Barometer API * Added the TextToSpeech API * Added the Launcher APIs * Fixed bugs * Update Location property name * Update several modules - Update AppInfo, Browser, Clipboard, Compass, Connectivity, DisplayInfo, DeviceInfo, Geocoding, TextToSpeech modules - Change module name DataTrasfer to Share, Maps to Map - Integrated module Power to Battery, ScreenLock to DeviceDisplay * Throw PlatformNotSupportedException for Tizen * Change the exception for the power saver feature * Add tizen privileges * Add FileBase * Add ShareFileRequest * Change enum for Browser * Change parameter for Permissions * Add SensorSpeedExtensions * Add Launcher for OpenFileRequest * Fix .csproj for VS2019 * Fix sample for watch * Fix Geolocation speed * Fix TextToSpeech ptich * Fixed missing using System; This was needed for the Math calls * Add Support for ⌚OS and 📺OS (#827) * Add Support for watchOS and tvOS * Fix up exception from shared netstandard code to figure out what to send. * Update Battery.ios.watchos.cs * Integrate Tizen into the netstandard not supported area. * [Tizen] Fix reference for avoid duplication (#850) * Fix reference to avoid version collision * Remove Vector3 reference on Tizen * Fix iPad not show share sheet (#873) Need to specify bottom center of the screen. * Added the Main Thread helpers from Xamarin.Forms (#849) * Added Invoke methods from Xamarin.Forms * Updated to use Essentials approach to calling the MainThread * Updated the docs with the new MainThread methods * Make overload more readable The old code was I think incorrect in that the `funcTask()` was never awaited or returned as a task. This is the same code as the overload with the generic type parameter, but without the type param. * Updated to use UrlEncode in GetMailToUrl (#848) * Updated to use UrlEncode in GetMailToUrl Fixes #843 * Added missing using * Fixed Using order and spacings * Use WebUtility.UrlEncode on placemark extensions * Added volatile to MainThread.Android (#877) Fixes #838 * Add Launcher.TryOpenAsync (#839) * Add Launcher.TryOpenAsync * Added ConfigureAwait(false) * Removed unnecessary async * Updated launcher docs * Updated the docs * Added Launch Tests * Add aka.ms for release notes (#883) * Remove experimental flags & fix launcher teasts (#887)
This commit is contained in:
Родитель
0bfbae9c10
Коммит
ff6dd3edb1
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -99,5 +99,35 @@ namespace DeviceTests
|
|||
{
|
||||
Assert.False(await Launcher.CanOpenAsync(uri));
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("http://www.example.com")]
|
||||
[InlineData("http://example.com/?query=blah")]
|
||||
[InlineData("https://example.com/?query=blah")]
|
||||
[InlineData("mailto://someone@microsoft.com")]
|
||||
[InlineData("mailto://someone@microsoft.com?subject=test")]
|
||||
[InlineData("tel:+1 555 010 9999")]
|
||||
[InlineData("sms:5550109999")]
|
||||
[Trait(Traits.InteractionType, Traits.InteractionTypes.Human)]
|
||||
public async Task TryOpen(string uri)
|
||||
{
|
||||
#if __IOS__
|
||||
if (DeviceInfo.DeviceType == DeviceType.Virtual && (uri.Contains("tel:") || uri.Contains("mailto:")))
|
||||
{
|
||||
Assert.False(await Launcher.TryOpenAsync(uri));
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
Assert.True(await Launcher.TryOpenAsync(uri));
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("ms-invalidurifortest:abc")]
|
||||
[Trait(Traits.InteractionType, Traits.InteractionTypes.Human)]
|
||||
public async Task CanNotTryOpen(string uri)
|
||||
{
|
||||
Assert.False(await Launcher.TryOpenAsync(new Uri(uri)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
using ElmSharp;
|
||||
using Samples.Tizen;
|
||||
using Xamarin.Forms;
|
||||
using Xamarin.Forms.Platform.Tizen;
|
||||
|
||||
[assembly: ExportCell(typeof(ViewCell), typeof(CustomViewCellRenderer))]
|
||||
namespace Samples.Tizen
|
||||
{
|
||||
public sealed class CustomViewCellRenderer : ViewCellRenderer
|
||||
{
|
||||
protected override EvasObject OnGetContent(Cell cell, string part)
|
||||
{
|
||||
var view = base.OnGetContent(cell, part);
|
||||
view.PropagateEvents = true;
|
||||
return view;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
using Xamarin.Forms;
|
||||
using Xamarin.Forms.Platform.Tizen;
|
||||
|
||||
namespace Samples.Tizen
|
||||
{
|
||||
class Program : FormsApplication
|
||||
{
|
||||
protected override void OnCreate()
|
||||
{
|
||||
base.OnCreate();
|
||||
|
||||
LoadApplication(new App());
|
||||
}
|
||||
|
||||
static void Main(string[] args)
|
||||
{
|
||||
var app = new Program();
|
||||
Forms.Init(app);
|
||||
if (Device.Idiom == TargetIdiom.Watch)
|
||||
global::Tizen.Wearable.CircularUI.Forms.Renderer.FormsCircularUI.Init();
|
||||
Xamarin.Essentials.Platform.MapServiceToken = "MAP_SERVICE_KEY";
|
||||
app.Run(args);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
<Project Sdk="Tizen.NET.Sdk/1.0.3">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>tizen40</TargetFramework>
|
||||
<TizenNetPackageVersion>4.0.0</TizenNetPackageVersion>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugType>portable</DebugType>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>None</DebugType>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\Xamarin.Essentials\Xamarin.Essentials.csproj" />
|
||||
<ProjectReference Include="..\Samples\Samples.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="lib\" />
|
||||
<Folder Include="res\" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Tizen.Wearable.CircularUI" Version="1.3.0-pre1-00043" />
|
||||
<PackageReference Include="System.Numerics.Vectors" Version="4.5.0">
|
||||
<ExcludeAssets>Runtime</ExcludeAssets>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
|
||||
<Import Project="$(MSBuildThisFileDirectory)..\..\CodeStyles.targets" />
|
||||
</Project>
|
|
@ -0,0 +1,4 @@
|
|||
This file was loaded from the app package.
|
||||
|
||||
You can use this as a starting point for your comments...
|
||||
|
Двоичный файл не отображается.
После Ширина: | Высота: | Размер: 5.9 KiB |
|
@ -0,0 +1,27 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest package="com.xamarin.essentials" version="1.0.0" api-version="4" xmlns="http://tizen.org/ns/packages">
|
||||
<profile name="common" />
|
||||
<ui-application appid="com.xamarin.essentials" exec="Samples.Tizen.dll" multiple="false" nodisplay="false" taskmanage="true" splash-screen-display="true" type="dotnet" launch_mode="single">
|
||||
<label>Xamarin.Essentials</label>
|
||||
<icon>Samples.Tizen.png</icon>
|
||||
<metadata key="http://tizen.org/metadata/prefer_dotnet_aot" value="true" />
|
||||
</ui-application>
|
||||
<privileges>
|
||||
<privilege>http://tizen.org/privilege/appmanager.launch</privilege>
|
||||
<privilege>http://tizen.org/privilege/externalstorage</privilege>
|
||||
<privilege>http://tizen.org/privilege/haptic</privilege>
|
||||
<privilege>http://tizen.org/privilege/internet</privilege>
|
||||
<privilege>http://tizen.org/privilege/led</privilege>
|
||||
<privilege>http://tizen.org/privilege/location</privilege>
|
||||
<privilege>http://tizen.org/privilege/mapservice</privilege>
|
||||
<privilege>http://tizen.org/privilege/mediastorage</privilege>
|
||||
<privilege>http://tizen.org/privilege/message.read</privilege>
|
||||
<privilege>http://tizen.org/privilege/network.get</privilege>
|
||||
</privileges>
|
||||
<provides-appdefined-privileges />
|
||||
<feature name="http://tizen.org/feature/location">true</feature>
|
||||
<feature name="http://tizen.org/feature/location.gps">true</feature>
|
||||
<feature name="http://tizen.org/feature/location.wps">true</feature>
|
||||
<feature name="http://tizen.org/feature/maps">true</feature>
|
||||
<feature name="http://tizen.org/feature/speech.synthesis">true</feature>
|
||||
</manifest>
|
|
@ -20,10 +20,6 @@ namespace Samples
|
|||
InitializeComponent();
|
||||
|
||||
// Enable currently experimental features
|
||||
ExperimentalFeatures.Enable(
|
||||
ExperimentalFeatures.EmailAttachments,
|
||||
ExperimentalFeatures.ShareFileRequest,
|
||||
ExperimentalFeatures.OpenFileRequest);
|
||||
|
||||
VersionTracking.Track();
|
||||
|
||||
|
|
|
@ -9,6 +9,8 @@ namespace Samples.View
|
|||
public BasePage()
|
||||
{
|
||||
NavigationPage.SetBackButtonTitle(this, "Back");
|
||||
if (Device.Idiom == TargetIdiom.Watch)
|
||||
NavigationPage.SetHasNavigationBar(this, false);
|
||||
}
|
||||
|
||||
protected override void OnAppearing()
|
||||
|
|
|
@ -24,10 +24,7 @@ namespace Tests
|
|||
await Assert.ThrowsAsync<NotImplementedInReferenceAssemblyException>(() => Launcher.OpenAsync(new Uri("http://www.xamarin.com")));
|
||||
|
||||
[Fact]
|
||||
public async Task Open_File_NetStandard()
|
||||
{
|
||||
TestUtils.EnableExperimentalFeatures();
|
||||
public async Task Open_File_NetStandard() =>
|
||||
await Assert.ThrowsAsync<NotImplementedInReferenceAssemblyException>(() => Launcher.OpenAsync(new OpenFileRequest()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,10 +20,7 @@ namespace Tests
|
|||
await Assert.ThrowsAsync<NotImplementedInReferenceAssemblyException>(() => Share.RequestAsync(new ShareTextRequest()));
|
||||
|
||||
[Fact]
|
||||
public async Task Request_File_Request_NetStandard()
|
||||
{
|
||||
TestUtils.EnableExperimentalFeatures();
|
||||
public async Task Request_File_Request_NetStandard() =>
|
||||
await Assert.ThrowsAsync<NotImplementedInReferenceAssemblyException>(() => Share.RequestAsync(new ShareFileRequest()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,10 +9,6 @@ namespace Tests
|
|||
{
|
||||
public static void EnableExperimentalFeatures()
|
||||
{
|
||||
ExperimentalFeatures.Enable(
|
||||
ExperimentalFeatures.EmailAttachments,
|
||||
ExperimentalFeatures.ShareFileRequest,
|
||||
ExperimentalFeatures.OpenFileRequest);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -45,6 +45,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DeviceTests.UWP", "DeviceTe
|
|||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DeviceTests.Shared", "DeviceTests\DeviceTests.Shared\DeviceTests.Shared.csproj", "{BE0DE9A3-D92C-47C5-9EC4-DFB546BBDF77}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Samples.Tizen", "Samples\Samples.Tizen\Samples.Tizen.csproj", "{4B1850CF-C568-4C16-8B42-3E9977DE5F56}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
|
@ -614,6 +616,54 @@ Global
|
|||
{BE0DE9A3-D92C-47C5-9EC4-DFB546BBDF77}.Samples|x64.Build.0 = Samples|Any CPU
|
||||
{BE0DE9A3-D92C-47C5-9EC4-DFB546BBDF77}.Samples|x86.ActiveCfg = Samples|Any CPU
|
||||
{BE0DE9A3-D92C-47C5-9EC4-DFB546BBDF77}.Samples|x86.Build.0 = Samples|Any CPU
|
||||
{4B1850CF-C568-4C16-8B42-3E9977DE5F56}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{4B1850CF-C568-4C16-8B42-3E9977DE5F56}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{4B1850CF-C568-4C16-8B42-3E9977DE5F56}.Debug|ARM.ActiveCfg = Debug|Any CPU
|
||||
{4B1850CF-C568-4C16-8B42-3E9977DE5F56}.Debug|ARM.Build.0 = Debug|Any CPU
|
||||
{4B1850CF-C568-4C16-8B42-3E9977DE5F56}.Debug|iPhone.ActiveCfg = Debug|Any CPU
|
||||
{4B1850CF-C568-4C16-8B42-3E9977DE5F56}.Debug|iPhone.Build.0 = Debug|Any CPU
|
||||
{4B1850CF-C568-4C16-8B42-3E9977DE5F56}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
|
||||
{4B1850CF-C568-4C16-8B42-3E9977DE5F56}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU
|
||||
{4B1850CF-C568-4C16-8B42-3E9977DE5F56}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{4B1850CF-C568-4C16-8B42-3E9977DE5F56}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{4B1850CF-C568-4C16-8B42-3E9977DE5F56}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{4B1850CF-C568-4C16-8B42-3E9977DE5F56}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{4B1850CF-C568-4C16-8B42-3E9977DE5F56}.Docs|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{4B1850CF-C568-4C16-8B42-3E9977DE5F56}.Docs|Any CPU.Build.0 = Debug|Any CPU
|
||||
{4B1850CF-C568-4C16-8B42-3E9977DE5F56}.Docs|ARM.ActiveCfg = Debug|Any CPU
|
||||
{4B1850CF-C568-4C16-8B42-3E9977DE5F56}.Docs|ARM.Build.0 = Debug|Any CPU
|
||||
{4B1850CF-C568-4C16-8B42-3E9977DE5F56}.Docs|iPhone.ActiveCfg = Debug|Any CPU
|
||||
{4B1850CF-C568-4C16-8B42-3E9977DE5F56}.Docs|iPhone.Build.0 = Debug|Any CPU
|
||||
{4B1850CF-C568-4C16-8B42-3E9977DE5F56}.Docs|iPhoneSimulator.ActiveCfg = Debug|Any CPU
|
||||
{4B1850CF-C568-4C16-8B42-3E9977DE5F56}.Docs|iPhoneSimulator.Build.0 = Debug|Any CPU
|
||||
{4B1850CF-C568-4C16-8B42-3E9977DE5F56}.Docs|x64.ActiveCfg = Debug|Any CPU
|
||||
{4B1850CF-C568-4C16-8B42-3E9977DE5F56}.Docs|x64.Build.0 = Debug|Any CPU
|
||||
{4B1850CF-C568-4C16-8B42-3E9977DE5F56}.Docs|x86.ActiveCfg = Debug|Any CPU
|
||||
{4B1850CF-C568-4C16-8B42-3E9977DE5F56}.Docs|x86.Build.0 = Debug|Any CPU
|
||||
{4B1850CF-C568-4C16-8B42-3E9977DE5F56}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{4B1850CF-C568-4C16-8B42-3E9977DE5F56}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{4B1850CF-C568-4C16-8B42-3E9977DE5F56}.Release|ARM.ActiveCfg = Release|Any CPU
|
||||
{4B1850CF-C568-4C16-8B42-3E9977DE5F56}.Release|ARM.Build.0 = Release|Any CPU
|
||||
{4B1850CF-C568-4C16-8B42-3E9977DE5F56}.Release|iPhone.ActiveCfg = Release|Any CPU
|
||||
{4B1850CF-C568-4C16-8B42-3E9977DE5F56}.Release|iPhone.Build.0 = Release|Any CPU
|
||||
{4B1850CF-C568-4C16-8B42-3E9977DE5F56}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
|
||||
{4B1850CF-C568-4C16-8B42-3E9977DE5F56}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
|
||||
{4B1850CF-C568-4C16-8B42-3E9977DE5F56}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{4B1850CF-C568-4C16-8B42-3E9977DE5F56}.Release|x64.Build.0 = Release|Any CPU
|
||||
{4B1850CF-C568-4C16-8B42-3E9977DE5F56}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{4B1850CF-C568-4C16-8B42-3E9977DE5F56}.Release|x86.Build.0 = Release|Any CPU
|
||||
{4B1850CF-C568-4C16-8B42-3E9977DE5F56}.Samples|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{4B1850CF-C568-4C16-8B42-3E9977DE5F56}.Samples|Any CPU.Build.0 = Release|Any CPU
|
||||
{4B1850CF-C568-4C16-8B42-3E9977DE5F56}.Samples|ARM.ActiveCfg = Release|Any CPU
|
||||
{4B1850CF-C568-4C16-8B42-3E9977DE5F56}.Samples|ARM.Build.0 = Release|Any CPU
|
||||
{4B1850CF-C568-4C16-8B42-3E9977DE5F56}.Samples|iPhone.ActiveCfg = Release|Any CPU
|
||||
{4B1850CF-C568-4C16-8B42-3E9977DE5F56}.Samples|iPhone.Build.0 = Release|Any CPU
|
||||
{4B1850CF-C568-4C16-8B42-3E9977DE5F56}.Samples|iPhoneSimulator.ActiveCfg = Release|Any CPU
|
||||
{4B1850CF-C568-4C16-8B42-3E9977DE5F56}.Samples|iPhoneSimulator.Build.0 = Release|Any CPU
|
||||
{4B1850CF-C568-4C16-8B42-3E9977DE5F56}.Samples|x64.ActiveCfg = Release|Any CPU
|
||||
{4B1850CF-C568-4C16-8B42-3E9977DE5F56}.Samples|x64.Build.0 = Release|Any CPU
|
||||
{4B1850CF-C568-4C16-8B42-3E9977DE5F56}.Samples|x86.ActiveCfg = Release|Any CPU
|
||||
{4B1850CF-C568-4C16-8B42-3E9977DE5F56}.Samples|x86.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
@ -629,6 +679,7 @@ Global
|
|||
{EE8FC716-27FC-405B-BD27-AF17E01A6671} = {EA9AC363-45BC-4959-BD17-FE3A1B724529}
|
||||
{4BD0D88F-7E7A-4C3B-9E34-BF3717A8FF4B} = {EA9AC363-45BC-4959-BD17-FE3A1B724529}
|
||||
{BE0DE9A3-D92C-47C5-9EC4-DFB546BBDF77} = {EA9AC363-45BC-4959-BD17-FE3A1B724529}
|
||||
{4B1850CF-C568-4C16-8B42-3E9977DE5F56} = {706C0487-6930-4E55-8720-C17D9FE6CA91}
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {105B0052-C7EA-44D0-8697-37A45E1392AF}
|
||||
|
|
|
@ -3,12 +3,12 @@
|
|||
public static partial class Accelerometer
|
||||
{
|
||||
internal static bool IsSupported =>
|
||||
throw new NotImplementedInReferenceAssemblyException();
|
||||
throw ExceptionUtils.NotSupportedOrImplementedException;
|
||||
|
||||
static void PlatformStart(SensorSpeed sensorSpeed) =>
|
||||
throw new NotImplementedInReferenceAssemblyException();
|
||||
throw ExceptionUtils.NotSupportedOrImplementedException;
|
||||
|
||||
static void PlatformStop() =>
|
||||
throw new NotImplementedInReferenceAssemblyException();
|
||||
throw ExceptionUtils.NotSupportedOrImplementedException;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
using Tizen.Sensor;
|
||||
using TizenAccelerometer = Tizen.Sensor.Accelerometer;
|
||||
|
||||
namespace Xamarin.Essentials
|
||||
{
|
||||
public static partial class Accelerometer
|
||||
{
|
||||
internal static TizenAccelerometer DefaultSensor =>
|
||||
(TizenAccelerometer)Platform.GetDefaultSensor(SensorType.Accelerometer);
|
||||
|
||||
internal static bool IsSupported =>
|
||||
TizenAccelerometer.IsSupported;
|
||||
|
||||
static void PlatformStart(SensorSpeed sensorSpeed)
|
||||
{
|
||||
DefaultSensor.Interval = sensorSpeed.ToPlatform();
|
||||
DefaultSensor.DataUpdated += DataUpdated;
|
||||
DefaultSensor.Start();
|
||||
}
|
||||
|
||||
static void PlatformStop()
|
||||
{
|
||||
DefaultSensor.DataUpdated -= DataUpdated;
|
||||
DefaultSensor.Stop();
|
||||
}
|
||||
|
||||
static void DataUpdated(object sender, AccelerometerDataUpdatedEventArgs e)
|
||||
{
|
||||
OnChanged(new AccelerometerData(e.X, e.Y, e.Z));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -16,7 +16,12 @@ namespace Xamarin.Essentials
|
|||
static string GetBundleValue(string key)
|
||||
=> NSBundle.MainBundle.ObjectForInfoDictionary(key)?.ToString();
|
||||
|
||||
#if __IOS__ || __TVOS__
|
||||
static void PlatformShowSettingsUI() =>
|
||||
UIApplication.SharedApplication.OpenUrl(new NSUrl(UIApplication.OpenSettingsUrlString));
|
||||
#else
|
||||
static void PlatformShowSettingsUI() =>
|
||||
throw new FeatureNotSupportedException();
|
||||
#endif
|
||||
}
|
||||
}
|
|
@ -2,14 +2,14 @@
|
|||
{
|
||||
public static partial class AppInfo
|
||||
{
|
||||
static string PlatformGetPackageName() => throw new NotImplementedInReferenceAssemblyException();
|
||||
static string PlatformGetPackageName() => throw ExceptionUtils.NotSupportedOrImplementedException;
|
||||
|
||||
static string PlatformGetName() => throw new NotImplementedInReferenceAssemblyException();
|
||||
static string PlatformGetName() => throw ExceptionUtils.NotSupportedOrImplementedException;
|
||||
|
||||
static string PlatformGetVersionString() => throw new NotImplementedInReferenceAssemblyException();
|
||||
static string PlatformGetVersionString() => throw ExceptionUtils.NotSupportedOrImplementedException;
|
||||
|
||||
static string PlatformGetBuild() => throw new NotImplementedInReferenceAssemblyException();
|
||||
static string PlatformGetBuild() => throw ExceptionUtils.NotSupportedOrImplementedException;
|
||||
|
||||
static void PlatformShowSettingsUI() => throw new NotImplementedInReferenceAssemblyException();
|
||||
static void PlatformShowSettingsUI() => throw ExceptionUtils.NotSupportedOrImplementedException;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
using System.Globalization;
|
||||
using Tizen.Applications;
|
||||
|
||||
namespace Xamarin.Essentials
|
||||
{
|
||||
public static partial class AppInfo
|
||||
{
|
||||
static string PlatformGetPackageName()
|
||||
=> Application.Current.ApplicationInfo.PackageId;
|
||||
|
||||
static string PlatformGetName()
|
||||
=> Application.Current.ApplicationInfo.Label;
|
||||
|
||||
static string PlatformGetVersionString()
|
||||
=> Platform.CurrentPackage.Version;
|
||||
|
||||
static string PlatformGetBuild()
|
||||
=> Version.Build.ToString(CultureInfo.InvariantCulture);
|
||||
|
||||
static void PlatformShowSettingsUI()
|
||||
{
|
||||
Permissions.EnsureDeclared(PermissionType.LaunchApp);
|
||||
AppControl.SendLaunchRequest(new AppControl() { Operation = AppControlOperations.Setting });
|
||||
}
|
||||
}
|
||||
}
|
|
@ -3,12 +3,12 @@
|
|||
public static partial class Barometer
|
||||
{
|
||||
internal static bool IsSupported =>
|
||||
throw new NotImplementedInReferenceAssemblyException();
|
||||
throw ExceptionUtils.NotSupportedOrImplementedException;
|
||||
|
||||
internal static void PlatformStart(SensorSpeed sensorSpeed) =>
|
||||
throw new NotImplementedInReferenceAssemblyException();
|
||||
throw ExceptionUtils.NotSupportedOrImplementedException;
|
||||
|
||||
internal static void PlatformStop() =>
|
||||
throw new NotImplementedInReferenceAssemblyException();
|
||||
throw ExceptionUtils.NotSupportedOrImplementedException;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
using Tizen.Sensor;
|
||||
using TizenBarometerSensor = Tizen.Sensor.PressureSensor;
|
||||
|
||||
namespace Xamarin.Essentials
|
||||
{
|
||||
public static partial class Barometer
|
||||
{
|
||||
static TizenBarometerSensor DefaultSensor
|
||||
=> (TizenBarometerSensor)Platform.GetDefaultSensor(SensorType.Barometer);
|
||||
|
||||
internal static bool IsSupported
|
||||
=> TizenBarometerSensor.IsSupported;
|
||||
|
||||
internal static void PlatformStart(SensorSpeed sensorSpeed)
|
||||
{
|
||||
DefaultSensor.Interval = sensorSpeed.ToPlatform();
|
||||
DefaultSensor.DataUpdated += DataUpdated;
|
||||
DefaultSensor.Start();
|
||||
}
|
||||
|
||||
internal static void PlatformStop()
|
||||
{
|
||||
DefaultSensor.DataUpdated -= DataUpdated;
|
||||
DefaultSensor.Stop();
|
||||
}
|
||||
|
||||
static void DataUpdated(object sender, PressureSensorDataUpdatedEventArgs e)
|
||||
{
|
||||
OnChanged(new BarometerData(e.Pressure));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,12 +1,20 @@
|
|||
using Foundation;
|
||||
#if __IOS__
|
||||
using UIKit;
|
||||
#elif __WATCHOS__
|
||||
using UIDevice = WatchKit.WKInterfaceDevice;
|
||||
using UIDeviceBatteryState = WatchKit.WKInterfaceDeviceBatteryState;
|
||||
#endif
|
||||
|
||||
namespace Xamarin.Essentials
|
||||
{
|
||||
public static partial class Battery
|
||||
{
|
||||
#if !__WATCHOS__
|
||||
static NSObject levelObserver;
|
||||
static NSObject stateObserver;
|
||||
#endif
|
||||
|
||||
static NSObject saverStatusObserver;
|
||||
|
||||
static void StartEnergySaverListeners()
|
||||
|
@ -28,18 +36,26 @@ namespace Xamarin.Essentials
|
|||
|
||||
static void StartBatteryListeners()
|
||||
{
|
||||
#if __WATCHOS__
|
||||
throw new FeatureNotSupportedException();
|
||||
#else
|
||||
UIDevice.CurrentDevice.BatteryMonitoringEnabled = true;
|
||||
levelObserver = UIDevice.Notifications.ObserveBatteryLevelDidChange(BatteryInfoChangedNotification);
|
||||
stateObserver = UIDevice.Notifications.ObserveBatteryStateDidChange(BatteryInfoChangedNotification);
|
||||
#endif
|
||||
}
|
||||
|
||||
static void StopBatteryListeners()
|
||||
{
|
||||
#if __WATCHOS__
|
||||
throw new FeatureNotSupportedException();
|
||||
#else
|
||||
UIDevice.CurrentDevice.BatteryMonitoringEnabled = false;
|
||||
levelObserver?.Dispose();
|
||||
levelObserver = null;
|
||||
stateObserver?.Dispose();
|
||||
stateObserver = null;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void BatteryInfoChangedNotification(object sender, NSNotificationEventArgs args)
|
|
@ -1,29 +0,0 @@
|
|||
namespace Xamarin.Essentials
|
||||
{
|
||||
public static partial class Battery
|
||||
{
|
||||
static void StartBatteryListeners() =>
|
||||
throw new NotImplementedInReferenceAssemblyException();
|
||||
|
||||
static void StopBatteryListeners() =>
|
||||
throw new NotImplementedInReferenceAssemblyException();
|
||||
|
||||
static double PlatformChargeLevel =>
|
||||
throw new NotImplementedInReferenceAssemblyException();
|
||||
|
||||
static BatteryState PlatformState =>
|
||||
throw new NotImplementedInReferenceAssemblyException();
|
||||
|
||||
static BatteryPowerSource PlatformPowerSource =>
|
||||
throw new NotImplementedInReferenceAssemblyException();
|
||||
|
||||
static void StartEnergySaverListeners() =>
|
||||
throw new NotImplementedInReferenceAssemblyException();
|
||||
|
||||
static void StopEnergySaverListeners() =>
|
||||
throw new NotImplementedInReferenceAssemblyException();
|
||||
|
||||
static EnergySaverStatus PlatformEnergySaverStatus =>
|
||||
throw new NotImplementedInReferenceAssemblyException();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
namespace Xamarin.Essentials
|
||||
{
|
||||
public static partial class Battery
|
||||
{
|
||||
static void StartBatteryListeners() =>
|
||||
throw ExceptionUtils.NotSupportedOrImplementedException;
|
||||
|
||||
static void StopBatteryListeners() =>
|
||||
throw ExceptionUtils.NotSupportedOrImplementedException;
|
||||
|
||||
static double PlatformChargeLevel =>
|
||||
throw ExceptionUtils.NotSupportedOrImplementedException;
|
||||
|
||||
static BatteryState PlatformState =>
|
||||
throw ExceptionUtils.NotSupportedOrImplementedException;
|
||||
|
||||
static BatteryPowerSource PlatformPowerSource =>
|
||||
throw ExceptionUtils.NotSupportedOrImplementedException;
|
||||
|
||||
static void StartEnergySaverListeners() =>
|
||||
throw ExceptionUtils.NotSupportedOrImplementedException;
|
||||
|
||||
static void StopEnergySaverListeners() =>
|
||||
throw ExceptionUtils.NotSupportedOrImplementedException;
|
||||
|
||||
static EnergySaverStatus PlatformEnergySaverStatus =>
|
||||
throw ExceptionUtils.NotSupportedOrImplementedException;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,62 @@
|
|||
using System;
|
||||
using TizenBattery = Tizen.System.Battery;
|
||||
|
||||
namespace Xamarin.Essentials
|
||||
{
|
||||
public static partial class Battery
|
||||
{
|
||||
static void OnChanged(object sender, object e)
|
||||
=> MainThread.BeginInvokeOnMainThread(OnBatteryInfoChanged);
|
||||
|
||||
static void StartBatteryListeners()
|
||||
{
|
||||
TizenBattery.PercentChanged += OnChanged;
|
||||
TizenBattery.ChargingStateChanged += OnChanged;
|
||||
TizenBattery.LevelChanged += OnChanged;
|
||||
}
|
||||
|
||||
static void StopBatteryListeners()
|
||||
{
|
||||
TizenBattery.PercentChanged -= OnChanged;
|
||||
TizenBattery.ChargingStateChanged -= OnChanged;
|
||||
TizenBattery.LevelChanged -= OnChanged;
|
||||
}
|
||||
|
||||
static double PlatformChargeLevel
|
||||
{
|
||||
get
|
||||
{
|
||||
return (double)TizenBattery.Percent / 100;
|
||||
}
|
||||
}
|
||||
|
||||
static BatteryState PlatformState
|
||||
{
|
||||
get
|
||||
{
|
||||
if (TizenBattery.IsCharging)
|
||||
return BatteryState.Charging;
|
||||
return BatteryState.Discharging;
|
||||
}
|
||||
}
|
||||
|
||||
static BatteryPowerSource PlatformPowerSource
|
||||
{
|
||||
get
|
||||
{
|
||||
if (TizenBattery.IsCharging)
|
||||
return BatteryPowerSource.Usb;
|
||||
return BatteryPowerSource.Battery;
|
||||
}
|
||||
}
|
||||
|
||||
static void StartEnergySaverListeners()
|
||||
=> throw new FeatureNotSupportedException("This API is not currently supported on Tizen.");
|
||||
|
||||
static void StopEnergySaverListeners()
|
||||
=> throw new FeatureNotSupportedException("This API is not currently supported on Tizen.");
|
||||
|
||||
static EnergySaverStatus PlatformEnergySaverStatus
|
||||
=> throw new FeatureNotSupportedException("This API is not currently supported on Tizen.");
|
||||
}
|
||||
}
|
|
@ -6,6 +6,6 @@ namespace Xamarin.Essentials
|
|||
public static partial class Browser
|
||||
{
|
||||
static Task<bool> PlatformOpenAsync(Uri uri, BrowserLaunchOptions options) =>
|
||||
throw new NotImplementedInReferenceAssemblyException();
|
||||
throw ExceptionUtils.NotSupportedOrImplementedException;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Tizen.Applications;
|
||||
|
||||
namespace Xamarin.Essentials
|
||||
{
|
||||
public static partial class Browser
|
||||
{
|
||||
static Task<bool> PlatformOpenAsync(Uri uri, BrowserLaunchOptions launchMode)
|
||||
{
|
||||
if (uri == null)
|
||||
throw new ArgumentNullException(nameof(uri));
|
||||
|
||||
Permissions.EnsureDeclared(PermissionType.LaunchApp);
|
||||
|
||||
var appControl = new AppControl
|
||||
{
|
||||
Operation = AppControlOperations.View,
|
||||
Uri = uri.AbsoluteUri
|
||||
};
|
||||
|
||||
var hasMatches = AppControl.GetMatchedApplicationIds(appControl).Any();
|
||||
|
||||
if (hasMatches)
|
||||
AppControl.SendLaunchRequest(appControl);
|
||||
|
||||
return Task.FromResult(hasMatches);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -5,12 +5,12 @@ namespace Xamarin.Essentials
|
|||
public static partial class Clipboard
|
||||
{
|
||||
static Task PlatformSetTextAsync(string text)
|
||||
=> throw new NotImplementedInReferenceAssemblyException();
|
||||
=> throw ExceptionUtils.NotSupportedOrImplementedException;
|
||||
|
||||
static bool PlatformHasText
|
||||
=> throw new NotImplementedInReferenceAssemblyException();
|
||||
=> throw ExceptionUtils.NotSupportedOrImplementedException;
|
||||
|
||||
static Task<string> PlatformGetTextAsync()
|
||||
=> throw new NotImplementedInReferenceAssemblyException();
|
||||
=> throw ExceptionUtils.NotSupportedOrImplementedException;
|
||||
}
|
||||
}
|
|
@ -3,12 +3,12 @@
|
|||
public static partial class Compass
|
||||
{
|
||||
internal static bool IsSupported =>
|
||||
throw new NotImplementedInReferenceAssemblyException();
|
||||
throw ExceptionUtils.NotSupportedOrImplementedException;
|
||||
|
||||
internal static void PlatformStart(SensorSpeed sensorSpeed, bool applyLowPassFilter) =>
|
||||
throw new NotImplementedInReferenceAssemblyException();
|
||||
throw ExceptionUtils.NotSupportedOrImplementedException;
|
||||
|
||||
internal static void PlatformStop() =>
|
||||
throw new NotImplementedInReferenceAssemblyException();
|
||||
throw ExceptionUtils.NotSupportedOrImplementedException;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
using Tizen.Sensor;
|
||||
using TizenCompass = Tizen.Sensor.OrientationSensor;
|
||||
|
||||
namespace Xamarin.Essentials
|
||||
{
|
||||
public static partial class Compass
|
||||
{
|
||||
internal static TizenCompass DefaultSensor =>
|
||||
(TizenCompass)Platform.GetDefaultSensor(SensorType.Compass);
|
||||
|
||||
internal static bool IsSupported =>
|
||||
TizenCompass.IsSupported;
|
||||
|
||||
internal static void PlatformStart(SensorSpeed sensorSpeed, bool applyLowPassFilter)
|
||||
{
|
||||
DefaultSensor.Interval = sensorSpeed.ToPlatform();
|
||||
DefaultSensor.DataUpdated += DataUpdated;
|
||||
DefaultSensor.Start();
|
||||
}
|
||||
|
||||
internal static void PlatformStop()
|
||||
{
|
||||
DefaultSensor.DataUpdated -= DataUpdated;
|
||||
DefaultSensor.Stop();
|
||||
}
|
||||
|
||||
static void DataUpdated(object sender, OrientationSensorDataUpdatedEventArgs e)
|
||||
{
|
||||
OnChanged(new CompassData(e.Azimuth));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -5,15 +5,15 @@ namespace Xamarin.Essentials
|
|||
public static partial class Connectivity
|
||||
{
|
||||
static NetworkAccess PlatformNetworkAccess =>
|
||||
throw new NotImplementedInReferenceAssemblyException();
|
||||
throw ExceptionUtils.NotSupportedOrImplementedException;
|
||||
|
||||
static IEnumerable<ConnectionProfile> PlatformConnectionProfiles =>
|
||||
throw new NotImplementedInReferenceAssemblyException();
|
||||
throw ExceptionUtils.NotSupportedOrImplementedException;
|
||||
|
||||
static void StartListeners() =>
|
||||
throw new NotImplementedInReferenceAssemblyException();
|
||||
throw ExceptionUtils.NotSupportedOrImplementedException;
|
||||
|
||||
static void StopListeners() =>
|
||||
throw new NotImplementedInReferenceAssemblyException();
|
||||
throw ExceptionUtils.NotSupportedOrImplementedException;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,81 @@
|
|||
using System.Collections.Generic;
|
||||
using Tizen.Network.Connection;
|
||||
|
||||
namespace Xamarin.Essentials
|
||||
{
|
||||
public static partial class Connectivity
|
||||
{
|
||||
static IList<ConnectionProfile> profiles = new List<ConnectionProfile>();
|
||||
|
||||
internal static void OnChanged(object sender, object e)
|
||||
{
|
||||
GetProfileListAsync();
|
||||
}
|
||||
|
||||
internal static async void GetProfileListAsync()
|
||||
{
|
||||
var list = await ConnectionProfileManager.GetProfileListAsync(ProfileListType.Connected);
|
||||
profiles.Clear();
|
||||
foreach (var result in list)
|
||||
{
|
||||
switch (result.Type)
|
||||
{
|
||||
case ConnectionProfileType.Bt:
|
||||
profiles.Add(ConnectionProfile.Bluetooth);
|
||||
break;
|
||||
|
||||
case ConnectionProfileType.Cellular:
|
||||
profiles.Add(ConnectionProfile.Cellular);
|
||||
break;
|
||||
|
||||
case ConnectionProfileType.Ethernet:
|
||||
profiles.Add(ConnectionProfile.Ethernet);
|
||||
break;
|
||||
|
||||
case ConnectionProfileType.WiFi:
|
||||
profiles.Add(ConnectionProfile.WiFi);
|
||||
break;
|
||||
}
|
||||
}
|
||||
OnConnectivityChanged();
|
||||
}
|
||||
|
||||
static NetworkAccess PlatformNetworkAccess
|
||||
{
|
||||
get
|
||||
{
|
||||
Permissions.EnsureDeclared(PermissionType.NetworkState);
|
||||
var currentAccess = ConnectionManager.CurrentConnection;
|
||||
switch (currentAccess.Type)
|
||||
{
|
||||
case ConnectionType.WiFi:
|
||||
case ConnectionType.Cellular:
|
||||
case ConnectionType.Ethernet:
|
||||
return NetworkAccess.Internet;
|
||||
default:
|
||||
return NetworkAccess.None;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static IEnumerable<ConnectionProfile> PlatformConnectionProfiles
|
||||
{
|
||||
get
|
||||
{
|
||||
return profiles;
|
||||
}
|
||||
}
|
||||
|
||||
static void StartListeners()
|
||||
{
|
||||
Permissions.EnsureDeclared(PermissionType.NetworkState);
|
||||
ConnectionManager.ConnectionTypeChanged += OnChanged;
|
||||
GetProfileListAsync();
|
||||
}
|
||||
|
||||
static void StopListeners()
|
||||
{
|
||||
ConnectionManager.ConnectionTypeChanged -= OnChanged;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,17 +0,0 @@
|
|||
namespace Xamarin.Essentials
|
||||
{
|
||||
public static partial class DeviceDisplay
|
||||
{
|
||||
static bool PlatformKeepScreenOn
|
||||
{
|
||||
get => throw new NotImplementedInReferenceAssemblyException();
|
||||
set => throw new NotImplementedInReferenceAssemblyException();
|
||||
}
|
||||
|
||||
static DisplayInfo GetMainDisplayInfo() => throw new NotImplementedInReferenceAssemblyException();
|
||||
|
||||
static void StartScreenMetricsListeners() => throw new NotImplementedInReferenceAssemblyException();
|
||||
|
||||
static void StopScreenMetricsListeners() => throw new NotImplementedInReferenceAssemblyException();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
namespace Xamarin.Essentials
|
||||
{
|
||||
public static partial class DeviceDisplay
|
||||
{
|
||||
static bool PlatformKeepScreenOn
|
||||
{
|
||||
get => throw ExceptionUtils.NotSupportedOrImplementedException;
|
||||
set => throw ExceptionUtils.NotSupportedOrImplementedException;
|
||||
}
|
||||
|
||||
static DisplayInfo GetMainDisplayInfo() => throw ExceptionUtils.NotSupportedOrImplementedException;
|
||||
|
||||
static void StartScreenMetricsListeners() => throw ExceptionUtils.NotSupportedOrImplementedException;
|
||||
|
||||
static void StopScreenMetricsListeners() => throw ExceptionUtils.NotSupportedOrImplementedException;
|
||||
}
|
||||
}
|
|
@ -1,7 +1,13 @@
|
|||
using System;
|
||||
using System.Diagnostics;
|
||||
using ObjCRuntime;
|
||||
#if __WATCHOS__
|
||||
using WatchKit;
|
||||
using UIDevice = WatchKit.WKInterfaceDevice;
|
||||
#else
|
||||
using UIKit;
|
||||
#endif
|
||||
|
||||
using ObjCRuntime;
|
||||
|
||||
namespace Xamarin.Essentials
|
||||
{
|
||||
|
@ -26,10 +32,20 @@ namespace Xamarin.Essentials
|
|||
|
||||
static string GetVersionString() => UIDevice.CurrentDevice.SystemVersion;
|
||||
|
||||
static DevicePlatform GetPlatform() => DevicePlatform.iOS;
|
||||
static DevicePlatform GetPlatform() =>
|
||||
#if __IOS__
|
||||
DevicePlatform.iOS;
|
||||
#elif __TVOS__
|
||||
DevicePlatform.tvOS;
|
||||
#elif __WATCHOS__
|
||||
DevicePlatform.watchOS;
|
||||
#endif
|
||||
|
||||
static DeviceIdiom GetIdiom()
|
||||
{
|
||||
#if __WATCHOS__
|
||||
return DeviceIdiom.Watch;
|
||||
#else
|
||||
switch (UIDevice.CurrentDevice.UserInterfaceIdiom)
|
||||
{
|
||||
case UIUserInterfaceIdiom.Pad:
|
||||
|
@ -43,6 +59,7 @@ namespace Xamarin.Essentials
|
|||
default:
|
||||
return DeviceIdiom.Unknown;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
static DeviceType GetDeviceType()
|
|
@ -2,13 +2,13 @@
|
|||
{
|
||||
public static partial class DeviceInfo
|
||||
{
|
||||
static string GetModel() => throw new NotImplementedInReferenceAssemblyException();
|
||||
static string GetModel() => throw ExceptionUtils.NotSupportedOrImplementedException;
|
||||
|
||||
static string GetManufacturer() => throw new NotImplementedInReferenceAssemblyException();
|
||||
static string GetManufacturer() => throw ExceptionUtils.NotSupportedOrImplementedException;
|
||||
|
||||
static string GetDeviceName() => throw new NotImplementedInReferenceAssemblyException();
|
||||
static string GetDeviceName() => throw ExceptionUtils.NotSupportedOrImplementedException;
|
||||
|
||||
static string GetVersionString() => throw new NotImplementedInReferenceAssemblyException();
|
||||
static string GetVersionString() => throw ExceptionUtils.NotSupportedOrImplementedException;
|
||||
|
||||
static DevicePlatform GetPlatform() => DevicePlatform.Unknown;
|
||||
|
||||
|
|
|
@ -0,0 +1,53 @@
|
|||
using Plat = Xamarin.Essentials.Platform;
|
||||
|
||||
namespace Xamarin.Essentials
|
||||
{
|
||||
public static partial class DeviceInfo
|
||||
{
|
||||
static string GetModel()
|
||||
=> Plat.GetSystemInfo("model_name");
|
||||
|
||||
static string GetManufacturer()
|
||||
=> Plat.GetSystemInfo("manufacturer");
|
||||
|
||||
static string GetDeviceName()
|
||||
=> Plat.GetSystemInfo("device_name");
|
||||
|
||||
static string GetVersionString()
|
||||
=> Plat.GetFeatureInfo("platform.version");
|
||||
|
||||
static DevicePlatform GetPlatform()
|
||||
=> DevicePlatform.Tizen;
|
||||
|
||||
static DeviceIdiom GetIdiom()
|
||||
{
|
||||
var profile = Plat.GetFeatureInfo("profile")?.ToUpperInvariant();
|
||||
|
||||
if (profile == null)
|
||||
return DeviceIdiom.Unknown;
|
||||
|
||||
if (profile.StartsWith("M"))
|
||||
return DeviceIdiom.Phone;
|
||||
else if (profile.StartsWith("W"))
|
||||
return DeviceIdiom.Watch;
|
||||
else if (profile.StartsWith("T"))
|
||||
return DeviceIdiom.TV;
|
||||
else
|
||||
return DeviceIdiom.Unknown;
|
||||
}
|
||||
|
||||
static DeviceType GetDeviceType()
|
||||
{
|
||||
var arch = Plat.GetFeatureInfo("platform.core.cpu.arch");
|
||||
var armv7 = Plat.GetFeatureInfo<bool>("platform.core.cpu.arch.armv7");
|
||||
var x86 = Plat.GetFeatureInfo<bool>("platform.core.cpu.arch.x86");
|
||||
|
||||
if (arch != null && arch.Equals("armv7") && armv7 && !x86)
|
||||
return DeviceType.Physical;
|
||||
else if (arch != null && arch.Equals("x86") && !armv7 && x86)
|
||||
return DeviceType.Virtual;
|
||||
else
|
||||
return DeviceType.Unknown;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -5,15 +5,17 @@ namespace Xamarin.Essentials
|
|||
public static partial class Email
|
||||
{
|
||||
internal static bool IsComposeSupported =>
|
||||
throw new NotImplementedInReferenceAssemblyException();
|
||||
throw ExceptionUtils.NotSupportedOrImplementedException;
|
||||
|
||||
static Task PlatformComposeAsync(EmailMessage message) =>
|
||||
throw new NotImplementedInReferenceAssemblyException();
|
||||
throw ExceptionUtils.NotSupportedOrImplementedException;
|
||||
}
|
||||
|
||||
#if NETSTANDARD1_0 || NETSTANDARD2_0
|
||||
public partial class EmailAttachment
|
||||
{
|
||||
string PlatformGetContentType(string extension) =>
|
||||
throw new NotImplementedInReferenceAssemblyException();
|
||||
throw ExceptionUtils.NotSupportedOrImplementedException;
|
||||
}
|
||||
#endif
|
||||
}
|
|
@ -2,6 +2,7 @@
|
|||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Xamarin.Essentials
|
||||
|
@ -29,15 +30,15 @@ namespace Xamarin.Essentials
|
|||
|
||||
var parts = new List<string>();
|
||||
if (!string.IsNullOrEmpty(message?.Body))
|
||||
parts.Add("body=" + Uri.EscapeUriString(message.Body));
|
||||
parts.Add("body=" + WebUtility.UrlEncode(message.Body));
|
||||
if (!string.IsNullOrEmpty(message?.Subject))
|
||||
parts.Add("subject=" + Uri.EscapeUriString(message.Subject));
|
||||
parts.Add("subject=" + WebUtility.UrlEncode(message.Subject));
|
||||
if (message?.To.Count > 0)
|
||||
parts.Add("to=" + string.Join(",", message.To));
|
||||
parts.Add("to=" + WebUtility.UrlEncode(string.Join(",", message.To)));
|
||||
if (message?.Cc.Count > 0)
|
||||
parts.Add("cc=" + string.Join(",", message.Cc));
|
||||
parts.Add("cc=" + WebUtility.UrlEncode(string.Join(",", message.Cc)));
|
||||
if (message?.Bcc.Count > 0)
|
||||
parts.Add("bcc=" + string.Join(",", message.Bcc));
|
||||
parts.Add("bcc=" + WebUtility.UrlEncode(string.Join(",", message.Bcc)));
|
||||
|
||||
var uri = "mailto:";
|
||||
if (parts.Count > 0)
|
||||
|
@ -85,19 +86,16 @@ namespace Xamarin.Essentials
|
|||
public EmailAttachment(string fullPath)
|
||||
: base(fullPath)
|
||||
{
|
||||
ExperimentalFeatures.VerifyEnabled(ExperimentalFeatures.EmailAttachments);
|
||||
}
|
||||
|
||||
public EmailAttachment(string fullPath, string contentType)
|
||||
: base(fullPath, contentType)
|
||||
{
|
||||
ExperimentalFeatures.VerifyEnabled(ExperimentalFeatures.EmailAttachments);
|
||||
}
|
||||
|
||||
public EmailAttachment(FileBase file)
|
||||
: base(file)
|
||||
{
|
||||
ExperimentalFeatures.VerifyEnabled(ExperimentalFeatures.EmailAttachments);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,37 @@
|
|||
using System.Threading.Tasks;
|
||||
using Tizen.Applications;
|
||||
|
||||
namespace Xamarin.Essentials
|
||||
{
|
||||
public static partial class Email
|
||||
{
|
||||
internal static bool IsComposeSupported
|
||||
=> Platform.GetFeatureInfo<bool>("email");
|
||||
|
||||
static Task PlatformComposeAsync(EmailMessage message)
|
||||
{
|
||||
Permissions.EnsureDeclared(PermissionType.LaunchApp);
|
||||
|
||||
var appControl = new AppControl
|
||||
{
|
||||
Operation = AppControlOperations.Compose,
|
||||
Uri = "mailto:",
|
||||
};
|
||||
|
||||
if (message.Bcc.Count > 0)
|
||||
appControl.ExtraData.Add("http://tizen.org/appcontrol/data/bcc", message.Bcc);
|
||||
if (!string.IsNullOrEmpty(message.Body))
|
||||
appControl.ExtraData.Add("http://tizen.org/appcontrol/data/text", message.Body);
|
||||
if (message.Cc.Count > 0)
|
||||
appControl.ExtraData.Add("http://tizen.org/appcontrol/data/cc", message.Cc);
|
||||
if (!string.IsNullOrEmpty(message.Subject))
|
||||
appControl.ExtraData.Add("http://tizen.org/appcontrol/data/subject", message.Subject);
|
||||
if (message.To.Count > 0)
|
||||
appControl.ExtraData.Add("http://tizen.org/appcontrol/data/to", message.To);
|
||||
|
||||
AppControl.SendLaunchRequest(appControl);
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -6,21 +6,21 @@ namespace Xamarin.Essentials
|
|||
public static partial class FileSystem
|
||||
{
|
||||
static string PlatformCacheDirectory
|
||||
=> throw new NotImplementedInReferenceAssemblyException();
|
||||
=> throw ExceptionUtils.NotSupportedOrImplementedException;
|
||||
|
||||
static string PlatformAppDataDirectory
|
||||
=> throw new NotImplementedInReferenceAssemblyException();
|
||||
=> throw ExceptionUtils.NotSupportedOrImplementedException;
|
||||
|
||||
static Task<Stream> PlatformOpenAppPackageFileAsync(string filename)
|
||||
=> throw new NotImplementedInReferenceAssemblyException();
|
||||
=> throw ExceptionUtils.NotSupportedOrImplementedException;
|
||||
}
|
||||
|
||||
public partial class FileBase
|
||||
{
|
||||
static string PlatformGetContentType(string extension) =>
|
||||
throw new NotImplementedInReferenceAssemblyException();
|
||||
throw ExceptionUtils.NotSupportedOrImplementedException;
|
||||
|
||||
internal void PlatformInit(FileBase file) =>
|
||||
throw new NotImplementedInReferenceAssemblyException();
|
||||
throw ExceptionUtils.NotSupportedOrImplementedException;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
using Tizen.Applications;
|
||||
|
||||
namespace Xamarin.Essentials
|
||||
{
|
||||
public static partial class FileSystem
|
||||
{
|
||||
static string PlatformCacheDirectory
|
||||
=> Application.Current.DirectoryInfo.Cache;
|
||||
|
||||
static string PlatformAppDataDirectory
|
||||
=> Application.Current.DirectoryInfo.Data;
|
||||
|
||||
static Task<Stream> PlatformOpenAppPackageFileAsync(string filename)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(filename))
|
||||
throw new ArgumentNullException(nameof(filename));
|
||||
|
||||
filename = filename.Replace('\\', Path.DirectorySeparatorChar);
|
||||
Stream fs = File.OpenRead(Path.Combine(Application.Current.DirectoryInfo.Resource, filename));
|
||||
return Task.FromResult(fs);
|
||||
}
|
||||
}
|
||||
|
||||
public partial class FileBase
|
||||
{
|
||||
static string PlatformGetContentType(string extension)
|
||||
{
|
||||
return Tizen.Content.MimeType.MimeUtil.GetMimeType(extension);
|
||||
}
|
||||
|
||||
internal void PlatformInit(FileBase file)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
|
@ -5,9 +5,9 @@ namespace Xamarin.Essentials
|
|||
public static partial class Flashlight
|
||||
{
|
||||
static Task PlatformTurnOnAsync() =>
|
||||
throw new NotImplementedInReferenceAssemblyException();
|
||||
throw ExceptionUtils.NotSupportedOrImplementedException;
|
||||
|
||||
static Task PlatformTurnOffAsync() =>
|
||||
throw new NotImplementedInReferenceAssemblyException();
|
||||
throw ExceptionUtils.NotSupportedOrImplementedException;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
using System.Threading.Tasks;
|
||||
using Tizen.System;
|
||||
|
||||
namespace Xamarin.Essentials
|
||||
{
|
||||
public static partial class Flashlight
|
||||
{
|
||||
internal static bool IsSupported
|
||||
=> Platform.GetFeatureInfo<bool>("camera.back.flash");
|
||||
|
||||
internal static Task SwitchFlashlight(bool switchOn)
|
||||
{
|
||||
Permissions.EnsureDeclared(PermissionType.Flashlight);
|
||||
return Task.Run(() =>
|
||||
{
|
||||
if (!IsSupported)
|
||||
throw new FeatureNotSupportedException();
|
||||
|
||||
if (switchOn)
|
||||
Led.Brightness = Led.MaxBrightness;
|
||||
else
|
||||
Led.Brightness = 0;
|
||||
});
|
||||
}
|
||||
|
||||
static Task PlatformTurnOnAsync()
|
||||
{
|
||||
return SwitchFlashlight(true);
|
||||
}
|
||||
|
||||
static Task PlatformTurnOffAsync()
|
||||
{
|
||||
return SwitchFlashlight(false);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -6,9 +6,9 @@ namespace Xamarin.Essentials
|
|||
public static partial class Geocoding
|
||||
{
|
||||
static Task<IEnumerable<Placemark>> PlatformGetPlacemarksAsync(double latitude, double longitude) =>
|
||||
throw new NotImplementedInReferenceAssemblyException();
|
||||
throw ExceptionUtils.NotSupportedOrImplementedException;
|
||||
|
||||
static Task<IEnumerable<Location>> PlatformGetLocationsAsync(string address) =>
|
||||
throw new NotImplementedInReferenceAssemblyException();
|
||||
throw ExceptionUtils.NotSupportedOrImplementedException;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,51 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Xamarin.Essentials
|
||||
{
|
||||
public static partial class Geocoding
|
||||
{
|
||||
static async Task<IEnumerable<Placemark>> PlatformGetPlacemarksAsync(double latitude, double longitude)
|
||||
{
|
||||
Permissions.EnsureDeclared(PermissionType.Maps);
|
||||
if (string.IsNullOrWhiteSpace(Platform.MapServiceToken))
|
||||
throw new ArgumentNullException(nameof(Platform.MapServiceToken));
|
||||
var map = await Platform.GetMapServiceAsync(Platform.MapServiceToken);
|
||||
var request = map.CreateReverseGeocodeRequest(latitude, longitude);
|
||||
|
||||
var list = new List<Placemark>();
|
||||
foreach (var address in await request.GetResponseAsync())
|
||||
{
|
||||
list.Add(new Placemark
|
||||
{
|
||||
CountryCode = address.CountryCode,
|
||||
CountryName = address.Country,
|
||||
AdminArea = address.State,
|
||||
SubAdminArea = address.County,
|
||||
Locality = address.City,
|
||||
SubLocality = address.District,
|
||||
Thoroughfare = address.Street,
|
||||
SubThoroughfare = address.Building,
|
||||
FeatureName = address.Street,
|
||||
Location = new Location(latitude, longitude),
|
||||
PostalCode = address.PostalCode,
|
||||
});
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
static async Task<IEnumerable<Location>> PlatformGetLocationsAsync(string address)
|
||||
{
|
||||
Permissions.EnsureDeclared(PermissionType.Maps);
|
||||
if (string.IsNullOrWhiteSpace(Platform.MapServiceToken))
|
||||
throw new ArgumentNullException(nameof(Platform.MapServiceToken));
|
||||
var map = await Platform.GetMapServiceAsync(Platform.MapServiceToken);
|
||||
var request = map.CreateGeocodeRequest(address);
|
||||
var list = new List<Location>();
|
||||
foreach (var position in await request.GetResponseAsync())
|
||||
list.Add(new Location(position.Latitude, position.Longitude));
|
||||
return list;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -7,9 +7,9 @@ namespace Xamarin.Essentials
|
|||
public static partial class Geolocation
|
||||
{
|
||||
static Task<Location> PlatformLastKnownLocationAsync() =>
|
||||
throw new NotImplementedInReferenceAssemblyException();
|
||||
throw ExceptionUtils.NotSupportedOrImplementedException;
|
||||
|
||||
static Task<Location> PlatformLocationAsync(GeolocationRequest request, CancellationToken cancellationToken) =>
|
||||
throw new NotImplementedInReferenceAssemblyException();
|
||||
throw ExceptionUtils.NotSupportedOrImplementedException;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,72 @@
|
|||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Tizen.Location;
|
||||
|
||||
namespace Xamarin.Essentials
|
||||
{
|
||||
public static partial class Geolocation
|
||||
{
|
||||
static Location lastKnownLocation = new Location();
|
||||
|
||||
static async Task<Location> PlatformLastKnownLocationAsync()
|
||||
{
|
||||
await Permissions.RequestAsync(PermissionType.LocationWhenInUse);
|
||||
|
||||
return lastKnownLocation;
|
||||
}
|
||||
|
||||
static async Task<Location> PlatformLocationAsync(GeolocationRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
await Permissions.RequireAsync(PermissionType.LocationWhenInUse);
|
||||
|
||||
Locator service = null;
|
||||
var gps = Platform.GetFeatureInfo<bool>("location.gps");
|
||||
var wps = Platform.GetFeatureInfo<bool>("location.wps");
|
||||
if (gps)
|
||||
{
|
||||
if (wps)
|
||||
service = new Locator(LocationType.Hybrid);
|
||||
else
|
||||
service = new Locator(LocationType.Gps);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (wps)
|
||||
service = new Locator(LocationType.Wps);
|
||||
else
|
||||
service = new Locator(LocationType.Passive);
|
||||
}
|
||||
|
||||
var tcs = new TaskCompletionSource<bool>();
|
||||
|
||||
cancellationToken = Utils.TimeoutToken(cancellationToken, request.Timeout);
|
||||
cancellationToken.Register(() =>
|
||||
{
|
||||
service?.Stop();
|
||||
tcs.TrySetResult(false);
|
||||
});
|
||||
|
||||
double KmToMetersPerSecond(double km) => km * 0.277778;
|
||||
service.LocationChanged += (s, e) =>
|
||||
{
|
||||
if (e.Location != null)
|
||||
{
|
||||
lastKnownLocation.Accuracy = e.Location.Accuracy;
|
||||
lastKnownLocation.Altitude = e.Location.Altitude;
|
||||
lastKnownLocation.Course = e.Location.Direction;
|
||||
lastKnownLocation.Latitude = e.Location.Latitude;
|
||||
lastKnownLocation.Longitude = e.Location.Longitude;
|
||||
lastKnownLocation.Speed = KmToMetersPerSecond(e.Location.Speed);
|
||||
lastKnownLocation.Timestamp = e.Location.Timestamp;
|
||||
}
|
||||
service?.Stop();
|
||||
tcs.TrySetResult(true);
|
||||
};
|
||||
service.Start();
|
||||
|
||||
await tcs.Task;
|
||||
|
||||
return lastKnownLocation;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -4,5 +4,9 @@
|
|||
// a specific target and scoped to a namespace, type, member, etc.
|
||||
|
||||
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "iOS is what we want.", Scope = "member", Target = "~P:Xamarin.Essentials.DevicePlatform.iOS")]
|
||||
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "tvOS is what we want.", Scope = "member", Target = "~P:Xamarin.Essentials.DevicePlatform.tvOS")]
|
||||
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "watchOS is what we want.", Scope = "member", Target = "~P:Xamarin.Essentials.DevicePlatform.watchOS")]
|
||||
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("StyleCop.CSharp.NamingRules", "SA1300:Element should begin with upper-case letter", Justification = "iOS is what we want.", Scope = "member", Target = "~P:Xamarin.Essentials.DevicePlatform.iOS")]
|
||||
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("StyleCop.CSharp.NamingRules", "SA1300:Element should begin with upper-case letter", Justification = "tvOS is what we want.", Scope = "member", Target = "~P:Xamarin.Essentials.DevicePlatform.tvOS")]
|
||||
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("StyleCop.CSharp.NamingRules", "SA1300:Element should begin with upper-case letter", Justification = "watchOS is what we want.", Scope = "member", Target = "~P:Xamarin.Essentials.DevicePlatform.watchOS")]
|
||||
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("StyleCop.CSharp.SpacingRules", "SA1008:Opening parenthesis should be spaced correctly", Justification = "Clashed with rule 1003", Scope = "member", Target = "~M:Xamarin.Essentials.SmsMessage.#ctor(System.String,System.String)")]
|
||||
|
|
|
@ -3,12 +3,12 @@
|
|||
public static partial class Gyroscope
|
||||
{
|
||||
internal static bool IsSupported =>
|
||||
throw new NotImplementedInReferenceAssemblyException();
|
||||
throw ExceptionUtils.NotSupportedOrImplementedException;
|
||||
|
||||
internal static void PlatformStart(SensorSpeed sensorSpeed) =>
|
||||
throw new NotImplementedInReferenceAssemblyException();
|
||||
throw ExceptionUtils.NotSupportedOrImplementedException;
|
||||
|
||||
internal static void PlatformStop() =>
|
||||
throw new NotImplementedInReferenceAssemblyException();
|
||||
throw ExceptionUtils.NotSupportedOrImplementedException;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
using Tizen.Sensor;
|
||||
using TizenGyroscope = Tizen.Sensor.Gyroscope;
|
||||
|
||||
namespace Xamarin.Essentials
|
||||
{
|
||||
public static partial class Gyroscope
|
||||
{
|
||||
internal static TizenGyroscope DefaultSensor =>
|
||||
(TizenGyroscope)Platform.GetDefaultSensor(SensorType.Gyroscope);
|
||||
|
||||
internal static bool IsSupported =>
|
||||
TizenGyroscope.IsSupported;
|
||||
|
||||
internal static void PlatformStart(SensorSpeed sensorSpeed)
|
||||
{
|
||||
DefaultSensor.Interval = sensorSpeed.ToPlatform();
|
||||
DefaultSensor.DataUpdated += DataUpdated;
|
||||
DefaultSensor.Start();
|
||||
}
|
||||
|
||||
internal static void PlatformStop()
|
||||
{
|
||||
DefaultSensor.DataUpdated -= DataUpdated;
|
||||
DefaultSensor.Stop();
|
||||
}
|
||||
|
||||
static void DataUpdated(object sender, GyroscopeDataUpdatedEventArgs e)
|
||||
{
|
||||
OnChanged(new GyroscopeData(e.X, e.Y, e.Z));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -45,5 +45,15 @@ namespace Xamarin.Essentials
|
|||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
static async Task<bool> PlatformTryOpenAsync(Uri uri)
|
||||
{
|
||||
var canOpen = await PlatformCanOpenAsync(uri).ConfigureAwait(false);
|
||||
|
||||
if (canOpen)
|
||||
await PlatformOpenAsync(uri).ConfigureAwait(false);
|
||||
|
||||
return canOpen;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,6 +14,17 @@ namespace Xamarin.Essentials
|
|||
static Task PlatformOpenAsync(Uri uri) =>
|
||||
UIApplication.SharedApplication.OpenUrlAsync(GetNativeUrl(uri), new UIApplicationOpenUrlOptions());
|
||||
|
||||
static Task<bool> PlatformTryOpenAsync(Uri uri)
|
||||
{
|
||||
var nativeUrl = GetNativeUrl(uri);
|
||||
var canOpen = UIApplication.SharedApplication.CanOpenUrl(nativeUrl);
|
||||
|
||||
if (canOpen)
|
||||
return UIApplication.SharedApplication.OpenUrlAsync(nativeUrl, new UIApplicationOpenUrlOptions());
|
||||
|
||||
return Task.FromResult(canOpen);
|
||||
}
|
||||
|
||||
internal static NSUrl GetNativeUrl(Uri uri)
|
||||
{
|
||||
try
|
||||
|
@ -27,6 +38,7 @@ namespace Xamarin.Essentials
|
|||
}
|
||||
}
|
||||
|
||||
#if __IOS__
|
||||
static Task PlatformOpenAsync(OpenFileRequest request)
|
||||
{
|
||||
var fileUrl = NSUrl.FromFilename(request.File.FullPath);
|
||||
|
@ -36,8 +48,23 @@ namespace Xamarin.Essentials
|
|||
|
||||
var vc = Platform.GetCurrentViewController();
|
||||
|
||||
documentController.PresentOpenInMenu(vc.View.Frame, vc.View, true);
|
||||
CoreGraphics.CGRect? rect = null;
|
||||
if (DeviceInfo.Idiom == DeviceIdiom.Tablet)
|
||||
{
|
||||
rect = new CoreGraphics.CGRect(new CoreGraphics.CGPoint(vc.View.Bounds.Width / 2, vc.View.Bounds.Height), CoreGraphics.CGRect.Empty.Size);
|
||||
}
|
||||
else
|
||||
{
|
||||
rect = vc.View.Bounds;
|
||||
}
|
||||
|
||||
documentController.PresentOpenInMenu(rect.Value, vc.View, true);
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
#else
|
||||
static Task PlatformOpenAsync(OpenFileRequest request) =>
|
||||
throw new FeatureNotSupportedException();
|
||||
#endif
|
||||
}
|
||||
}
|
|
@ -1,17 +0,0 @@
|
|||
using System;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Xamarin.Essentials
|
||||
{
|
||||
public static partial class Launcher
|
||||
{
|
||||
static Task<bool> PlatformCanOpenAsync(Uri uri) =>
|
||||
throw new NotImplementedInReferenceAssemblyException();
|
||||
|
||||
static Task PlatformOpenAsync(Uri uri) =>
|
||||
throw new NotImplementedInReferenceAssemblyException();
|
||||
|
||||
static Task PlatformOpenAsync(OpenFileRequest request) =>
|
||||
throw new NotImplementedInReferenceAssemblyException();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
using System;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Xamarin.Essentials
|
||||
{
|
||||
public static partial class Launcher
|
||||
{
|
||||
static Task<bool> PlatformCanOpenAsync(Uri uri) =>
|
||||
throw ExceptionUtils.NotSupportedOrImplementedException;
|
||||
|
||||
static Task PlatformOpenAsync(Uri uri) =>
|
||||
throw ExceptionUtils.NotSupportedOrImplementedException;
|
||||
|
||||
static Task PlatformOpenAsync(OpenFileRequest request) =>
|
||||
throw ExceptionUtils.NotSupportedOrImplementedException;
|
||||
|
||||
static Task<bool> PlatformTryOpenAsync(Uri uri) =>
|
||||
throw ExceptionUtils.NotSupportedOrImplementedException;
|
||||
}
|
||||
}
|
|
@ -40,29 +40,40 @@ namespace Xamarin.Essentials
|
|||
|
||||
public static Task OpenAsync(OpenFileRequest request)
|
||||
{
|
||||
ExperimentalFeatures.VerifyEnabled(ExperimentalFeatures.OpenFileRequest);
|
||||
|
||||
return PlatformOpenAsync(request);
|
||||
}
|
||||
|
||||
public static Task<bool> TryOpenAsync(string uri)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(uri))
|
||||
throw new ArgumentNullException(nameof(uri));
|
||||
|
||||
return PlatformTryOpenAsync(new Uri(uri));
|
||||
}
|
||||
|
||||
public static Task<bool> TryOpenAsync(Uri uri)
|
||||
{
|
||||
if (uri == null)
|
||||
throw new ArgumentNullException(nameof(uri));
|
||||
|
||||
return PlatformCanOpenAsync(uri);
|
||||
}
|
||||
}
|
||||
|
||||
public class OpenFileRequest
|
||||
{
|
||||
public OpenFileRequest()
|
||||
{
|
||||
ExperimentalFeatures.VerifyEnabled(ExperimentalFeatures.OpenFileRequest);
|
||||
}
|
||||
|
||||
public OpenFileRequest(string title, ReadOnlyFile file)
|
||||
{
|
||||
ExperimentalFeatures.VerifyEnabled(ExperimentalFeatures.OpenFileRequest);
|
||||
Title = title;
|
||||
File = file;
|
||||
}
|
||||
|
||||
public OpenFileRequest(string title, FileBase file)
|
||||
{
|
||||
ExperimentalFeatures.VerifyEnabled(ExperimentalFeatures.OpenFileRequest);
|
||||
Title = title;
|
||||
File = new ReadOnlyFile(file);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,68 @@
|
|||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Tizen.Applications;
|
||||
|
||||
namespace Xamarin.Essentials
|
||||
{
|
||||
public static partial class Launcher
|
||||
{
|
||||
static Task<bool> PlatformCanOpenAsync(Uri uri)
|
||||
=> Task.FromResult(uri.IsWellFormedOriginalString());
|
||||
|
||||
static Task PlatformOpenAsync(Uri uri)
|
||||
{
|
||||
Permissions.EnsureDeclared(PermissionType.LaunchApp);
|
||||
|
||||
var appControl = new AppControl
|
||||
{
|
||||
Operation = AppControlOperations.ShareText,
|
||||
Uri = uri.AbsoluteUri
|
||||
};
|
||||
|
||||
if (uri.AbsoluteUri.StartsWith("geo:"))
|
||||
appControl.Operation = AppControlOperations.Pick;
|
||||
else if (uri.AbsoluteUri.StartsWith("http"))
|
||||
appControl.Operation = AppControlOperations.View;
|
||||
else if (uri.AbsoluteUri.StartsWith("mailto:"))
|
||||
appControl.Operation = AppControlOperations.Compose;
|
||||
else if (uri.AbsoluteUri.StartsWith("sms:"))
|
||||
appControl.Operation = AppControlOperations.Compose;
|
||||
else if (uri.AbsoluteUri.StartsWith("tel:"))
|
||||
appControl.Operation = AppControlOperations.Dial;
|
||||
|
||||
AppControl.SendLaunchRequest(appControl);
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
static Task PlatformOpenAsync(OpenFileRequest request)
|
||||
{
|
||||
if (string.IsNullOrEmpty(request.File.FullPath))
|
||||
throw new ArgumentNullException(nameof(request.File.FullPath));
|
||||
|
||||
Permissions.EnsureDeclared(PermissionType.LaunchApp);
|
||||
|
||||
var appControl = new AppControl
|
||||
{
|
||||
Operation = AppControlOperations.View,
|
||||
};
|
||||
|
||||
if (!string.IsNullOrEmpty(request.File.FullPath))
|
||||
appControl.ExtraData.Add("http://tizen.org/appcontrol/data/path", request.File.FullPath);
|
||||
|
||||
AppControl.SendLaunchRequest(appControl);
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
static async Task<bool> PlatformTryOpenAsync(Uri uri)
|
||||
{
|
||||
var canOpen = await PlatformCanOpenAsync(uri).ConfigureAwait(false);
|
||||
|
||||
if (canOpen)
|
||||
await PlatformOpenAsync(uri).ConfigureAwait(false);
|
||||
|
||||
return canOpen;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -24,5 +24,15 @@ namespace Xamarin.Essentials
|
|||
|
||||
await WinLauncher.LaunchFileAsync(storageFile).AsTask();
|
||||
}
|
||||
|
||||
static async Task<bool> PlatformTryOpenAsync(Uri uri)
|
||||
{
|
||||
var canOpen = await PlatformCanOpenAsync(uri).ConfigureAwait(false);
|
||||
|
||||
if (canOpen)
|
||||
return await WinLauncher.LaunchUriAsync(uri).AsTask().ConfigureAwait(false);
|
||||
|
||||
return canOpen;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,12 +3,12 @@
|
|||
public static partial class Magnetometer
|
||||
{
|
||||
internal static bool IsSupported =>
|
||||
throw new NotImplementedInReferenceAssemblyException();
|
||||
throw ExceptionUtils.NotSupportedOrImplementedException;
|
||||
|
||||
internal static void PlatformStart(SensorSpeed sensorSpeed) =>
|
||||
throw new NotImplementedInReferenceAssemblyException();
|
||||
throw ExceptionUtils.NotSupportedOrImplementedException;
|
||||
|
||||
internal static void PlatformStop() =>
|
||||
throw new NotImplementedInReferenceAssemblyException();
|
||||
throw ExceptionUtils.NotSupportedOrImplementedException;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
using Tizen.Sensor;
|
||||
using TizenMagnetometer = Tizen.Sensor.Magnetometer;
|
||||
|
||||
namespace Xamarin.Essentials
|
||||
{
|
||||
public static partial class Magnetometer
|
||||
{
|
||||
internal static TizenMagnetometer DefaultSensor =>
|
||||
(TizenMagnetometer)Platform.GetDefaultSensor(SensorType.Magnetometer);
|
||||
|
||||
internal static bool IsSupported =>
|
||||
TizenMagnetometer.IsSupported;
|
||||
|
||||
internal static void PlatformStart(SensorSpeed sensorSpeed)
|
||||
{
|
||||
DefaultSensor.Interval = sensorSpeed.ToPlatform();
|
||||
DefaultSensor.DataUpdated += DataUpdated;
|
||||
DefaultSensor.Start();
|
||||
}
|
||||
|
||||
internal static void PlatformStop()
|
||||
{
|
||||
DefaultSensor.DataUpdated -= DataUpdated;
|
||||
DefaultSensor.Stop();
|
||||
}
|
||||
|
||||
static void DataUpdated(object sender, MagnetometerDataUpdatedEventArgs e)
|
||||
{
|
||||
OnChanged(new MagnetometerData(e.X, e.Y, e.Z));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -5,7 +5,7 @@ namespace Xamarin.Essentials
|
|||
{
|
||||
public static partial class MainThread
|
||||
{
|
||||
static Handler handler;
|
||||
static volatile Handler handler;
|
||||
|
||||
static bool PlatformIsMainThread
|
||||
{
|
||||
|
|
|
@ -5,9 +5,9 @@ namespace Xamarin.Essentials
|
|||
public static partial class MainThread
|
||||
{
|
||||
static void PlatformBeginInvokeOnMainThread(Action action) =>
|
||||
throw new NotImplementedInReferenceAssemblyException();
|
||||
throw ExceptionUtils.NotSupportedOrImplementedException;
|
||||
|
||||
static bool PlatformIsMainThread =>
|
||||
throw new NotImplementedInReferenceAssemblyException();
|
||||
throw ExceptionUtils.NotSupportedOrImplementedException;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Xamarin.Essentials
|
||||
|
@ -20,7 +21,7 @@ namespace Xamarin.Essentials
|
|||
}
|
||||
}
|
||||
|
||||
internal static Task InvokeOnMainThread(Action action)
|
||||
public static Task InvokeOnMainThreadAsync(Action action)
|
||||
{
|
||||
if (IsMainThread)
|
||||
{
|
||||
|
@ -50,11 +51,11 @@ namespace Xamarin.Essentials
|
|||
return tcs.Task;
|
||||
}
|
||||
|
||||
internal static Task<T> InvokeOnMainThread<T>(Func<T> action)
|
||||
public static Task<T> InvokeOnMainThreadAsync<T>(Func<T> func)
|
||||
{
|
||||
if (IsMainThread)
|
||||
{
|
||||
return Task.FromResult(action());
|
||||
return Task.FromResult(func());
|
||||
}
|
||||
|
||||
var tcs = new TaskCompletionSource<T>();
|
||||
|
@ -63,7 +64,7 @@ namespace Xamarin.Essentials
|
|||
{
|
||||
try
|
||||
{
|
||||
var result = action();
|
||||
var result = func();
|
||||
tcs.TrySetResult(result);
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
@ -74,5 +75,65 @@ namespace Xamarin.Essentials
|
|||
|
||||
return tcs.Task;
|
||||
}
|
||||
|
||||
public static Task InvokeOnMainThreadAsync(Func<Task> funcTask)
|
||||
{
|
||||
if (IsMainThread)
|
||||
{
|
||||
return funcTask();
|
||||
}
|
||||
|
||||
var tcs = new TaskCompletionSource<object>();
|
||||
|
||||
BeginInvokeOnMainThread(
|
||||
async () =>
|
||||
{
|
||||
try
|
||||
{
|
||||
await funcTask().ConfigureAwait(false);
|
||||
tcs.SetResult(null);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
tcs.SetException(e);
|
||||
}
|
||||
});
|
||||
|
||||
return tcs.Task;
|
||||
}
|
||||
|
||||
public static Task<T> InvokeOnMainThreadAsync<T>(Func<Task<T>> funcTask)
|
||||
{
|
||||
if (IsMainThread)
|
||||
{
|
||||
return funcTask();
|
||||
}
|
||||
|
||||
var tcs = new TaskCompletionSource<T>();
|
||||
|
||||
BeginInvokeOnMainThread(
|
||||
async () =>
|
||||
{
|
||||
try
|
||||
{
|
||||
var ret = await funcTask().ConfigureAwait(false);
|
||||
tcs.SetResult(ret);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
tcs.SetException(e);
|
||||
}
|
||||
});
|
||||
|
||||
return tcs.Task;
|
||||
}
|
||||
|
||||
public static async Task<SynchronizationContext> GetMainThreadSynchronizationContextAsync()
|
||||
{
|
||||
SynchronizationContext ret = null;
|
||||
await InvokeOnMainThreadAsync(() =>
|
||||
ret = SynchronizationContext.Current).ConfigureAwait(false);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
using System;
|
||||
using ElmSharp;
|
||||
|
||||
namespace Xamarin.Essentials
|
||||
{
|
||||
public static partial class MainThread
|
||||
{
|
||||
static void PlatformBeginInvokeOnMainThread(Action action)
|
||||
{
|
||||
if (PlatformIsMainThread)
|
||||
action();
|
||||
else
|
||||
EcoreMainloop.PostAndWakeUp(action);
|
||||
}
|
||||
|
||||
static bool PlatformIsMainThread
|
||||
=> EcoreMainloop.IsMainThread;
|
||||
}
|
||||
}
|
|
@ -21,6 +21,7 @@ namespace Xamarin.Essentials
|
|||
|
||||
internal static async Task PlatformOpenMapsAsync(Placemark placemark, MapLaunchOptions options)
|
||||
{
|
||||
#if __IOS__
|
||||
var address = new MKPlacemarkAddress
|
||||
{
|
||||
CountryCode = placemark.CountryCode,
|
||||
|
@ -29,13 +30,24 @@ namespace Xamarin.Essentials
|
|||
Street = placemark.Thoroughfare,
|
||||
City = placemark.Locality,
|
||||
Zip = placemark.PostalCode
|
||||
}.Dictionary;
|
||||
#else
|
||||
var address = new NSDictionary
|
||||
{
|
||||
[Contacts.CNPostalAddressKey.City] = new NSString(placemark.Locality),
|
||||
[Contacts.CNPostalAddressKey.Country] = new NSString(placemark.CountryName),
|
||||
[Contacts.CNPostalAddressKey.State] = new NSString(placemark.AdminArea),
|
||||
[Contacts.CNPostalAddressKey.Street] = new NSString(placemark.Thoroughfare),
|
||||
[Contacts.CNPostalAddressKey.PostalCode] = new NSString(placemark.PostalCode),
|
||||
[Contacts.CNPostalAddressKey.IsoCountryCode] = new NSString(placemark.CountryCode)
|
||||
};
|
||||
#endif
|
||||
|
||||
var coder = new CLGeocoder();
|
||||
CLPlacemark[] placemarks = null;
|
||||
try
|
||||
{
|
||||
placemarks = await coder.GeocodeAddressAsync(address.Dictionary);
|
||||
placemarks = await coder.GeocodeAddressAsync(address);
|
||||
}
|
||||
catch
|
||||
{
|
|
@ -5,9 +5,9 @@ namespace Xamarin.Essentials
|
|||
public static partial class Map
|
||||
{
|
||||
internal static Task PlatformOpenMapsAsync(double latitude, double longitude, MapLaunchOptions options)
|
||||
=> throw new NotImplementedInReferenceAssemblyException();
|
||||
=> throw ExceptionUtils.NotSupportedOrImplementedException;
|
||||
|
||||
internal static Task PlatformOpenMapsAsync(Placemark placemark, MapLaunchOptions options)
|
||||
=> throw new NotImplementedInReferenceAssemblyException();
|
||||
=> throw ExceptionUtils.NotSupportedOrImplementedException;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,44 @@
|
|||
using System.Globalization;
|
||||
using System.Threading.Tasks;
|
||||
using Tizen.Applications;
|
||||
|
||||
namespace Xamarin.Essentials
|
||||
{
|
||||
public static partial class Map
|
||||
{
|
||||
internal static Task PlatformOpenMapsAsync(double latitude, double longitude, MapLaunchOptions options)
|
||||
{
|
||||
Permissions.EnsureDeclared(PermissionType.LaunchApp);
|
||||
|
||||
var appControl = new AppControl
|
||||
{
|
||||
Operation = AppControlOperations.View,
|
||||
Uri = "geo:",
|
||||
};
|
||||
|
||||
appControl.Uri += $"{latitude.ToString(CultureInfo.InvariantCulture)},{longitude.ToString(CultureInfo.InvariantCulture)}";
|
||||
|
||||
AppControl.SendLaunchRequest(appControl);
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
internal static Task PlatformOpenMapsAsync(Placemark placemark, MapLaunchOptions options)
|
||||
{
|
||||
Permissions.EnsureDeclared(PermissionType.LaunchApp);
|
||||
|
||||
var appControl = new AppControl
|
||||
{
|
||||
Operation = AppControlOperations.Pick,
|
||||
Uri = "geo:",
|
||||
};
|
||||
|
||||
placemark = placemark.Escape();
|
||||
appControl.Uri += $"0,0?q={placemark.Thoroughfare} {placemark.Locality} {placemark.AdminArea} {placemark.PostalCode} {placemark.CountryName}";
|
||||
|
||||
AppControl.SendLaunchRequest(appControl);
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -3,12 +3,12 @@
|
|||
public static partial class OrientationSensor
|
||||
{
|
||||
internal static bool IsSupported =>
|
||||
throw new NotImplementedInReferenceAssemblyException();
|
||||
throw ExceptionUtils.NotSupportedOrImplementedException;
|
||||
|
||||
static void PlatformStart(SensorSpeed sensorSpeed) =>
|
||||
throw new NotImplementedInReferenceAssemblyException();
|
||||
throw ExceptionUtils.NotSupportedOrImplementedException;
|
||||
|
||||
static void PlatformStop() =>
|
||||
throw new NotImplementedInReferenceAssemblyException();
|
||||
throw ExceptionUtils.NotSupportedOrImplementedException;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
using Tizen.Sensor;
|
||||
using TizenRotationVectorSensor = Tizen.Sensor.RotationVectorSensor;
|
||||
|
||||
namespace Xamarin.Essentials
|
||||
{
|
||||
public static partial class OrientationSensor
|
||||
{
|
||||
static TizenRotationVectorSensor DefaultSensor
|
||||
=> (TizenRotationVectorSensor)Platform.GetDefaultSensor(SensorType.OrientationSensor);
|
||||
|
||||
internal static bool IsSupported
|
||||
=> TizenRotationVectorSensor.IsSupported;
|
||||
|
||||
static void PlatformStart(SensorSpeed sensorSpeed)
|
||||
{
|
||||
DefaultSensor.Interval = sensorSpeed.ToPlatform();
|
||||
DefaultSensor.DataUpdated += DataUpdated;
|
||||
DefaultSensor.Start();
|
||||
}
|
||||
|
||||
static void PlatformStop()
|
||||
{
|
||||
DefaultSensor.DataUpdated -= DataUpdated;
|
||||
DefaultSensor.Stop();
|
||||
}
|
||||
|
||||
static void DataUpdated(object sender, RotationVectorSensorDataUpdatedEventArgs e)
|
||||
{
|
||||
OnChanged(new OrientationSensorData(e.X, e.Y, e.Z, e.W));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -5,12 +5,12 @@ namespace Xamarin.Essentials
|
|||
internal static partial class Permissions
|
||||
{
|
||||
static bool PlatformEnsureDeclared(PermissionType permission, bool throwIfMissing) =>
|
||||
throw new NotImplementedInReferenceAssemblyException();
|
||||
throw ExceptionUtils.NotSupportedOrImplementedException;
|
||||
|
||||
static Task<PermissionStatus> PlatformCheckStatusAsync(PermissionType permission) =>
|
||||
throw new NotImplementedInReferenceAssemblyException();
|
||||
throw ExceptionUtils.NotSupportedOrImplementedException;
|
||||
|
||||
static Task<PermissionStatus> PlatformRequestAsync(PermissionType permission) =>
|
||||
throw new NotImplementedInReferenceAssemblyException();
|
||||
throw ExceptionUtils.NotSupportedOrImplementedException;
|
||||
}
|
||||
}
|
|
@ -24,7 +24,9 @@
|
|||
Battery,
|
||||
Camera,
|
||||
Flashlight,
|
||||
LaunchApp,
|
||||
LocationWhenInUse,
|
||||
Maps,
|
||||
NetworkState,
|
||||
Vibrate,
|
||||
WriteExternalStorage,
|
||||
|
|
|
@ -0,0 +1,118 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Tizen.Security;
|
||||
|
||||
namespace Xamarin.Essentials
|
||||
{
|
||||
internal static partial class Permissions
|
||||
{
|
||||
static bool PlatformEnsureDeclared(PermissionType permission, bool throwIfMissing)
|
||||
{
|
||||
var tizenPrivileges = permission.ToTizenPrivileges(onlyRuntimePermissions: false);
|
||||
|
||||
if (tizenPrivileges == null || !tizenPrivileges.Any())
|
||||
return false;
|
||||
|
||||
var package = Platform.CurrentPackage;
|
||||
foreach (var priv in tizenPrivileges)
|
||||
{
|
||||
if (!package.Privileges.Contains(priv))
|
||||
{
|
||||
if (throwIfMissing)
|
||||
throw new PermissionException($"You need to declare the privilege: `{priv}` in your tizen-manifest.xml");
|
||||
else
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static Task<PermissionStatus> PlatformCheckStatusAsync(PermissionType permission)
|
||||
{
|
||||
return CheckPrivacyPermission(permission, false);
|
||||
}
|
||||
|
||||
static Task<PermissionStatus> PlatformRequestAsync(PermissionType permission)
|
||||
{
|
||||
return CheckPrivacyPermission(permission, true);
|
||||
}
|
||||
|
||||
internal static async Task<PermissionStatus> CheckPrivacyPermission(PermissionType permission, bool askUser)
|
||||
{
|
||||
EnsureDeclared(permission);
|
||||
var tizenPrivileges = permission.ToTizenPrivileges(onlyRuntimePermissions: true);
|
||||
foreach (var priv in tizenPrivileges)
|
||||
{
|
||||
if (PrivacyPrivilegeManager.CheckPermission(priv) == CheckResult.Ask)
|
||||
{
|
||||
if (askUser)
|
||||
{
|
||||
var tcs = new TaskCompletionSource<bool>();
|
||||
PrivacyPrivilegeManager.ResponseContext context = null;
|
||||
PrivacyPrivilegeManager.GetResponseContext(priv).TryGetTarget(out context);
|
||||
void OnResponseFetched(object sender, RequestResponseEventArgs e)
|
||||
{
|
||||
tcs.TrySetResult(e.result == RequestResult.AllowForever);
|
||||
}
|
||||
context.ResponseFetched += OnResponseFetched;
|
||||
PrivacyPrivilegeManager.RequestPermission(priv);
|
||||
var result = await tcs.Task;
|
||||
context.ResponseFetched -= OnResponseFetched;
|
||||
if (result)
|
||||
continue;
|
||||
}
|
||||
return PermissionStatus.Denied;
|
||||
}
|
||||
else if (PrivacyPrivilegeManager.CheckPermission(priv) == CheckResult.Deny)
|
||||
{
|
||||
return PermissionStatus.Denied;
|
||||
}
|
||||
}
|
||||
return PermissionStatus.Granted;
|
||||
}
|
||||
}
|
||||
|
||||
static class PermissionTypeExtensions
|
||||
{
|
||||
internal static IEnumerable<string> ToTizenPrivileges(this PermissionType permissionType, bool onlyRuntimePermissions)
|
||||
{
|
||||
var privileges = new List<(string privilege, bool runtimePermission)>();
|
||||
|
||||
switch (permissionType)
|
||||
{
|
||||
case PermissionType.Flashlight:
|
||||
privileges.Add(("http://tizen.org/privilege/led", false));
|
||||
break;
|
||||
case PermissionType.LaunchApp:
|
||||
privileges.Add(("http://tizen.org/privilege/appmanager.launch", false));
|
||||
break;
|
||||
case PermissionType.LocationWhenInUse:
|
||||
privileges.Add(("http://tizen.org/privilege/location", true));
|
||||
break;
|
||||
case PermissionType.Maps:
|
||||
privileges.Add(("http://tizen.org/privilege/internet", false));
|
||||
privileges.Add(("http://tizen.org/privilege/mapservice", false));
|
||||
privileges.Add(("http://tizen.org/privilege/network.get", false));
|
||||
break;
|
||||
case PermissionType.NetworkState:
|
||||
privileges.Add(("http://tizen.org/privilege/internet", false));
|
||||
privileges.Add(("http://tizen.org/privilege/network.get", false));
|
||||
break;
|
||||
case PermissionType.Vibrate:
|
||||
privileges.Add(("http://tizen.org/privilege/haptic", false));
|
||||
break;
|
||||
}
|
||||
|
||||
if (onlyRuntimePermissions)
|
||||
{
|
||||
return privileges
|
||||
.Where(p => p.runtimePermission)
|
||||
.Select(p => p.privilege);
|
||||
}
|
||||
|
||||
return privileges.Select(p => p.privilege);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -3,9 +3,9 @@
|
|||
public static partial class PhoneDialer
|
||||
{
|
||||
internal static bool IsSupported =>
|
||||
throw new NotImplementedInReferenceAssemblyException();
|
||||
throw ExceptionUtils.NotSupportedOrImplementedException;
|
||||
|
||||
static void PlatformOpen(string number) =>
|
||||
throw new NotImplementedInReferenceAssemblyException();
|
||||
throw ExceptionUtils.NotSupportedOrImplementedException;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
using Tizen.Applications;
|
||||
|
||||
namespace Xamarin.Essentials
|
||||
{
|
||||
public static partial class PhoneDialer
|
||||
{
|
||||
internal static bool IsSupported
|
||||
=> Platform.GetFeatureInfo<bool>("contact");
|
||||
|
||||
static void PlatformOpen(string number)
|
||||
{
|
||||
Permissions.EnsureDeclared(PermissionType.LaunchApp);
|
||||
|
||||
var appControl = new AppControl
|
||||
{
|
||||
Operation = AppControlOperations.Dial,
|
||||
Uri = "tel:",
|
||||
};
|
||||
|
||||
if (!string.IsNullOrEmpty(number))
|
||||
appControl.Uri += number;
|
||||
|
||||
AppControl.SendLaunchRequest(appControl);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,16 +1,26 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using CoreMotion;
|
||||
using Foundation;
|
||||
using ObjCRuntime;
|
||||
using UIKit;
|
||||
|
||||
#if __IOS__
|
||||
using CoreMotion;
|
||||
#elif __WATCHOS__
|
||||
using CoreMotion;
|
||||
using UIDevice = WatchKit.WKInterfaceDevice;
|
||||
#endif
|
||||
|
||||
namespace Xamarin.Essentials
|
||||
{
|
||||
public static partial class Platform
|
||||
{
|
||||
#if __IOS__
|
||||
[DllImport(Constants.SystemLibrary, EntryPoint = "sysctlbyname")]
|
||||
#else
|
||||
[DllImport(Constants.libSystemLibrary, EntryPoint = "sysctlbyname")]
|
||||
#endif
|
||||
internal static extern int SysctlByName([MarshalAs(UnmanagedType.LPStr)] string property, IntPtr output, IntPtr oldLen, IntPtr newp, uint newlen);
|
||||
|
||||
internal static string GetSystemLibraryProperty(string property)
|
||||
|
@ -40,6 +50,7 @@ namespace Xamarin.Essentials
|
|||
internal static bool HasOSVersion(int major, int minor) =>
|
||||
UIDevice.CurrentDevice.CheckSystemVersion(major, minor);
|
||||
|
||||
#if __IOS__ || __TVOS__
|
||||
internal static UIViewController GetCurrentViewController(bool throwIfNull = true)
|
||||
{
|
||||
UIViewController viewController = null;
|
||||
|
@ -70,11 +81,14 @@ namespace Xamarin.Essentials
|
|||
|
||||
return viewController;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if __IOS__ || __WATCHOS__
|
||||
static CMMotionManager motionManager;
|
||||
|
||||
internal static CMMotionManager MotionManager =>
|
||||
motionManager ?? (motionManager = new CMMotionManager());
|
||||
#endif
|
||||
|
||||
internal static NSOperationQueue GetCurrentQueue() =>
|
||||
NSOperationQueue.CurrentQueue ?? new NSOperationQueue();
|
|
@ -0,0 +1,105 @@
|
|||
using System.Threading.Tasks;
|
||||
using Tizen.Applications;
|
||||
using Tizen.Maps;
|
||||
using Tizen.Sensor;
|
||||
using Tizen.System;
|
||||
using TizenAccelerometer = Tizen.Sensor.Accelerometer;
|
||||
using TizenBarometer = Tizen.Sensor.PressureSensor;
|
||||
using TizenCompass = Tizen.Sensor.OrientationSensor;
|
||||
using TizenGyroscope = Tizen.Sensor.Gyroscope;
|
||||
using TizenMagnetometer = Tizen.Sensor.Magnetometer;
|
||||
using TizenOrientationSensor = Tizen.Sensor.RotationVectorSensor;
|
||||
|
||||
namespace Xamarin.Essentials
|
||||
{
|
||||
public static partial class Platform
|
||||
{
|
||||
static TizenAccelerometer accelerometer = null;
|
||||
static TizenBarometer barometer = null;
|
||||
static TizenCompass compass = null;
|
||||
static TizenGyroscope gyroscope = null;
|
||||
static TizenMagnetometer magnetometer = null;
|
||||
static TizenOrientationSensor orientationSensor = null;
|
||||
static MapService mapService = null;
|
||||
|
||||
internal static Package CurrentPackage
|
||||
{
|
||||
get
|
||||
{
|
||||
var packageId = Application.Current.ApplicationInfo.PackageId;
|
||||
return PackageManager.GetPackage(packageId);
|
||||
}
|
||||
}
|
||||
|
||||
internal static string GetSystemInfo(string item) => GetSystemInfo<string>(item);
|
||||
|
||||
internal static T GetSystemInfo<T>(string item)
|
||||
{
|
||||
Information.TryGetValue<T>($"http://tizen.org/system/{item}", out var value);
|
||||
return value;
|
||||
}
|
||||
|
||||
internal static string GetFeatureInfo(string item) => GetFeatureInfo<string>(item);
|
||||
|
||||
internal static T GetFeatureInfo<T>(string item)
|
||||
{
|
||||
Information.TryGetValue<T>($"http://tizen.org/feature/{item}", out var value);
|
||||
return value;
|
||||
}
|
||||
|
||||
internal static Sensor GetDefaultSensor(SensorType type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case SensorType.Accelerometer:
|
||||
if (Platform.accelerometer == null)
|
||||
Platform.accelerometer = new TizenAccelerometer();
|
||||
return Platform.accelerometer;
|
||||
case SensorType.Barometer:
|
||||
if (Platform.barometer == null)
|
||||
Platform.barometer = new TizenBarometer();
|
||||
return Platform.barometer;
|
||||
case SensorType.Compass:
|
||||
if (Platform.compass == null)
|
||||
Platform.compass = new TizenCompass();
|
||||
return Platform.compass;
|
||||
case SensorType.Gyroscope:
|
||||
if (Platform.gyroscope == null)
|
||||
Platform.gyroscope = new TizenGyroscope();
|
||||
return Platform.gyroscope;
|
||||
case SensorType.Magnetometer:
|
||||
if (Platform.magnetometer == null)
|
||||
Platform.magnetometer = new TizenMagnetometer();
|
||||
return Platform.magnetometer;
|
||||
case SensorType.OrientationSensor:
|
||||
if (Platform.orientationSensor == null)
|
||||
Platform.orientationSensor = new TizenOrientationSensor();
|
||||
return Platform.orientationSensor;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
internal static async Task<MapService> GetMapServiceAsync(string key)
|
||||
{
|
||||
if (mapService == null)
|
||||
{
|
||||
mapService = new MapService("HERE", key);
|
||||
await mapService.RequestUserConsent();
|
||||
}
|
||||
return mapService;
|
||||
}
|
||||
|
||||
public static string MapServiceToken { get; set; }
|
||||
}
|
||||
|
||||
public enum SensorType
|
||||
{
|
||||
Accelerometer,
|
||||
Barometer,
|
||||
Compass,
|
||||
Gyroscope,
|
||||
Magnetometer,
|
||||
OrientationSensor
|
||||
}
|
||||
}
|
|
@ -3,18 +3,18 @@
|
|||
public static partial class Preferences
|
||||
{
|
||||
static bool PlatformContainsKey(string key, string sharedName) =>
|
||||
throw new NotImplementedInReferenceAssemblyException();
|
||||
throw ExceptionUtils.NotSupportedOrImplementedException;
|
||||
|
||||
static void PlatformRemove(string key, string sharedName) =>
|
||||
throw new NotImplementedInReferenceAssemblyException();
|
||||
throw ExceptionUtils.NotSupportedOrImplementedException;
|
||||
|
||||
static void PlatformClear(string sharedName) =>
|
||||
throw new NotImplementedInReferenceAssemblyException();
|
||||
throw ExceptionUtils.NotSupportedOrImplementedException;
|
||||
|
||||
static void PlatformSet<T>(string key, T value, string sharedName) =>
|
||||
throw new NotImplementedInReferenceAssemblyException();
|
||||
throw ExceptionUtils.NotSupportedOrImplementedException;
|
||||
|
||||
static T PlatformGet<T>(string key, T defaultValue, string sharedName) =>
|
||||
throw new NotImplementedInReferenceAssemblyException();
|
||||
throw ExceptionUtils.NotSupportedOrImplementedException;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,95 @@
|
|||
using System.Linq;
|
||||
using Tizen.Applications;
|
||||
|
||||
namespace Xamarin.Essentials
|
||||
{
|
||||
public static partial class Preferences
|
||||
{
|
||||
const string separator = "~";
|
||||
|
||||
static readonly object locker = new object();
|
||||
|
||||
static bool PlatformContainsKey(string key, string sharedName)
|
||||
{
|
||||
lock (locker)
|
||||
{
|
||||
return Preference.Contains(GetFullKey(key, sharedName));
|
||||
}
|
||||
}
|
||||
|
||||
static void PlatformRemove(string key, string sharedName)
|
||||
{
|
||||
lock (locker)
|
||||
{
|
||||
var fullKey = GetFullKey(key, sharedName);
|
||||
if (Preference.Contains(fullKey))
|
||||
Preference.Remove(fullKey);
|
||||
}
|
||||
}
|
||||
|
||||
static void PlatformClear(string sharedName)
|
||||
{
|
||||
lock (locker)
|
||||
{
|
||||
if (string.IsNullOrEmpty(sharedName))
|
||||
{
|
||||
Preference.RemoveAll();
|
||||
}
|
||||
else
|
||||
{
|
||||
var keys = Preference.Keys.Where(key => key.StartsWith($"{sharedName}{separator}")).ToList();
|
||||
foreach (var key in keys)
|
||||
Preference.Remove(key);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void PlatformSet<T>(string key, T value, string sharedName)
|
||||
{
|
||||
lock (locker)
|
||||
{
|
||||
var fullKey = GetFullKey(key, sharedName);
|
||||
if (value == null)
|
||||
Preference.Remove(fullKey);
|
||||
else
|
||||
Preference.Set(fullKey, value);
|
||||
}
|
||||
}
|
||||
|
||||
static T PlatformGet<T>(string key, T defaultValue, string sharedName)
|
||||
{
|
||||
lock (locker)
|
||||
{
|
||||
var value = defaultValue;
|
||||
var fullKey = GetFullKey(key, sharedName);
|
||||
if (Preference.Contains(fullKey))
|
||||
{
|
||||
switch (defaultValue)
|
||||
{
|
||||
case int i:
|
||||
case bool b:
|
||||
case long l:
|
||||
case double d:
|
||||
case float f:
|
||||
case string s:
|
||||
value = Preference.Get<T>(fullKey);
|
||||
break;
|
||||
default:
|
||||
// the case when the string is null
|
||||
if (typeof(T) == typeof(string))
|
||||
value = (T)(object)Preference.Get<string>(fullKey);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
static string GetFullKey(string key, string sharedName = null)
|
||||
{
|
||||
if (string.IsNullOrEmpty(sharedName))
|
||||
return key;
|
||||
return $"{sharedName}{separator}{key}";
|
||||
}
|
||||
}
|
||||
}
|
|
@ -5,15 +5,15 @@ namespace Xamarin.Essentials
|
|||
public partial class SecureStorage
|
||||
{
|
||||
static Task<string> PlatformGetAsync(string key) =>
|
||||
throw new NotImplementedInReferenceAssemblyException();
|
||||
throw ExceptionUtils.NotSupportedOrImplementedException;
|
||||
|
||||
static Task PlatformSetAsync(string key, string data) =>
|
||||
throw new NotImplementedInReferenceAssemblyException();
|
||||
throw ExceptionUtils.NotSupportedOrImplementedException;
|
||||
|
||||
static bool PlatformRemove(string key) =>
|
||||
throw new NotImplementedInReferenceAssemblyException();
|
||||
throw ExceptionUtils.NotSupportedOrImplementedException;
|
||||
|
||||
static void PlatformRemoveAll() =>
|
||||
throw new NotImplementedInReferenceAssemblyException();
|
||||
throw ExceptionUtils.NotSupportedOrImplementedException;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,66 @@
|
|||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Tizen.Security.SecureRepository;
|
||||
|
||||
namespace Xamarin.Essentials
|
||||
{
|
||||
public partial class SecureStorage
|
||||
{
|
||||
static Task<string> PlatformGetAsync(string key)
|
||||
{
|
||||
try
|
||||
{
|
||||
return Task.FromResult(Encoding.UTF8.GetString(DataManager.Get(key, null)));
|
||||
}
|
||||
catch
|
||||
{
|
||||
Tizen.Log.Error(Platform.CurrentPackage.Label, "Failed to load data.");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
static Task PlatformSetAsync(string key, string data)
|
||||
{
|
||||
try
|
||||
{
|
||||
DataManager.Save(key, Encoding.UTF8.GetBytes(data), new Policy());
|
||||
}
|
||||
catch
|
||||
{
|
||||
Tizen.Log.Error(Platform.CurrentPackage.Label, "Failed to save data.");
|
||||
throw;
|
||||
}
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
static void PlatformRemoveAll()
|
||||
{
|
||||
try
|
||||
{
|
||||
foreach (var key in DataManager.GetAliases())
|
||||
{
|
||||
DataManager.RemoveAlias(key);
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
Tizen.Log.Info(Platform.CurrentPackage.Label, "No save data.");
|
||||
}
|
||||
}
|
||||
|
||||
static bool PlatformRemove(string key)
|
||||
{
|
||||
try
|
||||
{
|
||||
DataManager.RemoveAlias(key);
|
||||
return true;
|
||||
}
|
||||
catch
|
||||
{
|
||||
Tizen.Log.Info(Platform.CurrentPackage.Label, "Failed to remove data.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -5,9 +5,9 @@ namespace Xamarin.Essentials
|
|||
public static partial class Share
|
||||
{
|
||||
static Task PlatformRequestAsync(ShareTextRequest request) =>
|
||||
throw new NotImplementedInReferenceAssemblyException();
|
||||
throw ExceptionUtils.NotSupportedOrImplementedException;
|
||||
|
||||
static Task PlatformRequestAsync(ShareFileRequest request) =>
|
||||
throw new NotImplementedInReferenceAssemblyException();
|
||||
throw ExceptionUtils.NotSupportedOrImplementedException;
|
||||
}
|
||||
}
|
|
@ -17,8 +17,6 @@ namespace Xamarin.Essentials
|
|||
|
||||
public static Task RequestAsync(ShareFileRequest request)
|
||||
{
|
||||
ExperimentalFeatures.VerifyEnabled(ExperimentalFeatures.ShareFileRequest);
|
||||
|
||||
return PlatformRequestAsync(request);
|
||||
}
|
||||
}
|
||||
|
@ -47,32 +45,27 @@ namespace Xamarin.Essentials
|
|||
{
|
||||
public ShareFileRequest()
|
||||
{
|
||||
ExperimentalFeatures.VerifyEnabled(ExperimentalFeatures.ShareFileRequest);
|
||||
}
|
||||
|
||||
public ShareFileRequest(string title, ShareFile file)
|
||||
{
|
||||
ExperimentalFeatures.VerifyEnabled(ExperimentalFeatures.ShareFileRequest);
|
||||
Title = title;
|
||||
File = file;
|
||||
}
|
||||
|
||||
public ShareFileRequest(string title, FileBase file)
|
||||
{
|
||||
ExperimentalFeatures.VerifyEnabled(ExperimentalFeatures.ShareFileRequest);
|
||||
Title = title;
|
||||
File = new ShareFile(file);
|
||||
}
|
||||
|
||||
public ShareFileRequest(ShareFile file)
|
||||
{
|
||||
ExperimentalFeatures.VerifyEnabled(ExperimentalFeatures.ShareFileRequest);
|
||||
File = file;
|
||||
}
|
||||
|
||||
public ShareFileRequest(FileBase file)
|
||||
{
|
||||
ExperimentalFeatures.VerifyEnabled(ExperimentalFeatures.ShareFileRequest);
|
||||
File = new ShareFile(file);
|
||||
}
|
||||
|
||||
|
@ -86,19 +79,16 @@ namespace Xamarin.Essentials
|
|||
public ShareFile(string fullPath)
|
||||
: base(fullPath)
|
||||
{
|
||||
ExperimentalFeatures.VerifyEnabled(ExperimentalFeatures.ShareFileRequest);
|
||||
}
|
||||
|
||||
public ShareFile(string fullPath, string contentType)
|
||||
: base(fullPath, contentType)
|
||||
{
|
||||
ExperimentalFeatures.VerifyEnabled(ExperimentalFeatures.ShareFileRequest);
|
||||
}
|
||||
|
||||
public ShareFile(FileBase file)
|
||||
: base(file)
|
||||
{
|
||||
ExperimentalFeatures.VerifyEnabled(ExperimentalFeatures.ShareFileRequest);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,57 @@
|
|||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Tizen.Applications;
|
||||
|
||||
namespace Xamarin.Essentials
|
||||
{
|
||||
public static partial class Share
|
||||
{
|
||||
static Task PlatformRequestAsync(ShareTextRequest request)
|
||||
{
|
||||
if (string.IsNullOrEmpty(request.Text) && string.IsNullOrEmpty(request.Uri))
|
||||
throw new ArgumentNullException(nameof(request.Text));
|
||||
|
||||
Permissions.EnsureDeclared(PermissionType.LaunchApp);
|
||||
|
||||
var appControl = new AppControl
|
||||
{
|
||||
Operation = AppControlOperations.ShareText,
|
||||
};
|
||||
|
||||
if (!string.IsNullOrEmpty(request.Text))
|
||||
appControl.ExtraData.Add("http://tizen.org/appcontrol/data/text", request.Text);
|
||||
if (!string.IsNullOrEmpty(request.Uri))
|
||||
appControl.ExtraData.Add("http://tizen.org/appcontrol/data/url", request.Uri);
|
||||
if (!string.IsNullOrEmpty(request.Subject))
|
||||
appControl.ExtraData.Add("http://tizen.org/appcontrol/data/subject", request.Subject);
|
||||
if (!string.IsNullOrEmpty(request.Title))
|
||||
appControl.ExtraData.Add("http://tizen.org/appcontrol/data/title", request.Title);
|
||||
|
||||
AppControl.SendLaunchRequest(appControl);
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
static Task PlatformRequestAsync(ShareFileRequest request)
|
||||
{
|
||||
if (string.IsNullOrEmpty(request.File.FullPath))
|
||||
throw new ArgumentNullException(nameof(request.File.FullPath));
|
||||
|
||||
Permissions.EnsureDeclared(PermissionType.LaunchApp);
|
||||
|
||||
var appControl = new AppControl
|
||||
{
|
||||
Operation = AppControlOperations.ShareText,
|
||||
};
|
||||
|
||||
if (!string.IsNullOrEmpty(request.File.FullPath))
|
||||
appControl.ExtraData.Add("http://tizen.org/appcontrol/data/path", request.File.FullPath);
|
||||
if (!string.IsNullOrEmpty(request.Title))
|
||||
appControl.ExtraData.Add("http://tizen.org/appcontrol/data/title", request.Title);
|
||||
|
||||
AppControl.SendLaunchRequest(appControl);
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -5,9 +5,9 @@ namespace Xamarin.Essentials
|
|||
public static partial class Sms
|
||||
{
|
||||
internal static bool IsComposeSupported
|
||||
=> throw new NotImplementedInReferenceAssemblyException();
|
||||
=> throw ExceptionUtils.NotSupportedOrImplementedException;
|
||||
|
||||
static Task PlatformComposeAsync(SmsMessage message)
|
||||
=> throw new NotImplementedInReferenceAssemblyException();
|
||||
=> throw ExceptionUtils.NotSupportedOrImplementedException;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
using System.Threading.Tasks;
|
||||
using Tizen.Applications;
|
||||
|
||||
namespace Xamarin.Essentials
|
||||
{
|
||||
public static partial class Sms
|
||||
{
|
||||
internal static bool IsComposeSupported
|
||||
=> Platform.GetFeatureInfo<bool>("network.telephony.sms");
|
||||
|
||||
static Task PlatformComposeAsync(SmsMessage message)
|
||||
{
|
||||
Permissions.EnsureDeclared(PermissionType.LaunchApp);
|
||||
|
||||
var appControl = new AppControl
|
||||
{
|
||||
Operation = AppControlOperations.Compose,
|
||||
Uri = "sms:",
|
||||
};
|
||||
|
||||
if (!string.IsNullOrEmpty(message.Body))
|
||||
appControl.ExtraData.Add("http://tizen.org/appcontrol/data/text", message.Body);
|
||||
if (message.Recipients.Count > 0)
|
||||
appControl.Uri += string.Join(" ", message.Recipients);
|
||||
|
||||
AppControl.SendLaunchRequest(appControl);
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -18,7 +18,7 @@ namespace Xamarin.Essentials
|
|||
return SpeakUtterance(speechUtterance, cancelToken);
|
||||
}
|
||||
|
||||
private static AVSpeechUtterance GetSpeechUtterance(string text, SpeechOptions options)
|
||||
static AVSpeechUtterance GetSpeechUtterance(string text, SpeechOptions options)
|
||||
{
|
||||
var speechUtterance = new AVSpeechUtterance(text);
|
||||
|
|
@ -7,9 +7,9 @@ namespace Xamarin.Essentials
|
|||
public static partial class TextToSpeech
|
||||
{
|
||||
internal static Task PlatformSpeakAsync(string text, SpeechOptions options, CancellationToken cancelToken = default) =>
|
||||
throw new NotImplementedInReferenceAssemblyException();
|
||||
throw ExceptionUtils.NotSupportedOrImplementedException;
|
||||
|
||||
internal static Task<IEnumerable<Locale>> PlatformGetLocalesAsync() =>
|
||||
throw new NotImplementedInReferenceAssemblyException();
|
||||
throw ExceptionUtils.NotSupportedOrImplementedException;
|
||||
}
|
||||
}
|
||||
|
|
Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше
Загрузка…
Ссылка в новой задаче