Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Adjust public APIs #19817

Merged
merged 12 commits into from
Apr 7, 2025
23 changes: 3 additions & 20 deletions src/SamplesApp/SamplesApp.Skia.WebAssembly.Browser/Program.cs
Original file line number Diff line number Diff line change
@@ -1,21 +1,4 @@
using System;
using SkiaSharp;
using Uno.Foundation.Extensibility;
using System.Threading;
using Windows.UI.Xaml;
using Windows.UI.Core;
using Uno.UI.Runtime.Skia.WebAssembly.Browser;
using System.Threading.Tasks;
using Uno.UI.Runtime.Skia.WebAssembly.Browser;

namespace SkiaSharpExample
{
class MainClass
{
[STAThread]
public static async Task Main(string[] args)
{
var host = new PlatformHost(() => new SamplesApp.App());
await host.Run();
}
}
}
var host = new WebAssemblyBrowserHost(() => new SamplesApp.App());
await host.Run();
Original file line number Diff line number Diff line change
@@ -1,13 +1,4 @@
using System.Threading.Tasks;
using UIKit;
using Uno.UI.Runtime.Skia.AppleUIKit;
using Uno.UI.Runtime.Skia.AppleUIKit;

namespace SamplesApp.MacCatalyst;
public class Application
{
public static void Main(string[] args)
{
var host = new PlatformHost(() => new SamplesApp.App());
host.Run();
}
}
var host = new AppleUIKitHost(() => new SamplesApp.App());
host.Run();
16 changes: 3 additions & 13 deletions src/SamplesApp/SamplesApp.Skia.netcoremobile/iOS/Main.iOS.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,4 @@
using System.Threading.Tasks;
using UIKit;
using Uno.UI.Runtime.Skia.AppleUIKit;
using Uno.UI.Runtime.Skia.AppleUIKit;

namespace SamplesApp.iOS;

public class Application
{
public static void Main(string[] args)
{
var host = new PlatformHost(() => new SamplesApp.App());
host.Run();
}
}
var host = new AppleUIKitHost(() => new SamplesApp.App());
host.Run();
16 changes: 3 additions & 13 deletions src/SamplesApp/SamplesApp.Skia.netcoremobile/tvOS/Main.tvOS.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,4 @@
using System.Threading.Tasks;
using UIKit;
using Uno.UI.Runtime.Skia.AppleUIKit;
using Uno.UI.Runtime.Skia.AppleUIKit;

namespace SamplesApp.tvOS;

