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

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

Issue 11172036: ABP/Android libadblockplus integration (Closed)
Patch Set: Created July 22, 2013, 8:52 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-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 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 } 120 }
121 121
122 @Override 122 @Override
123 public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, Str ing key) 123 public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, Str ing key)
124 { 124 {
125 if (getString(R.string.pref_proxyenabled).equals(key)) 125 if (getString(R.string.pref_proxyenabled).equals(key))
126 { 126 {
127 AdblockPlus application = AdblockPlus.getApplication(); 127 AdblockPlus application = AdblockPlus.getApplication();
128 boolean enabled = sharedPreferences.getBoolean(key, false); 128 boolean enabled = sharedPreferences.getBoolean(key, false);
129 boolean serviceRunning = application.isServiceRunning(); 129 boolean serviceRunning = application.isServiceRunning();
130 if (enabled && !serviceRunning) 130 if (enabled)
131 { 131 {
132 startService(new Intent(this, ProxyService.class)); 132 if (!serviceRunning)
133 startService(new Intent(this, ProxyService.class));
133 } 134 }
134 else 135 else
135 { 136 {
136 if (serviceRunning) 137 if (serviceRunning)
137 stopService(new Intent(this, ProxyService.class)); 138 stopService(new Intent(this, ProxyService.class));
138 // If disabled, disable filtering as well 139 // If disabled, disable filtering as well
139 SharedPreferences.Editor editor = sharedPreferences.edit(); 140 SharedPreferences.Editor editor = sharedPreferences.edit();
140 editor.putBoolean(getString(R.string.pref_enabled), enabled); 141 editor.putBoolean(getString(R.string.pref_enabled), false);
141 editor.commit(); 142 editor.commit();
142 application.setFilteringEnabled(false); 143 application.setFilteringEnabled(false);
143 application.stopEngine(false);
144 } 144 }
145 } 145 }
146 if (getString(R.string.pref_refresh).equals(key)) 146 if (getString(R.string.pref_refresh).equals(key))
147 { 147 {
148 int refresh = Integer.valueOf(sharedPreferences.getString(key, "0")); 148 int refresh = Integer.valueOf(sharedPreferences.getString(key, "0"));
149 findPreference(getString(R.string.pref_wifirefresh)).setEnabled(refresh > 0); 149 findPreference(getString(R.string.pref_wifirefresh)).setEnabled(refresh > 0);
150 } 150 }
151 if (getString(R.string.pref_crashreport).equals(key)) 151 if (getString(R.string.pref_crashreport).equals(key))
152 { 152 {
153 boolean report = sharedPreferences.getBoolean(key, getResources().getBoole an(R.bool.def_crashreport)); 153 boolean report = sharedPreferences.getBoolean(key, getResources().getBoole an(R.bool.def_crashreport));
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 Log.d(TAG, "Proxy service connected"); 267 Log.d(TAG, "Proxy service connected");
268 } 268 }
269 269
270 public void onServiceDisconnected(ComponentName className) 270 public void onServiceDisconnected(ComponentName className)
271 { 271 {
272 proxyService = null; 272 proxyService = null;
273 Log.d(TAG, "Proxy service disconnected"); 273 Log.d(TAG, "Proxy service disconnected");
274 } 274 }
275 }; 275 };
276 } 276 }
OLDNEW

Powered by Google App Engine
This is Rietveld