| Index: mobile/android/base/java/org/adblockplus/browser/MoreSubscriptionsPreferenceGroup.java |
| =================================================================== |
| --- a/mobile/android/base/java/org/adblockplus/browser/MoreSubscriptionsPreferenceGroup.java |
| +++ b/mobile/android/base/java/org/adblockplus/browser/MoreSubscriptionsPreferenceGroup.java |
| @@ -12,19 +12,22 @@ |
| * GNU General Public License for more details. |
| * |
| * You should have received a copy of the GNU General Public License |
| * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. |
| */ |
| package org.adblockplus.browser; |
| +import java.util.Arrays; |
| import java.util.HashMap; |
| import java.util.HashSet; |
| +import java.util.List; |
| import java.util.Map.Entry; |
| +import java.util.Set; |
| import java.util.concurrent.Semaphore; |
| import org.mozilla.gecko.R; |
| import org.mozilla.gecko.preferences.CustomCheckBoxPreference; |
| import org.mozilla.gecko.util.GeckoBundle; |
| import org.mozilla.gecko.util.ThreadUtils; |
| import android.app.ProgressDialog; |
| @@ -37,65 +40,55 @@ |
| import android.util.Log; |
| import android.view.View; |
| import android.view.ViewGroup; |
| public class MoreSubscriptionsPreferenceGroup extends PreferenceGroup implements |
| InputValidatorDialogPreference.OnInputReadyListener |
| { |
| private static final String TAG = "AdblockBrowser.OtherPreferenceGroup"; |
| - private static final HashMap<String, Integer> BUILTIN_URL_TO_INDEX = new HashMap<String, Integer>(); |
| - private static final HashSet<String> IGNORED_URLS = new HashSet<String>(); |
| + |
| + public static final List<String> BUILTIN_URLS = Arrays.asList( |
| + "https://easylist-downloads.adblockplus.org/easyprivacy.txt", |
|
anton
2019/04/17 09:46:35
the order of `BUILTIN_URLS` should be consistent t
|
| + "https://easylist-downloads.adblockplus.org/malwaredomains_full.txt", |
| + "https://easylist-downloads.adblockplus.org/antiadblockfilters.txt", |
| + "https://easylist-downloads.adblockplus.org/fanboy-social.txt" |
| + ); |
| + |
| + private static final List<Integer> BUILTIN_TITLES = Arrays.asList( |
| + R.string.abb_subscription_disable_tracking, |
| + R.string.abb_subscription_disable_malware, |
| + R.string.abb_subscription_disable_anti_adblock, |
| + R.string.abb_subscription_disable_social_media |
| + ); |
| + |
| + private static final Set<String> IGNORED_URLS = new HashSet<>(Arrays.asList( |
| + "https://easylist-downloads.adblockplus.org/exceptionrules.txt" |
| + )); |
| + |
| + private static final String USER_SUBSCRIPTION_PREFIX = "~user~"; |
| + |
| private static SubscriptionContainer recommendedSubscriptions = null; |
| private final CheckBoxChangeListener checkBoxChangeListener = new CheckBoxChangeListener(); |
| private final ActiveSubscriptionContainer activeSubscriptions = new ActiveSubscriptionContainer(); |
| private ProgressDialog progressDialog; |
| - private static final int[] BUILTIN_TITLES = |
| - { |
| - R.string.abb_subscription_disable_tracking, |
| - R.string.abb_subscription_disable_malware, |
| - R.string.abb_subscription_disable_anti_adblock, |
| - R.string.abb_subscription_disable_social_media |
| - }; |
| - |
| - private static final String[] BUILTIN_LISTS = |
| - { |
| - "EasyPrivacy", |
| - "https://easylist-downloads.adblockplus.org/easyprivacy.txt", |
| - "Malware Domains", |
| - "https://easylist-downloads.adblockplus.org/malwaredomains_full.txt", |
| - "Adblock Warning Removal List", |
| - "https://easylist-downloads.adblockplus.org/antiadblockfilters.txt", |
| - "Fanboy's Social Blocking List", |
| - "https://easylist-downloads.adblockplus.org/fanboy-social.txt" |
| - }; |
| - |
| - private static final String USER_SUBSCRIPTION_PREFIX = "~user~"; |
| - |
| - static |
| - { |
| - for (int i = 0; i < BUILTIN_TITLES.length; i++) |
| - { |
| - BUILTIN_URL_TO_INDEX.put(BUILTIN_LISTS[i * 2 + 1], Integer.valueOf(i)); |
| - } |
| - |
| - IGNORED_URLS.add("https://easylist-downloads.adblockplus.org/exceptionrules.txt"); |
| - } |
| - |
| private synchronized static void initRecommendedSubscriptions(final Context context) |
| { |
| if (recommendedSubscriptions == null) |
| { |
| recommendedSubscriptions = SubscriptionContainer.create(context, false); |
| for (SubscriptionContainer.Subscription s : recommendedSubscriptions.getSubscriptions(false)) |
| { |
| - IGNORED_URLS.add(s.url); |
| + if(!BUILTIN_URLS.contains(s.url)) |
|
jens
2019/04/17 09:39:22
The white space after the if is missing
|
| + { |
| + IGNORED_URLS.add(s.url); |
| + } |
| } |
| } |
| } |
| public MoreSubscriptionsPreferenceGroup(final Context context, final AttributeSet attrs) |
| { |
| this(context, attrs, 0); |
| } |
| @@ -163,31 +156,31 @@ |
| }); |
| } |
| }); |
| } |
| private void initEntries() |
| { |
| this.removeAll(); |
| - for (int i = 0; i < BUILTIN_TITLES.length; i++) |
| + for (int i = 0; i < BUILTIN_TITLES.size(); i++) |
| { |
| final CheckBoxPreference cbp = new CustomCheckBoxPreference(this.getContext()); |
| - final String url = BUILTIN_LISTS[i * 2 + 1]; |
| - cbp.setTitle(BUILTIN_TITLES[i]); |
| + final String url = BUILTIN_URLS.get(i); |
| + cbp.setTitle(BUILTIN_TITLES.get(i)); |
| cbp.setKey(url); |
| cbp.setChecked(this.activeSubscriptions.enabledSubscriptions.containsKey(url)); |
| cbp.setOnPreferenceChangeListener(this.checkBoxChangeListener); |
| cbp.setPersistent(false); |
| this.addPreference(cbp); |
| } |
| for (Entry<String, String> e : this.activeSubscriptions.enabledSubscriptions.entrySet()) |
| { |
| - if (!BUILTIN_URL_TO_INDEX.containsKey(e.getKey())) |
| + if (!BUILTIN_URLS.contains(e.getKey())) |
| { |
| final CheckBoxPreference cbp = new CustomCheckBoxPreference(this.getContext()); |
| cbp.setTitle(e.getValue()); |
| cbp.setKey(e.getKey()); |
| cbp.setChecked(true); |
| cbp.setOnPreferenceChangeListener(this.checkBoxChangeListener); |
| cbp.setPersistent(false); |
| this.addPreference(cbp); |