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

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

Issue 5697499218051072: Usage of new API, cleanups (reduced) (Closed)
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:
View unified diff | Download patch
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-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
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details. 12 * GNU General Public License for more details.
13 * 13 *
14 * You should have received a copy of the GNU General Public License 14 * You should have received a copy of the GNU General Public License
15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
16 */ 16 */
17 17
18 package org.adblockplus.android; 18 package org.adblockplus.android;
19 19
20 import android.content.BroadcastReceiver; 20 import android.content.BroadcastReceiver;
21 import android.content.Context; 21 import android.content.Context;
22 import android.content.Intent; 22 import android.content.Intent;
23 import android.content.SharedPreferences; 23 import android.content.SharedPreferences;
24 import android.preference.PreferenceManager; 24 import android.preference.PreferenceManager;
25 25
26 public class Starter extends BroadcastReceiver 26 public class Starter extends BroadcastReceiver
27 { 27 {
28 28
29 @Override 29 @Override
30 public void onReceive(Context context, Intent intent) 30 public void onReceive(final Context context, final Intent intent)
31 { 31 {
32 String action = intent.getAction(); 32 final String action = intent.getAction();
33 SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(cont ext); 33 final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreference s(context);
34 boolean enabled = prefs.getBoolean(context.getString(R.string.pref_enabled), false); 34 boolean enabled = prefs.getBoolean(context.getString(R.string.pref_enabled), false);
35 boolean proxyenabled = prefs.getBoolean(context.getString(R.string.pref_prox yenabled), true); 35 boolean proxyenabled = prefs.getBoolean(context.getString(R.string.pref_prox yenabled), true);
36 boolean autoconfigured = prefs.getBoolean(context.getString(R.string.pref_pr oxyautoconfigured), false); 36 final boolean autoconfigured = prefs.getBoolean(context.getString(R.string.p ref_proxyautoconfigured), false);
37 if (Intent.ACTION_PACKAGE_REPLACED.equals(action)) 37 if (Intent.ACTION_PACKAGE_REPLACED.equals(action))
38 { 38 {
39 String pkg = context.getApplicationInfo().packageName; 39 final String pkg = context.getApplicationInfo().packageName;
40 boolean us = pkg.equals(intent.getData().getSchemeSpecificPart()); 40 final boolean us = pkg.equals(intent.getData().getSchemeSpecificPart());
41 enabled &= us; 41 enabled &= us;
42 proxyenabled &= us; 42 proxyenabled &= us;
43 } 43 }
44 if (Intent.ACTION_BOOT_COMPLETED.equals(action)) 44 if (Intent.ACTION_BOOT_COMPLETED.equals(action))
45 { 45 {
46 boolean startAtBoot = prefs.getBoolean(context.getString(R.string.pref_sta rtatboot), context.getResources().getBoolean(R.bool.def_startatboot)); 46 final boolean startAtBoot = prefs.getBoolean(context.getString(R.string.pr ef_startatboot), context.getResources().getBoolean(R.bool.def_startatboot));
47 enabled &= startAtBoot; 47 enabled &= startAtBoot;
48 proxyenabled &= startAtBoot; 48 proxyenabled &= startAtBoot;
49 } 49 }
50 if (enabled) 50 if (enabled)
51 { 51 {
52 AdblockPlus application = AdblockPlus.getApplication(); 52 final AdblockPlus application = AdblockPlus.getApplication();
53 application.setFilteringEnabled(true); 53 application.setFilteringEnabled(true);
54 application.startEngine(); 54 application.startEngine();
55 } 55 }
56 if (enabled || (proxyenabled && !autoconfigured)) 56 if (enabled || (proxyenabled && !autoconfigured))
57 context.startService(new Intent(context, ProxyService.class)); 57 context.startService(new Intent(context, ProxyService.class));
58 } 58 }
59 59
60 } 60 }
OLDNEW
« no previous file with comments | « src/org/adblockplus/android/RefreshableListPreference.java ('k') | src/org/adblockplus/android/SubscriptionParser.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld