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
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();
DataModel attributes
Name | Type | Default | Description |
---|---|---|---|
id | Long | @NonNull | unique id of post. use in bookmark and vote icon event handler |
type | String | blog | type of post. use in future development |
by | String | @NonNull | author name of post |
time | Long | @NonNull | create time of post as timestamp format |
url | String | @NonNull | url of post |
description | String | @NonNull | description of post |
bookmark | boolean | false | bookmark status of post |
viewed | boolean | false | viewed status of post. use in future development |
rank | integer | 0 | rank of post by users. use in future development |
voted | boolean | false | vote status of post |
pageTitle | String | @NonNull | title of post |
ExtraWebViewCreator attributes
Name | Type | Default | Description |
---|---|---|---|
context | Context | @NonNull | context of current activity |
bookmarkIcon | boolean | false | show icon of bookmark when true |
customFont | String | @Nullable | use calligraphy library to set custom font. path of font in assets folder |
themeName | String | light | name of theme use in WebView ui |
dataModel | DataModel | @NonNull | object of DataModel class |
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 {
}
}
IntentServiceResult attributes
Name | Type | value |
---|---|---|
id | Long | current post id |
typeEvent | String | BOOKMARK or VOTE |
isChecked | boolean | status of icon. if true icon is checked |