B4A Library WebkitLibrariesSet (successor to UltimateWebView)

IMPORTANT!!!
Library deprecated. Use UltimateWebView2 instead.

WebkitLibrariesSet is an advanced successor to the UltimateWebView library. Instead of a single library that made up UltimateWebView, the new concept contains a collection of a large number of libraries that belong to the android.webkit class set. Each library that is an integral part of the WebkitLibrariesSet contains from one to at most several smaller classes.

The advantages of this approach are multiple, and I will mention only a part of them:
  • Each library in the set is independent from the others, but can be used in synergy with each of the libraries in the set.
  • For your project, you will use only those libraries from the kit that are needed for your project. With this approach, you can reduce the size of your final application compared to the size of the application using a single UltimateWebView library.
  • In addition to the fact that each library in the kit is independent, each of them can be used with the native B4A WebView. This means that if you do not need to use WebkitWebView (successor of UltimateWebView) with all its options, in that case you can use native WebView in synergy with other libraries in this set.
  • To use WebkitWebView Custom View (the successor of UltimateWebView), you don't have to use all the libraries from set, but only those that are necessary for your project (while using UltimateWebView all classes from the set of libraries were necessary).
Over time, this set of libraries will be upgraded with new libraries that will contain classes from the android.webkit class set. Also, these new libraries will be independent to use from other libraries in the kit and all will be able to be used with native B4A WebView.

Manifest requirements:
  • For WebkitWebChromeClient
    • Manifest:
      'Camera Permissions
      AddPermission(android.permission.CAMERA)
      AddPermission(android.permission.RECORD_AUDIO)
      AddPermission(android.permission.MODIFY_AUDIO_SETTINGS)
      AddPermission(android.permission.MICROPHONE)
      '------------------------
      
      'Geolocation Permissions
      AddPermission(android.permission.ACCESS_FINE_LOCATION)
      AddPermission(android.permission.ACCESS_COARSE_LOCATION)
      'AddPermission(android.permission.ACCESS_BACKGROUND_LOCATION)
      'AddPermission(android.permission.WRITE_EXTERNAL_STORAGE)
      '------------------------
  • For WebkitDownloadListener
    • Manifest:
      'DownloadListener Permissions
      AddPermission(android.permission.DOWNLOAD_WITHOUT_NOTIFICATION)
      '------------------------
  • For WebkitWebView Custom View.
    • Manifest:
      SetApplicationAttribute(android:usesCleartextTraffic,"true")
In the manifest, add lines that are necessary for your project, do not add unnecessary ones.

Version 1.0
libraries list:
  1. WebkitConsoleMessage 1.0
  2. WebkitCookieManager 1.0
  3. WebkitDownloadListener 1.0
  4. WebkitHttpAuthHandler 1.0
  5. WebkitJavascriptInterface 1.0
  6. WebkitJsResultAndJsPromptResult 1.0
  7. WebkitMimeTypeMap 1.0
  8. WebkitSafeBrowsingResponse 1.0
  9. WebkitURLUtil 1.0
  10. WebkitWebBackForwardList 1.0
  11. WebkitWebChromeClient 1.0
  12. WebkitWebResourceError 1.0
  13. WebkitWebResourceRequest 1.0
  14. WebkitWebResourceResponse 1.0
  15. WebkitWebView 1.0 Custom View
  16. WebkitWebViewAssetLoader 1.0
  17. WebkitWebViewClient 1.0
  18. WebkitWebViewDatabase 1.0
  19. WebkitWebViewSettings 1.0

If this libraries makes your work easier and saves time in creating your application, please make a donation.
 

Attachments

  • WebkitLibrariesSet_1.0_doc.rar
    30.4 KB · Views: 835
  • WebkitLibrariesSet_1.0_lib.zip
    143 KB · Views: 861
Last edited:

kofiking

Member
I am aware of the problem you mentioned. The problem is that this library requires the getWebViewClient and getWebChroneClient methods in order to work with the native B4A WebView. The process of reworking the library is in progress, i.e. creating a clone of this library in Eclipse. After that, it will be possible to overcome the above mentioned problems. I hope it will be ready in a few weeks. For now it is possible to use the library for Api 26 and above.
Ok, thank you very much.
 

kofiking

Member
I am trying to use the WebkitLibrariesSet library to create a multi-window browser. The problem I encountered is that after the WebkitWebView click hyper link with target="_blank", WebkitWebView successfully creates a new ChildWindow, but the ChildWindow does not load any URLs and is blank. How to get the URL of the ChildWindow or how to let the ChildWindow load the URL? Can anyone help me? Thank u!


