B4A Library UltimateWebView Custom View

Ivica Golubovic

Active Member
Licensed User
Try version 2.01. Problem fixed.
 

Ivica Golubovic

Active Member
Licensed User
no.not work
Sorry man, it's my fault. I forgot to put in a new B4AExample project after some system stuff related to Custom View properties was replaced in the library. The problem in B4AExample has been solved by deleting the UltimateWebView object through the designer and adding a new one. Get the new B4AExample from first post. Thanks again for pointing me to the problem.
 

Ivica Golubovic

Active Member
Licensed User
Can I suggest that you move the description - the motivation that led you to develop this library - to the beginning of the thread, rather than after the very long list of its members?
Okay, thank you for the useful advice. I will consider how to redesign the first post because the references are really very long. Maybe I'll remove the references from the first post.
 

Ivica Golubovic

Active Member
Licensed User
Version 2.1 released. Download library and documents from first post.

Changes:
  • Added method LoadHTMLString (HTMLString As String) to UltimateWebView class.
  • Edited event OnUnhandledKeyEvent (KeyCode As Int, AndroidViewKeyEvent As Object) 'Works from API level 1 to API level 21. WebViewClient required.
  • Added event OnUnhandledKeyEvent2 (KeyCode As Int, AndroidViewKeyEvent As Object) As Boolean 'Works from API level 28 and above.
  • Edited event OverrideUrl (Url As String) As Boolean 'Works from API level 1 to API level 23. WebViewClient required.
  • Added event OverrideUrl2 (WebResourceRequest1 As WebResourceRequest) As Boolean 'Works from API level 24 and above. WebViewClient required.
  • Edited event OverrideUrlWithExternalAppIntent (Url As String, ExternalAppIntent As Intent) As Boolean 'Works from API level 1 to API level 23. WebViewClient required.
  • Added event OverrideUrlWithExternalAppIntent2 (WebResourceRequest1 As WebResourceRequest, ExternalAppIntent As Intent) As Boolean 'Works from API level 24 and above. WebViewClient required.
  • Edited event ReceivedError (ErrorCode As Int, Description As String, FailingUrl As String) 'Works from API level 1 to API level 23. WebViewClient required.
  • Added event ReceivedError2 (WebResourceRequest1 As WebResourceRequest, WebResourceError1 as WebResourceError) 'Works from API level 23 and above. WebViewClient required.
 

Apip Bayok

Member
still face this error, UltimateWebView v2.10 device android 11, when I remove ultimatewebview object on designer and try to add new one it's not show on the list.
 

Ivica Golubovic

Active Member
Licensed User
still face this error, UltimateWebView v2.10 device android 11, when I remove ultimatewebview object on designer and try to add new one it's not show on the list.
Very strange, I tested on Android 11, 10, 9, 7 and 6 and it works without problems. I'll check again to see what could be causing the problem. Have you tried downloading the new B4AExample and uninstalling the old one before installing?
 

Ivica Golubovic

Active Member
Licensed User
Version 2.12 released. Download library and documents from first post.

Changes:
  • Edited method LoadHTMLString (HTMLString As String)
    • Fixed a bug that in some cases this method did not display the contents of the HTML string.
  • Edited method LoadFileFromDirAssets (FileName As String, IncludeSubFolders As Boolean)
    • IncludeSubFolders As Boolean - True for an html file whose objects are in a subfolder or multiple subfolders. False for an html file that has no additional objects in the subfolders but only at the root of the Asset folder. For a non html files value is not important (True or False).
    • It is now possible to use the standard file scheme to open files in subfolders through an HTML file. E.g:
    • Example::
      "file:///android_asset/subfolder/file.png"
  • Method SetWebChromeClient become property WebChromeClientEnabled (true or false).
    • B4X:
      UltimateWebView1.SetWebChromeClient  'old
      'Replace with
      UltimateWebView1.WebChromeClientEnabled=True 'or False for disable
  • Method SetWebViewClient become property WebViewClientEnabled (true or false).
    • B4X:
      UltimateWebView1.SetWebViewClient  'old
      'Replace with
      UltimateWebView1.WebViewClientEnabled=True 'or False for disable
  • Method SetDownloadListener become property DownloadListenerEnabled (true or false).
    • B4X:
      UltimateWebView1.SetDownloadListener  'old
      'Replace with
      UltimateWebView1.DownloadListenerEnabled=True 'or False for disable
  • The method FileChooserStart (for file upload) now starts the application chooser instead of the default file chooser.
 

