Sub Process_Globals
Type Control(Name As String, ActionBtn As Byte, ActionSub As String, MinChar As Int, MaxChar As Int, Uppercase As Boolean, PrevView As View, NextView As View)
Dim Alpha, Numeric, Punctuation As String
End Sub
Sub Init
Alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
Numeric = "0123456789"
Punctuation = "!@#$%&*()-+=,.;:?/'" & QUOTE
End Sub
Sub CreateLabel(Text As String, Color As Int) As Label
Dim myControl As Label
Dim ref As Reflector
myControl.Initialize("")
myControl.Text = Text
myControl.TextColor = Color
myControl.TextSize = 16
myControl.Typeface = Typeface.DEFAULT_BOLD
ref.Target = myControl
ref.RunMethod2("setLines", 1, "java.lang.int")
ref.RunMethod2("setHorizontallyScrolling", True, "java.lang.boolean")
ref.RunMethod2("setEllipsize", "MARQUEE", "android.text.TextUtils$TruncateAt")
ref.RunMethod2("setMarqueeRepeatLimit", -1, "java.lang.int")
ref.RunMethod2("setSelected", True, "java.lang.boolean")
Return myControl
End Sub
Sub CreateEdit(Name As String, Text As String, Hint As String, MultiLine As Boolean, DataType As Byte, ActionBtn As Byte, ActionSub As String, MinChar As Int, MaxChar As Int, Uppercase As Boolean, PrevView As View) As EditText
' DataType: 0=Text, 1=Sentence, 2=Alpha, 3=Numeric, 4=AlphaNumeric, 5=Float, 6=Password, 7=Email, 8=URL, 9=Phone, 10=Name, 11=DateTime, 12=Date, 13=Time
' ActionBtn: 0=Next, 1=Done, 2=Previous, 3=Go, 4=Search, 5=Send
Dim ref As Reflector
Dim IME As IME
Dim myControl As EditText
Dim baseOptions As Int
Dim controlBag As Control
myControl.Initialize("Edit")
IME.Initialize("IME")
controlBag.Initialize
controlBag.ActionBtn = ActionBtn
controlBag.ActionSub = ActionSub
controlBag.MaxChar = MaxChar
controlBag.MinChar = MinChar
controlBag.Name = Name
controlBag.PrevView = PrevView
controlBag.Uppercase = Uppercase
myControl.Tag = controlBag
If PrevView Is View Then
If PrevView.Tag Is Control Then
controlBag = PrevView.Tag
controlBag.NextView = myControl
End If
End If
myControl.Text = Text
myControl.Hint = Hint
baseOptions = 268435456
If MultiLine Then
myControl.SingleLine = False
myControl.Wrap= True
baseOptions = Bit.Or(baseOptions, 1073741824)
Else
myControl.SingleLine = True
myControl.Wrap= False
End If
Select Case DataType
Case 0 ' Text
myControl.InputType = 1
Case 1 ' Sentence
myControl.InputType = 16385
IME.SetCustomFilter(myControl, myControl.InputType, Alpha & Numeric & Punctuation)
Case 2 ' Alpha
myControl.InputType = 1
IME.SetCustomFilter(myControl, myControl.InputType, Alpha)
Case 3 ' Numeric
myControl.InputType = 2
IME.SetCustomFilter(myControl, myControl.InputType, Numeric)
Case 4 ' AlphaNumeric
myControl.InputType = 1
IME.SetCustomFilter(myControl, myControl.InputType, Alpha & Numeric)
Case 5 ' Float
myControl.InputType = 12290
IME.SetCustomFilter(myControl, myControl.InputType, Numeric & "-.")
Case 6 ' Password
myControl.InputType = 129
Case 7 ' Email
myControl.InputType = 33
Case 8 ' URL
myControl.InputType = 17
Case 9 ' Phone
myControl.InputType = 3
Case 10 ' Name
myControl.InputType = 8289
Case 11 ' DateTime
myControl.InputType = 4
Case 12 ' Date
myControl.InputType = 20
Case 13 ' Time
myControl.InputType = 36
End Select
If Uppercase Then myControl.InputType = Bit.Or(myControl.InputType, 4096)
'flagNoExtractUi= 268435456
'flagNoEnterAction= 1073741824
'imeOptions
Select Case ActionBtn
Case 0 ' Next 5
ref.Target = myControl
ref.RunMethod2("setImeOptions", Bit.Or(baseOptions, 5), "java.lang.int")
Case 1 ' Done 6
ref.Target = myControl
ref.RunMethod2("setImeOptions", Bit.Or(baseOptions, 6), "java.lang.int")
Case 2 ' Previous 7
ref.Target = myControl
ref.RunMethod2("setImeOptions", Bit.Or(baseOptions, 7), "java.lang.int")
Case 3 ' Go 2
ref.Target = myControl
ref.RunMethod2("setImeOptions", Bit.Or(baseOptions, 2), "java.lang.int")
Case 4 ' Search 3
ref.Target = myControl
ref.RunMethod2("setImeOptions", Bit.Or(baseOptions, 3), "java.lang.int")
Case 5 ' Send 4
ref.Target = myControl
ref.RunMethod2("setImeOptions", Bit.Or(baseOptions, 4), "java.lang.int")
End Select
IME.AddHandleActionEvent(myControl)
Return myControl
End Sub