Is there anyone can guide me how to migrate those custom view on UltimateWebView into UltimateWebView2 ?
Private Sub UltimateWebView1_FileDownloadInitialized (DownloadProperties1 As DownloadProperties) 'Works from API level 1 and above. DownloadListener required.
Log("Download INITIALIZED")
'Log(DownloadProperties1.url)
'Log(DownloadProperties1.userAgent)
'Log(DownloadProperties1.contentDisposition)
'Log(DownloadProperties1.mimeType)
'Log(DownloadProperties1.contentLength)
'Log(DownloadProperties1.cookies)
'Log(DownloadProperties1.fileName)
'Log(DownloadProperties1.FileExtension)
'Log(DownloadProperties1.DownloadID)
UltimateWebView1.StartFileDownload(DownloadProperties1,"TEST",True,True)
End Sub
Private Sub UltimateWebView1_FileDownloadStarted (DownloadProperties1 As DownloadProperties) 'Works from API level 9 and above. DownloadListener required.
Log("Download STARTED")
'Log(DownloadProperties1.url)
'Log(DownloadProperties1.userAgent)
'Log(DownloadProperties1.contentDisposition)
'Log(DownloadProperties1.mimeType)
'Log(DownloadProperties1.contentLength)
'Log(DownloadProperties1.cookies)
'Log(DownloadProperties1.fileName)
'Log(DownloadProperties1.FileExtension)
'Log(DownloadProperties1.DownloadID)
End Sub
Private Sub UltimateWebView1_FileDownloadCompleted (Success As Boolean, DownloadProperties1 As DownloadProperties) 'Works from API level 9 and above. DownloadListener required.
Log("Download COMPLETED; Success:" & Success)
'Log(DownloadProperties1.url)
'Log(DownloadProperties1.userAgent)
'Log(DownloadProperties1.contentDisposition)
'Log(DownloadProperties1.mimeType)
'Log(DownloadProperties1.contentLength)
'Log(DownloadProperties1.cookies)
'Log(DownloadProperties1.fileName)
'Log(DownloadProperties1.FileExtension)
'Log(DownloadProperties1.DownloadID)
End Sub
Private Sub UltimateWebView1_OverrideUrl (Url As String) As Boolean 'Works from API level 1 to API level 23. WebViewClient required.
'Log("OverrideUrl")
'Log(Url)
SavedURL = Url
Return False
End Sub
Private Sub UltimateWebView1_OverrideUrl2 (WebResourceRequest1 As WebResourceRequest) As Boolean 'Works from API level 24 and above. WebViewClient required.
'Log("OverrideUrl")
'Log(WebResourceRequest1.GetUrl)
SavedURL = WebResourceRequest1.GetUrl
Return False
End Sub
Private Sub UltimateWebView1_OverrideUrlWithExternalAppIntent (Url As String, ExternalAppIntent As Intent) As Boolean 'Works from API level 1 to API level 23. WebViewClient required.
'Log("OverrideUrlWithExternalAppIntent")
'Log(Url)
StartActivity(ExternalAppIntent)
Return True
End Sub
Private Sub UltimateWebView1_OverrideUrlWithExternalAppIntent2 (WebResourceRequest1 As WebResourceRequest, ExternalAppIntent As Intent) As Boolean 'Works from API level 24 and above. WebViewClient required.
'Log("OverrideUrlWithExternalAppIntent")
'Log(WebResourceRequest1.GetUrl)
StartActivity(ExternalAppIntent)
Return True
End Sub
Private Sub UltimateWebView1_FileChooserInitialized (FilePathCallback As Object, FileChooserParams1 As FileChooserParams) 'Works from API level 21 and above. WebChromeClient required.
UltimateWebView1.FileChooserStart(FilePathCallback,FileChooserParams1,False)
End Sub
Private Sub UltimateWebView1_PageFinished (Url As String) 'Works from API level 1 and above. WebViewClient required.
'Stop loading
stopLoading
'Log(Url)
Log($"UltimateWebView1_PageFinished(${Url})"$)
Dim Javascript As String
'MASUKKAN KODE JAVASCRIPT DISINI SUPAYA BISA DI AKSES OTOMATIS
Javascript=$""$
'Javascript=$"
'document.getElementById('nmuser').innerHTML = "Herryadhi Santosa";
'B4A.CallSub('GetVarFromWebview', true, 'oke', 'oke2');
'"$
'Log(Javascript)
WebViewExtras1.executeJavascript(UltimateWebView1.WebView, Javascript)
'CallSubDelayed(Me,"set_focus")
End Sub
private Sub GetVarFromWebview(WebVar As String, WebVar2 As String)
'MsgboxAsync(WebVar & "Pesan:" & WebVar2,"Peringatan")
Log(WebVar & "Pesan:" & WebVar2 & "Peringatan")
End Sub
Private Sub UltimateWebView1_PageStarted (Url As String, FavIcon As Bitmap) 'Works from API level 1 and above. WebViewClient required.
'If FavIcon<>Null Then
'do stuff...
'End If
End Sub
Private Sub UltimateWebView1_ReceivedIcon (Icon As Bitmap) 'Works from API level 1 and above. WebChromeClient required.
'If Icon<>Null Then
'do stuff...
'End If
End Sub
'Very important event for UltimateWebView permissions request (Camera, Geolocation, Microphone, Write Storage itd.)!!!
Private Sub UltimateWebView1_PermissionRequest (RequestedPermission As String) 'Works from API level 21 and above. WebChromeClient required.
Dim Permissions As RuntimePermissions
Permissions.CheckAndRequest(RequestedPermission)
Wait For Activity_PermissionResult (Permission As String, result As Boolean)
UltimateWebView1.GrantPermission(result)
End Sub
Private Sub UltimateWebView1_ReceivedError (ErrorCode As Int, Description As String, FailingUrl As String) 'Works from API level 1 to API level 23. WebViewClient required.
Log(ErrorCode)
'Log(Description)
'Log(FailingUrl)
'UltimateWebView1.LoadHTMLString(CustomWebviewError.GetErrorPageHtml(Description))
End Sub
Private Sub UltimateWebView1_ReceivedError2 (WebResourceRequest1 As WebResourceRequest, WebResourceError1 As WebResourceError) 'Works from API level 23 and above. WebViewClient required.
Log("ReceivedError")
'Log(WebResourceRequest1.GetUrl)
'Log(WebResourceError1.Description)
'Log(WebResourceError1.ErrorCode)
'UltimateWebView1.LoadHTMLString(CustomWebviewError.GetErrorPageHtml(Regex.Replace("net::",WebResourceError1.ErrorCode,"")))
Select WebResourceError1.ErrorCode
Case 403: 'forbidden access
UltimateWebView1.LoadHTMLString(CustomWebviewError.GetErrorPageHtml("Akses ke server tidak diizinkan"))
Case 404:
UltimateWebView1.LoadHTMLString(CustomWebviewError.GetErrorPageHtml("Koneksi ke server gagal"))
Case 500:
UltimateWebView1.LoadHTMLString(CustomWebviewError.GetErrorPageHtml("Sesi koneksi ke server habis"))
Case -6:
UltimateWebView1.LoadHTMLString(CustomWebviewError.GetErrorPageHtml("Koneksi timeout"))
Case -8:
UltimateWebView1.LoadHTMLString(CustomWebviewError.GetErrorPageHtml("Koneksi timeout"))
Case Else:
'MsgboxAsync("Error:" & WebResourceError1.ErrorCode,"Perhatian")
End Select
End Sub
Private Sub UltimateWebView1_ReceivedHttpError (WebResponseRequest1 As WebResourceRequest, WebResourceResponse1 As WebResourceResponse) 'Works from API level 23 and above. WebViewClient required.
Log("ReceivedHttpError")
Log(WebResponseRequest1.GetUrl)
Log(WebResourceResponse1.Encoding)
Log(WebResourceResponse1.StatusCode)
Select WebResourceResponse1.StatusCode
Case 403: 'forbidden access
UltimateWebView1.LoadHTMLString(CustomWebviewError.GetErrorPageHtml("Akses ke server tidak diizinkan"))
Case 404:
UltimateWebView1.LoadHTMLString(CustomWebviewError.GetErrorPageHtml("Koneksi ke server gagal"))
Case 500:
UltimateWebView1.LoadHTMLString(CustomWebviewError.GetErrorPageHtml("Sesi koneksi ke server habis"))
Case -6:
UltimateWebView1.LoadHTMLString(CustomWebviewError.GetErrorPageHtml("Koneksi timeout"))
Case Else:
'MsgboxAsync("Error:" & WebResourceResponse1.StatusCode,"Perhatian")
End Select
'UltimateWebView1.LoadHTMLString(CustomWebviewError.GetErrorPageHtml(WebResourceResponse1.StatusCode))
End Sub
Private Sub UltimateWebView1_ReceivedHttpAuthRequest (HttpAuthHandler1 As HttpAuthHandler, HttpAuthRequestProperties1 As HttpAuthRequestProperties) 'Works from API level 1 and above. WebViewClient required.
Log("ReceivedHttpAuthRequest")
'Log(HttpAuthRequestProperties1.Host)
'Log(HttpAuthRequestProperties1.Realm)
End Sub
Private Sub UltimateWebView1_ReceivedLoginRequest (LoginRequestProperties1 As LoginRequestProperties) 'Works from API level 12 and above. WebViewClient required.
Log("ReceivedLoginRequest")
'Log(LoginRequestProperties1.Realm)
'Log(LoginRequestProperties1.Account)
'Log(LoginRequestProperties1.Args)
End Sub
Private Sub UltimateWebView1_ShouldInterceptRequest (Request As WebResourceRequest) As WebResourceResponse 'Works from API level 21 and above. WebViewClient required.
'Log("ShouldInterceptRequest")
'Log(Request.GetUrl)
'Dim ins As InputStream
'ins.InitializeFromBytesArray(Array As Byte(100,231,155),0,3)
'Dim Response As WebResourceResponse
'Response.Initialize
'Response.Create("text/plain","utf-8",ins)
'Return Response
Return Null
End Sub
Private Sub UltimateWebView1_JsAlert (JsProperties1 As JsProperties, JsResult1 As JsResult) As Boolean 'Works from API level 1 and above. WebChromeClient required.
Log(JsProperties1.Message)
'Log("JsAlert")
'Log(JsProperties1.Url)
'Log(JsProperties1.Message)
'Log(JsProperties1.DefaultValue)
'JsResult1.Confirm
'Return True
Return False
End Sub
Private Sub UltimateWebView1_JsBeforeUnload (JsProperties1 As JsProperties, JsResult1 As JsResult) As Boolean 'Works from API level 1 and above. WebChromeClient required.
'Log("JsBeforeUnload")
'Log(JsProperties1.Url)
'Log(JsProperties1.Message)
'Log(JsProperties1.DefaultValue)
'JsResult1.Confirm
'Return True
Return False
End Sub
Private Sub UltimateWebView1_RenderProcessGone (DidCrash As Boolean, RendererPriorityAtExit As Int) 'Works from API level 26 and above. WebViewClient required.
Log(DidCrash)
Log(RendererPriorityAtExit)
End Sub
Private Sub UltimateWebView1_JsConfirm (JsProperties1 As JsProperties, JsResult1 As JsResult) As Boolean 'Works from API level 1 and above. WebChromeClient required.
'Log("JsConfirm")
'Log(JsProperties1.Url)
'Log(JsProperties1.Message)
'Log(JsProperties1.DefaultValue)
'JsResult1.Confirm
'Return True
Return False
End Sub
Private Sub UltimateWebView1_CreateChildWindow (IsDialog As Boolean, IsUserGesture As Boolean) As UltimateWebView 'Works from API level 1 and above. WebChromeClient required.
Log("Added New Child Window")
'Return Null if you do not want to create child window. Page will not be loaded!
Dim NewUltimateView As UltimateWebView
NewUltimateView.Initialize(Me,"NewUltimateView")
NewUltimateView.EnableSlowWholeDocumentDraw
NewUltimateView.Settings.ImportSettingsFrom(UltimateWebView1) 'Import settings from main UltimateWebView without referencing.
NewUltimateView.SetWebViewClient
NewUltimateView.SetWebChromeClient
NewUltimateView.SetDownloadListener
NewUltimateView.CookieManager.AcceptCookies=True
NewUltimateView.CookieManager.AcceptFileSchemeCookies=True
NewUltimateView.CookieManager.AcceptThirdPartyCookies=True
NewUltimateView.CookieManager.Flush
Return NewUltimateView 'Return created UltimateWebView like child window. Library will do the rest. You can initialize all needed events for this child.
End Sub
Private Sub NewUltimateView_FileDownloadInitialized (DownloadProperties1 As DownloadProperties) 'Works from API level 1 and above. DownloadListener required.
UltimateWebView1.StartFileDownload(DownloadProperties1,"Test",True,True)
End Sub