#Region Project Attributes
#ApplicationLabel: B4A Example
#VersionCode: 1
#VersionName:
'SupportedOrientations possible values: unspecified, landscape or portrait.
#SupportedOrientations: unspecified
#CanInstallToExternalStorage: False
#End Region
#Region Activity Attributes
#FullScreen: False
#IncludeTitle: True
#End Region
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Dim auth As DbxAuth
Dim Dropbox As DropboxV2
Dim token As String
Dim DropboxEnabled As Boolean
Dim client As DbxClientV2
Dim config As DbxRequestConfig
Dim dbxFiles As DbxUserFilesRequests
Dim dbxSharing As DbxUserSharingRequests
Dim dbxUsers As DbxUserUsersRequests
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.
Private btnStartOAuth As Button
Private lblToken As Label
Private btnListroot As Button
Private downloadrunning As Boolean
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("OAuth")
Dim dummy As String
dummy = Starter.kvs.GetDefault("token", "")
If dummy <> "" Then
token = dummy
lblToken.Text = token
Log("Token available (Activity Create. Try to enable Dropbox with this token")
config.Initialize("",token,"","de-de",5)
Dim dbxhost As DbxHost
dbxhost.Initialize
client.Initialize("Dropbox",config,token,dbxhost)
dbxFiles = client.files
dbxFiles.setEventname("dbxFiles")
dbxSharing = client.sharing
dbxSharing.setEventname("dbxSharing")
dbxUsers = client.users
dbxUsers.setEventname("dbxUsers")
End If
btnListroot.Enabled = False
DropboxEnabled = False
Dropbox.Initialize("")
auth.Initialize("8bgblt25ldqwh70")
downloadrunning = False
End Sub
Sub Activity_Resume
If auth.OAuth2Token <> Null Then
If auth.OAuth2Token <> "" Then
token = auth.OAuth2Token
lblToken.Text = token
DropboxEnabled = True
btnListroot.Enabled = True
Starter.kvs.Put("token", token)
Log("Token available. Dropbox enabled")
config.Initialize("",token,"","de-de",5)
Dim dbxhost As DbxHost
dbxhost.Initialize
client.Initialize("Dropbox",config,token,dbxhost)
dbxFiles = client.files
dbxFiles.setEventname("dbxFiles")
dbxSharing = client.sharing
dbxSharing.setEventname("dbxSharing")
dbxUsers = client.users
dbxUsers.setEventname("dbxUsers")
Else
Log($"Token = """$)
End If
Else
Log("Token is NULL")
If token <> "" Then
Log("Try to use the known token...")
'dbxFiles.listFolder("/B4A/",False,True,False,True,false)
'dbxSharing.listFolders ' Tested!
dbxUsers.CurrentAccount ' Tested!
End If
End If
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub btnStartOAuth_Click
auth.startOAuth2Authentication
End Sub
Sub btnListroot_Click
dbxFiles.listFolder("",False,True,False,True,True)
'dbxSharing.listFolders ' Tested!
'dbxUsers.CurrentAccount ' Tested!
End Sub
Sub dbxSharing_listFolders(success As Boolean, folders As List, error As String)
Log($"dbxSharing_listFolders(${success}, ${folders.Size}, ${error})"$)
If folders.Size > 0 Then
For i = 0 To folders.Size-1
Dim meta As SharedFolderMetadata = folders.Get(i)
'Log(meta.toString)
Next
End If
End Sub
Sub dbxSharing_AddFileMember(success As Boolean, members As List, error As String)
Log($"dbxSharing_listFolders(${success}, ${members.Size}, ${error})"$)
End Sub
Sub dbxSharing_listMountableFolders(success As Boolean, folders As List, error As String)
Log($"dbxSharing_listFolders(${success}, ${folders.Size}, ${error})"$)
End Sub
Sub dbxSharing_listReceivedFiles(success As Boolean, receivedFiles As List, error As String)
Log($"dbxSharing_listFolders(${success}, ${receivedFiles.Size}, ${error})"$)
End Sub
Sub dbxSharing_listSharedLinks(success As Boolean, sharedLinks As List, error As String)
Log($"dbxSharing_listFolders(${success}, ${sharedLinks.Size}, ${error})"$)
End Sub
Sub dbxSharing_SharedFolderMetadata(success As Boolean, meta As SharedFolderMetadata, error As String)
Log($"dbxSharing_listFolders(${success}, ${meta.toString}, ${error})"$)
End Sub
Sub dbxFiles_DownloadFinished(success As Boolean, meta As FileMetadata, error As String)
Log($"dbxFiles_DownloadFinished(${success}, ${meta}, ${error})"$)
End Sub
Sub dbxFiles_listFolder(success As Boolean, content As List, error As String)
Log($"dbxFiles_listFolders(${success}, ${content.Size}, ${error})"$)
If content.Size > 0 Then
For i = 0 To content.Size-1
Dim meta As Metadata = content.Get(i)
'Log(meta.toString)
Next
End If
End Sub
Sub dbxFiles_CopyBatch(success As Boolean, meta As Map, error As String)
End Sub
Sub dbxFiles_CopyBatchCheck(success As Boolean, meta As Map, error As String)
End Sub
Sub dbxFiles_CopyReference(metainfo As Map)
End Sub
Sub dbxFiles_CreateFolder(success As Boolean, meta As FolderMetadata, error As String)
End Sub
Sub dbxFiles_ListRevisions(success As Boolean, meta As Map, error As String)
End Sub
Sub dbxFiles_MoveBatch(success As Boolean, meta As Map, error As String)
End Sub
Sub dbxFiles_MoveBatchCheck(success As Boolean, meta As Map, error As String)
End Sub
Sub dbxFiles_Restore(success As Boolean, meta As FileMetadata, error As String)
End Sub
Sub dbxFiles_UploadFinished(success As Boolean, meta As FileMetadata, error As String)
End Sub
Sub dbxUsers_getAccount(account As BasicAccount)
Log($"dbxUsers_getAccount(${account})"$)
End Sub
Sub dbxUsers_getAccountBatch(batch As List)
End Sub
Sub dbxUsers_getCurrentAccount(account As FullAccount)
Log($"dbxUsers_getCurrentAccount(${account})"$)
End Sub