LEFT | RIGHT |
1 Adblock Plus Library for Android | 1 Adblock Plus Library for Android |
2 ======================== | 2 ======================== |
3 | 3 |
4 An Android library project, tests and demo application for AdblockWebView widget
. | 4 An Android library project, tests and demo application for AdblockWebView widget
. |
5 | 5 |
6 Updating the dependencies | 6 Updating the dependencies |
7 ------------------------- | 7 ------------------------- |
8 | 8 |
9 Adblock Plus Library for Android has dependencies that aren't in this repository
. | 9 Adblock Plus Library for Android has dependencies that aren't in this repository
. |
10 To update those, call: | 10 To update those, call: |
(...skipping 29 matching lines...) Expand all Loading... |
40 ### Requirements | 40 ### Requirements |
41 | 41 |
42 All 'Building with Ant' requirements and additional requirements: | 42 All 'Building with Ant' requirements and additional requirements: |
43 | 43 |
44 * [Maven](https://maven.apache.org) | 44 * [Maven](https://maven.apache.org) |
45 | 45 |
46 ### Building | 46 ### Building |
47 | 47 |
48 Go to android sdk directory '/platforms/android-21' and run: | 48 Go to android sdk directory '/platforms/android-21' and run: |
49 | 49 |
50 mvn install:install-file -Dfile=./android.jar -DgroupId=com.google.android -
DartifactId=android -Dversion=5.0 -Dpackaging=jar -DgeneratePom=true | 50 mvn install:install-file -Dfile=./android.jar -DgroupId=com.google.android -
DartifactId=android |
| 51 -Dversion=5.0 -Dpackaging=jar -DgeneratePom=true |
51 | 52 |
52 Set environment variable ANDROID_HOME to your Android SDK directory or pass it i
n command-line (below). | 53 Set environment variable ANDROID_HOME to your Android SDK directory or pass it i
n command-line (below). |
53 In the 'libadblockplus-android' directory run: | 54 In the root directory run: |
54 | 55 |
55 mvn clean install [-Dandroid.sdk.path=/some/where/sdk] | 56 mvn clean install [-Dandroid.sdk.path=/some/where/sdk] |
56 | 57 |
57 This will generate *.aar library artifact in the 'target' directory. | 58 This will generate *.aar library artifacts in the 'libadblockplus-android/target
', |
| 59 'libadblockplus-android-webview/target' directories and *.apk in |
| 60 'libadblockplus-android-webviewapp/target' directory. |
58 | 61 |
59 Building with Gradle/Android Studio | 62 Building with Gradle/Android Studio |
60 ----------------------------------- | 63 ----------------------------------- |
61 | 64 |
62 ### Requirements | 65 ### Requirements |
63 | 66 |
64 * [The Android SDK](http://developer.android.com/sdk) | 67 * [The Android SDK](http://developer.android.com/sdk) |
65 * Android SDK Build tools 22.0.1 | 68 * Android SDK Build tools 22.0.1 |
66 * [The Android NDK](https://developer.android.com/tools/sdk/ndk) | 69 * [The Android NDK](https://developer.android.com/tools/sdk/ndk) |
67 | 70 |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 | 134 |
132 ./gradlew assembleDebugAndroidTest | 135 ./gradlew assembleDebugAndroidTest |
133 | 136 |
134 This will generate *.apk in 'libadblockplus-android-tests/build/outputs/apk/' di
rectory. | 137 This will generate *.apk in 'libadblockplus-android-tests/build/outputs/apk/' di
rectory. |
135 | 138 |
136 ### Testing with Gradle/Android Studio | 139 ### Testing with Gradle/Android Studio |
137 | 140 |
138 You can select test class/method and click 'Run ..Test'. The library and test ap
p will be | 141 You can select test class/method and click 'Run ..Test'. The library and test ap
p will be |
139 compiled, installed to emulator/device and launched automatically. | 142 compiled, installed to emulator/device and launched automatically. |
140 | 143 |
141 ## WebView Application | 144 ## WebView |
142 | 145 |
143 You can find demo application for 'AdblockWebView' widget in | 146 You can find 'AdblockWebView' class in 'libadblockplus-android-webview' director
y. |
144 'libadblockplus-android-webviewapp' directory. | |
145 | |
146 ### AdblockWebView usage | |
147 | 147 |
148 `AdblockWebView` class provides built-in ad blocking | 148 `AdblockWebView` class provides built-in ad blocking |
149 (both resource loading filtering and element hiding), inherits from Android | 149 (both resource loading filtering and element hiding) and inherits from Android |
150 ['WebView'](https://developer.android.com/reference/android/webkit/WebView.html)
and is drop-in replacement: | 150 ['WebView'](https://developer.android.com/reference/android/webkit/WebView.html)
. |
| 151 |
| 152 ### Usage |
151 | 153 |
152 In layout XML: | 154 In layout XML: |
153 | 155 |
154 <org.adblockplus.android.AdblockWebView | 156 <org.adblockplus.libadblockplus.android.webview.AdblockWebView |
155 android:id="@+id/main_webview" | 157 android:id="@+id/main_webview" |
156 android:layout_width="match_parent" | 158 android:layout_width="match_parent" |
157 android:layout_height="match_parent"/> | 159 android:layout_height="match_parent"/> |
158 | 160 |
159 In java source code: | 161 In java source code: |
160 | 162 |
161 AdblockWebView webView = (AdblockWebView) findViewById(R.id.main_webview); | 163 AdblockWebView webView = (AdblockWebView) findViewById(R.id.main_webview); |
162 | 164 |
| 165 Use `setAdblockEnabled(boolean adblockEnabled)` to enable/disable adblocking. |
| 166 |
163 Use `setDebugMode(boolean debugMode)` to turn debug log output (Android log and
JS console) on/off. | 167 Use `setDebugMode(boolean debugMode)` to turn debug log output (Android log and
JS console) on/off. |
164 | 168 |
165 Use `setAllowDrawDelay(int allowDrawDelay)` to set custom delay to start render
webpage after 'DOMContentLoaded' event is fired. | 169 Use `setAllowDrawDelay(int allowDrawDelay)` to set custom delay to start render
webpage after 'DOMContentLoaded' event is fired. |
166 | 170 |
167 Use `setFilterEngine(FilterEngine newFilterEngine)` to use external filter engin
e | 171 Use `setAdblockEngine(AdblockEngine adblockEngine)` to use external adblock engi
ne |
168 If filter engine is not set, it's created by AdblockWebView instance automatical
ly. | 172 If adblock engine is not set, it's created by AdblockWebView instance automatica
lly. |
169 | 173 |
170 Use `setAcceptableAdsEnabled(boolean enabled)` to enable/disable Acceptable Ads. | 174 Use `dispose(Runnable disposeFinished)` to release resources (**required**). |
171 | 175 Note it can be invoked from background thread. |
172 Use `dispose()` to release resources (required). | 176 |
173 | 177 ### Building |
174 ### Building | |
175 | |
176 Make sure _Library_ requirements are present. | |
177 | 178 |
178 Building with Ant | 179 Building with Ant |
179 ----------------- | 180 ----------------- |
180 | 181 |
| 182 In the 'libadblockplus-android-webview' directory create the file _local.propert
ies_ and set |
| 183 _sdk.dir_ to where you installed it, e.g.: |
| 184 |
| 185 sdk.dir = /some/where/sdk |
| 186 |
| 187 Then run: |
| 188 |
| 189 ant debug |
| 190 |
| 191 |
| 192 Building with Gradle |
| 193 -------------------- |
| 194 |
| 195 In the project root directory run: |
| 196 |
| 197 ./gradlew assemble |
| 198 |
| 199 This will generate *.aar in 'libadblockplus-android-webview/build/outputs/aar' d
irectory. |
| 200 |
| 201 ## WebView Application |
| 202 |
| 203 You can find demo application for 'AdblockWebView' class in |
| 204 'libadblockplus-android-webviewapp' directory. |
| 205 |
| 206 ### Building |
| 207 |
| 208 Make sure _Library_ requirements are present. |
| 209 |
| 210 Building with Ant |
| 211 ----------------- |
| 212 |
181 In the 'libadblockplus-android-webviewapp' directory create the file _local.prop
erties_ and set | 213 In the 'libadblockplus-android-webviewapp' directory create the file _local.prop
erties_ and set |
182 _sdk.dir_ to where you installed it, e.g.: | 214 _sdk.dir_ to where you installed it, e.g.: |
183 | 215 |
184 sdk.dir = /some/where/sdk | 216 sdk.dir = /some/where/sdk |
185 | 217 |
186 Then run: | 218 Then run: |
187 | 219 |
188 ant debug | 220 ant debug |
189 | 221 |
190 This will generate *.apk in 'libadblockplus-android-webviewapp/bin/' directory. | 222 This will generate *.apk in 'libadblockplus-android-webviewapp/bin/' directory. |
191 | 223 |
192 Building with Gradle | 224 Building with Gradle |
193 -------------------- | 225 -------------------- |
194 | 226 |
195 In the project root directory run: | 227 In the project root directory run: |
196 | 228 |
197 ./gradlew assemble | 229 ./gradlew assemble |
198 | 230 |
199 This will generate *.apk in 'libadblockplus-android-webviewapp/build/outputs/apk
/' directory. | 231 This will generate *.apk in 'libadblockplus-android-webviewapp/build/outputs/apk
/' directory. |
LEFT | RIGHT |