OLD | NEW |
1 Adblock Plus Library for Android | 1 Adblock Plus Library for Android |
2 ======================== | 2 ======================== |
3 | 3 |
4 An Android library project that runs a proxy to block ads. | 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: |
11 | 11 |
12 ./ensure_dependencies.py | 12 ./ensure_dependencies.py |
13 | 13 |
14 ## Library | 14 ## Library |
(...skipping 23 matching lines...) Expand all Loading... |
38 ------------------- | 38 ------------------- |
39 | 39 |
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: |
| 49 |
| 50 mvn install:install-file -Dfile=./android.jar -DgroupId=com.google.android -
DartifactId=android |
| 51 -Dversion=5.0 -Dpackaging=jar -DgeneratePom=true |
| 52 |
48 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). |
49 In the 'libadblockplus-android' directory run: | 54 In the root directory run: |
50 | 55 |
51 mvn clean install [-Dandroid.sdk.path=/some/where/sdk] | 56 mvn clean install [-Dandroid.sdk.path=/some/where/sdk] |
52 | 57 |
53 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. |
54 | 61 |
55 Building with Gradle/Android Studio | 62 Building with Gradle/Android Studio |
56 ----------------------------------- | 63 ----------------------------------- |
57 | 64 |
58 ### Requirements | 65 ### Requirements |
59 | 66 |
60 * [The Android SDK](http://developer.android.com/sdk) | 67 * [The Android SDK](http://developer.android.com/sdk) |
61 * Android SDK Build tools 22.0.1 | 68 * Android SDK Build tools 22.0.1 |
62 * [The Android NDK](https://developer.android.com/tools/sdk/ndk) | 69 * [The Android NDK](https://developer.android.com/tools/sdk/ndk) |
63 | 70 |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 Make sure you've created _local.properties_ file to build the library (see above
). | 132 Make sure you've created _local.properties_ file to build the library (see above
). |
126 In the project root directory run: | 133 In the project root directory run: |
127 | 134 |
128 ./gradlew assembleDebugAndroidTest | 135 ./gradlew assembleDebugAndroidTest |
129 | 136 |
130 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. |
131 | 138 |
132 ### Testing with Gradle/Android Studio | 139 ### Testing with Gradle/Android Studio |
133 | 140 |
134 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 |
135 compiled, installed to emuator/device and launched automatically. | 142 compiled, installed to emulator/device and launched automatically. |
| 143 |
| 144 ## WebView |
| 145 |
| 146 You can find 'AdblockWebView' class in 'libadblockplus-android-webview' director
y. |
| 147 |
| 148 `AdblockWebView` class provides built-in ad blocking |
| 149 (both resource loading filtering and element hiding) and inherits from Android |
| 150 ['WebView'](https://developer.android.com/reference/android/webkit/WebView.html)
. |
| 151 |
| 152 ### Usage |
| 153 |
| 154 In layout XML: |
| 155 |
| 156 <org.adblockplus.libadblockplus.android.webview.AdblockWebView |
| 157 android:id="@+id/main_webview" |
| 158 android:layout_width="match_parent" |
| 159 android:layout_height="match_parent"/> |
| 160 |
| 161 In java source code: |
| 162 |
| 163 AdblockWebView webView = (AdblockWebView) findViewById(R.id.main_webview); |
| 164 |
| 165 Use `setAdblockEnabled(boolean adblockEnabled)` to enable/disable adblocking. |
| 166 |
| 167 Use `setDebugMode(boolean debugMode)` to turn debug log output (Android log and
JS console) on/off. |
| 168 |
| 169 Use `setAllowDrawDelay(int allowDrawDelay)` to set custom delay to start render
webpage after 'DOMContentLoaded' event is fired. |
| 170 |
| 171 Use `setAdblockEngine(AdblockEngine adblockEngine)` to use external adblock engi
ne |
| 172 If adblock engine is not set, it's created by AdblockWebView instance automatica
lly. |
| 173 |
| 174 Use `dispose(Runnable disposeFinished)` to release resources (**required**). |
| 175 Note it can be invoked from background thread. |
| 176 |
| 177 ### Building |
| 178 |
| 179 Building with Ant |
| 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 |
| 213 In the 'libadblockplus-android-webviewapp' directory create the file _local.prop
erties_ and set |
| 214 _sdk.dir_ to where you installed it, e.g.: |
| 215 |
| 216 sdk.dir = /some/where/sdk |
| 217 |
| 218 Then run: |
| 219 |
| 220 ant debug |
| 221 |
| 222 This will generate *.apk in 'libadblockplus-android-webviewapp/bin/' directory. |
| 223 |
| 224 Building with Gradle |
| 225 -------------------- |
| 226 |
| 227 In the project root directory run: |
| 228 |
| 229 ./gradlew assemble |
| 230 |
| 231 This will generate *.apk in 'libadblockplus-android-webviewapp/build/outputs/apk
/' directory. |
OLD | NEW |