-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathHomeScreen.uno
More file actions
60 lines (52 loc) · 1.23 KB
/
Copy pathHomeScreen.uno
File metadata and controls
60 lines (52 loc) · 1.23 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
using Uno;
using Uno.Collections;
using Fuse;
using Fuse.Triggers.Actions;
using Uno.Compiler.ExportTargetInterop;
public enum HomeScreenType
{
Finish,
CallIntent,
}
public class HomeScreen : TriggerAction
{
HomeScreenType _type = HomeScreenType.Finish;
public HomeScreenType Type
{
get { return _type; }
set
{
_type = value;
}
}
protected override void Perform(Node target)
{
if defined(Android)
{
if (Type == HomeScreenType.Finish) {
ExitAppFinish();
}
else if (Type == HomeScreenType.CallIntent) {
ExitAppIntent();
}
}
else {
debug_log "HomeScreen only defined for Android";
}
}
[Foreign(Language.Java)]
public static extern(Android) void ExitAppFinish()
@{
android.app.Activity a = @(Activity.Package).@(Activity.Name).GetRootActivity();
a.finish();
@}
[Foreign(Language.Java)]
public static extern(Android) void ExitAppIntent()
@{
android.content.Intent callIntent = new android.content.Intent(android.content.Intent.ACTION_MAIN);
callIntent.addCategory(android.content.Intent.CATEGORY_HOME);
callIntent.setFlags(android.content.Intent.FLAG_ACTIVITY_NEW_TASK);
android.app.Activity a = @(Activity.Package).@(Activity.Name).GetRootActivity();
a.startActivity(callIntent);
@}
}