Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: README.md

Issue 29361445: Issue 4399 - Add WebView inheritor with ad blocking (Closed)
Patch Set: renamings, updated README Created Dec. 19, 2016, 3:04 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « .hgignore ('k') | build.gradle » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 -------------------------
8 7
9 Adblock Plus Library for Android has dependencies that aren't in this repository . 8 Adblock Plus Library for Android has dependencies that aren't in this repository .
10 To update those, call: 9 To update those, call:
11 10
12 ./ensure_dependencies.py 11 ./ensure_dependencies.py
13 12
14 ## Library 13 ## Library
15 14
16 Building with Ant 15 ### Building with Ant
17 ------------------
18 16
19 ### Requirements 17 #### Requirements
20 18
21 * [The Android SDK](http://developer.android.com/sdk) 19 * [The Android SDK](http://developer.android.com/sdk)
22 * [The Android NDK](https://developer.android.com/tools/sdk/ndk) 20 * [The Android NDK](https://developer.android.com/tools/sdk/ndk)
23 * [Ant](http://ant.apache.org) 21 * [Ant](http://ant.apache.org)
24 22
25 ### Building 23 #### Building
26 24
27 In the 'libadblockplus-android' directory create the file _local.properties_ and set 25 In the 'libadblockplus-android' directory create the file _local.properties_ and set
28 _sdk.dir_ and _ndk.dir_ to where you installed it, e.g.: 26 _sdk.dir_ and _ndk.dir_ to where you installed it, e.g.:
29 27
30 sdk.dir = /some/where/sdk 28 sdk.dir = /some/where/sdk
31 ndk.dir = /some/where/ndk 29 ndk.dir = /some/where/ndk
32 30
33 Then run: 31 Then run:
34 32
35 ant debug 33 ant debug
36 34
37 Building with Maven 35 ### Building with Maven
38 -------------------
39 36
40 ### Requirements 37 #### Requirements
41 38
42 All 'Building with Ant' requirements and additional requirements: 39 All 'Building with Ant' requirements and additional requirements:
43 40
44 * [Maven](https://maven.apache.org) 41 * [Maven](https://maven.apache.org)
45 42
46 ### Building 43 #### Building
44
45 Go to android sdk directory '/platforms/android-21' and run:
46
47 mvn install:install-file -Dfile=./android.jar -DgroupId=com.google.android - DartifactId=android
48 -Dversion=5.0 -Dpackaging=jar -DgeneratePom=true
47 49
48 Set environment variable ANDROID_HOME to your Android SDK directory or pass it i n command-line (below). 50 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: 51 In the root directory run:
50 52
51 mvn clean install [-Dandroid.sdk.path=/some/where/sdk] 53 mvn clean install [-Dandroid.sdk.path=/some/where/sdk]
52 54
53 This will generate *.aar library artifact in the 'target' directory. 55 This will generate *.aar library artifacts in the 'libadblockplus-android/target ',
56 'libadblockplus-android-settings/target', 'libadblockplus-android-webview/target ' directories
57 and *.apk in the 'libadblockplus-android-webviewapp/target' directory.
54 58
55 Building with Gradle/Android Studio 59 ### Building with Gradle/Android Studio
56 -----------------------------------
57 60
58 ### Requirements 61 #### Requirements
59 62
60 * [The Android SDK](http://developer.android.com/sdk) 63 * [The Android SDK](http://developer.android.com/sdk)
61 * Android SDK Build tools 22.0.1 64 * Android SDK Build tools 24.0.1
62 * [The Android NDK](https://developer.android.com/tools/sdk/ndk) 65 * [The Android NDK](https://developer.android.com/tools/sdk/ndk)
63 66
64 Edit 'buildToolsVersion' in 'build.gradle' files if necessary. 67 Edit 'buildToolsVersion' in 'build.gradle' files if necessary.
65 68
66 ### Building from command-line 69 #### Building from command-line
67 70
68 In the project root directory create the file _local.properties_ and set 71 In the project root directory create the file _local.properties_ and set
69 _sdk.dir_ and _ndk.dir_ to where you installed it, e.g.: 72 _sdk.dir_ and _ndk.dir_ to where you installed it, e.g.:
70 73
71 sdk.dir = /some/where/sdk 74 sdk.dir = /some/where/sdk
72 ndk.dir = /some/where/ndk 75 ndk.dir = /some/where/ndk
73 76
74 In the project root directory run: 77 In the project root directory run:
75 78
76 ./gradlew assembleDebug 79 ./gradlew assembleDebug
77 80
78 This will generate *.aar library artifact in 'libadblockplus-android/build/outpu ts/aar/' directory. 81 This will generate *.aar library artifact in the 'libadblockplus-android/build/o utputs/aar/' directory.
79 82
80 ## Library tests 83 ## Library tests
81 84
82 ### Requirements 85 ### Requirements
83 86
84 Make sure _Library_ requirements are present. 87 Make sure _Library_ requirements are present.
85 88
86 ### Building with Ant 89 ### Building with Ant
87 90
88 Set ANDROID_HOME environment variable to your Android SDK directory. 91 Set ANDROID_HOME environment variable to your Android SDK directory.
89 92
90 In the 'libadblockplus-android-tests' run: 93 In the 'libadblockplus-android-tests' directory run:
91 94
92 ant instrument 95 ant instrument
93 96
94 ### Testing with Ant 97 ### Testing with Ant
95 98
96 1. Connect an Android device or start the Android Emulator. 99 1. Connect an Android device or start the Android Emulator.
97 2. In the 'libadblockplus-android-tests' directory run: 100 2. In the 'libadblockplus-android-tests' directory run:
98 101
99 ant instrument install test 102 ant instrument install test
100 103
(...skipping 14 matching lines...) Expand all
115 To run specific **test method** run: 118 To run specific **test method** run:
116 119
117 ant testOnly -DtestClass=full.test.class.name#testMethod 120 ant testOnly -DtestClass=full.test.class.name#testMethod
118 121
119 For example: 122 For example:
120 123
121 ant testOnly -DtestClass=org.adblockplus.libadblockplus.tests.NotificationTe st#testAddNotification 124 ant testOnly -DtestClass=org.adblockplus.libadblockplus.tests.NotificationTe st#testAddNotification
122 125
123 ### Building with Gradle/Android Studio 126 ### Building with Gradle/Android Studio
124 127
125 Make sure you've created _local.properties_ file to build the library (see above ). 128 Make sure you've created the _local.properties_ file to build the library (see a bove).
126 In the project root directory run: 129 In the project root directory run:
127 130
128 ./gradlew assembleDebugAndroidTest 131 ./gradlew assembleDebugAndroidTest
129 132
130 This will generate *.apk in 'libadblockplus-android-tests/build/outputs/apk/' di rectory. 133 This will generate *.apk in the 'libadblockplus-android-tests/build/outputs/apk/ ' directory.
131 134
132 ### Testing with Gradle/Android Studio 135 ### Testing with Gradle/Android Studio
133 136
134 You can select test class/method and click 'Run ..Test'. The library and test ap p will be 137 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. 138 compiled, installed to emulator/device and launched automatically.
139
140 ## Settings
141
142 You can find adblock fragments in the 'libadblockplus-android-settings' director y:
143 * GeneralSettingsFragment - main fragment
144 * WhitelistedDomainsSettingsFragment - whitelisted domains fragment
145
146 ### Usage
147
148 Create `AdblockEngine` instance with factory methods and `AdblockSettingsStorage ` instance.
149 You can use `SharedPrefsStorage` implementation to store settings in `SharedPref erences`.
150 Or you can use AdblockHelper:
151
152 AdblockHelper.get().init(this, true, AdblockHelper.PREFERENCE_NAME);
153
154 Implement the following interfaces in your settings activity:
155
156 * `BaseSettingsFragment.Provider`
157 * `GeneralSettingsFragment.Listener`
158 * `WhitelistedDomainsSettingsFragment.Listener`
159
160 and return created instance or AdblockHelper instances:
161
162 AdblockHelper.get().getEngine(); // engine
163 AdblockHelper.get().getStorage(); // storage
164
165 Retain Adblock instance in activity `onCreate` in synchronous mode (it may take few seconds):
diegocarloslima 2016/12/19 16:14:11 Shouldn't we also change from Adblock to AdblockHe
anton 2016/12/19 19:12:15 As for me, no. We retain `AdblockEngine` instance
166
167 AdblockHelper.get().retain(false);
168
169 or in asynchronous mode (without current thread lock):
170
171 AdblockHelper.get().retain(true);
172
173 Invoke `waitforReady` every time you need AdblockEngine instance if retained in asynchronous mode:
174
175 AdblockHelper.get().waitForReady();
176
177 Release Adblock instance in activity `onDestroy`:
diegocarloslima 2016/12/19 16:14:11 Shouldn't we also change from Adblock to AdblockHe
anton 2016/12/19 19:12:15 Same here
178
179 AdblockHelper.get().release();
180
181 Insert `GeneralSettingsFragment` fragment instance in runtime to start showing s ettings UI.
182
183 ### Building
184
185 #### Building with Ant
186
187 In the 'libadblockplus-android-settings' directory create the file _local.proper ties_ and set
188 _sdk.dir_ to where you installed it, e.g.:
189
190 sdk.dir = /some/where/sdk
191
192 Then run:
193
194 ant debug
195
196
197 #### Building with Gradle
198
199 In the project root directory run:
200
201 ./gradlew assemble
202
203 This will generate *.aar in the 'libadblockplus-android-settings/build/outputs/a ar' directory.
204
205 ## WebView Application
206
207 You can find demo application for 'AdblockWebView' class in
208 'libadblockplus-android-webviewapp' directory.
209
210 ### Building
211
212 Make sure _Library_ requirements are present.
213
214 #### Building with Ant
215
216 In the 'libadblockplus-android-webviewapp' directory create the file _local.prop erties_ and set
217 _sdk.dir_ to where you installed it, e.g.:
218
219 sdk.dir = /some/where/sdk
220
221 Then run:
222
223 ant debug
224
225 This will generate *.apk in the 'libadblockplus-android-webviewapp/bin/' directo ry.
226
227 #### Building with Gradle
228
229 In the project root directory run:
230
231 ./gradlew assemble
232
233 This will generate *.apk in the 'libadblockplus-android-webviewapp/build/outputs /apk/' directory.
234
235
236 ## WebView
237
238 You can find 'AdblockWebView' class in the 'libadblockplus-android-webview' dire ctory.
239
240 `AdblockWebView` class provides built-in ad blocking
241 (both resource loading filtering and element hiding) and inherits from Android
242 ['WebView'](https://developer.android.com/reference/android/webkit/WebView.html) .
243
244 ### Usage
245
246 In layout XML:
247
248 <org.adblockplus.libadblockplus.android.webview.AdblockWebView
249 android:id="@+id/main_webview"
250 android:layout_width="match_parent"
251 android:layout_height="match_parent"/>
252
253 In java source code:
254
255 AdblockWebView webView = (AdblockWebView) findViewById(R.id.main_webview);
256
257 Use `setAdblockEnabled(boolean adblockEnabled)` to enable/disable adblocking.
258
259 Use `setDebugMode(boolean debugMode)` to turn debug log output (Android log and JS console) on/off.
260
261 Use `setAllowDrawDelay(int allowDrawDelay)` to set custom delay to start render webpage after 'DOMContentLoaded' event is fired.
262
263 Use `setAdblockEngine(AdblockEngine adblockEngine)` to use external adblock engi ne.
264 If adblock engine is not set, it's created by AdblockWebView instance automatica lly.
265
266 Use `dispose(Runnable disposeFinished)` to release resources (**required**).
267 Note it can be invoked from background thread.
268
269 ### Building
270
271 #### Building with Ant
272
273 In the 'libadblockplus-android-webview' directory create the file _local.propert ies_ and set
274 _sdk.dir_ to where you installed it, e.g.:
275
276 sdk.dir = /some/where/sdk
277
278 Then run:
279
280 ant debug
281
282
283 #### Building with Gradle
284
285 In the project root directory run:
286
287 ./gradlew assemble
288
289 This will generate *.aar in the 'libadblockplus-android-webview/build/outputs/aa r' directory.
290
291 ## WebView Application
292
293 You can find demo application for 'AdblockWebView' class in the
294 'libadblockplus-android-webviewapp' directory.
295
296 ### Building
297
298 Make sure _Library_ requirements are present.
299
300 #### Building with Ant
301
302 In the 'libadblockplus-android-webviewapp' directory create the file _local.prop erties_ and set
303 _sdk.dir_ to where you installed it, e.g.:
304
305 sdk.dir = /some/where/sdk
306
307 Then run:
308
309 ant debug
310
311 This will generate *.apk in the 'libadblockplus-android-webviewapp/bin/' directo ry.
312
313 #### Building with Gradle
314
315 In the project root directory run:
316
317 ./gradlew assemble
318
319 This will generate *.apk in the 'libadblockplus-android-webviewapp/build/outputs /apk/' directory.
OLDNEW
« no previous file with comments | « .hgignore ('k') | build.gradle » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld