Class AndroidAppMainActivityHandler
- Namespace
- VpnHood.AppLib.App.Android.Activities
- Assembly
- VpnHood.AppLib.App.Android.dll
Provides the app's work for a main activity: its UI context, the window's insets, the access keys of links and files, and the activity's events.
public class AndroidAppMainActivityHandler
- Inheritance
-
AndroidAppMainActivityHandler
- Inherited Members
Remarks
It follows the activity's events from its construction; a UI's handler derives from it.
Constructors
AndroidAppMainActivityHandler(IActivityEvent, AndroidMainActivityOptions, Task<VhColor?>)
Initializes a new instance of the AndroidAppMainActivityHandler class, which follows the activity's events.
public AndroidAppMainActivityHandler(IActivityEvent activityEvent, AndroidMainActivityOptions options, Task<VhColor?> chromeColor)
Parameters
activityEventIActivityEventThe activity.
optionsAndroidMainActivityOptionsThe access keys the activity takes.
chromeColorTask<VhColor?>A task whose result is the UI's colour for the system bars and the ground behind them, as it becomes known; with a null result, no background of the UI's is painted.
Properties
ActivityEvent
Gets the activity, as the source of its events.
protected IActivityEvent ActivityEvent { get; }
Property Value
Methods
ImportAccessKey(string)
Imports an access key, makes its server the chosen one, and says so in a toast.
protected virtual void ImportAccessKey(string accessKey)
Parameters
accessKeystringThe access key.
Remarks
A UI that imports keys itself, and says so in its own way, overrides it.
Exceptions
- FormatException
The access key is no valid Base64, or an endpoint or a duration in it is not valid.
- NotSupportedException
The access key's version is not one the app reads.
- JsonException
The text holds no valid access key.
- InvalidDataException
The access key decodes to JSON
null.- OverflowException
A duration in the access key is out of range.
- UnauthorizedAccessException
The access key is a built-in VPN profile's.
OnActivityResult(int, Result, Intent?)
Called with the result of an activity this one started; it does nothing by default.
protected virtual void OnActivityResult(int requestCode, Result resultCode, Intent? data)
Parameters
requestCodeintThe request's code.
resultCodeResultThe result.
dataIntentThe result's data, or null.
OnConfigurationChanged(Configuration)
Called when the activity's configuration changed: it has the app update its UI.
protected virtual void OnConfigurationChanged(Configuration args)
Parameters
argsConfigurationThe new configuration.
OnCreate(Bundle?)
Called when the activity is created: it takes the app's UI context, configures the window's insets, and imports an access key the intent carries.
protected virtual void OnCreate(Bundle? savedInstanceState)
Parameters
OnDestroy()
Called when the activity is destroyed: it lets the app's UI context go where it is this activity's.
protected virtual void OnDestroy()
OnKeyDown(Keycode, KeyEvent?)
Called when a key is pressed; it handles none by default.
protected virtual bool OnKeyDown(Keycode keyCode, KeyEvent? keyEvent)
Parameters
Returns
OnNewIntent(Intent?)
Called when the activity gets a new intent: it imports an access key the intent carries.
protected virtual bool OnNewIntent(Intent? intent)
Parameters
Returns
- bool
true where it tried the intent's link or file, whether or not the import worked; false where the intent carries neither, the activity has no content resolver, or a file is of a type the activity does not take.
OnPause()
Called when the activity leaves the front; it does nothing by default.
protected virtual void OnPause()
OnRequestPermissionsResult(int, string[], Permission[])
Called with a permission request's result; it does nothing by default.
protected virtual void OnRequestPermissionsResult(int requestCode, string[] permissions, Permission[] grantResults)
Parameters
requestCodeintThe request's code.
permissionsstring[]The permissions asked for.
grantResultsPermission[]Whether each was granted.
OnResume()
Called when the activity comes to the front: it takes the app's UI context back.
protected virtual void OnResume()
TakeUiContext()
Makes this activity the app's UI context, unless it is already, as a context made again would tell the app of a new window, which may start an ad's preload and an update check once more.
public void TakeUiContext()
Remarks
An activity whose view asks for the context as it is built takes it before its own create builds that view.