#Region Service Attributes
#StartAtBoot: False
'#StartCommandReturnValue: android.app.Service.START_STICKY
#End Region
Sub Process_Globals
Dim OW As OverlayWindow
Dim OBtn_Resize, OBtn_Restore As OverlayButton
Dim OBtn_Analyze As OverlayButton
Dim MaxWidth, MaxHeight As Int
Dim iStartWidth As Int
Dim Timer_Svc As Timer
End Sub
Sub Service_Create
End Sub
Sub Service_Start (StartingIntent As Intent)
'The timer is used to generate fake content for the list
Timer_Svc.Initialize("TimerSvc", 2000)
Timer_Svc.Enabled = True
End Sub
Sub Service_Destroy
'Stops the timer
Timer_Svc.Enabled = False
If OW.IsInitialized Then
'Clears the Listview
Dim LV As ListView = OW.Panel.GetView(0)
LV.Clear
'Closes the window
OW.Close
End If
End Sub
Sub InitWindow
'Creates the overlay window
MaxWidth = GetDeviceLayoutValues.Width
MaxHeight = GetDeviceLayoutValues.Height
'TwoThirds = MaxHeight * 2 / 3
iStartWidth = 60dip
OW.Initialize(0, 0, iStartWidth, MaxHeight , "")
Dim Pnl As Panel = OW.Panel
Pnl.Color = Colors.ARGB(127, 80, 0, 0)
Dim bmpClose As BitmapDrawable
bmpClose.Initialize(LoadBitmap(File.DirAssets, "board1.png"))
Dim mBtn As Panel
mBtn.Initialize("mBtn")
mBtn.Color = Colors.Yellow
mBtn.Background= bmpClose
Pnl.AddView(mBtn, 0, 0, -1, -1)
'Creates the floating buttons
CreateResizeBtn
CreateAnalyzeBtn
End Sub
Sub CreateResizeBtn
OBtn_Resize.Initialize(5dip, 10dip, 40dip, 40dip, "BtnResize")
OBtn_Resize.BindTo(OW)
Dim DrwUp, DrwDown As BitmapDrawable
DrwUp.Initialize(LoadBitmap(File.DirAssets, "resize.png"))
DrwDown.Initialize(LoadBitmap(File.DirAssets, "resize_pressed.png"))
OBtn_Resize.SetStateImages(DrwUp, DrwDown, Null)
End Sub
Sub CreateRestoreBtn
OBtn_Restore.Initialize(5dip, 10, 40dip, 40dip, "BtnRestore")
OBtn_Restore.BindTo(OW)
Dim DrwUp, DrwDown As BitmapDrawable
DrwUp.Initialize(LoadBitmap(File.DirAssets, "restore.png"))
DrwDown.Initialize(LoadBitmap(File.DirAssets, "restore_pressed.png"))
OBtn_Restore.SetStateImages(DrwUp, DrwDown, Null)
End Sub
Sub CreateAnalyzeBtn
OBtn_Analyze.Initialize(5dip, 50dip, 40dip, 40dip, "BtnAnalyze")
OBtn_Analyze.BindTo(OW)
Dim DrwUp, DrwDown As BitmapDrawable
DrwUp.Initialize(LoadBitmap(File.DirAssets, "analyze.png"))
DrwDown.Initialize(LoadBitmap(File.DirAssets, "analyze.png"))
OBtn_Analyze.SetStateImages(DrwUp, DrwDown, Null)
End Sub
Sub ShowWindow
If Not(OW.IsInitialized) Then
InitWindow
End If
If Not(OW.IsOpen) Then
OW.Open
OW.KeepScreenOn = True
End If
OW.Visible = True
End Sub
Sub BtnResize_Click
'The window occupies the whole screen
'OW.X = 55dip
OW.Width = GetDeviceLayoutValues.Width
'Replaces the Resize button by the Restore button
OBtn_Resize.UnbindFrom(OW)
OBtn_Resize.Remove
CreateRestoreBtn
OBtn_Restore.Add
End Sub
Sub BtnRestore_Click
'The window occupies the lower part of the screen
'OW.Y = TwoThirds
OW.Width = iStartWidth
'Replaces the Restore button by the Resize button
OBtn_Restore.UnbindFrom(OW)
OBtn_Restore.Remove
CreateResizeBtn
OBtn_Resize.Add
End Sub
Sub BtnAnalyze_Click
ToastMessageShow("Clicked!",False)
End Sub
Sub TimerSvc_Tick
'Adds a line to the LV
Dim Ticks As Long = DateTime.Now
'Ensures that the window is visible
ShowWindow
End Sub