all my code:
Sub Globals
    'These global variables will be redeclared each time the activity is created.
    
    Private WebkitWebView1 As WebkitWebView
    Dim NewUltimateView As WebkitWebView
    
    
    
    Private ASViewPager1 As ASViewPager
    
    Private Label1 As Label
End Sub


Sub Activity_Create(FirstTime As Boolean)
    Activity.LoadLayout("Main")
    WebkitWebView1.Initialize(Me,"WebkitWebView1")

    WebkitWebView1.JavaScriptEnabled=True
    WebkitWebView1.Settings.AlgorithmicDarkeningAllowed=True
    WebkitWebView1.Settings.AllowContentAccess=True
    WebkitWebView1.Settings.AllowFileAccess=True
    WebkitWebView1.Settings.AllowFileAccessFromFileURLs=True
    WebkitWebView1.Settings.SupportMultipleWindows=True
    WebkitWebView1.Settings.JavaScriptCanOpenWindowsAutomatically=True
    WebkitWebView1.Settings.DomStorageEnabled=True
    WebkitWebView1.Settings.DatabaseEnabled=True
    WebkitWebView1.Settings.LoadWithOverviewMode=True
    WebkitWebView1.Settings.UseWideViewPort=True
    WebkitWebView1.Settings.LoadsImagesAutomatically=True
    
    WebkitWebView1.WebView.LoadHtml ($"
    <head>
        <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
    </head>
    <body>
        Click any link and wait some seconds
        <br><br>
        <a href="https://www.apple.com" target="_blank">Link with target="_blank"</a>
        <br><br>
        <a href="https://www.bing.com">Link without target="_blank"</a>
    </body>
    "$)
    
    ASViewPager1.AddPage(WebkitWebView1.View,"")
    
    
End Sub

Sub Activity_Resume
    
    
End Sub

Sub Activity_Pause (UserClosed As Boolean)
    
End Sub

Private Sub WebkitWebView1_CreateChildWindow (IsDialog As Boolean, IsUserGesture As Boolean) As WebView 'Works from API level 1 and above. SupportMultipleWindows option must be enabled.
    Log("Added New Child Window")
    ToastMessageShow("Added New Child Window",False)
    'Return Null if you do not want to create child window. Page will not be loaded!
    
    NewUltimateView.Initialize(Me,"NewUltimateView")
    NewUltimateView.EnableSlowWholeDocumentDraw
    NewUltimateView.Settings.ImportSettingsFrom(WebkitWebView1.WebView) 'Import settings from main UltimateWebView without referencing.
    
    NewUltimateView.CookieManager.AcceptCookies=True
    NewUltimateView.CookieManager.AcceptFileSchemeCookies=True
    NewUltimateView.CookieManager.AcceptThirdPartyCookies=True
    NewUltimateView.CookieManager.Flush
    Log(NewUltimateView.OriginalUrl)
    
    NewUltimateView.Width=100%x
    NewUltimateView.Height=100%y
    
    ASViewPager1.AddPage(NewUltimateView.View,"")
    
    
    Return NewUltimateView.WebView
End Sub


Private Sub NewUltimateView_OverrideUrl (Url As String) As Boolean 'Works from API level 1 to API level 23.
    Log("NewUltimateView_OverrideUrl")
    
End Sub



Private Sub NewUltimateView_OverrideUrl2 (WebResourceRequest As WebkitWebResourceRequest) As Boolean 'Works from API level 24 and above. WebkitWebResourceRequest library required.
    Log("NewUltimateView_OverrideUrl2")
    
End Sub





Private Sub WebkitWebView1_OverrideUrl (Url As String) As Boolean 'Works from API level 1 to API level 23.
    Log("WebkitWebView1_OverrideUrl")
    
    
End Sub

Private Sub WebkitWebView1_OverrideUrl2 (WebResourceRequest As WebkitWebResourceRequest) As Boolean 'Works from API level 24 and above. WebkitWebResourceRequest library required.
    Log("WebkitWebView1_OverrideUrl2")
    
End Sub


Private Sub WebkitWebView1_PageFinished (Url As String) 'Works from API level 1 and above.
    Log("PageFinished")
    
End Sub



Sub Activity_KeyPress (KeyCode As Int) As Boolean

    If KeyCode = KeyCodes.KEYCODE_BACK  Then    'back key pressed
        WebkitWebView1.GoBack
        Return True   'Return True to consume the event
    End If
'    Return False
End Sub


Private Sub Button1_Click
    ToastMessageShow(WebkitWebView1.WebChromeClient.WebViewsChildrenViews,False)
    Label1.Text=WebkitWebView1.WebChromeClient.WebViewsChildrenViews.Size
End Sub
 

Attachments

  • Mybrowser.zip
    159.5 KB · Views: 134
Top