fix proxy settings
This commit is contained in:
parent
ff7c54e739
commit
d90a011561
2 changed files with 19 additions and 7 deletions
|
@ -284,13 +284,20 @@ public class PreferencesFragment extends PreferenceFragment implements SharedPre
|
||||||
Boolean httpProxyEnabled = sharedPreferences.getBoolean("httpProxyEnabled", false);
|
Boolean httpProxyEnabled = sharedPreferences.getBoolean("httpProxyEnabled", false);
|
||||||
|
|
||||||
String httpServer = sharedPreferences.getString("httpProxyServer", "");
|
String httpServer = sharedPreferences.getString("httpProxyServer", "");
|
||||||
int httpPort = Integer.parseInt(sharedPreferences.getString("httpProxyPort", "-1"));
|
|
||||||
|
|
||||||
if (httpProxyEnabled && !httpServer.isEmpty() && (httpPort > 0 && httpPort < 65535)) {
|
try {
|
||||||
httpProxyPref.setSummary(httpServer + ":" + httpPort);
|
int httpPort = Integer.parseInt(sharedPreferences.getString("httpProxyPort", "-1"));
|
||||||
} else {
|
|
||||||
httpProxyPref.setSummary("");
|
if (httpProxyEnabled && !httpServer.isEmpty() && (httpPort > 0 && httpPort < 65535)) {
|
||||||
|
httpProxyPref.setSummary(httpServer + ":" + httpPort);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
// user has entered wrong port, fall back to empty summary
|
||||||
}
|
}
|
||||||
|
|
||||||
|
httpProxyPref.setSummary("");
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,10 +71,15 @@ public class OkHttpUtils {
|
||||||
|
|
||||||
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
|
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
|
||||||
|
|
||||||
|
|
||||||
boolean httpProxyEnabled = preferences.getBoolean("httpProxyEnabled", false);
|
boolean httpProxyEnabled = preferences.getBoolean("httpProxyEnabled", false);
|
||||||
String httpServer = preferences.getString("httpProxyServer", "");
|
String httpServer = preferences.getString("httpProxyServer", "");
|
||||||
int httpPort = Integer.parseInt(preferences.getString("httpProxyPort", "-1"));
|
int httpPort;
|
||||||
|
try {
|
||||||
|
httpPort = Integer.parseInt(preferences.getString("httpProxyPort", "-1"));
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
// user has entered wrong port, fall back to no proxy
|
||||||
|
httpPort = -1;
|
||||||
|
}
|
||||||
|
|
||||||
ConnectionSpec fallback = new ConnectionSpec.Builder(ConnectionSpec.MODERN_TLS)
|
ConnectionSpec fallback = new ConnectionSpec.Builder(ConnectionSpec.MODERN_TLS)
|
||||||
.allEnabledCipherSuites()
|
.allEnabledCipherSuites()
|
||||||
|
|
Loading…
Reference in a new issue