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
IsAppNotificationSettingsSupported
Gets a value indicating whether the app can open its notification settings in the system's settings.
bool IsAppNotificationSettingsSupported { get; }
Property Value
IsAppSettingsSupported
Gets a value indicating whether the app can open its own page in the system's settings.
bool IsAppSettingsSupported { get; }
Property Value
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
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
IsProxySettingsSupported
Gets a value indicating whether the device can tell its proxy settings.
bool IsProxySettingsSupported { get; }
Property Value
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
IsRequestNotificationSupported
Gets a value indicating whether the app can ask the person to let it show notifications.
bool IsRequestNotificationSupported { get; }
Property Value
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
IsSettingsSupported
Gets a value indicating whether the app can open the system's settings.
bool IsSettingsSupported { get; }
Property Value
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
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
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
uiContextIUiContextThe 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
uiContextIUiContextThe app's UI context.
valuebool
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
uiContextIUiContextThe 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
uiContextIUiContextThe 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
contextIUiContextThe 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
requiredContextIUiContextThe app's UI context.
Exceptions
- NotSupportedException
The device cannot open them.
OpenSettings(IUiContext)
Opens the system's settings.
void OpenSettings(IUiContext uiContext)
Parameters
uiContextIUiContextThe 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
uiContextIUiContextThe app's UI context.
cancellationTokenCancellationTokenThe token to monitor for cancellation requests.
Returns
Exceptions
- NotSupportedException
The device cannot ask for it.
- OperationCanceledException
cancellationTokenwas 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
uiContextIUiContextThe app's UI context.
cancellationTokenCancellationTokenThe token to monitor for cancellation requests.
Returns
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
cancellationTokenwas 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
uiContextIUiContextThe app's UI context.
fileNamestringThe file's name.
contentbyte[]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.