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: fixes according to Diego's suggestions Created Nov. 9, 2016, 12:27 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 '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 22.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
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 Make sure you've created _local.properties_ file to build the library (see above ). 128 Make sure you've created _local.properties_ file to build the library (see above ).
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 'libadblockplus-android-tests/build/outputs/apk/' di rectory.
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 'libadblockplus-android-settings' directory:
143 * AdblockGeneralSettingsFragment - main fragment
144 * AdblockWhitelistedDomainsSettingsFragment - whitelisted domains fragment
145
146 ### Usage
147
148 Create `AdblockEngine` instance with factory methods and `AdblockSettingsStorage ` instance.
149 You can use `AdblockSettingsSharedPrefsStorage` implementation to store settings in `SharedPreferences`.
150 Or you can use Adblock facade:
151
152 Adblock.get().init(this, true, Adblock.PREFERENCE_NAME);
153
154 Implement the following interfaces in your settings activity:
155
156 * `AdblockGeneralSettingsFragment.Provider`
157 * `AdblockGeneralSettingsFragment.Listener`
158 * `AdblockWhitelistedDomainsSettingsFragment.Listener`
159
160 and return created instance or Adblock facade instances:
161
162 Adblock.get().getEngine(); // engine
163 Adblock.get().getStorage(); // storage
164
165 Retain Adblock facade instance in activity `onCreate`:
166
167 Adblock.get().retain();
168
169 and release it in activity `onDestroy`:
170
171 Adblock.get().release();
172
173 Insert `AdblockGeneralSettingsFragment` fragment instance in runtime to start sh owing settings UI.
174
175 ### Building
176
177 #### Building with Ant
178
179 In the 'libadblockplus-android-settings' directory create the file _local.proper ties_ and set
180 _sdk.dir_ to where you installed it, e.g.:
181
182 sdk.dir = /some/where/sdk
183
184 Then run:
185
186 ant debug
187
188
189 #### Building with Gradle
190
191 In the project root directory run:
192
193 ./gradlew assemble
194
195 This will generate *.aar in 'libadblockplus-android-settings/build/outputs/aar' directory.
196
197 ## WebView Application
198
199 You can find demo application for 'AdblockWebView' class in
200 'libadblockplus-android-webviewapp' directory.
201
202 ### Building
203
204 Make sure _Library_ requirements are present.
205
206 #### Building with Ant
207
208 In the 'libadblockplus-android-webviewapp' directory create the file _local.prop erties_ and set
209 _sdk.dir_ to where you installed it, e.g.:
210
211 sdk.dir = /some/where/sdk
212
213 Then run:
214
215 ant debug
216
217 This will generate *.apk in 'libadblockplus-android-webviewapp/bin/' directory.
218
219 #### Building with Gradle
220
221 In the project root directory run:
222
223 ./gradlew assemble
224
225 This will generate *.apk in 'libadblockplus-android-webviewapp/build/outputs/apk /' directory.
226
227
228 ## WebView
229
230 You can find 'AdblockWebView' class in 'libadblockplus-android-webview' director y.
231
232 `AdblockWebView` class provides built-in ad blocking
233 (both resource loading filtering and element hiding) and inherits from Android
234 ['WebView'](https://developer.android.com/reference/android/webkit/WebView.html) .
235
236 ### Usage
237
238 In layout XML:
239
240 <org.adblockplus.libadblockplus.android.webview.AdblockWebView
241 android:id="@+id/main_webview"
242 android:layout_width="match_parent"
243 android:layout_height="match_parent"/>
244
245 In java source code:
246
247 AdblockWebView webView = (AdblockWebView) findViewById(R.id.main_webview);
248
249 Use `setAdblockEnabled(boolean adblockEnabled)` to enable/disable adblocking.
250
251 Use `setDebugMode(boolean debugMode)` to turn debug log output (Android log and JS console) on/off.
252
253 Use `setAllowDrawDelay(int allowDrawDelay)` to set custom delay to start render webpage after 'DOMContentLoaded' event is fired.
254
255 Use `setAdblockEngine(AdblockEngine adblockEngine)` to use external adblock engi ne.
256 If adblock engine is not set, it's created by AdblockWebView instance automatica lly.
257
258 Use `dispose(Runnable disposeFinished)` to release resources (**required**).
259 Note it can be invoked from background thread.
260
261 ### Building
262
263 #### Building with Ant
264
265 In the 'libadblockplus-android-webview' directory create the file _local.propert ies_ and set
266 _sdk.dir_ to where you installed it, e.g.:
267
268 sdk.dir = /some/where/sdk
269
270 Then run:
271
272 ant debug
273
274
275 #### Building with Gradle
276
277 In the project root directory run:
278
279 ./gradlew assemble
280
281 This will generate *.aar in 'libadblockplus-android-webview/build/outputs/aar' d irectory.
282
283 ## WebView Application
284
285 You can find demo application for 'AdblockWebView' class in
286 'libadblockplus-android-webviewapp' directory.
287
288 ### Building
289
290 Make sure _Library_ requirements are present.
291
292 #### Building with Ant
293
294 In the 'libadblockplus-android-webviewapp' directory create the file _local.prop erties_ and set
295 _sdk.dir_ to where you installed it, e.g.:
296
297 sdk.dir = /some/where/sdk
298
299 Then run:
300
301 ant debug
302
303 This will generate *.apk in 'libadblockplus-android-webviewapp/bin/' directory.
304
305 #### Building with Gradle
306
307 In the project root directory run:
308
309 ./gradlew assemble
310
311 This will generate *.apk in '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