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 .
*/
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 BUILTIN_URL_TO_INDEX = new HashMap();
- private static final HashSet IGNORED_URLS = new HashSet();
+
+ public static final List BUILTIN_URLS = Arrays.asList(
+ "https://easylist-downloads.adblockplus.org/easyprivacy.txt",
+ "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 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 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))
+ {
+ 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 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);
Index: mobile/android/base/java/org/adblockplus/browser/SubscriptionPreferenceCategory.java
===================================================================
--- a/mobile/android/base/java/org/adblockplus/browser/SubscriptionPreferenceCategory.java
+++ b/mobile/android/base/java/org/adblockplus/browser/SubscriptionPreferenceCategory.java
@@ -151,17 +151,20 @@
if (entries.isEmpty())
{
this.addPreference(this.createDisabledPreference(titleId, summaryId));
}
else
{
for (SubscriptionContainer.Subscription e : entries)
{
- this.addPreference(this.createEnabledCheckBox(e));
+ if(!MoreSubscriptionsPreferenceGroup.BUILTIN_URLS.contains(e.url))
+ {
+ this.addPreference(this.createEnabledCheckBox(e));
+ }
}
}
}
private void showProgressDialog()
{
this.progressDialog = new ProgressDialog(this.getContext());
this.progressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);