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

Delta Between Two Patch Sets: src/org/adblockplus/android/AdblockPlus.java

Issue 5697499218051072: Usage of new API, cleanups (reduced) (Closed)
Left Patch Set: Fixed leftover first-batch review issues. Created April 16, 2014, 5:51 p.m.
Right Patch Set: Even more review issues fixed. Created April 28, 2014, 10:18 a.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
« no previous file with change/comment | « src/org/adblockplus/android/AboutDialog.java ('k') | src/org/adblockplus/android/AdvancedPreferences.java » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 /* 1 /*
2 * This file is part of Adblock Plus <http://adblockplus.org/>, 2 * This file is part of Adblock Plus <http://adblockplus.org/>,
3 * Copyright (C) 2006-2014 Eyeo GmbH 3 * Copyright (C) 2006-2014 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 14 matching lines...) Expand all
25 import java.io.InputStreamReader; 25 import java.io.InputStreamReader;
26 import java.util.ArrayList; 26 import java.util.ArrayList;
27 import java.util.Calendar; 27 import java.util.Calendar;
28 import java.util.LinkedHashMap; 28 import java.util.LinkedHashMap;
29 import java.util.List; 29 import java.util.List;
30 import java.util.Map; 30 import java.util.Map;
31 import java.util.TimeZone; 31 import java.util.TimeZone;
32 import java.util.regex.Pattern; 32 import java.util.regex.Pattern;
33 33
34 import org.adblockplus.android.updater.AlarmReceiver; 34 import org.adblockplus.android.updater.AlarmReceiver;
35 35 import org.apache.commons.lang.StringUtils;
36 import com.github.rjeschke.neetutils.Strings;
37 36
38 import android.app.ActivityManager; 37 import android.app.ActivityManager;
39 import android.app.ActivityManager.RunningServiceInfo; 38 import android.app.ActivityManager.RunningServiceInfo;
40 import android.app.AlarmManager; 39 import android.app.AlarmManager;
41 import android.app.Application; 40 import android.app.Application;
42 import android.app.PendingIntent; 41 import android.app.PendingIntent;
43 import android.content.Context; 42 import android.content.Context;
44 import android.content.Intent; 43 import android.content.Intent;
45 import android.content.SharedPreferences; 44 import android.content.SharedPreferences;
46 import android.content.SharedPreferences.Editor; 45 import android.content.SharedPreferences.Editor;
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after
326 */ 325 */
327 public String[] getSelectorsForDomain(final String domain) 326 public String[] getSelectorsForDomain(final String domain)
328 { 327 {
329 /* We need to ignore element hiding rules here to work around two bugs: 328 /* We need to ignore element hiding rules here to work around two bugs:
330 * 1. CSS is being injected even when there's an exception rule with $elemhi de 329 * 1. CSS is being injected even when there's an exception rule with $elemhi de
331 * 2. The injected CSS causes blank pages in Chrome for Android 330 * 2. The injected CSS causes blank pages in Chrome for Android
332 * 331 *
333 * Starting with 1.1.2, we ignored element hiding rules after download anywa y, to keep the 332 * Starting with 1.1.2, we ignored element hiding rules after download anywa y, to keep the
334 * memory usage down. Doing this with libadblockplus is trickier, but would be the clean 333 * memory usage down. Doing this with libadblockplus is trickier, but would be the clean
335 * solution. */ 334 * solution. */
336
337 return null; 335 return null;
338 /* 336 /*
339 if (!filteringEnabled) 337 if (!filteringEnabled)
340 return null; 338 return null;
341 339
342 return abpEngine.getSelectorsForDomain(domain); 340 return abpEngine.getSelectorsForDomain(domain);
343 */ 341 */
344 } 342 }
345 343
346 /** 344 /**
347 * Checks if filters match request parameters. 345 * Checks if filters match request parameters.
348 * 346 *
349 * @param url 347 * @param url
350 * Request URL 348 * Request URL
351 * @param query 349 * @param query
352 * Request query string 350 * Request query string
353 * @param referrer 351 * @param referrer
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
425 /** 423 /**
426 * Enables or disables filtering. 424 * Enables or disables filtering.
427 */ 425 */
428 public void setFilteringEnabled(final boolean enable) 426 public void setFilteringEnabled(final boolean enable)
429 { 427 {
430 filteringEnabled = enable; 428 filteringEnabled = enable;
431 sendBroadcast(new Intent(BROADCAST_FILTERING_CHANGE).putExtra("enabled", fil teringEnabled)); 429 sendBroadcast(new Intent(BROADCAST_FILTERING_CHANGE).putExtra("enabled", fil teringEnabled));
432 } 430 }
433 431
434 /** 432 /**
435 * Starts ABP engine. It also initiates subscription refresh if it is enabled in user settings. 433 * Starts ABP engine. It also initiates subscription refresh if it is enabled
434 * in user settings.
436 */ 435 */
437 public void startEngine() 436 public void startEngine()
438 { 437 {
439 if (abpEngine == null) 438 if (abpEngine == null)
440 { 439 {
441 final File basePath = getFilesDir(); 440 final File basePath = getFilesDir();
442 abpEngine = ABPEngine.create(AdblockPlus.getApplication(), ABPEngine.gener ateAppInfo(this), basePath.getAbsolutePath()); 441 abpEngine = ABPEngine.create(AdblockPlus.getApplication(), ABPEngine.gener ateAppInfo(this), basePath.getAbsolutePath());
443 } 442 }
444 } 443 }
445 444
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
513 final StringBuilder out = new StringBuilder(); 512 final StringBuilder out = new StringBuilder();
514 int read; 513 int read;
515 do 514 do
516 { 515 {
517 read = reportFile.read(buffer, 0, buffer.length); 516 read = reportFile.read(buffer, 0, buffer.length);
518 if (read > 0) 517 if (read > 0)
519 out.append(buffer, 0, read); 518 out.append(buffer, 0, read);
520 } 519 }
521 while (read >= 0); 520 while (read >= 0);
522 final String report = out.toString(); 521 final String report = out.toString();
523 if (!Strings.isEmpty(report)) 522 if (StringUtils.isNotEmpty(report))
524 { 523 {
525 final Intent intent = new Intent(this, CrashReportDialog.class); 524 final Intent intent = new Intent(this, CrashReportDialog.class);
526 intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 525 intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
527 intent.putExtra("report", report); 526 intent.putExtra("report", report);
528 startActivity(intent); 527 startActivity(intent);
529 } 528 }
530 } 529 }
531 catch (final FileNotFoundException e) 530 catch (final FileNotFoundException e)
532 { 531 {
533 // ignore 532 // ignore
534 } 533 }
535 catch (final IOException e) 534 catch (final IOException e)
536 { 535 {
537 Log.e(TAG, e.getMessage(), e); 536 Log.e(TAG, e.getMessage(), e);
538 } 537 }
539 538
540 // Set crash handler 539 // Set crash handler
541 Thread.setDefaultUncaughtExceptionHandler(new CrashHandler(this)); 540 Thread.setDefaultUncaughtExceptionHandler(new CrashHandler(this));
542 541
543 // Initiate update check 542 // Initiate update check
544 scheduleUpdater(0); 543 scheduleUpdater(0);
545 } 544 }
546 } 545 }
LEFTRIGHT

Powered by Google App Engine
This is Rietveld