max123

Well-Known Member
Licensed User
Longtime User
Hi @Ivica Golubovic, you know because initializing JSInterface inside a Class this way fails?
B4X:
JSInterface.Initialize(Me)

I still search to port this @stevel05 library to B4A but app crashes on this line.
https://www.b4x.com/android/forum/threads/codemirror-wrapper-and-example.125775/

Log do not help, just says: Error occurred on line: 147 (CodeMirrorWrapper)

Many Thanks

Here the unfiltered log, for sure you are better than me to know it.
 
Last edited:

Ivica Golubovic

Active Member
Licensed User
Please share the part of code, I am not sure that I unerstand you...
 

max123

Well-Known Member
Licensed User
Longtime User
Thanks for reply,

maybe I found a mistake, I used this line in the DesignerCreateView where @stevel05 initialized a B4J Javascript using JavaObject and webEngine. Maybe don't like it?

What I do not know is because the UltimateWebView can be initialized with Me but JSInterface no.

Here a relevant code...
If you need I can send all class.

Many thanks

B4X:
In Class_Globals:  Public JSInterface As UltimateJavascriptInterface

Public Sub DesignerCreateView (Base As Object, Lbl As Label, Props As Map)

    mBase = Base
    Tag = mBase.Tag
 
    'Initial Values
    mWidth = mBase.Width
    mHeight = mBase.Height

    mBase.LoadLayout("codemirrorwrapper")
 
    mBase.Tag = Me
 
    ''''''''''''''''''''''''''''' SETUP B4J JS '''''''''''''''''''''''''''''''
''''''''''''    WebE = WebEngine_Static.New(WebView1)
 
''''''''''''    WebE.SetOnAlert(Me,"JSAlert")
''''''''''''    WebE.SetOnError(Me,"JSError")
 
'''''''    B4xCalls.Initialize
'''''''    RegisterB4XCall("JsLog",Me,"Js_Log")
'''''''    RegisterB4XCall("codechanged",mCallBack,mEventName & "_CodeChanged")
 
''''''''''    WebE.AddWorkerListener(Me,"LoadProgress")
    ''''''''''''''''''''''''''''''''''''

'''''''''''''''''''''''''''''''''''' SETUP B4A JS ''''''''''''''''''''''''''''''''''''
    UltimateWebView1.Initialize(Me, "UltimateWebView1")
'    UltimateWebView1.SetWebViewClient(True) 'Sets WebViewClient and its Events.
    UltimateWebView1.SetWebChromeClient(True) 'Sets WebChromeClient and its Events.
 
    'Other UltimateWebViewSettings
    UltimateWebView1.Settings.JavaScriptEnabled = True
    UltimateWebView1.Settings.JavaScriptCanOpenWindowsAutomatically = True
    UltimateWebView1.Settings.DisplayZoomControls = False
 
'    UltimateWebView1.Settings.AllowContentAccess = True
'    UltimateWebView1.Settings.AllowFileAccess = True
'    UltimateWebView1.Settings.AppCacheEnabled = True
'    UltimateWebView1.Settings.CacheMode = UltimateWebView1.Settings.Constants.CACHEMODE_LOAD_DEFAULT
'    UltimateWebView1.Settings.DomStorageEnabled = True
'    UltimateWebView1.Settings.MediaPlaybackRequiresUserGesture = False
'    UltimateWebView1.Settings.AllowFileAccessFromFileURLs = True
'    UltimateWebView1.Settings.AllowUniversalAccessFromFileURLs = True
'    UltimateWebView1.SetDownloadListener 'Sets and start DownloadListener'
 
    Log("InitMe=" & Me)
 
    JSInterface.Initialize(Me)   ' <<<<<<<  ERROR HERE
    '"B4A" is name of javascriptinterface. You can use different name if you want.
    UltimateWebView1.AddJavascriptInterface(JSInterface, "B4A")
 
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
End Sub
 
Last edited:

Ivica Golubovic

Active Member
Licensed User
First try not to initialize JSInterface to Designer sub. If that doesn't work, let me know so I can check the library code tomorrow.
 

max123

Well-Known Member
Licensed User
Longtime User
Sorry, I don't known it, what is Designer sub ?

Maybe you intend inside a class initializer ?
B4X:
Public Sub Initialize (Callback As Object, EventName As String)
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…