CustomWebView : An extended form of Web Viewer

1.Introduction

Extension Name: CustomWebView
It is an extended version of web viewer with more customization and flexibility.Its customization and additional features make it different from Web Viewer although it uses same Web View class.

Latest Version: 7.1
Released: 2020-05-12T18:30:00Z
Last Updated: 2020-07-01T18:30:00Z
Requires: Android 5+

2.Features

  • More customization options than normal web viewer
  • Long Click event
  • New window request event
  • Load local files and content using Html and Js
  • Find words and phrases in webview
  • Evaluate Js and get result
  • Block network loads to save data and load faster
  • Upload files to websites
  • Error occurred event
  • Get output from console
  • FormResubmission event
  • Get content height
  • Get SSL Certificate of website
  • Get cookies for particular url/website
  • Event for permission(s) request
  • Grant permission(s) manually
  • Print web content
  • A wide range of tools for working with JavaScript
  • Accepts external links
  • Download files using built-in download method
  • Scroll change event and function to scroll to particular position
  • Create and Remove webviews dynamically
  • Ad Blocker

3.Designer Properties

image

4.Blocks

Events

image

image

image

image

Methods/Functions

image

image

image

image

Properties



image
image
image
image

5.Documentation

Events

  • AfterJavaScriptEvaluated
    Event raised after evaluating Js with result
    component_event
    result ~ text
  • Cookies Removed
    Event raised after ‘ClearCokies’ method with result
    component_event (1)
    successful ~ boolean
  • File Upload Needed
    Event raised when file uploading is needed
    component_event (19)
    mimeType ~ text
    isCaptureEnabled ~ boolean
  • Find Result Received
    Event raised after ‘Find’ method with int ‘activeMatchOrdinal’,‘numberOfMatches’ and ‘isDoneCounting’
    component_event (2)
    activeMatchOrdinal ~ int
    numberOfMatches ~ int
    isDoneCounting ~ boolean
  • Got Ssl Certificate
    Event raised after getting SSL certificate of current displayed url/website with boolean ‘isSecure’ and Strings ‘issuedBy’,‘issuedTo’ and ‘validTill’.If ‘isSecure’ is false and other values are empty then assume that website is not secure
    component_event (3)
    isSecure ~ boolean
    issuedBy ~ text
    issuedTo ~ text
    validTill ~ text
  • Got Print Result
    Event raised after getting previus print’s result
    component_event (4)
    id ~ text
    isCompleted ~ boolean
    isFailed ~ boolean
    isBlocked ~ boolean
  • Long Clicked
    Event raised when something is long clicked in webview with item(image,string,empty,etc) and type(item type like 0,1,8,etc).Note: ‘SecondaryUrl’ is returned when long clicked item has both image and url.In that case ‘item’ returns the image url while ‘secondaryUrl’ returns the source url.
    component_event (17)
    item ~ text
    secondaryUrl ~ text
    type - int

Learn more: WebView.HitTestResult

  • On Console Message
    Event raised after getting console message
    component_event (6)
    message ~ text
    lineNumber ~ int
    sourceID ~ int
    level ~ text
  • On Download Needed
    Event raised when downloading is needed
    component_event (7)
    url ~ text
    contentDisposition ~ text
    mimeType ~ text
    size ~ int (long)
  • On Error Received
    Event raised when any error is received during loading url and returns message,error code and failing url
    component_event (8)
    message ~ text
    errorCode ~ int
    url ~ text
  • On Form Resubmission
    Event raised when resubmission of form is needed
    component_event (9)
  • On Hide Custom View
    Event raised when current page exits from full screen mode
    component_event (21)
  • On Js Alert
    Event raised when Js have to show an alert to user with message to be shown
    component_event (15)
    url ~ text
    message ~ text
  • On Js Confirm
    Tells to display a confirm dialog to the user
    component_event (16)
    url ~ text
    message ~ text
  • On Js Prompt
    Event raised when JavaScript needs input from user
    component_event (17)
    url ~ text
    message ~ text
    defaultValue ~ text
  • On New Window Requested
    Event raised when new window is requested by webview with target url ,boolean ‘isDialog’ and ‘isPopup’
    component_event (10)
    url ~ text
    isDialog ~ boolean
    isPopUp ~ boolean
  • On Permission Request
    Event raised when a website asks for specific permission(s)
    component_event (11)
    permissionsList ~ list < String >
  • On Progress Changed
    Event raised when page loading progress has changed
    component_event (12)
    progress ~ int
  • On Received Http Auth Request
    Notifies that the WebView received an HTTP authentication request
    component_event (18)
    host ~ text
    realm ~ text
  • On Scroll Changed
    Event raised when webview gets scrolled
    component_event (16)
    scrollX ~ int
    scrollY ~ int
    oldScrollX ~ int
    oldScrollY ~ int
    canGoLeft ~ boolean
    canGoRight ~ boolean
  • On WebView Created
    Event raised when a webview gets created and returns created webview’s id
    image
    id ~ int
  • On WebView Changed
    Event raised when current webview gets changed and returns old and new webview’s ids
    image
    oldId ~ int
    newId ~ int
  • On WebView Removed
    Event raised when a webview gets removed and returns removed webview’s id
    image
    id ~ int
  • On Show Custom View
    Event raised when current page enters in full screen mode
    component_event (22)
  • Page Started
    Event indicating that page loading has started in web view
    component_event (19)
    url ~ text
  • Page Loaded
    Event raised when page loading has finished
    component_event (13)
  • Web View String Change
    Event indicating change in webview string
    component_event (14)
    value ~ text

