Code for Main module and Designer Code as well
Hi all, here is the code for my main module along with layout "1" that is essentially a log module. I am trying to keep my phone from crashing when I change orientations.
Code:
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Dim hc As HttpClient
Dim URL As String
URL = "http://cowboy.ath.cx:851/walt/a2.php" 'a2 is authentication db
Dim HttpClient1 As HttpClient
Dim Pin As Int
Dim Company As Long
Dim result As String
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 Button1 As Button
Dim EditText1 As EditText ' phone
Dim EditText2 As EditText ' company name
Dim EditText3 As EditText ' pin code
Dim Label1, Label2, Label3 As Label
Dim Fone As String
Dim txtUID As EditText
Dim txtpin As EditText
Dim txtCO As EditText
Dim chkRememberUID As CheckBox
Dim chkRememberPW As CheckBox
Dim cd As CustomDialog
Dim btn As Button
Dim Color As ColorDialog
Dim Orientation As String
End Sub
Sub btn_Click
cd.Show("", "Login", "", "", Null)
Log(txtUID)
Log(txtpin)
Log(txtCO)
Button1_Click
End Sub
Sub Activity_Create(FirstTime As Boolean)
If Activity.Width > Activity.Height Then
Orientation = "Landscape"
Else
Orientation = "Portait"
End If
If FirstTime Then
hc.Initialize("hc")
Activity.LoadLayout("1")
End If
Label2.Initialize("")
Label2.Text = "SINCADS Mobility App"
Label2.TextColor = Colors.DarkGray
Label2.TextSize = 18
Activity.AddView(Label2, 60dip, 0dip, 300dip, 40dip)
Label3.Initialize("")
Label3.Text = "@Cyber Storm technologies Group 2011 - 2012"
Label3.TextColor = Colors.DarkGray
Label3.TextSize = 13
Activity.AddView(Label3, 20dip, 380dip, 380dip, 40dip) ' this is label3 "SINCADS" footer
' Activity.Color
btn.Initialize("btn")
btn.Text = "Click for System Login"
Activity.AddView(btn,80dip,100dip,150dip,100dip)
Dim pnl1 As Panel
pnl1.Initialize ("")
cd.AddView(pnl1, 0, 30dip, 450dip, 200dip)
Dim lblUID As Label
lblUID.Initialize("")
lblUID.Text = "User Name: "
lblUID.TextSize = 16
pnl1.AddView(lblUID, 20dip, 5dip, 100dip, 40dip)
txtUID.Initialize("")
txtUID.Hint = "Enter User Name"
pnl1.AddView(txtUID, 110dip, 0dip, 165dip, 40dip)
Dim lblpin As Label
lblpin.Initialize("")
lblpin.Text = "Password: "
lblpin.TextSize = 16
pnl1.AddView(lblpin, 20dip, 50dip, 100dip, 40dip)
txtpin.Initialize("")
txtpin.Hint = "Enter Password"
txtpin.PasswordMode = True
pnl1.AddView(txtpin, 110dip, 45dip, 165dip, 40dip)
Dim lblCO As Label
lblCO.Initialize("")
lblCO.Text = "Company #: "
lblCO.TextSize = 16
pnl1.AddView(lblCO, 20dip, 85dip, 165dip, 40dip)
txtCO.Initialize("")
txtCO.Hint = "Enter Company #"
txtCO.PasswordMode = True
pnl1.AddView(txtCO, 110dip, 85dip, 165dip, 40dip)
chkRememberUID.Initialize("")
chkRememberUID.Text = "Remember UID"
pnl1.AddView(chkRememberUID, 85dip, 120dip, 210dip, 40dip)
chkRememberPW.Initialize("")
chkRememberPW.Text = "Remember PW"
pnl1.AddView(chkRememberPW, 85dip, 155dip, 210dip, 40dip)
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub Button1_Click
Dim btn As Button
btn = Sender 'Fetch the actual button that raised this event.
CurrentTask = btn.Tag 'Take the object from its Tag property.
Dim request As HttpRequest
request.InitializeGet(URL & "?Fone=" & txtUID.Text & "&pincode=" & txtpin.Text & "&company=" & txtCO.Text & "&edit=Register")
Log(request)
If hc.Execute(request, 1) = False Then Return 'Will be false if their is already a running task (with the same id).
End Sub
Sub hc_ResponseSuccess (Response As HttpResponse, TaskId As Int)
ProgressDialogHide
result = Response.GetString ("UTF8") ' Convert the response to a string
Log(result)
StartActivity(SelectionList)
End Sub