#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
End Sub
Sub Globals
Private btnUploadAuth As Button
Private btnDownloadPublic As Button
Private btnUploadUser As Button
Private btnSignIn As Button
Private lblUser As Label
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("1")
End Sub
Sub Activity_Resume
If Starter.auth.CurrentUser.IsInitialized Then SignedIn
End Sub
Public Sub SignedIn
btnSignIn.Enabled = False
btnUploadAuth.Enabled = True
btnUploadUser.Enabled = True
lblUser.Text = $"User: ${Starter.auth.CurrentUser.DisplayName}"$
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub btnSignIn_Click
Starter.auth.SignInWithGoogle
End Sub
Sub btnUploadUser_Click
File.WriteString(File.DirInternalCache, "1.txt", "Only I can access this resource.")
Starter.storage.UploadFile(File.DirInternalCache, "1.txt", $"/user/${Starter.auth.CurrentUser.Uid}/1.txt"$)
End Sub
Sub btnDownloadPublic_Click
'You need to first upload a file from Firebase console.
Starter.storage.DownloadFile("/public/1.txt", File.DirInternalCache, "1.txt")
End Sub
Sub btnUploadAuth_Click
File.WriteString(File.DirInternalCache, "1.txt", "Any authenticated user can access this resource.")
Starter.storage.UploadFile(File.DirInternalCache, "1.txt", $"/auth/1.txt"$)
End Sub
Sub Storage_DownloadCompleted (ServerPath As String, Success As Boolean)
ToastMessageShow($"DownloadCompleted. Success = ${Success}"$, True)
If Not(Success) Then Log(LastException)
End Sub
Sub Storage_UploadCompleted (ServerPath As String, Success As Boolean)
ToastMessageShow($"UploadCompleted. Success = ${Success}"$, True)
If Not(Success) Then Log(LastException)
End Sub