Methods

  • Can Go Back
    Gets whether this WebView has a back history item
    component_method (3)
    Returns : boolean
  • Can Go Back Or Forward
    Gets whether the page can go back or forward the given number of steps
    component_method (4)
    steps ~ int
    Returns : boolean
  • Can Go Forward
    Gets whether this WebView has a forward history item
    component_method (5)
    Returns : boolean
  • Cancel Printing
    Cancels current print job. You can request cancellation of a queued, started, blocked, or failed print job
    component_method (6)
  • Clear Cache
    Clears the resource cache
    component_method (7)
  • Clear Internal History
    Tells this WebView to clear its internal back/forward list
    component_method (8)
  • Clear Location
    Clears all location preferences
    component_method (9)
  • Clear Matches
    Clears the highlighting surrounding text matches
    component_method (10)
  • Confirm Js
    Whether to proceed JavaScript originated request
    component_method (31)
    confirm ~ boolean
  • Content Height
    Returns content height of HTML content
    component_method (11)
    Returns : int
  • Continue Js
    Inputs a confirmation response to Js
    component_method (32)
    input ~ text
  • Create WebView
    Creates the webview in given arrangement by id. Horizontal and Vertical Arrangements are recommended.
    component_method (14)
    container ~ arrangement
    id ~ int
  • Current Id
    Returns current id
    image
    Returns : int
  • Dismiss Js Alert
    Dismiss previously requested Js alert
    component_method (33)
  • Download
    Downloads the file from url.Use this method with ‘OnDownloadNeeded’.
    Provide empty string in ‘fileName’ and ‘dwnloadDir’ to use default values.
    component_method (2)
    url ~ text
    mimeType ~ text
    contentDisposition ~ text
    fileName ~ text
    downloadDir ~ text
  • Evaluate JavaScript
    Asynchronously evaluates JavaScript in the context of the currently displayed page
    component_method (13)
    script ~ text
  • Find
    Finds all instances of find on the page and highlights them, asynchronously. Successive calls to this will cancel any pending searches
    component_method (14)
    string ~ text
  • Find Next
    Highlights and scrolls to the next match if ‘forward’ is true else scrolls to previous match
    component_method (15)
    forward ~ boolean
  • Get Cookies
    Get cookies for specific url
    component_method (16)
    url ~ text
  • Get Ids
    Returns a list of avilable ids
    component_method (18)
    Returns : list
  • Get Scroll X
    Return the scrolled left position of the webview
    component_method (11)
    Returns : int
  • Get Scroll Y
    Return the scrolled top position of the webview
    component_method (12)
    Returns : int
  • Get Ssl Certificate
    Gets the SSL certificate for the main top-level page and raises ‘GotCertificate’ event
    component_method (17)
  • Get WebView
    Returns webview object from id
    image
  • Go Back
    Goes back in the history of this WebView
    component_method (18)
  • Go Back Or Forward
    Goes to the history item that is the number of steps away from the current item. Steps is negative if backward and positive if forward
    component_method (19)
    steps ~ int
  • Go Forward
    Goes forward in the history of this WebView
    component_method (20)
  • Go To Url
    Loads the given URL
    component_method (21)
    url ~ text
  • Grant Permission
    Grants permissions to webview.It accepts a list of permissions
    component_method (22)
    permissions ~ list < String >
  • Load HTML
    Loads the given data into this WebView using a ‘data’ scheme URL
    component_method (23)
    html ~ text
  • Page Down
    Scrolls the contents of the WebView down by half the page size
    image
    bottom ~ boolean
  • Page Up
    Scrolls the contents of the WebView up by half the page size
    image
    top ~ boolean
  • Print Web Content
    Prints the content of webview
    image
  • Proceed Http Auth Request
    Instructs the WebView to proceed with the authentication with the given credentials.If both parameters are empty then it will cancel the request
    component_method (34)
    username ~ text
    password ~ text
  • Reload
    Reloads the current URL
    component_method (25)
  • Remove WebView
    Destroys the webview and removes it completely from the view system
    component_method (16)
  • Restart Printing
    Restarts current/previous print job. You can request restart of a failed print job
    component_method (26)
  • Resubmit Form
    Whether to resubmit form or not
    component_method (28)
    reSubmit ~ boolean
  • Set Visibility
    Sets the visibility of webview by id
    component_method (20)
    id ~ int
    visibility ~ boolean
  • Set WebView
    Set specific webview to current webview by id.Set webview will be active and receive all method calls.
    component_method (17)
    id ~ int
  • Scroll To
    Scrolls the webview to given position
    component_method (13)
    x ~ int
    y ~ int
  • Stop Loading
    Stops the current load
    component_method (30)
  • Upload File
    Uploads the given file from content uri
    component_method (4)
    contentUri ~ text
  • Zoom By
    Performs a zoom operation in the WebView by given zoom percent
    image
    zoomP ~ int
  • Zoom In
    Performs zoom in in the WebView
    image
  • Zoom Out
    Performs zoom out in the WebView
    image

