Sub Process_Globals
Dim num As Int
Dim javacode As String
Dim thisUrl As String
Dim thisHTML As String
Dim copyText As String
End Sub
Sub Globals
Private imgMenu As ImageView
Private txtAddress As AutoCompleteEditText
Private imgGo As ImageView
Private pnlTop As Panel
Private pnlBottom As Panel
'Dim WebViewExtras1 As WebViewExtras
Dim WebView1 As WebView
Dim FocusedView As View
Dim ActionMode As JavaObject
Private imgLookup As ImageView
Private imgHistory As ImageView
Private imgMore As ImageView
Private pnlContent As Panel
Private pnlAddress As Panel
Private imgClear As ImageView
Dim mnWeb As RSPopupMenu
Dim sql As clsFindWords
Private lblCount As Label
Dim playSound As MediaPlayer
Dim AdView1 As AdView
Private we As WebViewExtras
Dim client As DefaultWebViewClient
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("layout_copyweb1")
AdView1.Initialize("Ad", mUniform.bannerID)
sql.Initialize
pnlTop.Color = mUniform.subColor
pnlBottom.Color = mUniform.subColor
lblCount.TextColor = mUniform.subColor
lblCount.Color = Colors.White
'imgMenu.Initialize("imgMenu")
'imgGo.Initialize("imgGo")
WebView1.Initialize("WebView1")
we.Initialize(WebView1)
client.Initialize("client")
Dim jo As JavaObject = WebView1
Dim settings As JavaObject = jo.RunMethod("getSettings", Null)
settings.RunMethod("setDomStorageEnabled", Array(True))
pnlContent.AddView(WebView1, 0, 0, pnlContent.Width, pnlContent.Height - 50dip)
'WebView1.Left = 0
pnlContent.AddView(AdView1, 0, pnlContent.Height - 50dip, 100%x, 50dip)' AdView1.LoadAd 'loads an ad
AdView1.LoadAd
WebView1.JavaScriptEnabled = True
'WebViewExtras1.addJavascriptInterface(WebView1, "B4A")
'javacode = File.ReadString(File.DirAssets, "java.txt")
we.SetWebViewClient(client)
'Dim websetting As WebSettings
add the B4A javascript interface to the WebView
txtAddress.InputType = Bit.Or(txtAddress.INPUT_TYPE_TEXT, 0x00080000)
txtAddress.Color = Colors.Transparent
pnlAddress.Color = mUniform.mainColor
mnWeb.Initialize("mnWeb", imgMenu)
mnWeb.AddMenuItem(1, 1, "Bookmark this page...")
'mnWeb.AddMenuItem(2, 2, "History")
'mnWeb.AddMenuItem(3, 3, "Delete history")
mnWeb.AddMenuItem(4, 4, "Zoomin")
mnWeb.AddMenuItem(5, 5, "Zoomout")
mnWeb.AddMenuItem(6, 6, "Referesh")
Dim bookmark As List
bookmark = sql.GetBookmark
txtAddress.SetItems(bookmark)
playSound.Initialize()
playSound.Load(File.DirAssets, "complete.wav")
num = num + 1
EnableSlowWebViewDocumentDraw
'Dim job As HttpJob
'job.Initialize("j", Me)
'job.Download(WebView1.Url)
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub Activity_KeyPress (KeyCode As Int) As Boolean
'Pressing the back key while the slidemenu is open will close it
If KeyCode = KeyCodes.KEYCODE_BACK Then
Activity.Finish
End If
End Sub
Sub client_ReceivedError (ErrorCode As Int, Description As String, FailingUrl As String)
End Sub
Sub client_ReceivedSslError(SslErrorHandler1 As SslErrorHandler, SslError1 As SslError)
SslErrorHandler1.Cancel
'Log(SslError1)
' Dim Error(7) As String
'Error(0) = "The date of the certificate is invalid."
'Error(1) = "The certificate has expired."
'Error(2) = "Hostname mismatch."
'Error(3) = "A generic Error occurred."
'Error(4) = "This constant was deprecated in API level 14. This constant is not necessary for using the SslError API and can change from release to release."
'Error(5) = "The certificate is not yet valid."
'Error(6) = "The certificate authority is not trusted."
'Dim id As Int = SslError1.SSL_DATE_INVALID
'Dim DR As Int
'Dim dialogErr As BetterDialogs
'DR = dialogErr.Msgbox("<B>Certificate Alarm</B>", Error(id), "Cancel", "Continue", "", "")
'If DR = -2 Then
' SslErrorHandler1.Proceed
'Else
'End If
End Sub
Sub Ad_FailedToReceiveAd (ErrorCode As String)
'webContent.Height = pnlContent.Height
WebView1.Height = pnlContent.Height
End Sub
Sub Ad_ReceiveAd
WebView1.Height = pnlContent.Height - 50dip
End Sub
Sub imgMenu_Click
mnWeb.Show
End Sub
Sub WebView1_PageFinished (Url As String)
txtAddress.Text = Url
End Sub
Sub mnWeb_MenuItemClick (ItemId As Int) As Boolean
If ItemId = 1 Then
If txtAddress.Text <> "" Then
sql.AddBookMark(txtAddress.Text)
'Msgbox(txtAddress.Text,"")
End If
Else If ItemId = 2 Then
Else If ItemId = 3 Then
sql.DeleteHistory'
Else If ItemId = 4 Then
WebView1.Zoom(True) ' out
Else If ItemId = 5 Then
WebView1.Zoom(False) ' out
Else If ItemId = 6 Then
WebView1.LoadUrl(txtAddress.Text) ' out
End If
Return False
End Sub
Sub txtAddress_TextChanged (Old As String, New As String)
End Sub
Sub imgGo_Click
If txtAddress.Text <> "" Then
If txtAddress.Text.StartsWith("http") = False Then
txtAddress.Text = "https://" & txtAddress.Text
End If
End If
WebView1.LoadUrl(txtAddress.Text)
sql.AddWebHistory(txtAddress.Text)
End Sub
Sub MenuItem_Click
'WebView1.EnableSelectionMode
End Sub
Sub WebView1_SelectionReady(SelectedText As String)
'Msgbox(SelectedText, "Selected text:")
playSound.Play
If mUniform.copyFromWeb = "" Then
mUniform.copyFromWeb = SelectedText
Else
mUniform.copyFromWeb = mUniform.copyFromWeb & "</br>" & SelectedText
End If
mUniform.countCopy = mUniform.countCopy + 1
lblCount.Text = mUniform.countCopy
End Sub
Sub imgClear_Click
txtAddress.Text = ""
End Sub
Sub EnableSlowWebViewDocumentDraw
Dim p As Phone
If p.SdkVersion >= 21 Then
Dim jo As JavaObject
jo.InitializeStatic("android.webkit.WebView").RunMethod("enableSlowWholeDocumentDraw", Null)
End If
End Sub
Sub txtAddress_ItemClick (Value As String)
WebView1.LoadUrl(txtAddress.Text)
End Sub
Sub imgClosePopup_Click()
'pnlPopup.SendToBack
End Sub
Sub imgBack_Click
WebView1.Back
End Sub
Sub imgNext_Click
WebView1.Forward
End Sub