Fix settings

This commit is contained in:
Victor Shcherb 2017-05-27 18:49:51 +02:00
parent a594455dc8
commit a23bc2772c
3 changed files with 4 additions and 2 deletions

View file

@ -145,7 +145,7 @@ public class OsmandApplication extends MultiDexApplication {
appCustomization.setup(this);
osmandSettings = appCustomization.getOsmandSettings();
appInitializer.initVariables();
if (PreferenceManager.getDefaultSharedPreferences(this).getBoolean("enable_proxy", false)) {
if (osmandSettings.ENABLE_PROXY.get()) {
NetworkUtils.setProxy(osmandSettings.PROXY_HOST.get(), osmandSettings.PROXY_PORT.get());
}
if (appInitializer.isAppVersionChanged() && appInitializer.getPrevAppVersion() < AppInitializer.VERSION_2_3) {

View file

@ -999,6 +999,7 @@ public class OsmandSettings {
public final CommonPreference<Boolean> INTERRUPT_MUSIC = new BooleanPreference("interrupt_music", false).makeProfile();
public final CommonPreference<Boolean> ENABLE_PROXY = new BooleanPreference("enable_proxy", false).makeGlobal();
public final CommonPreference<String> PROXY_HOST = new StringPreference("proxy_host", "127.0.0.1").makeGlobal();
public final CommonPreference<Integer> PROXY_PORT = new IntPreference("proxy_port", 8118).makeGlobal();

View file

@ -342,6 +342,7 @@ public class SettingsGeneralActivity extends SettingsBaseActivity implements OnR
protected void enableProxy(boolean enable) {
settings.ENABLE_PROXY.set(enable);
if (enable) {
NetworkUtils.setProxy(settings.PROXY_HOST.get(), settings.PROXY_PORT.get());
} else {
@ -350,7 +351,7 @@ public class SettingsGeneralActivity extends SettingsBaseActivity implements OnR
}
private void addProxyPrefs(PreferenceGroup proxy) {
CheckBoxPreference enableProxyPref = (CheckBoxPreference) proxy.findPreference("enable_proxy");
CheckBoxPreference enableProxyPref = (CheckBoxPreference) proxy.findPreference(settings.ENABLE_PROXY.getId());
enableProxyPref.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {