yavsc/src/PostIt/PostIt.Android/PlatformBootstrap.cs

40 lines
1.8 KiB
C#
Raw Normal View History

using PostIt.Services;
using PostIt.Android.Services;
namespace PostIt.Android;
/// <summary>
/// One-shot platform bootstrap. Called from
/// <see cref="MainActivity.OnCreate"/> so that the shared OIDC login
/// path sees the Android-specific redirect URI and a working
/// <c>IBrowser</c> (Chrome Custom Tabs) without referencing Android
/// APIs from the shared library.
/// </summary>
internal static class PlatformBootstrap
{
2026-08-25 19:20:03 +01:00
internal static void InitPlatform()
{
Platform.CreateBrowser = () =>
{
var activity = MainActivity.Current;
return activity is null ? null : new AndroidSystemBrowser(activity);
};
2026-09-02 14:41:05 +01:00
Platform.CreateServiceProvider = AndroidServiceProvider.GetOrCreate;
Platform.BackgroundChatService = AndroidBackgroundChatService.Instance;
2026-09-02 14:41:05 +01:00
Platform.TryGetCurrentLocationAsync = AndroidCurrentLocationProvider.TryGetCurrentLocationAsync;
Platform.CreateVideoSurface = (player, replay) => new AndroidVideoSurface(player, replay);
if (System.OperatingSystem.IsAndroidVersionAtLeast(26))
{
Platform.GetLanCallDevices = AndroidLanCallMedia.GetDevices;
Platform.CreateLanCallMedia = (address, port) =>
System.OperatingSystem.IsAndroidVersionAtLeast(26)
? new AndroidLanCallMedia(address, port)
: throw new System.PlatformNotSupportedException("Android 8 requis pour les appels LAN.");
Platform.GetPodcastCaptureDevices = AndroidPodcastCapture.GetDevices;
Platform.RequestPodcastPermissionsAsync = AndroidPodcastCapture.RequestPermissionsAsync;
Platform.CreatePodcastCaptureAsync = AndroidPodcastCapture.StartAsync;
2026-11-05 10:44:19 +00:00
Platform.CreatePodcastPreviewAsync = AndroidPodcastCapture.StartPreviewAsync;
}
}
2026-07-11 03:26:13 +01:00
}