This is a fork of Lightning Browser with integrated Adblock Plus Android SDK. It is created to provide the reference implementation of Adblock Plus Android SDK browser integration.
Be aware that there are NO GUARANTEES for stability and availability of the Reference Implementation! We believe that the Lightning Browser is stable, as are the Adblock Plus code and Adblock Plus integration changes, but the resulting application is not tested to be production ready.
This reference integration inherits all the Lightning Browser features, adding the Adblock Plus features. The Lightning Browser already contains an adblocking solution. It is shown as Ad Block Settings
in Settings, while Adblock Plus is added as Adblock Plus
.
-
Adblock Plus with Acceptable Ads.
-
AdBlock Plus Settings interface.
The Adblock Plus Engine is required for AdblockWebView to function, and should be initialized as early as possible. The Engine is is integrated by adding imports and initialization (via AdblockHelper
) to BrowserApp.kt
. Please note the Timber initialization a bit earlier.
AdblockWebView is integrated by adding imports and changing the construction of WebView to that of AdblockWebView to LightningView.kt
. An important part is the disposal of AdblockWebView.
To make it easy to switch between Android WebView and AdblockWebView at runtime, a new variable isAdblockWebView is introduced in BrowserActivity.kt
.
The settings are integrated by adding the Settings Activity for Adblock Plus (AdblockPlusSettingsActivity.kt
) and adding the header entry for the Activity. There is also a string resource for Adblock Plus Settings.
We had to create a separate activity to host our settings fragments as a workaround.
There are two preloaded files for the subscriptions: easylist.txt
and exceptionrules.txt
. The files are also updated by a gradle task. Having those files included in the application allows Adblock Plus to function properly even before the subscriptions are downloaded for the first time.
- The root
build.gradle
now has an entry for maven repo for Adblockplus (it is downloaded as an AAR) and setsminSdkVersion = 21
. app\build.gradle
now has entries for adblock plus webview and settings and other settings.
There is a WebViewLoadUrlPerfTest.kt test that aims to compare page load times in Android WebView and AdblockWebView, and also does some analysis on the load times.