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

Side by Side Diff: src/org/adblockplus/android/AdblockPlus.java

Issue 5431458994847744: Automatically enable acceptable ads and notify the user about it (Closed)
Patch Set: Fix prefs and url encode issues Created Nov. 26, 2013, 1:58 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | src/org/adblockplus/android/Preferences.java » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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-2013 Eyeo GmbH 3 * Copyright (C) 2006-2013 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 18 matching lines...) Expand all
29 29
30 import org.adblockplus.android.updater.AlarmReceiver; 30 import org.adblockplus.android.updater.AlarmReceiver;
31 31
32 import android.app.ActivityManager; 32 import android.app.ActivityManager;
33 import android.app.ActivityManager.RunningServiceInfo; 33 import android.app.ActivityManager.RunningServiceInfo;
34 import android.app.AlarmManager; 34 import android.app.AlarmManager;
35 import android.app.Application; 35 import android.app.Application;
36 import android.app.PendingIntent; 36 import android.app.PendingIntent;
37 import android.content.Context; 37 import android.content.Context;
38 import android.content.Intent; 38 import android.content.Intent;
39 import android.content.SharedPreferences;
40 import android.content.SharedPreferences.Editor;
39 import android.content.pm.PackageInfo; 41 import android.content.pm.PackageInfo;
40 import android.content.pm.PackageManager; 42 import android.content.pm.PackageManager;
41 import android.content.pm.PackageManager.NameNotFoundException; 43 import android.content.pm.PackageManager.NameNotFoundException;
42 import android.net.ConnectivityManager; 44 import android.net.ConnectivityManager;
43 import android.net.NetworkInfo; 45 import android.net.NetworkInfo;
44 import android.net.Uri; 46 import android.net.Uri;
45 import android.os.Build; 47 import android.os.Build;
48 import android.preference.PreferenceManager;
46 import android.provider.Settings; 49 import android.provider.Settings;
47 import android.util.Log; 50 import android.util.Log;
48 51
49 public class AdblockPlus extends Application 52 public class AdblockPlus extends Application
50 { 53 {
51 private final static String TAG = "Application"; 54 private final static String TAG = "Application";
52 55
53 private final static Pattern RE_JS = Pattern.compile(".*\\.js$", Pattern.CASE_ INSENSITIVE); 56 private final static Pattern RE_JS = Pattern.compile(".*\\.js$", Pattern.CASE_ INSENSITIVE);
54 private final static Pattern RE_CSS = Pattern.compile(".*\\.css$", Pattern.CAS E_INSENSITIVE); 57 private final static Pattern RE_CSS = Pattern.compile(".*\\.css$", Pattern.CAS E_INSENSITIVE);
55 private final static Pattern RE_IMAGE = Pattern.compile(".*\\.(?:gif|png|jpe?g |bmp|ico)$", Pattern.CASE_INSENSITIVE); 58 private final static Pattern RE_IMAGE = Pattern.compile(".*\\.(?:gif|png|jpe?g |bmp|ico)$", Pattern.CASE_INSENSITIVE);
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 abpEngine.setAcceptableAdsEnabled(enabled); 287 abpEngine.setAcceptableAdsEnabled(enabled);
285 } 288 }
286 289
287 public String getAcceptableAdsUrl() 290 public String getAcceptableAdsUrl()
288 { 291 {
289 final String documentationLink = abpEngine.getDocumentationLink(); 292 final String documentationLink = abpEngine.getDocumentationLink();
290 final String locale = getResources().getConfiguration().locale.toString().re place("_", "-"); 293 final String locale = getResources().getConfiguration().locale.toString().re place("_", "-");
291 return documentationLink.replace("%LINK%", "acceptable_ads").replace("%LANG% ", locale); 294 return documentationLink.replace("%LINK%", "acceptable_ads").replace("%LANG% ", locale);
292 } 295 }
293 296
297 public void setNotifiedAboutAcceptableAds(boolean notified)
298 {
299 final SharedPreferences preferences = PreferenceManager.getDefaultSharedPref erences(this);
300 final Editor editor = preferences.edit();
301 editor.putBoolean("notified_about_acceptable_ads", notified);
302 editor.commit();
303 }
304
305 public boolean isNotifiedAboutAcceptableAds()
306 {
307 final SharedPreferences preferences = PreferenceManager.getDefaultSharedPref erences(this);
308 return preferences.getBoolean("notified_about_acceptable_ads", false);
309 }
310
294 /** 311 /**
295 * Returns ElemHide selectors for domain. 312 * Returns ElemHide selectors for domain.
296 * 313 *
297 * @param domain The domain 314 * @param domain The domain
298 * @return A list of CSS selectors 315 * @return A list of CSS selectors
299 */ 316 */
300 public String[] getSelectorsForDomain(final String domain) 317 public String[] getSelectorsForDomain(final String domain)
301 { 318 {
302 if (!filteringEnabled) 319 if (!filteringEnabled)
303 return null; 320 return null;
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
479 Log.e(TAG, e.getMessage(), e); 496 Log.e(TAG, e.getMessage(), e);
480 } 497 }
481 498
482 // Set crash handler 499 // Set crash handler
483 Thread.setDefaultUncaughtExceptionHandler(new CrashHandler(this)); 500 Thread.setDefaultUncaughtExceptionHandler(new CrashHandler(this));
484 501
485 // Initiate update check 502 // Initiate update check
486 scheduleUpdater(0); 503 scheduleUpdater(0);
487 } 504 }
488 } 505 }
OLDNEW
« no previous file with comments | « no previous file | src/org/adblockplus/android/Preferences.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld