Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
End Sub
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
' Dim dropbox As Dropbox
Dim drive As GoogleDrive
Dim cr As CloudRail
' Dim places As GooglePlaces
Dim rp As RuntimePermissions
Dim driveToken ="" As String
End Sub
Sub Activity_Create(FirstTime As Boolean)
'Do not forget to load the layout file created with the visual designer. For example:
'Activity.LoadLayout("Layout1")
cr.Initialize("CloudRail","ApiKey")
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub Activity_PermissionResult (Permission As String, Result As Boolean)
If Permission = rp.PERMISSION_WRITE_EXTERNAL_STORAGE Then
End If
End Sub
Sub CloudRail_Ready(Success As Boolean)
Log($"CloudRail_Ready(${Success})"$)
File.Copy(File.DirAssets,"impostazioni",File.DirDefaultExternal,"impostazioni") ' Copy one file for example from assets to DirDefaultExternal...
If Success Then
If Starter.kvs.ContainsKey("token") Then
driveToken = Starter.kvs.Getsimple("token")
End If
drive.Initialize("Drive","IdClient","ClientSecret")
End If
End Sub
Sub Drive_Ready(Success As Boolean)
Log($"Drive_Ready(${Success})"$)
If driveToken.Length>0 Then drive.loadAsString(driveToken)
drive.exists("/Tempfold")
End Sub
Sub Drive_DownloadFinished(success As Boolean, info As String, filePath As String, destPath As String, destFile As String)
Log($"Drive_DownloadFinished(${destFile}->${success},${destFile},${filePath})"$)
save_token
End Sub
Sub Drive_UploadFinished(destPath As String, info As String, success As Boolean)
Log($"Uploaded file ${destPath}, ${info}, ${success}"$)
save_token
drive.download("/Tempfold/impostazioni",rp.GetSafeDirDefaultExternal("Download"),"impostazioni")
End Sub
Sub Drive_CreateFolder(folderPath As String)
Log($"Drive folder created"$)
save_token
Msgbox("Cartella " & folderPath & " Creata","Drive")
If folderPath = "/Tempfold" Then
drive.upload(File.Combine(File.DirDefaultExternal,"impostazioni"), folderPath & "/impostazioni", File.Size(File.DirDefaultExternal,"impostazioni"), True)
End If
End Sub
Sub Drive_Exists(Path As String, exists As Boolean)
save_token
If exists Then
Msgbox("Cartella " & Path & " esistente","Drive")
Drive_CreateFolder(Path)
Else
drive.createFolder("/Tempfold")
End If
End Sub
Sub Drive_Login(Success As Boolean)
save_token
End Sub
Sub drive_Children(directories As List, listoffiles As List)
Log("dir:" & directories)
Log("files :"& listoffiles)
save_token
End Sub
Sub save_token
Log($"Save Token"$)
Dim t As String = drive.saveAsString
Log("Token="&t)
driveToken = t
Starter.kvs.PutSimple("token", driveToken)
End Sub