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

Unified 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.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mobile/android/thirdparty/org/adblockplus/browser/MoreSubscriptionsPreferenceGroup.java
===================================================================
--- a/mobile/android/thirdparty/org/adblockplus/browser/MoreSubscriptionsPreferenceGroup.java
+++ b/mobile/android/thirdparty/org/adblockplus/browser/MoreSubscriptionsPreferenceGroup.java
@@ -41,17 +41,17 @@ public class MoreSubscriptionsPreference
UrlInputDialog.UrlReadyCallback
{
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>();
private static SubscriptionContainer recommendedSubscriptions = null;
private final CheckBoxChangeListener checkBoxChangeListener = new CheckBoxChangeListener();
- private final ActiveSubscriptionContainer activeSubscriptions = new ActiveSubscriptionContainer();
+ private final ActiveSubscriptionContainer activeSubscriptions;
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
@@ -89,23 +89,24 @@ public class MoreSubscriptionsPreference
{
IGNORED_URLS.add(s.url);
}
}
}
public MoreSubscriptionsPreferenceGroup(final Context context, final AttributeSet attrs)
{
- super(context, attrs);
+ this(context, attrs, 0);
}
public MoreSubscriptionsPreferenceGroup(final Context context, final AttributeSet attrs,
final int defStyleAttr)
{
super(context, attrs, defStyleAttr);
+ this.activeSubscriptions = new ActiveSubscriptionContainer(context);
}
@Override
protected View onCreateView(final ViewGroup parent)
{
this.setLayoutResource(R.layout.abb_minimal_widget);
return super.onCreateView(parent);
}
@@ -273,16 +274,22 @@ public class MoreSubscriptionsPreference
Log.d(TAG, "Adding: " + url);
this.addNewSubscription(url);
}
private static class ActiveSubscriptionContainer implements AdblockPlusApiCallback
{
public final HashMap<String, String> enabledSubscriptions = new HashMap<String, String>();
private final Semaphore entriesReady = new Semaphore(0);
+ private final Context context;
+
+ ActiveSubscriptionContainer(Context context)
+ {
+ this.context = context;
+ }
public void refresh()
{
AddOnBridge.queryActiveSubscriptions(this);
this.entriesReady.acquireUninterruptibly();
}
@Override
@@ -292,17 +299,23 @@ public class MoreSubscriptionsPreference
{
this.enabledSubscriptions.clear();
if (jsObject.getBoolean("success"))
{
NativeJSObject[] subs = jsObject.getObjectArray("value");
for (int i = 0; i < subs.length; i++)
{
final String url = subs[i].getString("url");
- final String title = subs[i].has("title") ? subs[i].getString("title") : url;
+
+ String title = subs[i].has("title") ? subs[i].getString("title") : url;
+ if (title.startsWith("~user~"))
+ {
+ title = this.context.getString(R.string.abb_pref_category_whitelisted_sites);
+ }
+
if (!IGNORED_URLS.contains(url))
{
Log.d(TAG, "Adding: " + url + ", " + title);
this.enabledSubscriptions.put(url, title);
}
}
}
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld