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

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

Issue 9437197: ABP/Android Proxy switch (Closed)
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:
View unified diff | Download patch
OLDNEW
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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 55
56 private ProxyService proxyService = null; 56 private ProxyService proxyService = null;
57 57
58 @Override 58 @Override
59 public void onCreate(Bundle savedInstanceState) 59 public void onCreate(Bundle savedInstanceState)
60 { 60 {
61 super.onCreate(savedInstanceState); 61 super.onCreate(savedInstanceState);
62 62
63 addPreferencesFromResource(R.xml.preferences_advanced); 63 addPreferencesFromResource(R.xml.preferences_advanced);
64 64
65 SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this );
66
65 PreferenceScreen screen = getPreferenceScreen(); 67 PreferenceScreen screen = getPreferenceScreen();
66 if (ProxyService.NATIVE_PROXY_SUPPORTED) 68 if (ProxyService.NATIVE_PROXY_SUPPORTED)
67 { 69 {
68 screen.removePreference(findPreference(getString(R.string.pref_proxy))); 70 screen.removePreference(findPreference(getString(R.string.pref_proxy)));
71 if (prefs.getBoolean(getString(R.string.pref_proxyautoconfigured), false))
72 {
73 screen.removePreference(findPreference(getString(R.string.pref_proxyenab led)));
74 }
69 } 75 }
70 if (getResources().getBoolean(R.bool.def_release)) 76 if (getResources().getBoolean(R.bool.def_release))
71 { 77 {
72 screen.removePreference(findPreference(getString(R.string.pref_support))); 78 screen.removePreference(findPreference(getString(R.string.pref_support)));
73 } 79 }
74 else 80 else
75 { 81 {
76 Preference prefUpdate = findPreference(getString(R.string.pref_checkupdate )); 82 Preference prefUpdate = findPreference(getString(R.string.pref_checkupdate ));
77 prefUpdate.setOnPreferenceClickListener(new OnPreferenceClickListener() 83 prefUpdate.setOnPreferenceClickListener(new OnPreferenceClickListener()
78 { 84 {
(...skipping 30 matching lines...) Expand all
109 @Override 115 @Override
110 public void onPause() 116 public void onPause()
111 { 117 {
112 super.onPause(); 118 super.onPause();
113 disconnect(); 119 disconnect();
114 } 120 }
115 121
116 @Override 122 @Override
117 public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, Str ing key) 123 public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, Str ing key)
118 { 124 {
125 if (getString(R.string.pref_proxyenabled).equals(key))
126 {
127 AdblockPlus application = AdblockPlus.getApplication();
128 boolean enabled = sharedPreferences.getBoolean(key, false);
129 boolean serviceRunning = application.isServiceRunning();
130 if (enabled && !serviceRunning)
131 {
132 startService(new Intent(this, ProxyService.class));
133 }
134 else
135 {
136 if (serviceRunning)
137 stopService(new Intent(this, ProxyService.class));
138 // If disabled, disable filtering as well
139 SharedPreferences.Editor editor = sharedPreferences.edit();
140 editor.putBoolean(getString(R.string.pref_enabled), enabled);
141 editor.commit();
142 application.setFilteringEnabled(false);
143 application.stopEngine(false);
144 }
145 }
119 if (getString(R.string.pref_refresh).equals(key)) 146 if (getString(R.string.pref_refresh).equals(key))
120 { 147 {
121 int refresh = Integer.valueOf(sharedPreferences.getString(key, "0")); 148 int refresh = Integer.valueOf(sharedPreferences.getString(key, "0"));
122 findPreference(getString(R.string.pref_wifirefresh)).setEnabled(refresh > 0); 149 findPreference(getString(R.string.pref_wifirefresh)).setEnabled(refresh > 0);
123 } 150 }
124 if (getString(R.string.pref_crashreport).equals(key)) 151 if (getString(R.string.pref_crashreport).equals(key))
125 { 152 {
126 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));
127 try 154 try
128 { 155 {
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 Log.d(TAG, "Proxy service connected"); 267 Log.d(TAG, "Proxy service connected");
241 } 268 }
242 269
243 public void onServiceDisconnected(ComponentName className) 270 public void onServiceDisconnected(ComponentName className)
244 { 271 {
245 proxyService = null; 272 proxyService = null;
246 Log.d(TAG, "Proxy service disconnected"); 273 Log.d(TAG, "Proxy service disconnected");
247 } 274 }
248 }; 275 };
249 } 276 }
OLDNEW
« no previous file with comments | « src/org/adblockplus/android/AdblockPlus.java ('k') | src/org/adblockplus/android/Preferences.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld