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