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

Delta Between Two Patch Sets: adblockplussbrowser/src/main/java/org/adblockplus/sbrowser/contentblocker/MainPreferences.java

Issue 29673565: Issue 6066 - Implement 'force update' functionality for subscriptions (Closed)
Left Patch Set: Created Jan. 18, 2018, 1:47 p.m.
Right Patch Set: Fixes Created Jan. 23, 2018, 3:12 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
LEFTRIGHT
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
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 23 matching lines...) Expand all
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)
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.hasInternetConncetion(this); 253 if (ConnectivityUtils.hasNonMeteredConnection(this))
254 if (hasInternet && ConnectivityUtils.hasWifiConncetion(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(hasInternet ? 262 .setMessage(
anton 2018/01/19 10:53:02 i prefer long ?: to look like this: condition ? d
jens 2018/01/19 11:00:28 Acknowledged.
263 R.string.metered_connection_warning : R.string.check_your_connec tion) 263 meteredInternetAvailable
264 ? R.string.metered_connection_warning
265 : R.string.check_your_connection)
264 .setNegativeButton(android.R.string.cancel, new OnClickListener() 266 .setNegativeButton(android.R.string.cancel, new OnClickListener()
265 { 267 {
266 @Override 268 @Override
267 public void onClick(DialogInterface dialog, int which) 269 public void onClick(DialogInterface dialog, int which)
268 { 270 {
269 dialog.cancel(); 271 dialog.cancel();
270 } 272 }
271 }) 273 })
272 .create(); 274 .create();
273 275
274 if (hasInternet) 276 if (meteredInternetAvailable)
275 { 277 {
276 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),
277 new OnClickListener() 279 new OnClickListener()
278 { 280 {
279 @Override 281 @Override
280 public void onClick(DialogInterface dialogInterface, int i) 282 public void onClick(DialogInterface dialogInterface, int i)
281 { 283 {
282 engine.forceUpdateSubscriptions(true); 284 engine.forceUpdateSubscriptions(true);
283 } 285 }
284 }); 286 });
285 } 287 }
286 this.dialog.show(); 288 this.dialog.show();
287 } 289 }
288 return true; 290 return true;
289 } 291 }
290 return false; 292 return false;
291 } 293 }
292 } 294 }
LEFTRIGHT

Powered by Google App Engine
This is Rietveld