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

Side by Side Diff: adblockplussbrowser/src/main/java/org/adblockplus/sbrowser/contentblocker/util/SubscriptionUtils.java

Issue 29757571: Issue 6591 - Bundle ABP for Samsung Internet China with Easylist for China (Closed)
Patch Set: Adjustments regarding Anton's comments Created April 20, 2018, 3:13 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
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-present eyeo GmbH 3 * Copyright (C) 2006-present 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
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details. 12 * GNU General Public License for more details.
13 * 13 *
14 * You should have received a copy of the GNU General Public License 14 * You should have received a copy of the GNU General Public License
15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
16 */ 16 */
17 17
18 package org.adblockplus.sbrowser.contentblocker.util; 18 package org.adblockplus.sbrowser.contentblocker.util;
19 19
20 import java.util.List; 20 import java.util.List;
21 import java.util.Locale; 21 import java.util.Locale;
22 22
23 import org.adblockplus.adblockplussbrowser.BuildConfig;
23 import org.adblockplus.sbrowser.contentblocker.engine.DefaultSubscriptionInfo; 24 import org.adblockplus.sbrowser.contentblocker.engine.DefaultSubscriptionInfo;
24 import org.adblockplus.sbrowser.contentblocker.engine.Engine; 25 import org.adblockplus.sbrowser.contentblocker.engine.Engine;
25 26
26 import android.content.res.Resources; 27 import android.content.res.Resources;
27 28
28 public class SubscriptionUtils 29 public class SubscriptionUtils
29 { 30 {
30 31
32 public static final String EASYLIST_URL = "https://easylist-downloads.adblockp lus.org/easylist.txt";
33 private static final String EASYLIST_CHINA_URL ="https://easylist-downloads.ad blockplus.org/easylistchina+easylist.txt";
34
31 private static final String INDONESIAN_OLD = "in"; 35 private static final String INDONESIAN_OLD = "in";
32 private static final String INDONESIAN_NEW = "id"; 36 private static final String INDONESIAN_NEW = "id";
33 private static final String HEBREW_OLD = "iw"; 37 private static final String HEBREW_OLD = "iw";
34 private static final String HEBREW_NEW = "he"; 38 private static final String HEBREW_NEW = "he";
35 private static final String YIDDISH_OLD = "ji"; 39 private static final String YIDDISH_OLD = "ji";
36 private static final String YIDDISH_NEW = "yi"; 40 private static final String YIDDISH_NEW = "yi";
37 41
38 /** 42 /**
39 * @param defaultSubscriptions 43 * @param defaultSubscriptions
40 * @return The URL of the filter list which fits best for the device language. 44 * @return The URL of the filter list which fits best for the device language.
41 * If no match was found, return EASYLIST as default. 45 * If no match was found, return EASYLIST as default.
42 */ 46 */
43 public static String chooseDefaultSubscriptionUrl(List<DefaultSubscriptionInfo > defaultSubscriptions) 47 public static String chooseDefaultSubscriptionUrl(List<DefaultSubscriptionInfo > defaultSubscriptions)
44 { 48 {
49 if (BuildConfig.FLAVOR.equals(BuildConfig.FLAVOR_REGION_CHINA))
50 {
51 return EASYLIST_CHINA_URL;
52 }
45 for (final DefaultSubscriptionInfo info : defaultSubscriptions) 53 for (final DefaultSubscriptionInfo info : defaultSubscriptions)
46 { 54 {
47 if (info != null && info.getPrefixes().contains(getDeviceLanguageCode()) & & info.isComplete()) 55 if (info != null && info.getPrefixes().contains(getDeviceLanguageCode()) & & info.isComplete())
48 { 56 {
49 return info.getUrl(); 57 return info.getUrl();
50 } 58 }
51 } 59 }
52 return Engine.EASYLIST_URL; 60 return EASYLIST_URL;
53 } 61 }
54 62
55 @SuppressWarnings("deprecation") 63 @SuppressWarnings("deprecation")
56 private static String getDeviceLanguageCode() 64 private static String getDeviceLanguageCode()
57 { 65 {
58 Locale locale; 66 Locale locale;
59 if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N) 67 if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N)
60 { 68 {
61 locale = Resources.getSystem().getConfiguration().getLocales().get(0); 69 locale = Resources.getSystem().getConfiguration().getLocales().get(0);
62 } 70 }
(...skipping 19 matching lines...) Expand all
82 return HEBREW_NEW; 90 return HEBREW_NEW;
83 case YIDDISH_OLD: 91 case YIDDISH_OLD:
84 return YIDDISH_NEW; 92 return YIDDISH_NEW;
85 case INDONESIAN_OLD: 93 case INDONESIAN_OLD:
86 return INDONESIAN_NEW; 94 return INDONESIAN_NEW;
87 default: 95 default:
88 return language; 96 return language;
89 } 97 }
90 } 98 }
91 } 99 }
OLDNEW

Powered by Google App Engine
This is Rietveld