Properties

  • Ad Hosts
    Sets the ad hosts which will be blocked

    Accepts text
  • Auto Load Images
    Get/Set auto loading of images
    image
    Accepts boolean
    Default : true
  • Auto Play Media
    Get/Set auto play of media (audio/video).
    image
    Accepts bolean
    Default : false
  • Background Color
    Set background color of web view
    image
    Accepts int
    Default : 0 (Transparent) for empty webview , -1 (White) for non-empty webview and -16777216 (Black) for HTML content
  • Block Ads
    Sets whether to block ads or not

    Accepts boolean
    Default : false
  • Block Network Loads
    Get/Set block network loads
    image
    Accepts boolean
    Default : false
  • Current Page Title
    Get current page title
    image
    Returns : text
  • Current Url
    Get current url
    image
    Returns : text
  • Desktop Mode
    Get/Set desktop mode
    image
    Accepts boolean
    Default : false
  • Deep Links
    Gets/Sets whether to enable deep linking in webview
    image
    Default : false
  • Display Zoom
    Sets whether the WebView should display on-screen zoom controls
    image
    Accepts boolean
    Default : true
    Note: This property should be used before creating any webview.
  • Enable Js
    Get/Set whether the WebView should supports Js execution
    image
    Accepts boolean
    Default : true
  • File Access
    Get/Set whether the WebView can access local files
    image
    Accepts boolean
    Default : false
  • Follow Links
    Get/Set whether to follow links when they are clicked in the WebView
    image
    Accepts boolean
    Default :true
  • Font Size
    Get/Set font size of text in WebView
    image
    Accepts int
    Default : 16
  • Ignore Ssl errors
    Get/Set whether to ignore SSL errors
    image
    Accepts boolean
    Default : false
  • Load with Overview Mode
    Get/Set whether the WebView loads pages in overview mode, that is, zooms out the content to fit on screen by width
    image
    Accepts boolean
    Default : true
  • Long Clickable
    Get/Set whether text selection and context menu are enabled
    image
    Accepts boolean
    Default : true
  • Prompt For Permission
    Get/Set whether webview will prompt for permission and raise ‘OnPermissionRequest’ event or not
    image
    Accepts boolean
    Default : true
  • Scrollbar
    Set whether webview will show horizonatal and vertical scrollbar
    image
    Accepts boolean
    Default : true
  • Support Multiple Windows
    Get/Set whether the WebView supports multiple windows and raised ‘OnNewWindowRequest’ event
    image
    Accepts boolean
    Default : true
  • Use Wide View Port
    Get/Set whether the WebView should enable support for the ‘viewport’ HTML meta tag or should use a wide viewport
    image
    Accepts boolean
    Default : true
  • Visible
    Returns the visibility of current webview
    image
    Returns : boolean
  • Web View String
    Get/Set web view string
    image
    image
    Accepts string
    Default : " "
  • Zoom Enabled
    Set whether web view supports zoom and built-in zoom controls are enabled or not
    image
    Accepts boolean
    Default : true
    Note: This property should be used before creating any webview.
  • Zoom Percent
    Set zoom percent of web view
    image
    Accepts int
    Default : 100
    Note: This property should be used before creating any webview.

6.Downloads

Aix file

Download Link1: com.sunny.CustomWebView.aix (64.0 KB)
Download Link2: com.sunny.CustomWebView.aix - Google Drive

Aia file

???
Waiting for someone’s contribution :heart_eyes:

7.Open Source

This extension is open source so that anyone can modify and improve it :innocent:
Here is the repo on GitHub:

8.Credits

I would like to say thank you to @ontstudios , @Yoshi , @sivasreerama7 , @Maayur , @Xoma , @karan_kawad and @rizubarury for testing extension and giving their precious feedbacks.
Also thank you to @almeidapablo for motivating me.
And a lot of thanks to Kodular for this great platform :heart:
A lot of thanks to @Ken for sources of his Deep Links extension and for his guidance :heart_eyes:

