26 changed files with 25 additions and 428 deletions
@ -1,10 +0,0 @@ |
|||
using System; |
|||
using Avalonia.Controls.ApplicationLifetimes; |
|||
|
|||
namespace Avalonia.Android; |
|||
|
|||
public interface IAvaloniaActivity : IActivityResultHandler, IActivityNavigationService |
|||
{ |
|||
event EventHandler<ActivatedEventArgs> Activated; |
|||
event EventHandler<ActivatedEventArgs> Deactivated; |
|||
} |
|||
@ -1,23 +0,0 @@ |
|||
using System; |
|||
|
|||
namespace Avalonia.Controls.ApplicationLifetimes; |
|||
|
|||
/// <summary>
|
|||
/// Event args for an Application Lifetime Activated or Deactivated events.
|
|||
/// </summary>
|
|||
public class ActivatedEventArgs : EventArgs |
|||
{ |
|||
/// <summary>
|
|||
/// Ctor for ActivatedEventArgs
|
|||
/// </summary>
|
|||
/// <param name="kind">The <see cref="ActivationKind"/> that this event represents</param>
|
|||
public ActivatedEventArgs(ActivationKind kind) |
|||
{ |
|||
Kind = kind; |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// The <see cref="ActivationKind"/> that this event represents.
|
|||
/// </summary>
|
|||
public ActivationKind Kind { get; } |
|||
} |
|||
@ -1,25 +0,0 @@ |
|||
namespace Avalonia.Controls.ApplicationLifetimes; |
|||
|
|||
public enum ActivationKind |
|||
{ |
|||
/// <summary>
|
|||
/// When the application is passed a URI to open.
|
|||
/// </summary>
|
|||
OpenUri = 20, |
|||
|
|||
/// <summary>
|
|||
/// When the application is asked to reopen.
|
|||
/// An example of this is on MacOS when all the windows are closed,
|
|||
/// application continues to run in the background and the user clicks
|
|||
/// the application's dock icon.
|
|||
/// </summary>
|
|||
Reopen = 30, |
|||
|
|||
/// <summary>
|
|||
/// When the application enters or leaves a background state.
|
|||
/// An example is when on MacOS the user hides or shows and application (not window),
|
|||
/// or when a browser application switchs tabs or when a mobile applications goes into
|
|||
/// the background.
|
|||
/// </summary>
|
|||
Background = 40 |
|||
} |
|||
@ -1,35 +0,0 @@ |
|||
using System; |
|||
|
|||
namespace Avalonia.Controls.ApplicationLifetimes; |
|||
|
|||
/// <summary>
|
|||
/// An interface for ApplicationLifetimes where the application can be Activated and Deactivated.
|
|||
/// </summary>
|
|||
public interface IActivatableApplicationLifetime |
|||
{ |
|||
/// <summary>
|
|||
/// An event that is raised when the application is Activated for various reasons
|
|||
/// as described by the <see cref="ActivationKind"/> enumeration.
|
|||
/// </summary>
|
|||
event EventHandler<ActivatedEventArgs> Activated; |
|||
|
|||
/// <summary>
|
|||
/// An event that is raised when the application is Deactivated for various reasons
|
|||
/// as described by the <see cref="ActivationKind"/> enumeration.
|
|||
/// </summary>
|
|||
event EventHandler<ActivatedEventArgs> Deactivated; |
|||
|
|||
/// <summary>
|
|||
/// Tells the application that it should attempt to leave its background state.
|
|||
/// For example on OSX this would be [NSApp unhide]
|
|||
/// </summary>
|
|||
/// <returns>true if it was possible and the platform supports this. false otherwise</returns>
|
|||
public bool TryLeaveBackground(); |
|||
|
|||
/// <summary>
|
|||
/// Tells the application that it should attempt to enter its background state.
|
|||
/// For example on OSX this would be [NSApp hide]
|
|||
/// </summary>
|
|||
/// <returns>true if it was possible and the platform supports this. false otherwise</returns>
|
|||
public bool TryEnterBackground(); |
|||
} |
|||
@ -1,13 +0,0 @@ |
|||
using System; |
|||
|
|||
namespace Avalonia.Controls.ApplicationLifetimes; |
|||
|
|||
public class ProtocolActivatedEventArgs : ActivatedEventArgs |
|||
{ |
|||
public ProtocolActivatedEventArgs(ActivationKind kind, Uri uri) : base(kind) |
|||
{ |
|||
Uri = uri; |
|||
} |
|||
|
|||
public Uri Uri { get; } |
|||
} |
|||
@ -1,50 +0,0 @@ |
|||
using System; |
|||
using Avalonia.Controls.ApplicationLifetimes; |
|||
using Avalonia.Controls.Platform; |
|||
|
|||
namespace Avalonia.Native; |
|||
|
|||
#nullable enable |
|||
|
|||
internal class MacOSClassicDesktopStyleApplicationLifetime : ClassicDesktopStyleApplicationLifetime, |
|||
IActivatableApplicationLifetime |
|||
{ |
|||
/// <inheritdoc />
|
|||
public event EventHandler<ActivatedEventArgs>? Activated; |
|||
|
|||
/// <inheritdoc />
|
|||
public event EventHandler<ActivatedEventArgs>? Deactivated; |
|||
|
|||
/// <inheritdoc />
|
|||
public bool TryLeaveBackground() |
|||
{ |
|||
var nativeApplicationCommands = AvaloniaLocator.Current.GetService<INativeApplicationCommands>(); |
|||
nativeApplicationCommands?.ShowApp(); |
|||
|
|||
return true; |
|||
} |
|||
|
|||
/// <inheritdoc />
|
|||
public bool TryEnterBackground() |
|||
{ |
|||
var nativeApplicationCommands = AvaloniaLocator.Current.GetService<INativeApplicationCommands>(); |
|||
nativeApplicationCommands?.HideApp(); |
|||
|
|||
return true; |
|||
} |
|||
|
|||
internal void RaiseUrl(Uri uri) |
|||
{ |
|||
Activated?.Invoke(this, new ProtocolActivatedEventArgs(ActivationKind.OpenUri, uri)); |
|||
} |
|||
|
|||
internal void RaiseActivated(ActivationKind kind) |
|||
{ |
|||
Activated?.Invoke(this, new ActivatedEventArgs(kind)); |
|||
} |
|||
|
|||
internal void RaiseDeactivated(ActivationKind kind) |
|||
{ |
|||
Deactivated?.Invoke(this, new ActivatedEventArgs(kind)); |
|||
} |
|||
} |
|||
@ -1,27 +0,0 @@ |
|||
using System; |
|||
using Avalonia.Controls; |
|||
using Avalonia.Controls.ApplicationLifetimes; |
|||
|
|||
namespace Avalonia.iOS; |
|||
|
|||
internal class SingleViewLifetime : ISingleViewApplicationLifetime, IActivatableApplicationLifetime |
|||
{ |
|||
public SingleViewLifetime(IAvaloniaAppDelegate avaloniaAppDelegate) |
|||
{ |
|||
avaloniaAppDelegate.Activated += (_, args) => Activated?.Invoke(this, args); |
|||
avaloniaAppDelegate.Deactivated += (_, args) => Deactivated?.Invoke(this, args); |
|||
} |
|||
|
|||
public AvaloniaView View; |
|||
|
|||
public Control MainView |
|||
{ |
|||
get => View.Content; |
|||
set => View.Content = value; |
|||
} |
|||
|
|||
public event EventHandler<ActivatedEventArgs> Activated; |
|||
public event EventHandler<ActivatedEventArgs> Deactivated; |
|||
public bool TryLeaveBackground() => false; |
|||
public bool TryEnterBackground() => false; |
|||
} |
|||
Loading…
Reference in new issue