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 -Dversion=5.0 -Dpackaging=jar -DgeneratePom=true |
| 51 |
48 Set environment variable ANDROID_HOME to your Android SDK directory or pass it i
n command-line (below). | 52 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: | 53 In the 'libadblockplus-android' directory run: |
50 | 54 |
51 mvn clean install [-Dandroid.sdk.path=/some/where/sdk] | 55 mvn clean install [-Dandroid.sdk.path=/some/where/sdk] |
52 | 56 |
53 This will generate *.aar library artifact in the 'target' directory. | 57 This will generate *.aar library artifact in the 'target' directory. |
54 | 58 |
55 Building with Gradle/Android Studio | 59 Building with Gradle/Android Studio |
56 ----------------------------------- | 60 ----------------------------------- |
57 | 61 |
(...skipping 67 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
). | 129 Make sure you've created _local.properties_ file to build the library (see above
). |
126 In the project root directory run: | 130 In the project root directory run: |
127 | 131 |
128 ./gradlew assembleDebugAndroidTest | 132 ./gradlew assembleDebugAndroidTest |
129 | 133 |
130 This will generate *.apk in 'libadblockplus-android-tests/build/outputs/apk/' di
rectory. | 134 This will generate *.apk in 'libadblockplus-android-tests/build/outputs/apk/' di
rectory. |
131 | 135 |
132 ### Testing with Gradle/Android Studio | 136 ### Testing with Gradle/Android Studio |
133 | 137 |
134 You can select test class/method and click 'Run ..Test'. The library and test ap
p will be | 138 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. | 139 compiled, installed to emulator/device and launched automatically. |
| 140 |
| 141 ## WebView Application |
| 142 |
| 143 You can find demo application for 'AdblockWebView' widget in |
| 144 'libadblockplus-android-webviewapp' directory. |
| 145 |
| 146 ### AdblockWebView usage |
| 147 |
| 148 `AdblockWebView` class provides built-in ad blocking |
| 149 (both resource loading filtering and element hiding), inherits from Android |
| 150 ['WebView'](https://developer.android.com/reference/android/webkit/WebView.html)
and is drop-in replacement: |
| 151 |
| 152 In layout XML: |
| 153 |
| 154 <org.adblockplus.android.AdblockWebView |
| 155 android:id="@+id/main_webview" |
| 156 android:layout_width="match_parent" |
| 157 android:layout_height="match_parent"/> |
| 158 |
| 159 In java source code: |
| 160 |
| 161 AdblockWebView webView = (AdblockWebView) findViewById(R.id.main_webview); |
| 162 |
| 163 Use `setDebugMode(boolean debugMode)` to turn debug log output (Android log and
JS console) on/off. |
| 164 |
| 165 Use `setAllowDrawDelay(int allowDrawDelay)` to set custom delay to start render
webpage after 'DOMContentLoaded' event is fired. |
| 166 |
| 167 Use `setFilterEngine(FilterEngine newFilterEngine)` to use external filter engin
e |
| 168 If filter engine is not set, it's created by AdblockWebView instance automatical
ly. |
| 169 |
| 170 Use `setAcceptableAdsEnabled(boolean enabled)` to enable/disable Acceptable Ads. |
| 171 |
| 172 Use `dispose()` to release resources (required). |
| 173 |
| 174 ### Building |
| 175 |
| 176 Make sure _Library_ requirements are present. |
| 177 |
| 178 Building with Ant |
| 179 ----------------- |
| 180 |
| 181 In the 'libadblockplus-android-webviewapp' directory create the file _local.prop
erties_ and set |
| 182 _sdk.dir_ to where you installed it, e.g.: |
| 183 |
| 184 sdk.dir = /some/where/sdk |
| 185 |
| 186 Then run: |
| 187 |
| 188 ant debug |
| 189 |
| 190 This will generate *.apk in 'libadblockplus-android-webviewapp/bin/' directory. |
| 191 |
| 192 Building with Gradle |
| 193 -------------------- |
| 194 |
| 195 In the project root directory run: |
| 196 |
| 197 ./gradlew assemble |
| 198 |
| 199 This will generate *.apk in 'libadblockplus-android-webviewapp/build/outputs/apk
/' directory. |
OLD | NEW |