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 29430610: Issue 5193 - Apply Samsung Internet UI changes to the frist run slide (Closed)
Patch Set: Changes according to Diegos comments Created May 9, 2017, 9:44 a.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 | « adblockplussbrowser/src/org/adblockplus/sbrowser/contentblocker/MainPreferences.java ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 25 matching lines...) Expand all
36 import java.util.List; 36 import java.util.List;
37 import java.util.Map; 37 import java.util.Map;
38 import java.util.Set; 38 import java.util.Set;
39 import java.util.TreeSet; 39 import java.util.TreeSet;
40 import java.util.concurrent.LinkedBlockingQueue; 40 import java.util.concurrent.LinkedBlockingQueue;
41 import java.util.concurrent.TimeUnit; 41 import java.util.concurrent.TimeUnit;
42 import java.util.concurrent.locks.ReentrantLock; 42 import java.util.concurrent.locks.ReentrantLock;
43 import java.util.regex.Pattern; 43 import java.util.regex.Pattern;
44 44
45 import org.adblockplus.adblockplussbrowser.R; 45 import org.adblockplus.adblockplussbrowser.R;
46 import org.adblockplus.sbrowser.contentblocker.MainPreferences;
46 47
47 import android.content.Context; 48 import android.content.Context;
48 import android.content.Intent; 49 import android.content.Intent;
49 import android.content.SharedPreferences; 50 import android.content.SharedPreferences;
51 import android.content.pm.PackageInfo;
52 import android.content.pm.PackageManager;
50 import android.content.pm.ResolveInfo; 53 import android.content.pm.ResolveInfo;
51 import android.net.ConnectivityManager; 54 import android.net.ConnectivityManager;
52 import android.net.NetworkInfo; 55 import android.net.NetworkInfo;
53 import android.net.Uri; 56 import android.net.Uri;
54 import android.os.Handler; 57 import android.os.Handler;
55 import android.os.Looper; 58 import android.os.Looper;
56 import android.preference.PreferenceManager; 59 import android.preference.PreferenceManager;
57 import android.text.TextUtils; 60 import android.text.TextUtils;
58 import android.util.Log; 61 import android.util.Log;
59 62
(...skipping 10 matching lines...) Expand all
70 public static final Pattern RE_FILTER_REGEXP = Pattern 73 public static final Pattern RE_FILTER_REGEXP = Pattern
71 .compile("^(@@)?\\/.*\\/(?:\\$~?[\\w\\-]+(?:=[^,\\s]+)?(?:,~?[\\w\\-]+(?:= [^,\\s]+)?)*)?$"); 74 .compile("^(@@)?\\/.*\\/(?:\\$~?[\\w\\-]+(?:=[^,\\s]+)?(?:,~?[\\w\\-]+(?:= [^,\\s]+)?)*)?$");
72 public static final Pattern RE_FILTER_OPTIONS = Pattern 75 public static final Pattern RE_FILTER_OPTIONS = Pattern
73 .compile("\\$(~?[\\w\\-]+(?:=[^,\\s]+)?(?:,~?[\\w\\-]+(?:=[^,\\s]+)?)*)$") ; 76 .compile("\\$(~?[\\w\\-]+(?:=[^,\\s]+)?(?:,~?[\\w\\-]+(?:=[^,\\s]+)?)*)$") ;
74 public static final Pattern RE_FILTER_CSSPROPERTY = Pattern 77 public static final Pattern RE_FILTER_CSSPROPERTY = Pattern
75 .compile("\\[\\-abp\\-properties=([\"'])([^\"']+)\\1\\]"); 78 .compile("\\[\\-abp\\-properties=([\"'])([^\"']+)\\1\\]");
76 79
77 public static final String USER_FILTERS_TITLE = "__filters"; 80 public static final String USER_FILTERS_TITLE = "__filters";
78 public static final String USER_EXCEPTIONS_TITLE = "__exceptions"; 81 public static final String USER_EXCEPTIONS_TITLE = "__exceptions";
79 82
83 public static final String SBROWSER_APP_ID = "com.sec.android.app.sbrowser";
80 public static final String ACTION_OPEN_SETTINGS = "com.samsung.android.sbrowse r.contentBlocker.ACTION_SETTING"; 84 public static final String ACTION_OPEN_SETTINGS = "com.samsung.android.sbrowse r.contentBlocker.ACTION_SETTING";
81 public static final String ACTION_UPDATE = "com.samsung.android.sbrowser.conte ntBlocker.ACTION_UPDATE"; 85 public static final String ACTION_UPDATE = "com.samsung.android.sbrowser.conte ntBlocker.ACTION_UPDATE";
82 public static final String EASYLIST_URL = "https://easylist-downloads.adblockp lus.org/easylist.txt"; 86 public static final String EASYLIST_URL = "https://easylist-downloads.adblockp lus.org/easylist.txt";
83 87
84 public static final String SUBSCRIPTIONS_EXCEPTIONSURL = "subscriptions_except ionsurl"; 88 public static final String SUBSCRIPTIONS_EXCEPTIONSURL = "subscriptions_except ionsurl";
85 89
86 public static final String CHARSET_UTF_8 = "UTF-8"; 90 public static final String CHARSET_UTF_8 = "UTF-8";
87 private static final String PREFS_KEY_PREVIOUS_VERSION = "key_previous_version "; 91 private static final String PREFS_KEY_PREVIOUS_VERSION = "key_previous_version ";
88 92
89 // The value below specifies an interval of [x, 2*x[, where x = 93 // The value below specifies an interval of [x, 2*x[, where x =
90 // INITIAL_UPDATE_CHECK_DELAY_SECONDS 94 // INITIAL_UPDATE_CHECK_DELAY_SECONDS
91 private static final long INITIAL_UPDATE_CHECK_DELAY_SECONDS = 5; 95 private static final long INITIAL_UPDATE_CHECK_DELAY_SECONDS = 5;
92 private static final long UPDATE_CHECK_INTERVAL_MINUTES = 30; 96 private static final long UPDATE_CHECK_INTERVAL_MINUTES = 30;
93 private static final long BROADCAST_COMBINATION_DELAY_MILLIS = 2500; 97 private static final long BROADCAST_COMBINATION_DELAY_MILLIS = 2500;
94 98
95 public static final long MILLIS_PER_SECOND = 1000; 99 public static final long MILLIS_PER_SECOND = 1000;
96 public static final long MILLIS_PER_MINUTE = 60 * MILLIS_PER_SECOND; 100 public static final long MILLIS_PER_MINUTE = 60 * MILLIS_PER_SECOND;
97 public static final long MILLIS_PER_HOUR = 60 * MILLIS_PER_MINUTE; 101 public static final long MILLIS_PER_HOUR = 60 * MILLIS_PER_MINUTE;
98 public static final long MILLIS_PER_DAY = 24 * MILLIS_PER_HOUR; 102 public static final long MILLIS_PER_DAY = 24 * MILLIS_PER_HOUR;
99 103
104 private static final int NO_FLAG = 0;
105 private static final int OLDEST_SAMSUNG_INTERNET_5_VERSIONCODE = 500000000;
106
100 private final ReentrantLock accessLock = new ReentrantLock(); 107 private final ReentrantLock accessLock = new ReentrantLock();
101 private DefaultSubscriptions defaultSubscriptions; 108 private DefaultSubscriptions defaultSubscriptions;
102 private Subscriptions subscriptions; 109 private Subscriptions subscriptions;
103 private JSONPrefs jsonPrefs; 110 private JSONPrefs jsonPrefs;
104 private AppInfo appInfo; 111 private AppInfo appInfo;
105 private LinkedBlockingQueue<EngineEvent> engineEvents = new LinkedBlockingQueu e<EngineEvent>(); 112 private LinkedBlockingQueue<EngineEvent> engineEvents = new LinkedBlockingQueu e<EngineEvent>();
106 private Thread handlerThread; 113 private Thread handlerThread;
107 private Downloader downloader; 114 private Downloader downloader;
108 private final Context serviceContext; 115 private final Context serviceContext;
109 private boolean wasFirstRun = false; 116 private boolean wasFirstRun = false;
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 { 159 {
153 return activityContext.getPackageManager() 160 return activityContext.getPackageManager()
154 .queryIntentActivities(new Intent(ACTION_OPEN_SETTINGS), 0).size() > 0 ; 161 .queryIntentActivities(new Intent(ACTION_OPEN_SETTINGS), 0).size() > 0 ;
155 } 162 }
156 catch (final Throwable t) 163 catch (final Throwable t)
157 { 164 {
158 return false; 165 return false;
159 } 166 }
160 } 167 }
161 168
169 /**
170 * Starting with Samsung Internet 5.0, the way to enable ad blocking has chang ed. As a result, we
171 * need to check for the version of Samsung Internet and apply text changes to the first run slide.
172 *
173 * @param activityContext
174 * @return a boolean that indicates, if the user has Samsung Internet version 5.x
175 */
176 public static boolean hasSamsungInternetVersion5OrNewer(final Context activity Context)
177 {
178 try
179 {
180 PackageInfo packageInfo = activityContext.getPackageManager().getPackageIn fo(SBROWSER_APP_ID, NO_FLAG);
181 return packageInfo.versionCode >= OLDEST_SAMSUNG_INTERNET_5_VERSIONCODE;
182 }
183 catch (PackageManager.NameNotFoundException e)
184 {
185 // Should never happen, as checkAAStatusAndProceed() should not be called if the user
186 // has no compatible SBrowser installed. Nevertheless we have to handle th e Exception.
187 Log.d(TAG, "No compatible Samsung Browser found.", e);
188 return false;
189 }
190 }
191
162 public void requestUpdateBroadcast() 192 public void requestUpdateBroadcast()
163 { 193 {
164 this.lock(); 194 this.lock();
165 try 195 try
166 { 196 {
167 this.nextUpdateBroadcast = System.currentTimeMillis() + BROADCAST_COMBINAT ION_DELAY_MILLIS; 197 this.nextUpdateBroadcast = System.currentTimeMillis() + BROADCAST_COMBINAT ION_DELAY_MILLIS;
168 } 198 }
169 finally 199 finally
170 { 200 {
171 this.unlock(); 201 this.unlock();
(...skipping 598 matching lines...) Expand 10 before | Expand all | Expand 10 after
770 Log.d(TAG, headers.toString()); 800 Log.d(TAG, headers.toString());
771 this.downloader.enqueueDownload(this.createDownloadURL(sub), sub.getId(), headers); 801 this.downloader.enqueueDownload(this.createDownloadURL(sub), sub.getId(), headers);
772 } 802 }
773 } 803 }
774 804
775 public void connectivityChanged() 805 public void connectivityChanged()
776 { 806 {
777 this.downloader.connectivityChanged(); 807 this.downloader.connectivityChanged();
778 } 808 }
779 } 809 }
OLDNEW
« no previous file with comments | « adblockplussbrowser/src/org/adblockplus/sbrowser/contentblocker/MainPreferences.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld