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: Addressed new review issues Created April 28, 2014, 8:34 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
29 @Override 28 @Override
30 public void onReceive(Context context, Intent intent) 29 public void onReceive(final Context context, final Intent intent)
31 { 30 {
32 String action = intent.getAction(); 31 final String action = intent.getAction();
33 SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(cont ext); 32 final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreference s(context);
34 boolean enabled = prefs.getBoolean(context.getString(R.string.pref_enabled), false); 33 boolean enabled = prefs.getBoolean(context.getString(R.string.pref_enabled), false);
35 boolean proxyenabled = prefs.getBoolean(context.getString(R.string.pref_prox yenabled), true); 34 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); 35 final boolean autoconfigured = prefs.getBoolean(context.getString(R.string.p ref_proxyautoconfigured), false);
37 if (Intent.ACTION_PACKAGE_REPLACED.equals(action)) 36 if (Intent.ACTION_PACKAGE_REPLACED.equals(action))
38 { 37 {
39 String pkg = context.getApplicationInfo().packageName; 38 final String pkg = context.getApplicationInfo().packageName;
40 boolean us = pkg.equals(intent.getData().getSchemeSpecificPart()); 39 final boolean us = pkg.equals(intent.getData().getSchemeSpecificPart());
41 enabled &= us; 40 enabled &= us;
42 proxyenabled &= us; 41 proxyenabled &= us;
43 } 42 }
44 if (Intent.ACTION_BOOT_COMPLETED.equals(action)) 43 if (Intent.ACTION_BOOT_COMPLETED.equals(action))
45 { 44 {
46 boolean startAtBoot = prefs.getBoolean(context.getString(R.string.pref_sta rtatboot), context.getResources().getBoolean(R.bool.def_startatboot)); 45 final boolean startAtBoot = prefs.getBoolean(context.getString(R.string.pr ef_startatboot), context.getResources().getBoolean(R.bool.def_startatboot));
47 enabled &= startAtBoot; 46 enabled &= startAtBoot;
48 proxyenabled &= startAtBoot; 47 proxyenabled &= startAtBoot;
49 } 48 }
50 if (enabled) 49 if (enabled)
51 { 50 {
52 AdblockPlus application = AdblockPlus.getApplication(); 51 final AdblockPlus application = AdblockPlus.getApplication();
53 application.setFilteringEnabled(true); 52 application.setFilteringEnabled(true);
54 application.startEngine(); 53 application.startEngine();
55 } 54 }
56 if (enabled || (proxyenabled && !autoconfigured)) 55 if (enabled || (proxyenabled && !autoconfigured))
57 context.startService(new Intent(context, ProxyService.class)); 56 context.startService(new Intent(context, ProxyService.class));
58 } 57 }
59
60 } 58 }
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