public class Application
{
public static void Main(string[] args)
{
var host = new PlatformHost(() => new SamplesApp.App());
host.Run();
}
}
var host = new AppleUIKitHost(() => new SamplesApp.App());
host.Run();
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ public class Program
{
public static async Task Main(string[] args)
{
var host = new PlatformHost(() => new App());
var host = new WebAssemblyBrowserHost(() => new App());
await host.Run();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

namespace Uno.UI.Runtime.Skia.Android;

public class AndroidSkiaHost : ISkiaApplicationHost
public class AndroidHost : ISkiaApplicationHost
{
private Func<Application> _appBuilder;

Expand All @@ -24,7 +24,7 @@ public class AndroidSkiaHost : ISkiaApplicationHost
/// <remarks>
/// Environment.CommandLine is used to fill LaunchEventArgs.Arguments.
/// </remarks>
public AndroidSkiaHost(Func<Application> appBuilder)
public AndroidHost(Func<Application> appBuilder)
{
_appBuilder = appBuilder;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public partial class BaseActivity : AndroidX.AppCompat.App.AppCompatActivity
/// <summary>
/// Occurs when the <see cref="Current"/> activity changed.
/// </summary>
public static event EventHandler<CurrentActivityChangedEventArgs>? CurrentChanged;
internal static event EventHandler<CurrentActivityChangedEventArgs>? CurrentChanged;

private static int _instanceCount;
private static Dictionary<int, BaseActivity> _instances = new Dictionary<int, BaseActivity>();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
using System;
using System.Linq;

namespace Uno.UI
namespace Uno.UI;

internal class CurrentActivityChangedEventArgs : EventArgs
{
public class CurrentActivityChangedEventArgs : EventArgs
internal CurrentActivityChangedEventArgs(BaseActivity? current)
{
internal CurrentActivityChangedEventArgs(BaseActivity? current)
{
Current = current;
}

/// <summary>
/// Gets the new current activity, if any.
/// </summary>
public BaseActivity? Current { get; }
Current = current;
}

/// <summary>
/// Gets the new current activity, if any.
/// </summary>
public BaseActivity? Current { get; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,39 +4,38 @@
using Uno.UI.Xaml.Controls;
using Window = Microsoft.UI.Xaml.Window;

namespace Uno.UI
namespace Uno.UI;

public class OnSystemUiVisibilityChangeListener
: Java.Lang.Object, View.IOnSystemUiVisibilityChangeListener
{
public class OnSystemUiVisibilityChangeListener
: Java.Lang.Object, View.IOnSystemUiVisibilityChangeListener
public void OnSystemUiVisibilityChange([GeneratedEnum] StatusBarVisibility visibility)
{
public void OnSystemUiVisibilityChange([GeneratedEnum] StatusBarVisibility visibility)
{
var activity = ContextHelper.Current as Activity;
var decorView = activity!.Window!.DecorView;
var activity = ContextHelper.Current as Activity;
var decorView = activity!.Window!.DecorView;
#pragma warning disable 618
#pragma warning disable CA1422 // Validate platform compatibility
var newUiOptions = (int)decorView.SystemUiVisibility;
var newUiOptions = (int)decorView.SystemUiVisibility;
#pragma warning restore CA1422 // Validate platform compatibility
#pragma warning restore 618


if (((int)visibility & (int)SystemUiFlags.HideNavigation) == 0)
{
newUiOptions &= ~(int)SystemUiFlags.HideNavigation;
}
else
{
newUiOptions |= (int)SystemUiFlags.HideNavigation;
}
if (((int)visibility & (int)SystemUiFlags.HideNavigation) == 0)
{
newUiOptions &= ~(int)SystemUiFlags.HideNavigation;
}
else
{
newUiOptions |= (int)SystemUiFlags.HideNavigation;
}

// We actually don't want to update the decorView.SystemUiVisibility because of the difference between SystemUiFlags.HideNavigation and SystemUiFlags.LayoutHideNavigation
// - HideNavigation : User can show the navigation bar by sliding up from the bottom of the screen but it will disappear after 2-3 seconds
// - LayoutHideNavigation : User can show the navigation bar by sliding up from the bottom of the screen and have the option to dock it / undock it
// In the case we set the navigation bar to LayoutHideNavigation, when the user hide the bar, HideNavigation will be triggered.
// But we don't want to inject it in the decorView.SystemUiVisibility to let the navigation bar dockable again
NativeWindowWrapper.Instance.SystemUiVisibility = newUiOptions;
// We actually don't want to update the decorView.SystemUiVisibility because of the difference between SystemUiFlags.HideNavigation and SystemUiFlags.LayoutHideNavigation
// - HideNavigation : User can show the navigation bar by sliding up from the bottom of the screen but it will disappear after 2-3 seconds
// - LayoutHideNavigation : User can show the navigation bar by sliding up from the bottom of the screen and have the option to dock it / undock it
// In the case we set the navigation bar to LayoutHideNavigation, when the user hide the bar, HideNavigation will be triggered.
// But we don't want to inject it in the decorView.SystemUiVisibility to let the navigation bar dockable again
NativeWindowWrapper.Instance.SystemUiVisibility = newUiOptions;

activity.OnConfigurationChanged(activity!.Resources!.Configuration!);
}
activity.OnConfigurationChanged(activity!.Resources!.Configuration!);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace Uno.UI.Runtime.Skia.Android;
/// <summary>
/// State of an on-going text editing session.
/// </summary>
public class TextEditState
internal class TextEditState
{
public string text;
public int selectionStart;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace Uno.UI.Runtime.Skia.Android;

/// A representation of the change that occurred to an editing state, along with the resulting
/// composing and selection regions.
public record TextEditingDelta(
internal record TextEditingDelta(
string OldText,
int DeltaStart,
int DeltaEnd,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

namespace Uno.UI.Runtime.Skia.AppleUIKit;

public class PlatformHost : ISkiaApplicationHost
public class AppleUIKitHost : ISkiaApplicationHost
{
/// <summary>
/// Creates a host for an Uno Skia Android application.
Expand All @@ -23,7 +23,7 @@ public class PlatformHost : ISkiaApplicationHost
/// <remarks>
/// Environment.CommandLine is used to fill LaunchEventArgs.Arguments.
/// </remarks>
public PlatformHost(Func<Application> appBuilder)
public AppleUIKitHost(Func<Application> appBuilder)
{
CreateAppAction = (ApplicationInitializationCallbackParams _) =>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

namespace Uno.UI.Runtime.Skia.AppleUIKit;

internal class RootViewController : UINavigationController, IRotationAwareViewController, IAppleUIKitXamlRootHost
internal class RootViewController : UINavigationController, IAppleUIKitXamlRootHost
{
private SkiaCanvas? _skCanvasView;
private XamlRoot? _xamlRoot;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@
</PropertyGroup>

<ItemGroup>
<Compile Include="..\Uno.UI\Controls\BringIntoViewMode.Apple.cs" Link="Controls\BringIntoViewMode.Apple.cs" />
<Compile Include="..\Uno.UI\Controls\IRotationAwareViewController.UIKit.cs" Link="Controls\IRotationAwareViewController.UIKit.cs" />
<Compile Include="..\Uno.UI\UI\Xaml\Controls\TextBox\InputScopeHelper.UIKit.cs" Link="UI\Xaml\Controls\TextBox\InputScopeHelper.UIKit.cs" />
</ItemGroup>

Expand Down
2 changes: 1 addition & 1 deletion src/Uno.UI.Runtime.Skia.AppleUIKit/UnoSkiaAppDelegate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public UnoSkiaAppDelegate()

public override void FinishedLaunching(UIApplication application)
{
Application.Start(PlatformHost.CreateAppAction);
Application.Start(AppleUIKitHost.CreateAppAction);
}

private void SubscribeBackgroundNotifications()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

namespace Uno.UI.Runtime.Skia.WebAssembly.Browser;

public partial class PlatformHost : ISkiaApplicationHost, IXamlRootHost
public partial class WebAssemblyBrowserHost : ISkiaApplicationHost, IXamlRootHost
{
private readonly CoreApplicationExtension? _coreApplicationExtension;

Expand All @@ -32,7 +32,7 @@ public partial class PlatformHost : ISkiaApplicationHost, IXamlRootHost
/// <remarks>
/// Environment.CommandLine is used to fill LaunchEventArgs.Arguments.
/// </remarks>
public PlatformHost(Func<Application> appBuilder)
public WebAssemblyBrowserHost(Func<Application> appBuilder)
{
_appBuilder = appBuilder;

Expand Down Expand Up @@ -84,7 +84,7 @@ void CreateApp(ApplicationInitializationCallbackParams _)
DisplayInformation.GetForCurrentView();
}

PersistBootstrapperLoader();
NativeMethods.PersistBootstrapperLoader();

_renderer = new BrowserRenderer(this);

Expand Down Expand Up @@ -119,6 +119,9 @@ void IXamlRootHost.InvalidateRender()

UIElement? IXamlRootHost.RootElement => Window.Current!.RootElement;

[JSImport("globalThis.Uno.UI.Runtime.Skia.WebAssemblyWindowWrapper.persistBootstrapperLoader")]
public static partial void PersistBootstrapperLoader();
private static partial class NativeMethods
{
[JSImport("globalThis.Uno.UI.Runtime.Skia.WebAssemblyWindowWrapper.persistBootstrapperLoader")]
public static partial void PersistBootstrapperLoader();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

namespace Uno.UI.Runtime.Skia.Win32;

public class Win32NativeElementHostingExtension(ContentPresenter presenter) : ContentPresenter.INativeElementHostingExtension
internal class Win32NativeElementHostingExtension(ContentPresenter presenter) : ContentPresenter.INativeElementHostingExtension
{
private static HWND _enumProcRet;
private static readonly SKPath _lastClipPath = new();
Expand Down
43 changes: 24 additions & 19 deletions src/Uno.UI/ActivityHelper.Android.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,29 @@
using Android.Widget;
using Android.Content.PM;

namespace Uno.UI
namespace Uno.UI;

/// <summary>
/// Provides helpers for Android Activity.
/// </summary>
public static class ActivityHelper
{
public static class ActivityHelper
{
public const ConfigChanges AllConfigChanges =
ConfigChanges.Orientation |
ConfigChanges.KeyboardHidden |
ConfigChanges.FontScale |
ConfigChanges.Keyboard |
ConfigChanges.Locale |
ConfigChanges.Mcc |
ConfigChanges.Mnc |
ConfigChanges.Navigation |
ConfigChanges.ScreenLayout |
ConfigChanges.ScreenSize |
ConfigChanges.SmallestScreenSize |
ConfigChanges.Touchscreen |
ConfigChanges.LayoutDirection |
ConfigChanges.UiMode;
}
/// <summary>
/// Represents all configuration changes handled by Uno Platform.
/// </summary>
public const ConfigChanges AllConfigChanges =
ConfigChanges.Orientation |
ConfigChanges.KeyboardHidden |
ConfigChanges.FontScale |
ConfigChanges.Keyboard |
ConfigChanges.Locale |
ConfigChanges.Mcc |
ConfigChanges.Mnc |
ConfigChanges.Navigation |
ConfigChanges.ScreenLayout |
ConfigChanges.ScreenSize |
ConfigChanges.SmallestScreenSize |
ConfigChanges.Touchscreen |
ConfigChanges.LayoutDirection |
ConfigChanges.UiMode;
}
7 changes: 6 additions & 1 deletion src/Uno.UI/DelegateActivity.Android.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,12 @@ public class DelegateActivity : BaseActivity
/// <param name="intent">The Intent you want to send</param>
/// <param name="requestCode">A specific Response code, this is useful if you send more than one type of request in parallel</param>
/// <returns>OnActivityResultArgs : an object containing the parameters of the OnActivityResult</returns>
public async Task<OnActivityResultArgs> GetActivityResult(CancellationToken ct, Intent intent, int requestCode = 0)
#if ANDROID_SKIA
internal
#else
public
#endif
async Task<OnActivityResultArgs> GetActivityResult(CancellationToken ct, Intent intent, int requestCode = 0)
{
try
{
Expand Down
Loading
Loading