Table of Contents

Interface IDeviceUiProvider

Namespace
VpnHood.AppLib.Abstractions.Device
Assembly
VpnHood.AppLib.Abstractions.dll

Represents what the app's UI asks of the device: the system's settings pages, its permissions, its share sheet, and what it tells of its proxy, private DNS and system bars.

public interface IDeviceUiProvider

Remarks

Each feature has its Is...Supported flag, which the UI reads before it offers the feature; the request or the page behind a feature the device does not support throws NotSupportedException. The readings answer null or the defaults where the device cannot tell, and KeepScreenOn(IUiContext, bool) may do nothing, as where it is not supported.

Properties

IsAlwaysOnSettingsSupported

Gets a value indicating whether the app can open the system's always-on VPN setting.

bool IsAlwaysOnSettingsSupported { get; }

Property Value

bool

IsAppNotificationSettingsSupported

Gets a value indicating whether the app can open its notification settings in the system's settings.

bool IsAppNotificationSettingsSupported { get; }

Property Value

bool

IsAppSettingsSupported

Gets a value indicating whether the app can open its own page in the system's settings.

bool IsAppSettingsSupported { get; }

Property Value

bool

IsKillSwitchSettingsSupported

Gets a value indicating whether the app can open the system's kill switch setting, which blocks the connections made without the VPN.

bool IsKillSwitchSettingsSupported { get; }

Property Value

bool

IsNotificationEnabled

Gets a value indicating whether the app may show notifications, or null where the device does not say.

bool? IsNotificationEnabled { get; }

Property Value

bool?

IsPrivateDnsSettingsSupported

Gets a value indicating whether the device has a private DNS setting, which can take the DNS past the VPN.

bool IsPrivateDnsSettingsSupported { get; }

Property Value

bool

IsProxySettingsSupported

Gets a value indicating whether the device can tell its proxy settings.

bool IsProxySettingsSupported { get; }

Property Value

bool

IsQuickLaunchSupported

Gets a value indicating whether the device offers the app's Quick Launch: a shortcut in the system's own UI, as Android's Quick Settings tile, that connects the VPN.

bool IsQuickLaunchSupported { get; }

Property Value

bool

IsRequestNotificationSupported

Gets a value indicating whether the app can ask the person to let it show notifications.

bool IsRequestNotificationSupported { get; }

Property Value

bool

IsRequestQuickLaunchSupported

Gets a value indicating whether the app can ask the system to add its Quick Launch for the person.

bool IsRequestQuickLaunchSupported { get; }

Property Value

bool

IsSettingsSupported

Gets a value indicating whether the app can open the system's settings.

bool IsSettingsSupported { get; }

Property Value

bool

IsShareSupported

Whether the device has a share sheet, which hands a file to an app the user picks. False on a TV and a computer, where the UI copies the text instead.

bool IsShareSupported { get; }

Property Value

bool

IsWebBrowserSupported

Whether a page can be handed to an EXTERNAL browser. Not "can this app draw a page" — the UI can always render a page inside itself; this is only about leaving the app. False on a device with no browser, which is where an outbound link opens nothing at all: the UI withholds the link rather than offering a dead one.

bool IsWebBrowserSupported { get; }

Property Value

bool

Methods

GetBarsInfo(IUiContext)

Gets the heights of the system bars over the app's window, for its layout to leave room.

SystemBarsInfo GetBarsInfo(IUiContext uiContext)

Parameters

uiContext IUiContext

The app's UI context.

Returns

SystemBarsInfo

The bars' heights; none where the device cannot tell them.

GetPrivateDns()

Gets the device's private DNS, which can take the DNS past the VPN.

PrivateDns? GetPrivateDns()

Returns

PrivateDns

The private DNS, or null where the device cannot tell it.

GetProxySettings()

Gets the device's proxy settings.

DeviceProxySettings? GetProxySettings()

Returns

DeviceProxySettings

The settings, or null where the device has no proxy or cannot tell it.

KeepScreenOn(IUiContext, bool)

Holds off the screen's idle sleep while the app is in front, for a page that is meant to stay up with nobody at the remote. An implementation that does not support it, as the Windows one, does nothing.

Task KeepScreenOn(IUiContext uiContext, bool value)

Parameters

uiContext IUiContext

The app's UI context.

value bool

true to keep the screen on; false to let it sleep again.

Returns

Task

A task that completes once it is set.

OpenAlwaysOnSettings(IUiContext)

Opens the system's VPN settings, where the person turns always-on VPN on for the app.

void OpenAlwaysOnSettings(IUiContext uiContext)

Parameters

uiContext IUiContext

The app's UI context.

Exceptions

NotSupportedException

The device cannot open them.

OpenAppNotificationSettings(IUiContext)

Opens the app's notification settings in the system's settings.

void OpenAppNotificationSettings(IUiContext uiContext)

Parameters

uiContext IUiContext

The app's UI context.

Exceptions

NotSupportedException

The device cannot open them.

OpenAppSettings(IUiContext)

Opens the app's own page in the system's settings.

void OpenAppSettings(IUiContext context)

Parameters

context IUiContext

The app's UI context.

Exceptions

NotSupportedException

The device cannot open it.

OpenKillSwitchSettings(IUiContext)

Opens the system's VPN settings, where the person turns the system's kill switch on for the app.

void OpenKillSwitchSettings(IUiContext requiredContext)

Parameters

requiredContext IUiContext

The app's UI context.

Exceptions

NotSupportedException

The device cannot open them.

OpenSettings(IUiContext)

Opens the system's settings.

void OpenSettings(IUiContext uiContext)

Parameters

uiContext IUiContext

The app's UI context.

Exceptions

NotSupportedException

The device cannot open them.

RequestNotification(IUiContext, CancellationToken)

Asks the person to let the app show notifications.

Task<bool> RequestNotification(IUiContext uiContext, CancellationToken cancellationToken)

Parameters

uiContext IUiContext

The app's UI context.

cancellationToken CancellationToken

The token to monitor for cancellation requests.

Returns

Task<bool>

A task whose result is true where the app may show them now.

Exceptions

NotSupportedException

The device cannot ask for it.

OperationCanceledException

cancellationToken was canceled.

RequestQuickLaunch(IUiContext, CancellationToken)

Asks the system to add the app's Quick Launch, which the person accepts or refuses.

Task<bool> RequestQuickLaunch(IUiContext uiContext, CancellationToken cancellationToken)

Parameters

uiContext IUiContext

The app's UI context.

cancellationToken CancellationToken

The token to monitor for cancellation requests.

Returns

Task<bool>

A task whose result is true where the Quick Launch is added, or was already.

Remarks

Android's throws its RequestQuickLaunchException where the system answers no within a second of the request.

Exceptions

NotSupportedException

The device cannot ask for it.

OperationCanceledException

cancellationToken was canceled.

ShareFile(IUiContext, string, byte[])

Hands a file to an app the person picks in the device's share sheet.

void ShareFile(IUiContext uiContext, string fileName, byte[] content)

Parameters

uiContext IUiContext

The app's UI context.

fileName string

The file's name.

content byte[]

The file's content.

Exceptions

NotSupportedException

The device has no share sheet.

InvalidOperationException

There is no window to share from, as iOS's finds none.