forked from xamarin/Essentials
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
xamarinGH-23: Added Tizen backend (xamarin#555)
* Adding the initial work to get Tizen started. xamarin#23 * Adding the initial work to get Tizen started. xamarin#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
- Loading branch information
Showing
42 changed files
with
1,634 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<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" /> | ||
</ItemGroup> | ||
|
||
<Import Project="$(MSBuildThisFileDirectory)..\..\CodeStyles.targets" /> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
This file was loaded from the app package. | ||
|
||
You can use this as a starting point for your comments... | ||
|
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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)); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 }); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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)); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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."); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
using System; | ||
using System.Threading.Tasks; | ||
|
||
namespace Xamarin.Essentials | ||
{ | ||
public static partial class Clipboard | ||
{ | ||
static Task PlatformSetTextAsync(string text) | ||
=> throw new PlatformNotSupportedException("This API is not currently supported on Tizen."); | ||
|
||
static bool PlatformHasText | ||
=> throw new PlatformNotSupportedException("This API is not currently supported on Tizen."); | ||
|
||
static Task<string> PlatformGetTextAsync() | ||
=> throw new PlatformNotSupportedException("This API is not currently supported on Tizen."); | ||
} | ||
} |
Oops, something went wrong.