| 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); |
| } |
| } |
| } |
| } |