OLD | NEW |
1 /* | 1 /* |
2 * This file is part of Adblock Plus <https://adblockplus.org/>, | 2 * This file is part of Adblock Plus <https://adblockplus.org/>, |
3 * Copyright (C) 2006-2015 Eyeo GmbH | 3 * Copyright (C) 2006-2015 Eyeo GmbH |
4 * | 4 * |
5 * Adblock Plus is free software: you can redistribute it and/or modify | 5 * Adblock Plus is free software: you can redistribute it and/or modify |
6 * it under the terms of the GNU General Public License version 3 as | 6 * it under the terms of the GNU General Public License version 3 as |
7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
8 * | 8 * |
9 * Adblock Plus is distributed in the hope that it will be useful, | 9 * Adblock Plus is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 * GNU General Public License for more details. | 12 * GNU General Public License for more details. |
13 * | 13 * |
14 * You should have received a copy of the GNU General Public License | 14 * You should have received a copy of the GNU General Public License |
15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. | 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. |
16 */ | 16 */ |
17 | 17 |
18 package org.adblockplus.android; | 18 package org.adblockplus.android; |
19 | 19 |
20 import java.io.File; | 20 import java.io.File; |
21 import java.io.FileNotFoundException; | 21 import java.io.FileNotFoundException; |
22 import java.io.IOException; | 22 import java.io.IOException; |
23 import java.io.InputStreamReader; | 23 import java.io.InputStreamReader; |
24 import java.util.List; | 24 import java.util.List; |
25 import java.util.regex.Pattern; | 25 import java.util.regex.Pattern; |
26 | 26 |
27 import org.adblockplus.libadblockplus.FilterEngine.ContentType; | 27 import org.adblockplus.libadblockplus.FilterEngine.ContentType; |
| 28 import org.adblockplus.libadblockplus.Notification; |
28 import org.apache.commons.lang.StringUtils; | 29 import org.apache.commons.lang.StringUtils; |
29 | 30 |
30 import android.app.ActivityManager; | 31 import android.app.ActivityManager; |
31 import android.app.ActivityManager.RunningServiceInfo; | 32 import android.app.ActivityManager.RunningServiceInfo; |
32 import android.app.Application; | 33 import android.app.Application; |
33 import android.content.Context; | 34 import android.content.Context; |
34 import android.content.Intent; | 35 import android.content.Intent; |
35 import android.content.SharedPreferences; | 36 import android.content.SharedPreferences; |
36 import android.content.SharedPreferences.Editor; | 37 import android.content.SharedPreferences.Editor; |
37 import android.content.pm.PackageInfo; | 38 import android.content.pm.PackageInfo; |
38 import android.content.pm.PackageManager; | 39 import android.content.pm.PackageManager; |
39 import android.content.pm.PackageManager.NameNotFoundException; | 40 import android.content.pm.PackageManager.NameNotFoundException; |
40 import android.net.ConnectivityManager; | 41 import android.net.ConnectivityManager; |
41 import android.net.NetworkInfo; | 42 import android.net.NetworkInfo; |
42 import android.net.Uri; | 43 import android.net.Uri; |
43 import android.os.Build; | 44 import android.os.Build; |
44 import android.preference.PreferenceManager; | 45 import android.preference.PreferenceManager; |
45 import android.provider.Settings; | 46 import android.provider.Settings; |
46 import android.util.Log; | 47 import android.util.Log; |
47 | 48 |
48 public class AdblockPlus extends Application | 49 public class AdblockPlus extends Application |
49 { | 50 { |
| 51 public static final int ONGOING_NOTIFICATION_ID = R.string.app_name; |
| 52 public static final int UPDATE_NOTIFICATION_ID = R.string.app_name + 1; |
| 53 public static final int SERVER_NOTIFICATION_ID = R.string.app_name + 2; |
| 54 |
50 private static final String TAG = Utils.getTag(AdblockPlus.class); | 55 private static final String TAG = Utils.getTag(AdblockPlus.class); |
51 | 56 |
52 private static final Pattern RE_JS = Pattern.compile("\\.js$", Pattern.CASE_IN
SENSITIVE); | 57 private static final Pattern RE_JS = Pattern.compile("\\.js$", Pattern.CASE_IN
SENSITIVE); |
53 private static final Pattern RE_CSS = Pattern.compile("\\.css$", Pattern.CASE_
INSENSITIVE); | 58 private static final Pattern RE_CSS = Pattern.compile("\\.css$", Pattern.CASE_
INSENSITIVE); |
54 private static final Pattern RE_IMAGE = Pattern.compile("\\.(?:gif|png|jpe?g|b
mp|ico)$", Pattern.CASE_INSENSITIVE); | 59 private static final Pattern RE_IMAGE = Pattern.compile("\\.(?:gif|png|jpe?g|b
mp|ico)$", Pattern.CASE_INSENSITIVE); |
55 private static final Pattern RE_FONT = Pattern.compile("\\.(?:ttf|woff)$", Pat
tern.CASE_INSENSITIVE); | 60 private static final Pattern RE_FONT = Pattern.compile("\\.(?:ttf|woff)$", Pat
tern.CASE_INSENSITIVE); |
56 private static final Pattern RE_HTML = Pattern.compile("\\.html?$", Pattern.CA
SE_INSENSITIVE); | 61 private static final Pattern RE_HTML = Pattern.compile("\\.html?$", Pattern.CA
SE_INSENSITIVE); |
57 | 62 |
58 /** | 63 /** |
59 * Broadcasted when filtering is enabled or disabled. | 64 * Broadcasted when filtering is enabled or disabled. |
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
380 { | 385 { |
381 if (abpEngine != null) | 386 if (abpEngine != null) |
382 { | 387 { |
383 abpEngine.dispose(); | 388 abpEngine.dispose(); |
384 abpEngine = null; | 389 abpEngine = null; |
385 Log.i(TAG, "stopEngine"); | 390 Log.i(TAG, "stopEngine"); |
386 } | 391 } |
387 } | 392 } |
388 | 393 |
389 /** | 394 /** |
| 395 * @return Notification to show for the given URL, {@code null} if none |
| 396 * available |
| 397 */ |
| 398 public Notification getNextNotificationToShow(String url) |
| 399 { |
| 400 return this.abpEngine.getNextNotificationToShow(url); |
| 401 } |
| 402 |
| 403 /** |
| 404 * @return Notification to show, {@code null} if none available |
| 405 */ |
| 406 public Notification getNextNotificationToShow() |
| 407 { |
| 408 return this.abpEngine.getNextNotificationToShow(); |
| 409 } |
| 410 |
| 411 /** |
390 * Initiates immediate interactive check for available update. | 412 * Initiates immediate interactive check for available update. |
391 */ | 413 */ |
392 public void checkUpdates() | 414 public void checkUpdates() |
393 { | 415 { |
394 abpEngine.checkForUpdates(); | 416 abpEngine.checkForUpdates(); |
395 } | 417 } |
396 | 418 |
397 @Override | 419 @Override |
398 public void onCreate() | 420 public void onCreate() |
399 { | 421 { |
(...skipping 29 matching lines...) Expand all Loading... |
429 } | 451 } |
430 catch (final IOException e) | 452 catch (final IOException e) |
431 { | 453 { |
432 Log.e(TAG, e.getMessage(), e); | 454 Log.e(TAG, e.getMessage(), e); |
433 } | 455 } |
434 | 456 |
435 // Set crash handler | 457 // Set crash handler |
436 Thread.setDefaultUncaughtExceptionHandler(new CrashHandler(this)); | 458 Thread.setDefaultUncaughtExceptionHandler(new CrashHandler(this)); |
437 } | 459 } |
438 } | 460 } |
OLD | NEW |