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

Side by Side Diff: adblockplussbrowser/src/org/adblockplus/sbrowser/contentblocker/engine/Engine.java

Issue 29453623: Noissue - Project cleanup (Closed)
Patch Set: Created June 1, 2017, 1:45 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-2016 Eyeo GmbH 3 * Copyright (C) 2006-2016 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
(...skipping 23 matching lines...) Expand all
34 import java.util.ArrayList; 34 import java.util.ArrayList;
35 import java.util.Collections; 35 import java.util.Collections;
36 import java.util.HashMap; 36 import java.util.HashMap;
37 import java.util.List; 37 import java.util.List;
38 import java.util.Map; 38 import java.util.Map;
39 import java.util.Set; 39 import java.util.Set;
40 import java.util.TreeSet; 40 import java.util.TreeSet;
41 import java.util.concurrent.LinkedBlockingQueue; 41 import java.util.concurrent.LinkedBlockingQueue;
42 import java.util.concurrent.TimeUnit; 42 import java.util.concurrent.TimeUnit;
43 import java.util.concurrent.locks.ReentrantLock; 43 import java.util.concurrent.locks.ReentrantLock;
44 import java.util.regex.Pattern;
45 44
46 import org.adblockplus.adblockplussbrowser.R; 45 import org.adblockplus.adblockplussbrowser.R;
47 import org.adblockplus.sbrowser.contentblocker.MainPreferences;
48 46
49 import android.content.Context; 47 import android.content.Context;
50 import android.content.Intent; 48 import android.content.Intent;
51 import android.content.SharedPreferences; 49 import android.content.SharedPreferences;
52 import android.content.pm.PackageInfo; 50 import android.content.pm.PackageInfo;
53 import android.content.pm.PackageManager; 51 import android.content.pm.PackageManager;
54 import android.content.pm.ResolveInfo; 52 import android.content.pm.ResolveInfo;
55 import android.net.ConnectivityManager; 53 import android.net.ConnectivityManager;
56 import android.net.NetworkInfo; 54 import android.net.NetworkInfo;
57 import android.net.Uri; 55 import android.net.Uri;
58 import android.os.Handler; 56 import android.os.Handler;
59 import android.os.Looper; 57 import android.os.Looper;
60 import android.preference.PreferenceManager; 58 import android.preference.PreferenceManager;
61 import android.text.TextUtils; 59 import android.text.TextUtils;
62 import android.util.Log; 60 import android.util.Log;
63 61
64 public final class Engine 62 public final class Engine
65 { 63 {
66 private static final String TAG = Engine.class.getSimpleName(); 64 private static final String TAG = Engine.class.getSimpleName();
67 65
68 // TODO make use of this regex's
69 public static final Pattern RE_SUBSCRIPTION_HEADER = Pattern.compile(
70 "\\[Adblock(?:\\s*Plus\\s*([\\d\\.]+)?)?\\]", Pattern.CASE_INSENSITIVE);
71 public static final Pattern RE_FILTER_META = Pattern.compile("^\\s*!\\s*(\\w+) \\s*:\\s*(.*)");
72 public static final Pattern RE_FILTER_ELEMHIDE = Pattern
73 .compile("^([^\\/\\*\\|\\@\"!]*?)#(\\@)?(?:([\\w\\-]+|\\*)((?:\\([\\w\\-]+ (?:[$^*]?=[^\\(\\)\"]*)?\\))*)|#([^{}]+))$");
74 public static final Pattern RE_FILTER_REGEXP = Pattern
75 .compile("^(@@)?\\/.*\\/(?:\\$~?[\\w\\-]+(?:=[^,\\s]+)?(?:,~?[\\w\\-]+(?:= [^,\\s]+)?)*)?$");
76 public static final Pattern RE_FILTER_OPTIONS = Pattern
77 .compile("\\$(~?[\\w\\-]+(?:=[^,\\s]+)?(?:,~?[\\w\\-]+(?:=[^,\\s]+)?)*)$") ;
78 public static final Pattern RE_FILTER_CSSPROPERTY = Pattern
79 .compile("\\[\\-abp\\-properties=([\"'])([^\"']+)\\1\\]");
80
81 public static final String USER_FILTERS_TITLE = "__filters"; 66 public static final String USER_FILTERS_TITLE = "__filters";
82 public static final String USER_EXCEPTIONS_TITLE = "__exceptions"; 67 public static final String USER_EXCEPTIONS_TITLE = "__exceptions";
83 68
84 public static final String SBROWSER_APP_ID = "com.sec.android.app.sbrowser"; 69 public static final String SBROWSER_APP_ID = "com.sec.android.app.sbrowser";
85 public static final String ACTION_OPEN_SETTINGS = "com.samsung.android.sbrowse r.contentBlocker.ACTION_SETTING"; 70 public static final String ACTION_OPEN_SETTINGS = "com.samsung.android.sbrowse r.contentBlocker.ACTION_SETTING";
86 public static final String ACTION_UPDATE = "com.samsung.android.sbrowser.conte ntBlocker.ACTION_UPDATE"; 71 public static final String ACTION_UPDATE = "com.samsung.android.sbrowser.conte ntBlocker.ACTION_UPDATE";
87 public static final String EASYLIST_URL = "https://easylist-downloads.adblockp lus.org/easylist.txt"; 72 public static final String EASYLIST_URL = "https://easylist-downloads.adblockp lus.org/easylist.txt";
88 73
89 public static final String SUBSCRIPTIONS_EXCEPTIONSURL = "subscriptions_except ionsurl"; 74 public static final String SUBSCRIPTIONS_EXCEPTIONSURL = "subscriptions_except ionsurl";
90 75
(...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after
530 try 515 try
531 { 516 {
532 final URI uri = new URI(url); 517 final URI uri = new URI(url);
533 final String host = uri.getHost() != null ? uri.getHost() : uri.getPat h(); 518 final String host = uri.getHost() != null ? uri.getHost() : uri.getPat h();
534 w.write("@@||" + host + "^$document"); 519 w.write("@@||" + host + "^$document");
535 w.write('\n'); 520 w.write('\n');
536 } 521 }
537 catch (URISyntaxException e) 522 catch (URISyntaxException e)
538 { 523 {
539 Log.w(TAG, "Failed to parse whitelisted website: " + url); 524 Log.w(TAG, "Failed to parse whitelisted website: " + url);
540 continue;
541 } 525 }
542 } 526 }
543 } 527 }
544 } 528 }
545 529
546 private static File getCachedFilterFile(Context context) 530 private static File getCachedFilterFile(Context context)
547 { 531 {
548 final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreference s(context); 532 final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreference s(context);
549 final String cachedFilterPath = prefs.getString(context.getString(R.string.k ey_cached_filter_path), null); 533 final String cachedFilterPath = prefs.getString(context.getString(R.string.k ey_cached_filter_path), null);
550 if (cachedFilterPath != null) 534 if (cachedFilterPath != null)
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
776 Log.d(TAG, headers.toString()); 760 Log.d(TAG, headers.toString());
777 this.downloader.enqueueDownload(this.createDownloadURL(sub), sub.getId(), headers); 761 this.downloader.enqueueDownload(this.createDownloadURL(sub), sub.getId(), headers);
778 } 762 }
779 } 763 }
780 764
781 public void connectivityChanged() 765 public void connectivityChanged()
782 { 766 {
783 this.downloader.connectivityChanged(); 767 this.downloader.connectivityChanged();
784 } 768 }
785 } 769 }
OLDNEW

Powered by Google App Engine
This is Rietveld