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

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

Issue 9437197: ABP/Android Proxy switch (Closed)
Left Patch Set: Created Feb. 28, 2013, 1:20 p.m.
Right Patch Set: ABP/Android Proxy switch Created March 11, 2013, 7:29 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/ProxySettings.java ('k') | no next file » | 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 the Adblock Plus, 2 * This file is part of the Adblock Plus,
3 * Copyright (C) 2006-2012 Eyeo GmbH 3 * Copyright (C) 2006-2012 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 17 matching lines...) Expand all
28 28
29 @Override 29 @Override
30 public void onReceive(Context context, Intent intent) 30 public void onReceive(Context context, Intent intent)
31 { 31 {
32 String action = intent.getAction(); 32 String action = intent.getAction();
33 SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(cont ext); 33 SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(cont ext);
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), false); 35 boolean proxyenabled = prefs.getBoolean(context.getString(R.string.pref_prox yenabled), false);
36 if (Intent.ACTION_PACKAGE_REPLACED.equals(action)) 36 if (Intent.ACTION_PACKAGE_REPLACED.equals(action))
37 { 37 {
38 boolean us = "org.adblockplus.android".equals(intent.getData().getSchemeSp ecificPart()); 38 String pkg = context.getApplicationInfo().packageName;
Felix Dahlke 2013/03/11 06:57:38 Any idea how we could not hard code the package he
Andrey Novikov 2013/03/11 07:32:55 Done.
Andrey Novikov 2013/03/11 07:32:55 Done.
39 boolean us = pkg.equals(intent.getData().getSchemeSpecificPart());
39 enabled &= us; 40 enabled &= us;
40 proxyenabled &= us; 41 proxyenabled &= us;
41 } 42 }
42 if (Intent.ACTION_BOOT_COMPLETED.equals(action)) 43 if (Intent.ACTION_BOOT_COMPLETED.equals(action))
43 { 44 {
44 boolean startAtBoot = prefs.getBoolean(context.getString(R.string.pref_sta rtatboot), context.getResources().getBoolean(R.bool.def_startatboot)); 45 boolean startAtBoot = prefs.getBoolean(context.getString(R.string.pref_sta rtatboot), context.getResources().getBoolean(R.bool.def_startatboot));
45 enabled &= startAtBoot; 46 enabled &= startAtBoot;
46 proxyenabled &= startAtBoot; 47 proxyenabled &= startAtBoot;
47 } 48 }
48 if (enabled) 49 if (enabled)
49 { 50 {
50 AdblockPlus application = AdblockPlus.getApplication(); 51 AdblockPlus application = AdblockPlus.getApplication();
51 application.setFilteringEnabled(true); 52 application.setFilteringEnabled(true);
52 application.startEngine(); 53 application.startEngine();
53 } 54 }
54 if (proxyenabled) 55 if (proxyenabled)
55 context.startService(new Intent(context, ProxyService.class)); 56 context.startService(new Intent(context, ProxyService.class));
56 } 57 }
57 58
58 } 59 }
LEFTRIGHT

Powered by Google App Engine
This is Rietveld