Left: | ||
Right: |
LEFT | RIGHT |
---|---|
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 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
197 } | 197 } |
198 | 198 |
199 if (this.dialogTitleResId == R.string.initialization_title) | 199 if (this.dialogTitleResId == R.string.initialization_title) |
200 { | 200 { |
201 this.dismissDialog(); | 201 this.dismissDialog(); |
202 | 202 |
203 this.checkForCompatibleSBrowserAndProceed(); | 203 this.checkForCompatibleSBrowserAndProceed(); |
204 } | 204 } |
205 | 205 |
206 Fragment preferecesFragment = getFragmentManager().findFragmentByTag(Prefere nces.class.getSimpleName()); | 206 Fragment preferecesFragment = getFragmentManager().findFragmentByTag(Prefere nces.class.getSimpleName()); |
207 Preference button = ((Preferences) preferecesFragment).findPreference(getStr ing(R.string.key_update_subscriptions)); | 207 Preference button = ((Preferences) preferecesFragment).findPreference(getStr ing(R.string.key_force_update_subscriptions)); |
208 button.setOnPreferenceClickListener(this); | 208 button.setOnPreferenceClickListener(this); |
209 } | 209 } |
210 | 210 |
211 @Override | 211 @Override |
212 public void onSharedPreferenceChanged(String key) | 212 public void onSharedPreferenceChanged(String key) |
213 { | 213 { |
214 if (this.getString(R.string.key_automatic_updates).equals(key) && this.engin e != null) | 214 if (this.getString(R.string.key_automatic_updates).equals(key) && this.engin e != null) |
215 { | 215 { |
216 this.engine.connectivityChanged(); | 216 this.engine.connectivityChanged(); |
217 } | 217 } |
(...skipping 21 matching lines...) Expand all Loading... | |
239 : getString(R.string.remove_subscription_dialog_message)); | 239 : getString(R.string.remove_subscription_dialog_message)); |
240 } | 240 } |
241 | 241 |
242 @Override | 242 @Override |
243 public void subscriptionUpdatedApplied() | 243 public void subscriptionUpdatedApplied() |
244 { | 244 { |
245 this.dismissDialog(); | 245 this.dismissDialog(); |
246 } | 246 } |
247 | 247 |
248 @Override | 248 @Override |
249 public boolean onPreferenceClick(Preference preference) | 249 public boolean onPreferenceClick(Preference preference) |
diegocarloslima
2018/01/19 13:59:00
So far, instead of adding specific preference logi
jens
2018/01/19 14:32:55
Right, but we only did that for those preferences,
| |
250 { | 250 { |
251 if (getString(R.string.key_update_subscriptions).equals(preference.getKey()) ) | 251 if (getString(R.string.key_force_update_subscriptions).equals(preference.get Key())) |
252 { | 252 { |
253 boolean hasInternet = ConnectivityUtils.hasInternetConnection(this); | 253 if (ConnectivityUtils.hasNonMeteredConnection(this)) |
254 if (hasInternet && ConnectivityUtils.hasWifiConnection(this)) | |
255 { | 254 { |
256 engine.forceUpdateSubscriptions(false); | 255 engine.forceUpdateSubscriptions(false); |
257 } | 256 } |
258 else | 257 else |
259 { | 258 { |
259 boolean meteredInternetAvailable = ConnectivityUtils.canUseInternet(this , true); | |
260 this.dialog = new AlertDialog.Builder(this) | 260 this.dialog = new AlertDialog.Builder(this) |
261 .setTitle(R.string.update_subscriptions) | 261 .setTitle(R.string.update_subscriptions) |
262 .setMessage( | 262 .setMessage( |
263 hasInternet | 263 meteredInternetAvailable |
264 ? R.string.metered_connection_warning | 264 ? R.string.metered_connection_warning |
265 : R.string.check_your_connection) | 265 : R.string.check_your_connection) |
266 .setNegativeButton(android.R.string.cancel, new OnClickListener() | 266 .setNegativeButton(android.R.string.cancel, new OnClickListener() |
267 { | 267 { |
268 @Override | 268 @Override |
269 public void onClick(DialogInterface dialog, int which) | 269 public void onClick(DialogInterface dialog, int which) |
270 { | 270 { |
271 dialog.cancel(); | 271 dialog.cancel(); |
272 } | 272 } |
273 }) | 273 }) |
274 .create(); | 274 .create(); |
275 | 275 |
276 if (hasInternet) | 276 if (meteredInternetAvailable) |
277 { | 277 { |
278 this.dialog.setButton(DialogInterface.BUTTON_POSITIVE, getString(andro id.R.string.yes), | 278 this.dialog.setButton(DialogInterface.BUTTON_POSITIVE, getString(andro id.R.string.yes), |
279 new OnClickListener() | 279 new OnClickListener() |
280 { | 280 { |
281 @Override | 281 @Override |
282 public void onClick(DialogInterface dialogInterface, int i) | 282 public void onClick(DialogInterface dialogInterface, int i) |
283 { | 283 { |
284 engine.forceUpdateSubscriptions(true); | 284 engine.forceUpdateSubscriptions(true); |
285 } | 285 } |
286 }); | 286 }); |
287 } | 287 } |
288 this.dialog.show(); | 288 this.dialog.show(); |
289 } | 289 } |
290 return true; | 290 return true; |
291 } | 291 } |
292 return false; | 292 return false; |
293 } | 293 } |
294 } | 294 } |
LEFT | RIGHT |