LEFT | RIGHT |
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 Loading... |
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 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 |
294 public void setNotifiedAboutAcceptableAds(boolean notified) | 297 public void setNotifiedAboutAcceptableAds(boolean notified) |
295 { | 298 { |
296 abpEngine.setNotifiedAboutAcceptableAds(notified); | 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(); |
297 } | 303 } |
298 | 304 |
299 public boolean isNotifiedAboutAcceptableAds() | 305 public boolean isNotifiedAboutAcceptableAds() |
300 { | 306 { |
301 return abpEngine.isNotifiedAboutAcceptableAds(); | 307 final SharedPreferences preferences = PreferenceManager.getDefaultSharedPref
erences(this); |
| 308 return preferences.getBoolean("notified_about_acceptable_ads", false); |
302 } | 309 } |
303 | 310 |
304 /** | 311 /** |
305 * Returns ElemHide selectors for domain. | 312 * Returns ElemHide selectors for domain. |
306 * | 313 * |
307 * @param domain The domain | 314 * @param domain The domain |
308 * @return A list of CSS selectors | 315 * @return A list of CSS selectors |
309 */ | 316 */ |
310 public String[] getSelectorsForDomain(final String domain) | 317 public String[] getSelectorsForDomain(final String domain) |
311 { | 318 { |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
489 Log.e(TAG, e.getMessage(), e); | 496 Log.e(TAG, e.getMessage(), e); |
490 } | 497 } |
491 | 498 |
492 // Set crash handler | 499 // Set crash handler |
493 Thread.setDefaultUncaughtExceptionHandler(new CrashHandler(this)); | 500 Thread.setDefaultUncaughtExceptionHandler(new CrashHandler(this)); |
494 | 501 |
495 // Initiate update check | 502 // Initiate update check |
496 scheduleUpdater(0); | 503 scheduleUpdater(0); |
497 } | 504 } |
498 } | 505 } |
LEFT | RIGHT |