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

Side by Side Diff: mobile/android/thirdparty/org/adblockplus/browser/MoreSubscriptionsPreferenceGroup.java

Issue 29505606: Issue 5360 - Whitelist subscription shown as '-user-35236' (Closed)
Patch Set: Adjustments in code style Created Aug. 7, 2017, 7:22 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
« no previous file with comments | « no previous file | 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 28 matching lines...) Expand all
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
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
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)
285 {
286 this.context = context;
287 }
281 288
282 public void refresh() 289 public void refresh()
283 { 290 {
284 AddOnBridge.queryActiveSubscriptions(this); 291 AddOnBridge.queryActiveSubscriptions(this);
285 this.entriesReady.acquireUninterruptibly(); 292 this.entriesReady.acquireUninterruptibly();
286 } 293 }
287 294
288 @Override 295 @Override
289 public void onApiRequestSucceeded(NativeJSObject jsObject) 296 public void onApiRequestSucceeded(NativeJSObject jsObject)
290 { 297 {
291 try 298 try
292 { 299 {
293 this.enabledSubscriptions.clear(); 300 this.enabledSubscriptions.clear();
294 if (jsObject.getBoolean("success")) 301 if (jsObject.getBoolean("success"))
295 { 302 {
296 NativeJSObject[] subs = jsObject.getObjectArray("value"); 303 NativeJSObject[] subs = jsObject.getObjectArray("value");
297 for (int i = 0; i < subs.length; i++) 304 for (int i = 0; i < subs.length; i++)
298 { 305 {
299 final String url = subs[i].getString("url"); 306 final String url = subs[i].getString("url");
300 final String title = subs[i].has("title") ? subs[i].getString("title ") : url; 307
308 String title = subs[i].has("title") ? subs[i].getString("title") : u rl;
309 if (title.startsWith("~user~"))
310 {
311 title = this.context.getString(R.string.abb_pref_category_whitelis ted_sites);
312 }
313
301 if (!IGNORED_URLS.contains(url)) 314 if (!IGNORED_URLS.contains(url))
302 { 315 {
303 Log.d(TAG, "Adding: " + url + ", " + title); 316 Log.d(TAG, "Adding: " + url + ", " + title);
304 this.enabledSubscriptions.put(url, title); 317 this.enabledSubscriptions.put(url, title);
305 } 318 }
306 } 319 }
307 } 320 }
308 } 321 }
309 finally 322 finally
310 { 323 {
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
348 // ignored 361 // ignored
349 } 362 }
350 363
351 @Override 364 @Override
352 public void onApiRequestFailed(String errorMessage) 365 public void onApiRequestFailed(String errorMessage)
353 { 366 {
354 // ignored 367 // ignored
355 } 368 }
356 } 369 }
357 } 370 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld