FIx crash in proxy setting
This commit is contained in:
parent
e5781e92ba
commit
9050c44f76
2 changed files with 16 additions and 3 deletions
|
@ -9,6 +9,7 @@
|
|||
3. All your modified/created strings are in the top of the file (to make easier find what\'s translated).
|
||||
PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy
|
||||
-->
|
||||
<string name="wrong_format">Wrong format</string>
|
||||
<string name="shared_string_road">Road</string>
|
||||
<string name="show_map">Show map</string>
|
||||
<string name="route_is_calculated">Route is calculated</string>
|
||||
|
|
|
@ -58,6 +58,12 @@ import java.util.List;
|
|||
|
||||
public class SettingsGeneralActivity extends SettingsBaseActivity implements OnRequestPermissionsResultCallback {
|
||||
|
||||
private static final String IP_ADDRESS_PATTERN =
|
||||
"^([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\." +
|
||||
"([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\." +
|
||||
"([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\." +
|
||||
"([01]?\\d\\d?|2[0-4]\\d|25[0-5])$";
|
||||
|
||||
private Preference applicationDir;
|
||||
private ListPreference applicationModePreference;
|
||||
private Preference drivingRegionPreference;
|
||||
|
@ -366,9 +372,15 @@ public class SettingsGeneralActivity extends SettingsBaseActivity implements OnR
|
|||
hostPref.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||
settings.PROXY_HOST.set((String) newValue);
|
||||
enableProxy(NetworkUtils.getProxy() != null);
|
||||
return true;
|
||||
String ipAddress = (String) newValue;
|
||||
if (ipAddress.matches(IP_ADDRESS_PATTERN)) {
|
||||
settings.PROXY_HOST.set(ipAddress);
|
||||
enableProxy(NetworkUtils.getProxy() != null);
|
||||
return true;
|
||||
} else {
|
||||
Toast.makeText(SettingsGeneralActivity.this, getString(R.string.wrong_format), Toast.LENGTH_SHORT).show();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in a new issue