-
Notifications
You must be signed in to change notification settings - Fork 0
/
Tile_Shortcut.cs
91 lines (77 loc) · 2.67 KB
/
Tile_Shortcut.cs
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
using Android.App;
using Android.Content;
using Android.Graphics.Drawables;
using Android.Service.QuickSettings;
using Java.Lang;
namespace Scan2ClipBoard
{
[Service(Name = "com.otaltan.Scan2ClipBoard.Tile_Shortcut",
Permission = Android.Manifest.Permission.BindQuickSettingsTile,
Label = "S2C",
Icon = "@drawable/Tile_S2C")]
[IntentFilter(new[] { ActionQsTile })]
public class Tile_Shortcut : TileService
{
//First time tile is added to quick settings
public override void OnTileAdded()
{
base.OnTileAdded();
}
//Called each time tile is visible
public override void OnStartListening()
{
base.OnStartListening();
//Tile associated with the service
var tile = QsTile;
//Update label, icon, description, and state
tile.Icon = Icon.CreateWithResource(this, Resource.Drawable.Tile_S2C);
tile.Label = "S2C";
//Set state here and UI will respond automatically
tile.State = TileState.Inactive;
tile.UpdateTile();
}
//Called when tile is no longer visible
public override void OnStopListening()
{
base.OnStopListening();
}
//Called when tile is removed by the user
public override void OnTileRemoved()
{
base.OnTileRemoved();
}
public override void OnClick()
{
base.OnClick();
//Tile associated with the service
var tile = QsTile;
//Update label, icon, description, and state
tile.Icon = Icon.CreateWithResource(this, Resource.Drawable.Tile_S2C);
tile.Label = "S2C";
//Set state here and UI will respond automatically
tile.State = TileState.Active;
tile.UpdateTile();
if (IsLocked)
{
// Start the app after unlocking the phone
UnlockAndRun(new Runnable(() =>
{
//Start the App
Intent i = new Intent(this, typeof(MainActivity));
i.AddFlags(ActivityFlags.NewTask);
StartActivityAndCollapse(i);
}));
}
else
{
//Start the App
Intent i = new Intent(this, typeof(MainActivity));
i.AddFlags(ActivityFlags.NewTask);
StartActivityAndCollapse(i);
}
//Set state here and UI will respond automatically
tile.State = TileState.Inactive;
tile.UpdateTile();
}
}
}