Loading...

Android Extra WebView Library

We have come up with yet another simple but filled with a new feature, the Java library for our android developers. The Extra WebView Library is developed to change add new features and themes inside the webView instead of it being just a regular view of the website.


The android library contains beautiful new themes and also is compatible with API Level 17. Libraries are an important part in android development as it reduces a lot of burden from developers. This webView library has been built to make webView implementation easy and flexible.


Before discussing the usage let us give a quick overview of the java library(WebView):


  • Compatible with API Level 17

  • RTL support

  • Multi theme support

  • Full-screen feature

  • Easy sharing of URL

  • Search in page support

  • Contains Bookmark and Vote icon using EventBus Library


The demo for this is available, just follow the link below:

https://github.com/bkhezry/ExtraWebView/blob/master/assets/DemoExtraWebView-last.apk


Samples:

You can also go through the sample photos provided below as a reference on themes and buttons available in this easy webView Library. 


From the sample, you can get a view of 6 different themes available in this Extra webView library. Different themes are made available for use as per individual’s preference. The samples also provide a glimpse of the new features available such as Vote and Bookmark buttons and a way for users to take a full-screen experience.



Screenshots

### full screen mode

Setup

The Extra webView library is easy to be implemented in your application. Just follow these simple steps:

1. Provide the gradle dependency

For this, add it to your root build. gradle at the end of repositories:

allprojects {
 repositories {
  ...
  maven { url "https://jitpack.io" }
 }
}

Then, simply add this dependency: 

dependencies {
 implementation 'com.github.bkhezry:ExtraWebView:1.2.۵'
}

2. Add your code

The next step is to add ItemActivity to AndroidManifest.xml

 <activity
            android:name="com.github.bkhezry.extrawebview.ItemActivity"
            android:screenOrientation="portrait" />
DataModel dataModel = new DataModelBuilder()
                .withId(id)
                .withType("blog")
                .withBy(authorName)
                .withTime(timestamp)
                .withUrl(url)
                .withDescription(description)
                .withBookmark(true)
                .withViewed(true)
                .withRank(0)
                .withVoted(true)
                .withPageTitle(title)
                .build();
new ExtraWebViewCreator()
 .withContext(MainActivity.this)
 .withBookmarkIcon(true)
 .withVoteIcon(true)
 .withCustomFont("fonts/IRANSansMobile.ttf")
 .withThemeName(themeName)
 .withDataModel(dataModel)
 .show();
After following the steps, new activity starts with WebViw ui

DataModel attributes

NameTypeDefaultDescription
idLong@NonNullunique id of post. use in bookmark and vote icon event handler
typeStringblogtype of post. use in future development
byString@NonNullauthor name of post
timeLong@NonNullcreate time of post as timestamp format
urlString@NonNullurl of post
descriptionString@NonNulldescription of post
bookmarkbooleanfalsebookmark status of post
viewedbooleanfalseviewed status of post. use in future development
rankinteger0rank of post by users. use in future development
votedbooleanfalsevote status of post
pageTitleString@NonNulltitle of post

ExtraWebViewCreator attributes

NameTypeDefaultDescription
contextContext@NonNullcontext of current activity
bookmarkIconbooleanfalseshow icon of bookmark when true
customFontString@Nullableuse calligraphy library to set custom font. path of font in assets folder
themeNameStringlightname of theme use in WebView ui
dataModelDataModel@NonNullobject of DataModel class
List of theme name: lightdarksepiagreensolarized and solarized_dark ThemePreference.java

Additional Setup


The Bookmark and vote buttons can be used as an event handling medium. You can handle bookmark and vote icon click event. For that, just add these code shown below to onCreate method of activity:

EventBus.getDefault().register(this);


After that, for use subscribe method as listener as follows:


EventBus.getDefault().register(this);

Through this code, EventBus shall return an object of intentServiceResult, when icons are clicked.


@Subscribe(threadMode = ThreadMode.MAIN)
public void doThis(IntentServiceResult intentServiceResult) {
 if (intentServiceResult.isChecked()) {

 } else {

 }
}
when each icon has been clicked, EventBus return object of IntentServiceResult.

IntentServiceResult attributes

NameTypevalue
idLongcurrent post id
typeEventStringBOOKMARK or VOTE
isCheckedbooleanstatus of icon. if true icon is checked

Download complete project source code from GitHub
WebView 7820694363716283458
Home item