| Left: | ||
| Right: |
| 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-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 28 matching lines...) Expand all Loading... | |
| 39 | 39 |
| 40 public class MoreSubscriptionsPreferenceGroup extends PreferenceGroup implements | 40 public class MoreSubscriptionsPreferenceGroup extends PreferenceGroup implements |
| 41 UrlInputDialog.UrlReadyCallback | 41 UrlInputDialog.UrlReadyCallback |
| 42 { | 42 { |
| 43 private static final String TAG = "AdblockBrowser.OtherPreferenceGroup"; | 43 private static final String TAG = "AdblockBrowser.OtherPreferenceGroup"; |
| 44 private static final HashMap<String, Integer> BUILTIN_URL_TO_INDEX = new HashM ap<String, Integer>(); | 44 private static final HashMap<String, Integer> BUILTIN_URL_TO_INDEX = new HashM ap<String, Integer>(); |
| 45 private static final HashSet<String> IGNORED_URLS = new HashSet<String>(); | 45 private static final HashSet<String> IGNORED_URLS = new HashSet<String>(); |
| 46 private static SubscriptionContainer recommendedSubscriptions = null; | 46 private static SubscriptionContainer recommendedSubscriptions = null; |
| 47 | 47 |
| 48 private final CheckBoxChangeListener checkBoxChangeListener = new CheckBoxChan geListener(); | 48 private final CheckBoxChangeListener checkBoxChangeListener = new CheckBoxChan geListener(); |
| 49 private final ActiveSubscriptionContainer activeSubscriptions = new ActiveSubs criptionContainer(); | 49 private final ActiveSubscriptionContainer activeSubscriptions; |
| 50 private ProgressDialog progressDialog; | 50 private ProgressDialog progressDialog; |
| 51 | 51 |
| 52 private static final int[] BUILTIN_TITLES = | 52 private static final int[] BUILTIN_TITLES = |
| 53 { | 53 { |
| 54 R.string.abb_subscription_disable_tracking, | 54 R.string.abb_subscription_disable_tracking, |
| 55 R.string.abb_subscription_disable_malware, | 55 R.string.abb_subscription_disable_malware, |
| 56 R.string.abb_subscription_disable_anti_adblock, | 56 R.string.abb_subscription_disable_anti_adblock, |
| 57 R.string.abb_subscription_disable_social_media | 57 R.string.abb_subscription_disable_social_media |
| 58 }; | 58 }; |
| 59 | 59 |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 87 | 87 |
| 88 for (SubscriptionContainer.Subscription s : recommendedSubscriptions.getSu bscriptions(false)) | 88 for (SubscriptionContainer.Subscription s : recommendedSubscriptions.getSu bscriptions(false)) |
| 89 { | 89 { |
| 90 IGNORED_URLS.add(s.url); | 90 IGNORED_URLS.add(s.url); |
| 91 } | 91 } |
| 92 } | 92 } |
| 93 } | 93 } |
| 94 | 94 |
| 95 public MoreSubscriptionsPreferenceGroup(final Context context, final Attribute Set attrs) | 95 public MoreSubscriptionsPreferenceGroup(final Context context, final Attribute Set attrs) |
| 96 { | 96 { |
| 97 super(context, attrs); | 97 this(context, attrs, 0); |
| 98 } | 98 } |
| 99 | 99 |
| 100 public MoreSubscriptionsPreferenceGroup(final Context context, final Attribute Set attrs, | 100 public MoreSubscriptionsPreferenceGroup(final Context context, final Attribute Set attrs, |
| 101 final int defStyleAttr) | 101 final int defStyleAttr) |
| 102 { | 102 { |
| 103 super(context, attrs, defStyleAttr); | 103 super(context, attrs, defStyleAttr); |
| 104 this.activeSubscriptions = new ActiveSubscriptionContainer(context); | |
| 104 } | 105 } |
| 105 | 106 |
| 106 @Override | 107 @Override |
| 107 protected View onCreateView(final ViewGroup parent) | 108 protected View onCreateView(final ViewGroup parent) |
| 108 { | 109 { |
| 109 this.setLayoutResource(R.layout.abb_minimal_widget); | 110 this.setLayoutResource(R.layout.abb_minimal_widget); |
| 110 return super.onCreateView(parent); | 111 return super.onCreateView(parent); |
| 111 } | 112 } |
| 112 | 113 |
| 113 public static Preference createCheckBoxOrSwitch(final Context context) | 114 public static Preference createCheckBoxOrSwitch(final Context context) |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 271 } | 272 } |
| 272 | 273 |
| 273 Log.d(TAG, "Adding: " + url); | 274 Log.d(TAG, "Adding: " + url); |
| 274 this.addNewSubscription(url); | 275 this.addNewSubscription(url); |
| 275 } | 276 } |
| 276 | 277 |
| 277 private static class ActiveSubscriptionContainer implements AdblockPlusApiCall back | 278 private static class ActiveSubscriptionContainer implements AdblockPlusApiCall back |
| 278 { | 279 { |
| 279 public final HashMap<String, String> enabledSubscriptions = new HashMap<Stri ng, String>(); | 280 public final HashMap<String, String> enabledSubscriptions = new HashMap<Stri ng, String>(); |
| 280 private final Semaphore entriesReady = new Semaphore(0); | 281 private final Semaphore entriesReady = new Semaphore(0); |
| 282 private final Context context; | |
| 283 | |
| 284 ActiveSubscriptionContainer(Context context) { | |
|
anton
2017/08/07 09:40:16
`{` should be in the next line
diegocarloslima
2017/08/07 11:07:34
Acknowledged.
| |
| 285 this.context = context; | |
| 286 } | |
| 281 | 287 |
| 282 public void refresh() | 288 public void refresh() |
| 283 { | 289 { |
| 284 AddOnBridge.queryActiveSubscriptions(this); | 290 AddOnBridge.queryActiveSubscriptions(this); |
| 285 this.entriesReady.acquireUninterruptibly(); | 291 this.entriesReady.acquireUninterruptibly(); |
| 286 } | 292 } |
| 287 | 293 |
| 288 @Override | 294 @Override |
| 289 public void onApiRequestSucceeded(NativeJSObject jsObject) | 295 public void onApiRequestSucceeded(NativeJSObject jsObject) |
| 290 { | 296 { |
| 291 try | 297 try |
| 292 { | 298 { |
| 293 this.enabledSubscriptions.clear(); | 299 this.enabledSubscriptions.clear(); |
| 294 if (jsObject.getBoolean("success")) | 300 if (jsObject.getBoolean("success")) |
| 295 { | 301 { |
| 296 NativeJSObject[] subs = jsObject.getObjectArray("value"); | 302 NativeJSObject[] subs = jsObject.getObjectArray("value"); |
| 297 for (int i = 0; i < subs.length; i++) | 303 for (int i = 0; i < subs.length; i++) |
| 298 { | 304 { |
| 299 final String url = subs[i].getString("url"); | 305 final String url = subs[i].getString("url"); |
| 300 final String title = subs[i].has("title") ? subs[i].getString("title ") : url; | 306 |
| 307 String title = subs[i].has("title") ? subs[i].getString("title") : u rl; | |
| 308 if(title.startsWith("~user~")) { | |
|
anton
2017/08/07 09:40:16
space expected between `if` and `(`
anton
2017/08/07 09:40:16
`{` is expected to be in the next line
diegocarloslima
2017/08/07 11:07:34
Acknowledged.
| |
| 309 title = this.context.getString(R.string.abb_pref_category_whitelis ted_sites); | |
| 310 } | |
| 311 | |
| 301 if (!IGNORED_URLS.contains(url)) | 312 if (!IGNORED_URLS.contains(url)) |
| 302 { | 313 { |
| 303 Log.d(TAG, "Adding: " + url + ", " + title); | 314 Log.d(TAG, "Adding: " + url + ", " + title); |
| 304 this.enabledSubscriptions.put(url, title); | 315 this.enabledSubscriptions.put(url, title); |
| 305 } | 316 } |
| 306 } | 317 } |
| 307 } | 318 } |
| 308 } | 319 } |
| 309 finally | 320 finally |
| 310 { | 321 { |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 348 // ignored | 359 // ignored |
| 349 } | 360 } |
| 350 | 361 |
| 351 @Override | 362 @Override |
| 352 public void onApiRequestFailed(String errorMessage) | 363 public void onApiRequestFailed(String errorMessage) |
| 353 { | 364 { |
| 354 // ignored | 365 // ignored |
| 355 } | 366 } |
| 356 } | 367 } |
| 357 } | 368 } |
| OLD | NEW |