All platform code is now internal
- public APIs live in the *.shared.cs files - all platform code is internal or private
This commit is contained in:
Родитель
480242314f
Коммит
831c22d3cc
|
@ -51,15 +51,15 @@ namespace Xamarin.Essentials
|
|||
// acceleration due to gravity
|
||||
const double gravity = 9.81;
|
||||
|
||||
public AccelerometerListener()
|
||||
internal AccelerometerListener()
|
||||
{
|
||||
}
|
||||
|
||||
public void OnAccuracyChanged(Sensor sensor, [GeneratedEnum] SensorStatus accuracy)
|
||||
void ISensorEventListener.OnAccuracyChanged(Sensor sensor, [GeneratedEnum] SensorStatus accuracy)
|
||||
{
|
||||
}
|
||||
|
||||
public void OnSensorChanged(SensorEvent e)
|
||||
void ISensorEventListener.OnSensorChanged(SensorEvent e)
|
||||
{
|
||||
var data = new AccelerometerData(e.Values[0] / gravity, e.Values[1] / gravity, e.Values[2] / gravity);
|
||||
Accelerometer.OnChanged(data);
|
||||
|
|
|
@ -30,7 +30,7 @@ namespace Xamarin.Essentials
|
|||
batteryReceiver = null;
|
||||
}
|
||||
|
||||
public static double ChargeLevel
|
||||
static double PlatformChargeLevel
|
||||
{
|
||||
get
|
||||
{
|
||||
|
@ -50,7 +50,7 @@ namespace Xamarin.Essentials
|
|||
}
|
||||
}
|
||||
|
||||
public static BatteryState State
|
||||
static BatteryState PlatformState
|
||||
{
|
||||
get
|
||||
{
|
||||
|
@ -77,7 +77,7 @@ namespace Xamarin.Essentials
|
|||
}
|
||||
}
|
||||
|
||||
public static BatteryPowerSource PowerSource
|
||||
static BatteryPowerSource PlatformPowerSource
|
||||
{
|
||||
get
|
||||
{
|
||||
|
@ -108,11 +108,11 @@ namespace Xamarin.Essentials
|
|||
{
|
||||
Action onChanged;
|
||||
|
||||
public BatteryBroadcastReceiver()
|
||||
internal BatteryBroadcastReceiver()
|
||||
{
|
||||
}
|
||||
|
||||
public BatteryBroadcastReceiver(Action onChanged) =>
|
||||
internal BatteryBroadcastReceiver(Action onChanged) =>
|
||||
this.onChanged = onChanged;
|
||||
|
||||
public override void OnReceive(Context context, Intent intent) =>
|
||||
|
|
|
@ -27,7 +27,7 @@ namespace Xamarin.Essentials
|
|||
static void BatteryChangedNotification(object sender, NSNotificationEventArgs args)
|
||||
=> Platform.BeginInvokeOnMainThread(OnBatteryChanged);
|
||||
|
||||
public static double ChargeLevel
|
||||
static double PlatformChargeLevel
|
||||
{
|
||||
get
|
||||
{
|
||||
|
@ -44,7 +44,7 @@ namespace Xamarin.Essentials
|
|||
}
|
||||
}
|
||||
|
||||
public static BatteryState State
|
||||
static BatteryState PlatformState
|
||||
{
|
||||
get
|
||||
{
|
||||
|
@ -73,7 +73,7 @@ namespace Xamarin.Essentials
|
|||
}
|
||||
}
|
||||
|
||||
public static BatteryPowerSource PowerSource
|
||||
static BatteryPowerSource PlatformPowerSource
|
||||
{
|
||||
get
|
||||
{
|
||||
|
|
|
@ -8,13 +8,13 @@
|
|||
static void StopBatteryListeners() =>
|
||||
throw new NotImplementedInReferenceAssemblyException();
|
||||
|
||||
public static double ChargeLevel =>
|
||||
static double PlatformChargeLevel =>
|
||||
throw new NotImplementedInReferenceAssemblyException();
|
||||
|
||||
public static BatteryState State =>
|
||||
static BatteryState PlatformState =>
|
||||
throw new NotImplementedInReferenceAssemblyException();
|
||||
|
||||
public static BatteryPowerSource PowerSource =>
|
||||
static BatteryPowerSource PlatformPowerSource =>
|
||||
throw new NotImplementedInReferenceAssemblyException();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,6 +12,12 @@ namespace Xamarin.Essentials
|
|||
static BatteryPowerSource currentSource;
|
||||
static BatteryState currentState;
|
||||
|
||||
public static double ChargeLevel => PlatformChargeLevel;
|
||||
|
||||
public static BatteryState State => PlatformState;
|
||||
|
||||
public static BatteryPowerSource PowerSource => PlatformPowerSource;
|
||||
|
||||
public static event BatteryChangedEventHandler BatteryChanged
|
||||
{
|
||||
add
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
static Windows.Devices.Power.Battery DefaultBattery =>
|
||||
Windows.Devices.Power.Battery.AggregateBattery;
|
||||
|
||||
public static double ChargeLevel
|
||||
static double PlatformChargeLevel
|
||||
{
|
||||
get
|
||||
{
|
||||
|
@ -31,7 +31,7 @@
|
|||
}
|
||||
}
|
||||
|
||||
public static BatteryState State
|
||||
static BatteryState PlatformState
|
||||
{
|
||||
get
|
||||
{
|
||||
|
@ -58,7 +58,7 @@
|
|||
}
|
||||
}
|
||||
|
||||
public static BatteryPowerSource PowerSource
|
||||
static BatteryPowerSource PlatformPowerSource
|
||||
{
|
||||
get
|
||||
{
|
||||
|
|
|
@ -10,7 +10,7 @@ namespace Xamarin.Essentials
|
|||
{
|
||||
public static partial class Browser
|
||||
{
|
||||
public static Task OpenAsync(Uri uri, BrowserLaunchType launchType)
|
||||
static Task PlatformOpenAsync(Uri uri, BrowserLaunchType launchType)
|
||||
{
|
||||
if (uri == null)
|
||||
throw new ArgumentNullException(nameof(uri));
|
||||
|
|
|
@ -7,7 +7,7 @@ namespace Xamarin.Essentials
|
|||
{
|
||||
public static partial class Browser
|
||||
{
|
||||
public static Task OpenAsync(Uri uri, BrowserLaunchType launchType)
|
||||
static Task PlatformOpenAsync(Uri uri, BrowserLaunchType launchType)
|
||||
{
|
||||
if (uri == null)
|
||||
throw new ArgumentNullException(nameof(uri));
|
||||
|
|
|
@ -5,7 +5,7 @@ namespace Xamarin.Essentials
|
|||
{
|
||||
public static partial class Browser
|
||||
{
|
||||
public static Task OpenAsync(Uri uri, BrowserLaunchType launchType) =>
|
||||
static Task PlatformOpenAsync(Uri uri, BrowserLaunchType launchType) =>
|
||||
throw new NotImplementedInReferenceAssemblyException();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,6 +20,9 @@ namespace Xamarin.Essentials
|
|||
|
||||
public static Task OpenAsync(Uri uri) =>
|
||||
OpenAsync(uri, BrowserLaunchType.SystemPreferred);
|
||||
|
||||
public static Task OpenAsync(Uri uri, BrowserLaunchType launchType) =>
|
||||
PlatformOpenAsync(uri, launchType);
|
||||
}
|
||||
|
||||
public enum BrowserLaunchType
|
||||
|
|
|
@ -5,7 +5,7 @@ namespace Xamarin.Essentials
|
|||
{
|
||||
public static partial class Browser
|
||||
{
|
||||
public static Task OpenAsync(Uri uri, BrowserLaunchType launchType)
|
||||
static Task PlatformOpenAsync(Uri uri, BrowserLaunchType launchType)
|
||||
{
|
||||
if (uri == null)
|
||||
throw new ArgumentNullException(nameof(uri));
|
||||
|
|
|
@ -5,13 +5,13 @@ namespace Xamarin.Essentials
|
|||
{
|
||||
public static partial class Clipboard
|
||||
{
|
||||
public static void SetText(string text)
|
||||
static void PlatformSetText(string text)
|
||||
=> Platform.ClipboardManager.PrimaryClip = ClipData.NewPlainText("Text", text);
|
||||
|
||||
public static bool HasText
|
||||
static bool PlatformHasText
|
||||
=> Platform.ClipboardManager.HasPrimaryClip;
|
||||
|
||||
public static Task<string> GetTextAsync()
|
||||
static Task<string> PlatformGetTextAsync()
|
||||
=> Task.FromResult(Platform.ClipboardManager.PrimaryClip?.GetItemAt(0)?.Text);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,13 +5,13 @@ namespace Xamarin.Essentials
|
|||
{
|
||||
public static partial class Clipboard
|
||||
{
|
||||
public static void SetText(string text)
|
||||
static void PlatformSetText(string text)
|
||||
=> UIPasteboard.General.String = text;
|
||||
|
||||
public static bool HasText
|
||||
static bool PlatformHasText
|
||||
=> UIPasteboard.General.HasStrings;
|
||||
|
||||
public static Task<string> GetTextAsync()
|
||||
static Task<string> PlatformGetTextAsync()
|
||||
=> Task.FromResult(UIPasteboard.General.String);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,13 +4,13 @@ namespace Xamarin.Essentials
|
|||
{
|
||||
public static partial class Clipboard
|
||||
{
|
||||
public static void SetText(string text)
|
||||
static void PlatformSetText(string text)
|
||||
=> throw new NotImplementedInReferenceAssemblyException();
|
||||
|
||||
public static bool HasText
|
||||
static bool PlatformHasText
|
||||
=> throw new NotImplementedInReferenceAssemblyException();
|
||||
|
||||
public static Task<string> GetTextAsync()
|
||||
static Task<string> PlatformGetTextAsync()
|
||||
=> throw new NotImplementedInReferenceAssemblyException();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
using System;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Xamarin.Essentials
|
||||
{
|
||||
public static partial class Clipboard
|
||||
{
|
||||
public static void SetText(string text)
|
||||
=> PlatformSetText(text);
|
||||
|
||||
public static bool HasText
|
||||
=> PlatformHasText;
|
||||
|
||||
public static Task<string> GetTextAsync()
|
||||
=> PlatformGetTextAsync();
|
||||
}
|
||||
}
|
|
@ -8,17 +8,17 @@ namespace Xamarin.Essentials
|
|||
{
|
||||
public static partial class Clipboard
|
||||
{
|
||||
public static void SetText(string text)
|
||||
static void PlatformSetText(string text)
|
||||
{
|
||||
var dataPackage = new DataPackage();
|
||||
dataPackage.SetText(text);
|
||||
SetContent(dataPackage);
|
||||
}
|
||||
|
||||
public static bool HasText
|
||||
static bool PlatformHasText
|
||||
=> GetContent().Contains(StandardDataFormats.Text);
|
||||
|
||||
public static Task<string> GetTextAsync()
|
||||
static Task<string> PlatformGetTextAsync()
|
||||
{
|
||||
var clipboardContent = GetContent();
|
||||
return clipboardContent.Contains(StandardDataFormats.Text)
|
||||
|
|
|
@ -64,17 +64,17 @@ namespace Xamarin.Essentials
|
|||
string magnetometer;
|
||||
string accelerometer;
|
||||
|
||||
public SensorListener(string accelerometer, string magnetometer, SensorDelay delay)
|
||||
internal SensorListener(string accelerometer, string magnetometer, SensorDelay delay)
|
||||
{
|
||||
this.magnetometer = magnetometer;
|
||||
this.accelerometer = accelerometer;
|
||||
}
|
||||
|
||||
public void OnAccuracyChanged(Sensor sensor, [GeneratedEnum] SensorStatus accuracy)
|
||||
void ISensorEventListener.OnAccuracyChanged(Sensor sensor, [GeneratedEnum] SensorStatus accuracy)
|
||||
{
|
||||
}
|
||||
|
||||
public void OnSensorChanged(SensorEvent e)
|
||||
void ISensorEventListener.OnSensorChanged(SensorEvent e)
|
||||
{
|
||||
if (e.Sensor.Name == accelerometer && !lastAccelerometerSet)
|
||||
{
|
||||
|
|
|
@ -39,7 +39,7 @@ namespace Xamarin.Essentials
|
|||
static NetworkAccess IsBetterAccess(NetworkAccess currentAccess, NetworkAccess newAccess) =>
|
||||
newAccess > currentAccess ? newAccess : currentAccess;
|
||||
|
||||
public static NetworkAccess NetworkAccess
|
||||
static NetworkAccess PlatformNetworkAccess
|
||||
{
|
||||
get
|
||||
{
|
||||
|
@ -110,7 +110,7 @@ namespace Xamarin.Essentials
|
|||
}
|
||||
}
|
||||
|
||||
public static IEnumerable<ConnectionProfile> Profiles
|
||||
static IEnumerable<ConnectionProfile> PlatformProfiles
|
||||
{
|
||||
get
|
||||
{
|
||||
|
@ -207,11 +207,11 @@ namespace Xamarin.Essentials
|
|||
{
|
||||
Action onChanged;
|
||||
|
||||
public ConnectivityBroadcastReceiver()
|
||||
internal ConnectivityBroadcastReceiver()
|
||||
{
|
||||
}
|
||||
|
||||
public ConnectivityBroadcastReceiver(Action onChanged) =>
|
||||
internal ConnectivityBroadcastReceiver(Action onChanged) =>
|
||||
this.onChanged = onChanged;
|
||||
|
||||
public override async void OnReceive(Context context, Intent intent)
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Xamarin.Essentials
|
||||
{
|
||||
|
@ -22,7 +23,7 @@ namespace Xamarin.Essentials
|
|||
listener = null;
|
||||
}
|
||||
|
||||
public static NetworkAccess NetworkAccess
|
||||
static NetworkAccess PlatformNetworkAccess
|
||||
{
|
||||
get
|
||||
{
|
||||
|
@ -38,7 +39,7 @@ namespace Xamarin.Essentials
|
|||
}
|
||||
}
|
||||
|
||||
public static IEnumerable<ConnectionProfile> Profiles
|
||||
static IEnumerable<ConnectionProfile> PlatformProfiles
|
||||
{
|
||||
get
|
||||
{
|
||||
|
|
|
@ -37,7 +37,7 @@ namespace Xamarin.Essentials
|
|||
}
|
||||
}
|
||||
|
||||
public static NetworkStatus InternetConnectionStatus()
|
||||
internal static NetworkStatus InternetConnectionStatus()
|
||||
{
|
||||
var status = NetworkStatus.NotReachable;
|
||||
|
||||
|
@ -124,7 +124,7 @@ namespace Xamarin.Essentials
|
|||
NetworkReachability defaultRouteReachability;
|
||||
NetworkReachability remoteHostReachability;
|
||||
|
||||
public ReachabilityListener()
|
||||
internal ReachabilityListener()
|
||||
{
|
||||
var ip = new IPAddress(0);
|
||||
defaultRouteReachability = new NetworkReachability(ip);
|
||||
|
@ -141,9 +141,11 @@ namespace Xamarin.Essentials
|
|||
remoteHostReachability.Schedule(CFRunLoop.Main, CFRunLoop.ModeDefault);
|
||||
}
|
||||
|
||||
public event Action ReachabilityChanged;
|
||||
internal event Action ReachabilityChanged;
|
||||
|
||||
public void Dispose()
|
||||
void IDisposable.Dispose() => Dispose();
|
||||
|
||||
internal void Dispose()
|
||||
{
|
||||
defaultRouteReachability?.Dispose();
|
||||
defaultRouteReachability = null;
|
||||
|
|
|
@ -4,10 +4,10 @@ namespace Xamarin.Essentials
|
|||
{
|
||||
public static partial class Connectivity
|
||||
{
|
||||
public static NetworkAccess NetworkAccess =>
|
||||
static NetworkAccess PlatformNetworkAccess =>
|
||||
throw new NotImplementedInReferenceAssemblyException();
|
||||
|
||||
public static IEnumerable<ConnectionProfile> Profiles =>
|
||||
static IEnumerable<ConnectionProfile> PlatformProfiles =>
|
||||
throw new NotImplementedInReferenceAssemblyException();
|
||||
|
||||
static void StartListeners() =>
|
||||
|
|
|
@ -13,6 +13,10 @@ namespace Xamarin.Essentials
|
|||
static NetworkAccess currentAccess;
|
||||
static List<ConnectionProfile> currentProfiles;
|
||||
|
||||
public static NetworkAccess NetworkAccess => PlatformNetworkAccess;
|
||||
|
||||
public static IEnumerable<ConnectionProfile> Profiles => PlatformProfiles;
|
||||
|
||||
public static event ConnectivityChangedEventHandler ConnectivityChanged
|
||||
{
|
||||
add
|
||||
|
|
|
@ -15,7 +15,7 @@ namespace Xamarin.Essentials
|
|||
static void StopListeners() =>
|
||||
NetworkInformation.NetworkStatusChanged -= NetworkStatusChanged;
|
||||
|
||||
public static NetworkAccess NetworkAccess
|
||||
static NetworkAccess PlatformNetworkAccess
|
||||
{
|
||||
get
|
||||
{
|
||||
|
@ -38,7 +38,7 @@ namespace Xamarin.Essentials
|
|||
}
|
||||
}
|
||||
|
||||
public static IEnumerable<ConnectionProfile> Profiles
|
||||
static IEnumerable<ConnectionProfile> PlatformProfiles
|
||||
{
|
||||
get
|
||||
{
|
||||
|
|
|
@ -7,7 +7,7 @@ namespace Xamarin.Essentials
|
|||
{
|
||||
public static partial class DataTransfer
|
||||
{
|
||||
public static Task RequestAsync(ShareTextRequest request)
|
||||
static Task PlatformRequestAsync(ShareTextRequest request)
|
||||
{
|
||||
var items = new List<string>();
|
||||
if (!string.IsNullOrWhiteSpace(request.Text))
|
||||
|
|
|
@ -7,7 +7,7 @@ namespace Xamarin.Essentials
|
|||
{
|
||||
public static partial class DataTransfer
|
||||
{
|
||||
public static Task RequestAsync(ShareTextRequest request)
|
||||
static Task PlatformRequestAsync(ShareTextRequest request)
|
||||
{
|
||||
var items = new List<NSObject>();
|
||||
if (!string.IsNullOrWhiteSpace(request.Text))
|
||||
|
@ -38,7 +38,7 @@ namespace Xamarin.Essentials
|
|||
NSObject item;
|
||||
string subject;
|
||||
|
||||
public ShareActivityItemSource(NSObject item, string subject)
|
||||
internal ShareActivityItemSource(NSObject item, string subject)
|
||||
{
|
||||
this.item = item;
|
||||
this.subject = subject;
|
||||
|
|
|
@ -4,7 +4,7 @@ namespace Xamarin.Essentials
|
|||
{
|
||||
public static partial class DataTransfer
|
||||
{
|
||||
public static Task RequestAsync(ShareTextRequest request) =>
|
||||
static Task PlatformRequestAsync(ShareTextRequest request) =>
|
||||
throw new NotImplementedInReferenceAssemblyException();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,6 +9,9 @@ namespace Xamarin.Essentials
|
|||
|
||||
public static Task RequestAsync(string text, string title) =>
|
||||
RequestAsync(new ShareTextRequest(text, title));
|
||||
|
||||
public static Task RequestAsync(ShareTextRequest request) =>
|
||||
PlatformRequestAsync(request);
|
||||
}
|
||||
|
||||
public class ShareTextRequest
|
||||
|
|
|
@ -6,7 +6,7 @@ namespace Xamarin.Essentials
|
|||
{
|
||||
public static partial class DataTransfer
|
||||
{
|
||||
public static Task RequestAsync(ShareTextRequest request)
|
||||
static Task PlatformRequestAsync(ShareTextRequest request)
|
||||
{
|
||||
var dataTransferManager = DataTransferManager.GetForCurrentView();
|
||||
|
||||
|
|
|
@ -96,7 +96,7 @@ namespace Xamarin.Essentials
|
|||
{
|
||||
Action onChanged;
|
||||
|
||||
public Listener(Context context, Action handler)
|
||||
internal Listener(Context context, Action handler)
|
||||
: base(context)
|
||||
{
|
||||
onChanged = handler;
|
||||
|
|
|
@ -7,13 +7,13 @@ namespace Xamarin.Essentials
|
|||
{
|
||||
public partial class FileSystem
|
||||
{
|
||||
public static string CacheDirectory
|
||||
static string PlatformCacheDirectory
|
||||
=> Platform.AppContext.CacheDir.AbsolutePath;
|
||||
|
||||
public static string AppDataDirectory
|
||||
static string PlatformAppDataDirectory
|
||||
=> Platform.AppContext.FilesDir.AbsolutePath;
|
||||
|
||||
public static Task<Stream> OpenAppPackageFileAsync(string filename)
|
||||
static Task<Stream> PlatformOpenAppPackageFileAsync(string filename)
|
||||
{
|
||||
if (filename == null)
|
||||
throw new ArgumentNullException(nameof(filename));
|
||||
|
|
|
@ -7,13 +7,13 @@ namespace Xamarin.Essentials
|
|||
{
|
||||
public static partial class FileSystem
|
||||
{
|
||||
public static string CacheDirectory
|
||||
static string PlatformCacheDirectory
|
||||
=> GetDirectory(NSSearchPathDirectory.CachesDirectory);
|
||||
|
||||
public static string AppDataDirectory
|
||||
static string PlatformAppDataDirectory
|
||||
=> GetDirectory(NSSearchPathDirectory.LibraryDirectory);
|
||||
|
||||
public static Task<Stream> OpenAppPackageFileAsync(string filename)
|
||||
static Task<Stream> PlatformOpenAppPackageFileAsync(string filename)
|
||||
{
|
||||
if (filename == null)
|
||||
throw new ArgumentNullException(nameof(filename));
|
||||
|
|
|
@ -5,13 +5,13 @@ namespace Xamarin.Essentials
|
|||
{
|
||||
public static partial class FileSystem
|
||||
{
|
||||
public static string CacheDirectory
|
||||
static string PlatformCacheDirectory
|
||||
=> throw new NotImplementedInReferenceAssemblyException();
|
||||
|
||||
public static string AppDataDirectory
|
||||
static string PlatformAppDataDirectory
|
||||
=> throw new NotImplementedInReferenceAssemblyException();
|
||||
|
||||
public static Task<Stream> OpenAppPackageFileAsync(string filename)
|
||||
static Task<Stream> PlatformOpenAppPackageFileAsync(string filename)
|
||||
=> throw new NotImplementedInReferenceAssemblyException();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,17 @@
|
|||
namespace Xamarin.Essentials
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Xamarin.Essentials
|
||||
{
|
||||
public static partial class FileSystem
|
||||
{
|
||||
public static string CacheDirectory
|
||||
=> PlatformCacheDirectory;
|
||||
|
||||
public static string AppDataDirectory
|
||||
=> PlatformAppDataDirectory;
|
||||
|
||||
public static Task<Stream> OpenAppPackageFileAsync(string filename)
|
||||
=> PlatformOpenAppPackageFileAsync(filename);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,13 +8,13 @@ namespace Xamarin.Essentials
|
|||
{
|
||||
public static partial class FileSystem
|
||||
{
|
||||
public static string CacheDirectory
|
||||
static string PlatformCacheDirectory
|
||||
=> ApplicationData.Current.LocalCacheFolder.Path;
|
||||
|
||||
public static string AppDataDirectory
|
||||
static string PlatformAppDataDirectory
|
||||
=> ApplicationData.Current.LocalFolder.Path;
|
||||
|
||||
public static Task<Stream> OpenAppPackageFileAsync(string filename)
|
||||
static Task<Stream> PlatformOpenAppPackageFileAsync(string filename)
|
||||
{
|
||||
if (filename == null)
|
||||
throw new ArgumentNullException(nameof(filename));
|
||||
|
|
|
@ -8,7 +8,7 @@ namespace Xamarin.Essentials
|
|||
{
|
||||
public static partial class Geocoding
|
||||
{
|
||||
public static async Task<IEnumerable<Placemark>> GetPlacemarksAsync(double latitude, double longitude)
|
||||
static async Task<IEnumerable<Placemark>> PlatformGetPlacemarksAsync(double latitude, double longitude)
|
||||
{
|
||||
using (var geocoder = new Geocoder(Platform.AppContext))
|
||||
{
|
||||
|
@ -17,7 +17,7 @@ namespace Xamarin.Essentials
|
|||
}
|
||||
}
|
||||
|
||||
public static async Task<IEnumerable<Location>> GetLocationsAsync(string address)
|
||||
static async Task<IEnumerable<Location>> PlatformGetLocationsAsync(string address)
|
||||
{
|
||||
if (address == null)
|
||||
throw new ArgumentNullException(nameof(address));
|
||||
|
|
|
@ -6,7 +6,7 @@ namespace Xamarin.Essentials
|
|||
{
|
||||
public static partial class Geocoding
|
||||
{
|
||||
public static async Task<IEnumerable<Placemark>> GetPlacemarksAsync(double latitude, double longitude)
|
||||
static async Task<IEnumerable<Placemark>> PlatformGetPlacemarksAsync(double latitude, double longitude)
|
||||
{
|
||||
using (var geocoder = new CLGeocoder())
|
||||
{
|
||||
|
@ -16,7 +16,7 @@ namespace Xamarin.Essentials
|
|||
}
|
||||
}
|
||||
|
||||
public static async Task<IEnumerable<Location>> GetLocationsAsync(string address)
|
||||
static async Task<IEnumerable<Location>> PlatformGetLocationsAsync(string address)
|
||||
{
|
||||
using (var geocoder = new CLGeocoder())
|
||||
{
|
||||
|
|
|
@ -5,10 +5,10 @@ namespace Xamarin.Essentials
|
|||
{
|
||||
public static partial class Geocoding
|
||||
{
|
||||
public static Task<IEnumerable<Placemark>> GetPlacemarksAsync(double latitude, double longitude) =>
|
||||
static Task<IEnumerable<Placemark>> PlatformGetPlacemarksAsync(double latitude, double longitude) =>
|
||||
throw new NotImplementedInReferenceAssemblyException();
|
||||
|
||||
public static Task<IEnumerable<Location>> GetLocationsAsync(string address) =>
|
||||
static Task<IEnumerable<Location>> PlatformGetLocationsAsync(string address) =>
|
||||
throw new NotImplementedInReferenceAssemblyException();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,5 +15,11 @@ namespace Xamarin.Essentials
|
|||
|
||||
return GetPlacemarksAsync(location.Latitude, location.Longitude);
|
||||
}
|
||||
|
||||
public static Task<IEnumerable<Placemark>> GetPlacemarksAsync(double latitude, double longitude)
|
||||
=> PlatformGetPlacemarksAsync(latitude, longitude);
|
||||
|
||||
public static Task<IEnumerable<Location>> GetLocationsAsync(string address)
|
||||
=> PlatformGetLocationsAsync(address);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ namespace Xamarin.Essentials
|
|||
{
|
||||
public static partial class Geocoding
|
||||
{
|
||||
public static async Task<IEnumerable<Placemark>> GetPlacemarksAsync(double latitude, double longitude)
|
||||
static async Task<IEnumerable<Placemark>> PlatformGetPlacemarksAsync(double latitude, double longitude)
|
||||
{
|
||||
ValidateMapKey();
|
||||
|
||||
|
@ -19,7 +19,7 @@ namespace Xamarin.Essentials
|
|||
return queryResults?.Locations?.ToPlacemarks();
|
||||
}
|
||||
|
||||
public static async Task<IEnumerable<Location>> GetLocationsAsync(string address)
|
||||
static async Task<IEnumerable<Location>> PlatformGetLocationsAsync(string address)
|
||||
{
|
||||
ValidateMapKey();
|
||||
|
||||
|
|
|
@ -197,15 +197,15 @@ namespace Xamarin.Essentials
|
|||
|
||||
float desiredAccuracy;
|
||||
|
||||
public AndroidLocation BestLocation { get; set; }
|
||||
internal AndroidLocation BestLocation { get; set; }
|
||||
|
||||
HashSet<string> activeProviders = new HashSet<string>();
|
||||
|
||||
bool wasRaised = false;
|
||||
|
||||
public Action<AndroidLocation> LocationHandler { get; set; }
|
||||
internal Action<AndroidLocation> LocationHandler { get; set; }
|
||||
|
||||
public SingleLocationListener(LocationManager manager, float desiredAccuracy, IEnumerable<string> activeProviders)
|
||||
internal SingleLocationListener(LocationManager manager, float desiredAccuracy, IEnumerable<string> activeProviders)
|
||||
{
|
||||
this.desiredAccuracy = desiredAccuracy;
|
||||
|
||||
|
@ -219,7 +219,7 @@ namespace Xamarin.Essentials
|
|||
}
|
||||
}
|
||||
|
||||
public void OnLocationChanged(AndroidLocation location)
|
||||
void ILocationListener.OnLocationChanged(AndroidLocation location)
|
||||
{
|
||||
if (location.Accuracy <= desiredAccuracy)
|
||||
{
|
||||
|
@ -239,28 +239,28 @@ namespace Xamarin.Essentials
|
|||
}
|
||||
}
|
||||
|
||||
public void OnProviderDisabled(string provider)
|
||||
void ILocationListener.OnProviderDisabled(string provider)
|
||||
{
|
||||
lock (activeProviders)
|
||||
activeProviders.Remove(provider);
|
||||
}
|
||||
|
||||
public void OnProviderEnabled(string provider)
|
||||
void ILocationListener.OnProviderEnabled(string provider)
|
||||
{
|
||||
lock (activeProviders)
|
||||
activeProviders.Add(provider);
|
||||
}
|
||||
|
||||
public void OnStatusChanged(string provider, [GeneratedEnum] Availability status, Bundle extras)
|
||||
void ILocationListener.OnStatusChanged(string provider, [GeneratedEnum] Availability status, Bundle extras)
|
||||
{
|
||||
switch (status)
|
||||
{
|
||||
case Availability.Available:
|
||||
OnProviderEnabled(provider);
|
||||
((ILocationListener)this).OnProviderEnabled(provider);
|
||||
break;
|
||||
|
||||
case Availability.OutOfService:
|
||||
OnProviderDisabled(provider);
|
||||
((ILocationListener)this).OnProviderDisabled(provider);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -72,7 +72,7 @@ namespace Xamarin.Essentials
|
|||
{
|
||||
bool wasRaised = false;
|
||||
|
||||
public Action<CLLocation> LocationHandler { get; set; }
|
||||
internal Action<CLLocation> LocationHandler { get; set; }
|
||||
|
||||
public override void LocationsUpdated(CLLocationManager manager, CLLocation[] locations)
|
||||
{
|
||||
|
|
|
@ -48,15 +48,15 @@ namespace Xamarin.Essentials
|
|||
|
||||
class GyroscopeListener : Java.Lang.Object, ISensorEventListener
|
||||
{
|
||||
public GyroscopeListener()
|
||||
internal GyroscopeListener()
|
||||
{
|
||||
}
|
||||
|
||||
public void OnAccuracyChanged(Sensor sensor, [GeneratedEnum] SensorStatus accuracy)
|
||||
void ISensorEventListener.OnAccuracyChanged(Sensor sensor, [GeneratedEnum] SensorStatus accuracy)
|
||||
{
|
||||
}
|
||||
|
||||
public void OnSensorChanged(SensorEvent e)
|
||||
void ISensorEventListener.OnSensorChanged(SensorEvent e)
|
||||
{
|
||||
var data = new GyroscopeData(e.Values[0], e.Values[1], e.Values[2]);
|
||||
Gyroscope.OnChanged(data);
|
||||
|
|
|
@ -48,15 +48,15 @@ namespace Xamarin.Essentials
|
|||
|
||||
class MagnetometerListener : Java.Lang.Object, ISensorEventListener
|
||||
{
|
||||
public MagnetometerListener()
|
||||
internal MagnetometerListener()
|
||||
{
|
||||
}
|
||||
|
||||
public void OnAccuracyChanged(Sensor sensor, [GeneratedEnum] SensorStatus accuracy)
|
||||
void ISensorEventListener.OnAccuracyChanged(Sensor sensor, [GeneratedEnum] SensorStatus accuracy)
|
||||
{
|
||||
}
|
||||
|
||||
public void OnSensorChanged(SensorEvent e)
|
||||
void ISensorEventListener.OnSensorChanged(SensorEvent e)
|
||||
{
|
||||
var data = new MagnetometerData(e.Values[0], e.Values[1], e.Values[2]);
|
||||
Magnetometer.OnChanged(data);
|
||||
|
|
|
@ -21,7 +21,7 @@ namespace Xamarin.Essentials
|
|||
}
|
||||
}
|
||||
|
||||
public static void Open(string number)
|
||||
static void PlatformOpen(string number)
|
||||
{
|
||||
ValidateOpen(number);
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ namespace Xamarin.Essentials
|
|||
}
|
||||
}
|
||||
|
||||
public static void Open(string number)
|
||||
static void PlatformOpen(string number)
|
||||
{
|
||||
ValidateOpen(number);
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
internal static bool IsSupported =>
|
||||
throw new NotImplementedInReferenceAssemblyException();
|
||||
|
||||
public static void Open(string number) =>
|
||||
static void PlatformOpen(string number) =>
|
||||
throw new NotImplementedInReferenceAssemblyException();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,5 +12,8 @@ namespace Xamarin.Essentials
|
|||
if (!IsSupported)
|
||||
throw new FeatureNotSupportedException();
|
||||
}
|
||||
|
||||
public static void Open(string number)
|
||||
=> PlatformOpen(number);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ namespace Xamarin.Essentials
|
|||
internal static bool IsSupported =>
|
||||
ApiInformation.IsTypePresent("Windows.ApplicationModel.Calls.PhoneCallManager");
|
||||
|
||||
public static void Open(string number)
|
||||
static void PlatformOpen(string number)
|
||||
{
|
||||
ValidateOpen(number);
|
||||
|
||||
|
|
|
@ -56,7 +56,7 @@ namespace Xamarin.Essentials
|
|||
internal static bool HasApiLevel(BuildVersionCodes versionCode) =>
|
||||
(int)Build.VERSION.SdkInt >= (int)versionCode;
|
||||
|
||||
public static void BeginInvokeOnMainThread(Action action)
|
||||
static void PlatformBeginInvokeOnMainThread(Action action)
|
||||
{
|
||||
if (handler?.Looper != Looper.MainLooper)
|
||||
handler = new Handler(Looper.MainLooper);
|
||||
|
@ -90,39 +90,39 @@ namespace Xamarin.Essentials
|
|||
{
|
||||
WeakReference<Activity> currentActivity = new WeakReference<Activity>(null);
|
||||
|
||||
public Context Context =>
|
||||
internal Context Context =>
|
||||
Activity ?? Application.Context;
|
||||
|
||||
public Activity Activity =>
|
||||
internal Activity Activity =>
|
||||
currentActivity.TryGetTarget(out var a) ? a : null;
|
||||
|
||||
public void OnActivityCreated(Activity activity, Bundle savedInstanceState)
|
||||
void Application.IActivityLifecycleCallbacks.OnActivityCreated(Activity activity, Bundle savedInstanceState)
|
||||
{
|
||||
}
|
||||
|
||||
public void OnActivityDestroyed(Activity activity)
|
||||
void Application.IActivityLifecycleCallbacks.OnActivityDestroyed(Activity activity)
|
||||
{
|
||||
}
|
||||
|
||||
public void OnActivityPaused(Activity activity)
|
||||
void Application.IActivityLifecycleCallbacks.OnActivityPaused(Activity activity)
|
||||
{
|
||||
currentActivity.SetTarget(null);
|
||||
}
|
||||
|
||||
public void OnActivityResumed(Activity activity)
|
||||
void Application.IActivityLifecycleCallbacks.OnActivityResumed(Activity activity)
|
||||
{
|
||||
currentActivity.SetTarget(activity);
|
||||
}
|
||||
|
||||
public void OnActivitySaveInstanceState(Activity activity, Bundle outState)
|
||||
void Application.IActivityLifecycleCallbacks.OnActivitySaveInstanceState(Activity activity, Bundle outState)
|
||||
{
|
||||
}
|
||||
|
||||
public void OnActivityStarted(Activity activity)
|
||||
void Application.IActivityLifecycleCallbacks.OnActivityStarted(Activity activity)
|
||||
{
|
||||
}
|
||||
|
||||
public void OnActivityStopped(Activity activity)
|
||||
void Application.IActivityLifecycleCallbacks.OnActivityStopped(Activity activity)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ namespace Xamarin.Essentials
|
|||
{
|
||||
public static partial class Platform
|
||||
{
|
||||
public static void BeginInvokeOnMainThread(Action action)
|
||||
static void PlatformBeginInvokeOnMainThread(Action action)
|
||||
{
|
||||
if (NSThread.Current.IsMainThread)
|
||||
{
|
||||
|
|
|
@ -4,7 +4,7 @@ namespace Xamarin.Essentials
|
|||
{
|
||||
public static partial class Platform
|
||||
{
|
||||
public static void BeginInvokeOnMainThread(Action action) =>
|
||||
static void PlatformBeginInvokeOnMainThread(Action action) =>
|
||||
throw new NotImplementedInReferenceAssemblyException();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,6 +5,9 @@ namespace Xamarin.Essentials
|
|||
{
|
||||
public static partial class Platform
|
||||
{
|
||||
public static void BeginInvokeOnMainThread(Action action)
|
||||
=> PlatformBeginInvokeOnMainThread(action);
|
||||
|
||||
internal static Task InvokeOnMainThread(Action action)
|
||||
{
|
||||
var tcs = new TaskCompletionSource<object>();
|
||||
|
|
|
@ -6,7 +6,7 @@ namespace Xamarin.Essentials
|
|||
{
|
||||
public static partial class Platform
|
||||
{
|
||||
public static void BeginInvokeOnMainThread(Action action)
|
||||
static void PlatformBeginInvokeOnMainThread(Action action)
|
||||
{
|
||||
var dispatcher = CoreApplication.MainView.CoreWindow.Dispatcher;
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ namespace Xamarin.Essentials
|
|||
{
|
||||
public static partial class ScreenLock
|
||||
{
|
||||
public static bool IsActive
|
||||
static bool PlatformIsActive
|
||||
{
|
||||
get
|
||||
{
|
||||
|
@ -14,13 +14,13 @@ namespace Xamarin.Essentials
|
|||
}
|
||||
}
|
||||
|
||||
public static void RequestActive()
|
||||
static void PlatformRequestActive()
|
||||
{
|
||||
var activity = Platform.CurrentActivity;
|
||||
activity?.Window?.AddFlags(WindowManagerFlags.KeepScreenOn);
|
||||
}
|
||||
|
||||
public static void RequestRelease()
|
||||
static void PlatformRequestRelease()
|
||||
{
|
||||
var activity = Platform.CurrentActivity;
|
||||
activity?.Window?.ClearFlags(WindowManagerFlags.KeepScreenOn);
|
||||
|
|
|
@ -4,13 +4,13 @@ namespace Xamarin.Essentials
|
|||
{
|
||||
public static partial class ScreenLock
|
||||
{
|
||||
public static bool IsActive
|
||||
static bool PlatformIsActive
|
||||
=> UIApplication.SharedApplication.IdleTimerDisabled;
|
||||
|
||||
public static void RequestActive()
|
||||
static void PlatformRequestActive()
|
||||
=> UIApplication.SharedApplication.IdleTimerDisabled = true;
|
||||
|
||||
public static void RequestRelease()
|
||||
static void PlatformRequestRelease()
|
||||
=> UIApplication.SharedApplication.IdleTimerDisabled = false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,13 +2,13 @@
|
|||
{
|
||||
public static partial class ScreenLock
|
||||
{
|
||||
public static bool IsActive
|
||||
static bool PlatformIsActive
|
||||
=> throw new NotImplementedInReferenceAssemblyException();
|
||||
|
||||
public static void RequestActive()
|
||||
static void PlatformRequestActive()
|
||||
=> throw new NotImplementedInReferenceAssemblyException();
|
||||
|
||||
public static void RequestRelease()
|
||||
static void PlatformRequestRelease()
|
||||
=> throw new NotImplementedInReferenceAssemblyException();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,5 +2,10 @@
|
|||
{
|
||||
public static partial class ScreenLock
|
||||
{
|
||||
public static bool IsActive => PlatformIsActive;
|
||||
|
||||
public static void RequestActive() => PlatformRequestActive();
|
||||
|
||||
public static void RequestRelease() => PlatformRequestRelease();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@ namespace Xamarin.Essentials
|
|||
static readonly object locker = new object();
|
||||
static DisplayRequest displayRequest;
|
||||
|
||||
public static bool IsActive
|
||||
static bool PlatformIsActive
|
||||
{
|
||||
get
|
||||
{
|
||||
|
@ -18,7 +18,7 @@ namespace Xamarin.Essentials
|
|||
}
|
||||
}
|
||||
|
||||
public static void RequestActive()
|
||||
static void PlatformRequestActive()
|
||||
{
|
||||
lock (locker)
|
||||
{
|
||||
|
@ -30,7 +30,7 @@ namespace Xamarin.Essentials
|
|||
}
|
||||
}
|
||||
|
||||
public static void RequestRelease()
|
||||
static void PlatformRequestRelease()
|
||||
{
|
||||
lock (locker)
|
||||
{
|
||||
|
|
|
@ -60,7 +60,7 @@ namespace Xamarin.Essentials
|
|||
const string prefsMasterKey = "SecureStorageKey";
|
||||
const int initializationVectorLen = 12; // Android supports an IV of 12 for AES/GCM
|
||||
|
||||
public AndroidKeyStore(Context context, string keystoreAlias, bool alwaysUseAsymmetricKeyStorage)
|
||||
internal AndroidKeyStore(Context context, string keystoreAlias, bool alwaysUseAsymmetricKeyStorage)
|
||||
{
|
||||
alwaysUseAsymmetricKey = alwaysUseAsymmetricKeyStorage;
|
||||
appContext = context;
|
||||
|
@ -192,7 +192,7 @@ namespace Xamarin.Essentials
|
|||
return unwrapped;
|
||||
}
|
||||
|
||||
public byte[] Encrypt(string data)
|
||||
internal byte[] Encrypt(string data)
|
||||
{
|
||||
var key = GetKey();
|
||||
|
||||
|
@ -231,7 +231,7 @@ namespace Xamarin.Essentials
|
|||
return r;
|
||||
}
|
||||
|
||||
public string Decrypt(byte[] data)
|
||||
internal string Decrypt(byte[] data)
|
||||
{
|
||||
if (data.Length < initializationVectorLen)
|
||||
return null;
|
||||
|
|
|
@ -36,7 +36,7 @@ namespace Xamarin.Essentials
|
|||
};
|
||||
}
|
||||
|
||||
public string ValueForKey(string key, string service)
|
||||
internal string ValueForKey(string key, string service)
|
||||
{
|
||||
var record = ExistingRecordForKey(key, service);
|
||||
SecStatusCode resultCode;
|
||||
|
@ -48,7 +48,7 @@ namespace Xamarin.Essentials
|
|||
return string.Empty;
|
||||
}
|
||||
|
||||
public void SetValueForKey(string value, string key, string service)
|
||||
internal void SetValueForKey(string value, string key, string service)
|
||||
{
|
||||
var record = ExistingRecordForKey(key, service);
|
||||
if (string.IsNullOrEmpty(value))
|
||||
|
|
Загрузка…
Ссылка в новой задаче