This path is my smartphone.
The code:
#Region Module Attributes
#FullScreen: True
#IncludeTitle: False
#ApplicationLabel: FTP Auto Sample
#VersionCode: 1
#VersionName: 1.0.1
#SupportedOrientations: landscape
#CanInstallToExternalStorage: False
#End Region
'APP Name: FTP Auto Sample
'Last Mod: March 24th, 2014
'Written By: Margret
'Location: Home System
'Version: For Library Version - 1.06
'Created In: B4A Version 3.2
#Region Activity Variables
Sub Process_Globals
End Sub
Sub Globals
Dim FTP As FTP_Auto
FTP.Initialize(Activity, Me, "ftp.domain.com", "username", "password", 21, False, False)
'Just used for the Layout*********************
Private Pmain, p1 As Panel '*
Private b1, b2, b3, b4, fset As Button '*
Private l1 As Label '*
Dim FTPSet, Pmain As Panel '*
Private mmap As Map : mmap.Initialize '*
Private ETdomain, ETuser, ETpass As EditText'*
'*********************************************
End Sub
#End Region
#Region Activity Create, Resume, etc.
Sub Activity_Create(FirstTime As Boolean)
SetDisplay
AddMenuItems
End Sub
Sub Activity_Resume
DoFTPInitialize
If Not(FTP.WiFi_IsConnected) Then
Msgbox("WiFi Is Off. Turn WiFi On And Restart App.", "NOTICE")
Activity.Finish
End If
File.MakeDir(File.DirInternal, "downloads")
End Sub
Sub Activity_KeyPress(KeyCode As Int) As Boolean
If KeyCode = KeyCodes.KEYCODE_BACK Then
Activity.Finish 'Exit Program
End If
End Sub
#End Region
#Region Set The Display & Menu Items
Sub SetDisplay
Activity.LoadLayout("acti")
Pmain.Width = Activity.Width
Pmain.Height = Activity.Height
l1.Width = Activity.Width
p1.Width = Activity.Width
Dim wherew As Int = (Activity.Width/2) - (b1.Width/2)
Dim wherev As Int = ((Activity.Height-40)/4) - (b1.Height/2)
b1.Left = wherew
b2.Left = wherew
b3.Left = wherew
b4.Left = wherew
b1.Top = wherev *1
b2.Top = wherev *2
b3.Top = wherev *3
b4.Top = wherev *4
End Sub
Sub AddMenuItems
File.MakeDir(File.DirInternal, "storage/emulated/0/Download")
File.Copy(File.DirAssets, "cropped-modal-min.jpg", File.DirInternal & "/storage/emulated/0/Download", "sample1.jpg")
File.Copy(File.DirAssets, "sample2.jpg", File.DirInternal & "/storage/emulated/0/Download", "sample2.jpg")
File.Copy(File.DirAssets, "sample3.jpg", File.DirInternal & "/storage/emulated/0/Download", "sample3.jpg")
Activity.AddMenuItem("Server Setup", "ServerSet")
Activity.AddMenuItem("Change Color", "CC")
Activity.AddMenuItem("Stealth On", "Stealth")
Activity.AddMenuItem("Sticky On", "Sticky")
Activity.AddMenuItem("Change Text Size", "ChangeTextSize")
Activity.AddMenuItem("Change Text", "ChangeText")
Activity.AddMenuItem("Set Progress Complete", "SetProgressOn")
Activity.AddMenuItem("Show Dialogs", "SetStealthDialogs")
End Sub
#End Region
#Region Buttons Click & Callback Events
Sub FTP_ProcessComplete
'If you use: FTP.SetProcessCompleteOn(True), this sub will be called after the last
'process completes.
Msgbox("Process Complete...", "NOTICE")
End Sub
Sub b1_Click 'Upload a single file, create folder first if it does not exist.
Log("Sending File...")
FTP.MakeDir("ftpsample")
FTP.UpLoadFile(File.DirAssets, "ftpsample", "ftpsample.jpg")
End Sub
Sub b2_Click 'Download a single file.
Log("Downloading File...")
'This command will call FTP_FileExist when finished.
FTP.FileOrFolderExist("ftpsample.jpg" , "ftpsample" , False)
End Sub
Sub FTP_FileExist(Found As Boolean)
'If you use: FTP.FileOrFolderExist(), this sub will be called as the process
'completes. Be sure to include this sub.
If Found Then
FTP.DownLoadFile(File.DirInternal & "/storage/emulated/0/Download", "ftpsample", "ftpsample.jpg", False)
Else
Msgbox("No Such File Found...", "NOTICE")
End If
End Sub
Sub b3_Click 'Uploads a file set with a wildcard, creates the folder if it does not exist.
Log("Sending File Set...")
FTP.MakeDir("ftpsample")
Dim SendFiles As String = File.DirInternal & "/storage/emulated/0/Download/*.jpg"
Log(SendFiles)
FTP.UploadFileSet("ftpsample", Array As String(SendFiles), False)
End Sub
Sub b4_Click 'Downloads a file set with a wildcard.
Log("Downloading File Set...")
Dim GetFiles As String = "ftpsample/*.jpg"
FTP.DownloadFileSet(File.DirInternal & "/storage/emulated/0/Download", Array As String(GetFiles), False)
End Sub
#End Region
#Region Change FTP Settings
Sub DoFTPInitialize
If File.Exists(File.DirInternal, "ftpsettings.map") Then
mmap = File.ReadMap(File.DirInternal, "ftpsettings.map")
FTP.Initialize(Activity, Me, mmap.Get("domain"), mmap.Get("user"), mmap.Get("pass"), 21, False, False)
Else
ChangeFTP
End If
End Sub
Sub ChangeFTP
FTPSet.Initialize("FTPSet")
Activity.AddView(FTPSet, 0, 0, Activity.Width, Activity.Height)
FTPSet.LoadLayout("ftpset")
Pmain.Left = Activity.Width/2 - Pmain.Width/2
Pmain.Top = Activity.Height/2 - Pmain.Height/2
If File.Exists(File.DirInternal, "ftpsettings.map") Then
mmap = File.ReadMap(File.DirInternal, "ftpsettings.map")
ETdomain.Text = mmap.Get("domain")
ETuser.Text = mmap.Get("user")
ETpass.Text = mmap.Get("pass")
End If
End Sub
Sub fset_Click
FTPSet.RemoveView
mmap.Put("domain", ETdomain.TexT)
mmap.Put("user", ETuser.TexT)
mmap.Put("pass", ETpass.TexT)
File.WriteMap(File.DirInternal, "ftpsettings.map", mmap)
DoFTPInitialize
End Sub
Sub ServerSet_Click
ChangeFTP
End Sub
Sub CC_Click
'Allows you to change the colors to anything you wish.
FTP.SetColors(Colors.White, Colors.White, Colors.White, Colors.Black, Colors.White)
End Sub
Sub Stealth_Click
'This causes the FTP dialog to not show and stay hidden. You can set: FTP.SetProcessCompleteOn(True)
'to call a sub when completed. See SetProgressOn_Click below. If you don't set
'FTP.SetProcessCompleteOn(True), there will be no indication if the process is complete
'or is still working.
FTP.SetStealthOn(True)
End Sub
Sub Sticky_Click
'This causes the FTP dialog to stay on the screen after the process, until the done button
'is clicked.
FTP.SetStickyOn(True)
End Sub
Sub ChangeTextSize_Click
'Changes the text size that the dialog displays.
FTP.SetTextSize(12,10,10,12)
End Sub
Sub ChangeText_Click
'This changes the text to what you want on the FTP dialog
FTP.SetText("Getting Files...", "Sending Files...", "Overall", "Each File", "Abort", "Finished")
End Sub
Sub SetProgressOn_Click
'This set to true will call a sub named: FTP_ProcessComplete if you have added it, when
'the process called completes it's task.
FTP.SetProcessCompleteOn(True)
End Sub
Sub SetStealthDialogs_Click
FTP.SetStealthOn(True)
FTP.SetCompletedDownloadDialog(True, "Update is Available")
FTP.SetCompletedUploadDialog(True, "All Files Transfered To Server")
End Sub
#End Region