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

Side by Side Diff: src/org/adblockplus/android/AdblockPlus.java

Issue 5327480814567424: Issue 1108 - Support notifications (Closed)
Patch Set: Removed markAsShown() Created Feb. 18, 2015, 2:46 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
OLDNEW
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 // Insert new NOTIFICATION_IDs in between here
54 public static final int GROUPED_NOTIFICATION_ID = R.string.app_name + 32;
55 // Do not add NOTIFICATION_IDs here
56
50 private static final String TAG = Utils.getTag(AdblockPlus.class); 57 private static final String TAG = Utils.getTag(AdblockPlus.class);
51 58
52 private static final Pattern RE_JS = Pattern.compile("\\.js$", Pattern.CASE_IN SENSITIVE); 59 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); 60 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); 61 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); 62 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); 63 private static final Pattern RE_HTML = Pattern.compile("\\.html?$", Pattern.CA SE_INSENSITIVE);
57 64
58 /** 65 /**
59 * Broadcasted when filtering is enabled or disabled. 66 * Broadcasted when filtering is enabled or disabled.
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after
380 { 387 {
381 if (abpEngine != null) 388 if (abpEngine != null)
382 { 389 {
383 abpEngine.dispose(); 390 abpEngine.dispose();
384 abpEngine = null; 391 abpEngine = null;
385 Log.i(TAG, "stopEngine"); 392 Log.i(TAG, "stopEngine");
386 } 393 }
387 } 394 }
388 395
389 /** 396 /**
397 * @return Notification to show for the given URL, {@code null} if none
398 * available
399 */
400 public Notification getNextNotificationToShow(String url)
401 {
402 return this.abpEngine.getNextNotificationToShow(url);
403 }
404
405 /**
406 * @return Notification to show, {@code null} if none available
407 */
408 public Notification getNextNotificationToShow()
409 {
410 return this.abpEngine.getNextNotificationToShow();
411 }
412
413 /**
390 * Initiates immediate interactive check for available update. 414 * Initiates immediate interactive check for available update.
391 */ 415 */
392 public void checkUpdates() 416 public void checkUpdates()
393 { 417 {
394 abpEngine.checkForUpdates(); 418 abpEngine.checkForUpdates();
395 } 419 }
396 420
397 @Override 421 @Override
398 public void onCreate() 422 public void onCreate()
399 { 423 {
(...skipping 29 matching lines...) Expand all
429 } 453 }
430 catch (final IOException e) 454 catch (final IOException e)
431 { 455 {
432 Log.e(TAG, e.getMessage(), e); 456 Log.e(TAG, e.getMessage(), e);
433 } 457 }
434 458
435 // Set crash handler 459 // Set crash handler
436 Thread.setDefaultUncaughtExceptionHandler(new CrashHandler(this)); 460 Thread.setDefaultUncaughtExceptionHandler(new CrashHandler(this));
437 } 461 }
438 } 462 }
OLDNEW

Powered by Google App Engine
This is Rietveld