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

Unified Diff: src/org/adblockplus/android/AdvancedPreferences.java

Issue 9437197: ABP/Android Proxy switch (Closed)
Patch Set: Created Feb. 28, 2013, 1:20 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/org/adblockplus/android/AdvancedPreferences.java
===================================================================
--- a/src/org/adblockplus/android/AdvancedPreferences.java
+++ b/src/org/adblockplus/android/AdvancedPreferences.java
@@ -62,10 +62,16 @@
addPreferencesFromResource(R.xml.preferences_advanced);
+ SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
+
PreferenceScreen screen = getPreferenceScreen();
if (ProxyService.NATIVE_PROXY_SUPPORTED)
{
screen.removePreference(findPreference(getString(R.string.pref_proxy)));
+ if (prefs.getBoolean(getString(R.string.pref_proxyautoconfigured), false))
+ {
+ screen.removePreference(findPreference(getString(R.string.pref_proxyenabled)));
+ }
}
if (getResources().getBoolean(R.bool.def_release))
{
@@ -116,6 +122,27 @@
@Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key)
{
+ if (getString(R.string.pref_proxyenabled).equals(key))
+ {
+ AdblockPlus application = AdblockPlus.getApplication();
+ boolean enabled = sharedPreferences.getBoolean(key, false);
+ boolean serviceRunning = application.isServiceRunning();
+ if (enabled && !serviceRunning)
+ {
+ startService(new Intent(this, ProxyService.class));
+ }
+ else
+ {
+ if (serviceRunning)
+ stopService(new Intent(this, ProxyService.class));
+ // If disabled, disable filtering as well
+ SharedPreferences.Editor editor = sharedPreferences.edit();
+ editor.putBoolean(getString(R.string.pref_enabled), enabled);
+ editor.commit();
+ application.setFilteringEnabled(false);
+ application.stopEngine(false);
+ }
+ }
if (getString(R.string.pref_refresh).equals(key))
{
int refresh = Integer.valueOf(sharedPreferences.getString(key, "0"));

Powered by Google App Engine
This is Rietveld