OLD | NEW |
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 |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 private void init() | 62 private void init() |
63 { | 63 { |
64 this.setLayoutResource(R.layout.abb_minimal_widget); | 64 this.setLayoutResource(R.layout.abb_minimal_widget); |
65 } | 65 } |
66 | 66 |
67 @Override | 67 @Override |
68 protected void onAttachedToActivity() | 68 protected void onAttachedToActivity() |
69 { | 69 { |
70 super.onAttachedToActivity(); | 70 super.onAttachedToActivity(); |
71 this.showDialog(); | 71 this.showDialog(); |
72 AddOnBridge.queryWhitelistedWebsites(this); | 72 ExtensionBridge.queryWhitelistedWebsites(this); |
73 } | 73 } |
74 | 74 |
75 @Override | 75 @Override |
76 public void onApiRequestSucceeded(GeckoBundle bundle) | 76 public void onApiRequestSucceeded(GeckoBundle bundle) |
77 { | 77 { |
78 this.dismissDialog(); | 78 this.dismissDialog(); |
79 this.initEntries(bundle); | 79 this.initEntries(bundle); |
80 } | 80 } |
81 | 81 |
82 @Override | 82 @Override |
83 public void onApiRequestFailed(String errorMessage) | 83 public void onApiRequestFailed(String errorMessage) |
84 { | 84 { |
85 Log.w(TAG, "queryWhitelistedWebsites failed: " + errorMessage); | 85 Log.w(TAG, "queryWhitelistedWebsites failed: " + errorMessage); |
86 this.dismissDialog(); | 86 this.dismissDialog(); |
87 } | 87 } |
88 | 88 |
89 @Override | 89 @Override |
90 public void onInputReady(String input) | 90 public void onInputReady(String input) |
91 { | 91 { |
92 this.whitelistedWebsites.add(UrlUtils.getHostFromUrl(input)); | 92 this.whitelistedWebsites.add(UrlUtils.getHostFromUrl(input)); |
93 AddOnBridge.whitelistWebsite(input, true, this.whitelistCallback); | 93 ExtensionBridge.whitelistWebsite(input, true, this.whitelistCallback); |
94 this.refreshEntries(); | 94 this.refreshEntries(); |
95 } | 95 } |
96 | 96 |
97 private void initEntries(GeckoBundle bundle) | 97 private void initEntries(GeckoBundle bundle) |
98 { | 98 { |
99 this.whitelistedWebsites.clear(); | 99 this.whitelistedWebsites.clear(); |
100 | 100 |
101 for(final GeckoBundle whitelistedWebsite : bundle.getBundleArray("value")) | 101 for(final GeckoBundle whitelistedWebsite : bundle.getBundleArray("value")) |
102 { | 102 { |
103 final String url = whitelistedWebsite.getString("url"); | 103 final String url = whitelistedWebsite.getString("url"); |
104 this.whitelistedWebsites.add(url); | 104 this.whitelistedWebsites.add(url); |
105 } | 105 } |
106 | 106 |
107 this.refreshEntries(); | 107 this.refreshEntries(); |
108 } | 108 } |
109 | 109 |
110 private void refreshEntries() | 110 private void refreshEntries() |
111 { | 111 { |
112 this.removeAll(); | 112 this.removeAll(); |
113 for (final String url : this.whitelistedWebsites) | 113 for (final String url : this.whitelistedWebsites) |
114 { | 114 { |
115 final WhitelistedWebsitePreference whitelistedWebsitePreference = | 115 final WhitelistedWebsitePreference whitelistedWebsitePreference = |
116 new WhitelistedWebsitePreference(this.getContext(), url, new DialogInt
erface.OnClickListener() | 116 new WhitelistedWebsitePreference(this.getContext(), url, new DialogInt
erface.OnClickListener() |
117 { | 117 { |
118 @Override | 118 @Override |
119 public void onClick(DialogInterface dialog, int which) | 119 public void onClick(DialogInterface dialog, int which) |
120 { | 120 { |
121 AddOnBridge.whitelistWebsite(url, false, WhitelistedWebsitesPrefer
enceGroup.this.whitelistCallback); | 121 ExtensionBridge.whitelistWebsite(url, false, WhitelistedWebsitesPr
eferenceGroup.this.whitelistCallback); |
122 WhitelistedWebsitesPreferenceGroup.this.whitelistedWebsites.remove
(url); | 122 WhitelistedWebsitesPreferenceGroup.this.whitelistedWebsites.remove
(url); |
123 WhitelistedWebsitesPreferenceGroup.this.refreshEntries(); | 123 WhitelistedWebsitesPreferenceGroup.this.refreshEntries(); |
124 } | 124 } |
125 }); | 125 }); |
126 this.addPreference(whitelistedWebsitePreference); | 126 this.addPreference(whitelistedWebsitePreference); |
127 } | 127 } |
128 | 128 |
129 final InputValidatorDialogPreference inputPreference = new InputValidatorDia
logPreference( | 129 final InputValidatorDialogPreference inputPreference = new InputValidatorDia
logPreference( |
130 this.getContext()); | 130 this.getContext()); |
131 inputPreference.setValidationType(InputValidatorDialogPreference.ValidationT
ype.DOMAIN); | 131 inputPreference.setValidationType(InputValidatorDialogPreference.ValidationT
ype.DOMAIN); |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 ThreadUtils.postToUiThread(this.reloadTabsRunnable); | 236 ThreadUtils.postToUiThread(this.reloadTabsRunnable); |
237 } | 237 } |
238 | 238 |
239 @Override | 239 @Override |
240 public void onApiRequestFailed(String errorMessage) | 240 public void onApiRequestFailed(String errorMessage) |
241 { | 241 { |
242 Log.w(TAG, "whitelistWebsite failed: " + errorMessage); | 242 Log.w(TAG, "whitelistWebsite failed: " + errorMessage); |
243 } | 243 } |
244 } | 244 } |
245 } | 245 } |
OLD | NEW |