-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAutoStartModule.uno
More file actions
73 lines (59 loc) · 1.93 KB
/
AutoStartModule.uno
File metadata and controls
73 lines (59 loc) · 1.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
using Fuse;
using Fuse.Scripting;
using Uno;
using Uno.UX;
using Uno.Compiler.ExportTargetInterop;
[UXGlobalModule]
class AutoStartModule : NativeModule
{
static bool _inited;
public AutoStartModule()
{
if (_inited)
return;
_inited = true;
Resource.SetGlobalKey(this, "FuseJS/AutoStart");
AddMember(new NativeFunction("hasPermission", (context, args) => {
if defined(ANDROID)
return HasSystemAlertWindowPermissionJava();
return false;
}));
AddMember(new NativeFunction("askForPermission", (context, args) => {
if defined(ANDROID)
AskForSystemAlertWindowPermissionJava();
return null;
}));
AddMember(new NativeFunction("restartOnDestroy", (context, args) => {
if defined(ANDROID)
{
if (args.Length != 0)
{
try { EnableRestartOnDestroyJava((bool) args[0]); }
catch (Exception e) { debug_log e.ToString(); }
}
return IsRestartOnDestroyEnabledJava();
}
return null;
}));
}
[Foreign(Language.Java)]
extern(ANDROID) bool HasSystemAlertWindowPermissionJava()
@{
return com.fuse.immortal.BootCompletedReceiver.hasSystemAlertWindowPermission();
@}
[Foreign(Language.Java)]
extern(ANDROID) void AskForSystemAlertWindowPermissionJava()
@{
com.fuse.immortal.BootCompletedReceiver.askForSystemAlertWindowPermission();
@}
[Foreign(Language.Java)]
extern(ANDROID) bool IsRestartOnDestroyEnabledJava()
@{
return com.fuse.immortal.ImmortalActivity.isRestartOnDestroyEnabled();
@}
[Foreign(Language.Java)]
extern(ANDROID) void EnableRestartOnDestroyJava(bool enabled)
@{
com.fuse.immortal.ImmortalActivity.enableRestartOnDestroy(enabled);
@}
}