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

Side by Side Diff: libadblockplus-android-settings/src/org/adblockplus/libadblockplus/android/settings/AdblockSettingsStorage.java

Issue 29361445: Issue 4399 - Add WebView inheritor with ad blocking (Closed)
Patch Set: added retaining in asynchronous mode Created Nov. 25, 2016, 7:08 a.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
(Empty)
1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-2016 Eyeo GmbH
4 *
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
7 * published by the Free Software Foundation.
8 *
9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
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/>.
16 */
17
18 package org.adblockplus.libadblockplus.android.settings;
19
20 import org.adblockplus.libadblockplus.android.AdblockEngine;
21 import org.adblockplus.libadblockplus.android.Subscription;
22
23 import java.util.LinkedList;
24 import java.util.List;
25
26 /**
27 * Settings storage base class
28 */
29 public abstract class AdblockSettingsStorage
30 {
31 /**
32 * Load settings from the storage
33 *
34 * Warning: can return null if not saved yet
35 * Warning: subscriptions can have `url` and `title` only to be identified amo ng available in AdblockEngine
36 * @return AdblockSettings instance or null
37 */
38 public abstract AdblockSettings load();
39
40 /**
41 * Save settings to the storage
42 *
43 * @param settings should be not null
44 */
45 public abstract void save(AdblockSettings settings);
46
47 /**
48 * Get default settings
49 *
50 * @param adblockEngine adblock engine
51 * @return not null default settings
52 */
53 public static AdblockSettings getDefaultSettings(AdblockEngine adblockEngine)
54 {
55 AdblockSettings settings = new AdblockSettings();
56
57 // read actual values from adblock engine
58 settings.setAdblockEnabled(adblockEngine.isEnabled());
59 settings.setAcceptableAdsEnabled(adblockEngine.isAcceptableAdsEnabled());
60
61 // we need to filter out exceptions subscription to show languages subscript ions only
62 Subscription[] listedSubscriptions = adblockEngine.getListedSubscriptions();
63 List<Subscription> subscriptionsWithoutAA = new LinkedList<Subscription>();
diegocarloslima 2016/11/29 17:47:44 I wouldn't insist, but I would advise to use the d
64 String acceptableAdsURL = adblockEngine.getAcceptableAdsSubscriptionURL();
65
66 for (Subscription eachListedSubscription : listedSubscriptions)
67 {
68 if (!eachListedSubscription.url.equals(acceptableAdsURL))
69 {
70 subscriptionsWithoutAA.add(eachListedSubscription);
71 }
72 }
73
74 settings.setSubscriptions(subscriptionsWithoutAA);
75
76 return settings;
77 }
78 }
OLDNEW

Powered by Google App Engine
This is Rietveld