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 110 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
). | 125 Make sure you've created _local.properties_ file to build the library (see above
). |
126 In the project root directory run: | 126 In the project root directory run: |
127 | 127 |
128 ./gradlew assembleDebugAndroidTest | 128 ./gradlew assembleDebugAndroidTest |
129 | 129 |
130 This will generate *.apk in 'libadblockplus-android-tests/build/outputs/apk/' di
rectory. | 130 This will generate *.apk in 'libadblockplus-android-tests/build/outputs/apk/' di
rectory. |
131 | 131 |
132 ### Testing with Gradle/Android Studio | 132 ### Testing with Gradle/Android Studio |
133 | 133 |
134 You can select test class/method and click 'Run ..Test'. The library and test ap
p will be | 134 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. | 135 compiled, installed to emulator/device and launched automatically. |
| 136 |
| 137 ## WebView |
| 138 |
| 139 You can find 'AdblockWebView' class in 'libadblockplus-android-webview' director
y. |
| 140 |
| 141 `AdblockWebView` class provides built-in ad blocking |
| 142 (both resource loading filtering and element hiding) and inherits from Android |
| 143 ['WebView'](https://developer.android.com/reference/android/webkit/WebView.html)
. |
| 144 |
| 145 ### Usage |
| 146 |
| 147 In layout XML: |
| 148 |
| 149 <org.adblockplus.android.AdblockWebView |
| 150 android:id="@+id/main_webview" |
| 151 android:layout_width="match_parent" |
| 152 android:layout_height="match_parent"/> |
| 153 |
| 154 In java source code: |
| 155 |
| 156 AdblockWebView webView = (AdblockWebView) findViewById(R.id.main_webview); |
| 157 |
| 158 Use `setDebugMode(boolean debugMode)` to turn debug log output (Android log and
JS console) on/off. |
| 159 |
| 160 Use `setAllowDrawDelay(int allowDrawDelay)` to set custom delay to start render
webpage after 'DOMContentLoaded' event is fired. |
| 161 |
| 162 Use `setFilterEngine(FilterEngine newFilterEngine)` to use external filter engin
e |
| 163 If filter engine is not set, it's created by AdblockWebView instance automatical
ly. |
| 164 |
| 165 Use `setAcceptableAdsEnabled(boolean enabled)` to enable/disable Acceptable Ads. |
| 166 |
| 167 Use `dispose()` to release resources (**required**). |
| 168 |
| 169 ### Building |
| 170 |
| 171 Building with Ant |
| 172 ----------------- |
| 173 |
| 174 In the 'libadblockplus-android-webview' directory create the file _local.propert
ies_ and set |
| 175 _sdk.dir_ to where you installed it, e.g.: |
| 176 |
| 177 sdk.dir = /some/where/sdk |
| 178 |
| 179 Then run: |
| 180 |
| 181 ant debug |
| 182 |
| 183 |
| 184 Building with Gradle |
| 185 -------------------- |
| 186 |
| 187 In the project root directory run: |
| 188 |
| 189 ./gradlew assemble |
| 190 |
| 191 This will generate *.aar in 'libadblockplus-android-webview/build/outputs/aar' d
irectory. |
| 192 |
| 193 ## WebView Application |
| 194 |
| 195 You can find demo application for 'AdblockWebView' class in |
| 196 'libadblockplus-android-webviewapp' directory. |
| 197 |
| 198 ### Building |
| 199 |
| 200 Make sure _Library_ requirements are present. |
| 201 |
| 202 Building with Ant |
| 203 ----------------- |
| 204 |
| 205 In the 'libadblockplus-android-webviewapp' directory create the file _local.prop
erties_ and set |
| 206 _sdk.dir_ to where you installed it, e.g.: |
| 207 |
| 208 sdk.dir = /some/where/sdk |
| 209 |
| 210 Then run: |
| 211 |
| 212 ant debug |
| 213 |
| 214 This will generate *.apk in 'libadblockplus-android-webviewapp/bin/' directory. |
| 215 |
| 216 Building with Gradle |
| 217 -------------------- |
| 218 |
| 219 In the project root directory run: |
| 220 |
| 221 ./gradlew assemble |
| 222 |
| 223 This will generate *.apk in 'libadblockplus-android-webviewapp/build/outputs/apk
/' directory. |
OLD | NEW |