Hi all,
for my 3D Printing Host app I need to do ESP8266-ESP32 OTA updates directly inside the app instead of use external browser.
I never used WebView for my projects before now, so I have some problems to know how to do it.
With current code I wrote I'm able to see on the WebView the ESP OTA update page, but when I press the button to choose a binary file (.bin)
the WebView show a message that says there in no application to do it.
This is the code I wrote, next I will put my questions:
	
	
	
	
	
	
	
		
			
			
			
			
			
		
	
	
	
		
	
	
		
	
My questions are:
1) I've used UserAndPasswordRequired sub to pass the username and password, after I added this It successfull login and I see the OTA update page, but want I want is to show the original login (as showed on browser) so the user insert username and password itself directly on the login view, is that possible?
2) When I load a page, pressing on button to choose a binary file, a message show that there are no applications to do it, I do not khow how I can handle it... Maybe need an Intent or I'm wrong ?
Attached some images of attemp on the app and the original login from Android FireFox browser.
Many thanks for any clarification.
			
			for my 3D Printing Host app I need to do ESP8266-ESP32 OTA updates directly inside the app instead of use external browser.
I never used WebView for my projects before now, so I have some problems to know how to do it.
With current code I wrote I'm able to see on the WebView the ESP OTA update page, but when I press the button to choose a binary file (.bin)
the WebView show a message that says there in no application to do it.
This is the code I wrote, next I will put my questions:
			
				B4A Code:
			
		
		
		WebView1.JavaScriptEnabled = True  ' Already enabled by default
'WebView1.ZoomEnabled = False
'WebView1.Zoom(True)
WebView1.Color = Colors.LightGray
WebView1.SendToBack
        
Dim wve As WebViewExtras
wve.addWebChromeClient(WebView1, "wve")
wve.addJavascriptInterface(WebView1, "b4a") ' Is this required ???
Dim WebViewSettings1 As WebViewSettings
Log("UserAgent before: " & WebViewSettings1.getUserAgentString(WebView1))
Dim UserAgent As String = "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.4) Gecko/20100101 Firefox/4.0"
WebViewSettings1.setUserAgentString (WebView1, UserAgent)
'WebViewSettings1.setDefaultZoom(WebView1, "FAR")
'WebViewSettings1.setUseWideViewPort(WebView1, True)
'WebViewSettings1.setLoadWithOverviewMode(WebView1, True)
    
Log("Save passwords: " & WebViewSettings1.getSavePassword(WebView1))
Log("UserAgent after: " & WebViewSettings1.getUserAgentString(WebView1))
..........
..........
Sub btnStart_On(Index As Int, Tag As String)
    btnStart.DisableNoMask
    Dim URL As String = txtHost.Text.Trim
    WebView1.LoadUrl(URL)
    Log("Loading URL: " &  WebView1.Url)
    ToastMessageShow("Loading URL: " & WebView1.Url, False)
    
    WriteSlotVal(79, URL)
End Sub
Sub btnStop_On(Index As Int, Tag As String)
    btnStart.Enabled = True
    WebView1.StopLoading
    Sleep(400)
    btnStart.Value = 0
    btnStop.Value = 0
End Sub
Sub WebView1_UserAndPasswordRequired (Host As String, Realm As String) As String()
    ToastMessageShow(Host & " require Username and Password to access: " & Realm, True)
    Log(Host & " require Username and Password to access: " & Realm)
    Return Array As String("admin", "password") ' OTA update page, we set on ESP to require a login
End Sub
Sub WebView1_OverrideUrl (Url As String) 'As Boolean
    ToastMessageShow("Override URL: " &  Url, False)
    Log("Override URL: " &  Url)
End Sub
Sub WebView1_PageFinished (Url As String)
    ToastMessageShow("PageFinished: " &  Url, False)
    Log("PageFinished: " & Url)
End SubMy questions are:
1) I've used UserAndPasswordRequired sub to pass the username and password, after I added this It successfull login and I see the OTA update page, but want I want is to show the original login (as showed on browser) so the user insert username and password itself directly on the login view, is that possible?
2) When I load a page, pressing on button to choose a binary file, a message show that there are no applications to do it, I do not khow how I can handle it... Maybe need an Intent or I'm wrong ?
Attached some images of attemp on the app and the original login from Android FireFox browser.
Many thanks for any clarification.
 
				 
 
		 
			 
			 
			 
						
					 
			 
			 
			 
 
		 
 
		 
 
		 
 
		 
 
		