9.Liked my work

Thank you :hugs:
Donation link will be available soon :slightly_smiling_face:
Thank you for your love :heart_eyes:

Thank you for reading this.
Hope this helps ! :grin:

10.Updates/Bug Fixes

ChangeLog Version2

Changes

  • Fixed some spelling and grammar mistakes
  • Some internal changes

Bug Fixes

  • Fixed bug in Web View String Change event
ChangeLog Version3

New Events/Methods
image
image

Bug Fixes

  • Fixed bug in Grant Permission block

Changes

  • Removed un-necessary color mode from PrintWebContent method
  • Fixed spelling and grammar mistakes
ChangeLog Version4

New blocks
image

Changes

  • Added deep links support
  • Added external links support.Now it will try to open externally taped links in your app.
  • Added custom fiilee uploading method.

Bug Fixes

  • Fixed bug in PrintWebContent method
  • Fixed bug in EvaluateJavaScript method
  • Fixed several spelling and grammar mistakes
ChangeLog Version5

New blocks
image

Changes

  • Added secondaryUrl parameter in LongClicked event
    component_event (17)|305x8550%
ChangeLog Version6

New Blocks

Changes

  • Added ‘id’ parameter in CreateWebView method

  • Added ‘mimeType’ and ‘isCaptureEnabled’ values in FileUploadNeeded event

  • Removed most of the designer properties
  • Some internal changes
  • Fixed grammar and spelling mistakes
ChangeLog Version7

New Blocks




Bug Fixes

  • Fixed bug in PrintWebContent method
  • Fixed bug in FileUploadNeeded method

What’s new

  • Ad Blocker
ChangeLog Version7.1 (Patch Update)

Changes

  • Re-added some properties to designer
  • Added missing permissions

Bug Fixes

  • Fixed bug in LongClickable property
52 Likes

Another great extension from @vknow360
:clap: :smiley: :metal:

3 Likes

Extraordinary extension! Looking forward to working with you again! <3

4 Likes

@vknow360 you are a great extension developer
Such a great extension for free? :thinking:
You are developing innovative/useful extensions
Keep it up…
Just loved your work…
:heart:

6 Likes

Here is a question to dear Koders:

Should I give documentation for properties?

  • Yes
  • No
  • Can’t say

0 voters

1 Like

It helps koders understand better and eliminate doubts
Otherwise you will get question on how to use blocks
It is better than replying to question

2 Likes

OMG its owsm extension
@vknow360 :heart_eyes: >3000

2 Likes

Is it working now?

1 Like

Yes it works.
But I have never tried to compare it with content height returned from js.
So I can’t be sure.

1 Like

With html content

1 Like

Sorry…I am unable to understand.

I think Discourse is not working correctly as I am not getting notification for this topic even I am author (i.e. I am watching this topic)

4 Likes

As I said at the other topic, this is an amazing extension that will help me a lot. And I am not the only one with a browser app or another kind of app that will like the exclusive options of your extensions. I am sure when more people know about it many people will be using it and all of us will be thankful to you for this great work.

I really think I don’t diserve any thanks, but thank you for thanking me :joy: it feels good imagine that I could motivate you at least a little.

You can be sure in the next few days I will test your extension as much as I can and if I find any bug I will tell you.

Check this new webviewer extension @techcvr , @Xoma , @fastearn00 , @saurav_shaw612 , @Techno_Vedang
Sorry to mention you all but I know you guys have projects that can make a great use of it.

5 Likes

Thank you for your precious suggestion.
After getting huge response I have added documentation for properties :+1:
Thank you everyone :heart_eyes:

2 Likes

Nice extension :fire::fire::fire:

1 Like

I downloaded via your miniurl but i get naked ladies in front of a camera. I don’t think that is what you want.

4 Likes

Sorry…I was not aware that MiniURL will do that.
I am sorry :disappointed_relieved:
I will replace that as soon as possible.

2 Likes

I tested your extension with my e-book template. Still have to do some more work.

I had to change and add some blocks. Now i have a search function also. I like your extension very much.

5 Likes

Thank you @Peter.
Your appreciation means a lot to me :heart_eyes:
Once again Thank you :heart:

3 Likes

In my e-book template i have a javascript that records the position on the html page. I tried to make it work with your extension but i wasn’t succeeding. Now i saw the webview string change block. When i want to use that to store the value it gives me a

runtime error with unbound location $value at the end.

image

2 Likes

Thank you.
I will try to fix it as soon as possible (at least 30 minutes mom shouting at me :sweat_smile: ) :heart_eyes:

But I have found the bug.It is just because of not running method/task on ui thread.

3 Likes