remove check if URL isEmpty; dont set 5055 as default port
Этот коммит содержится в:
@@ -290,13 +290,8 @@ public class MainActivity extends PreferenceActivity implements OnSharedPreferen
|
||||
}
|
||||
|
||||
private boolean validateServerURL(String userUrl) {
|
||||
if (userUrl == null || userUrl.trim().length() == 0) {
|
||||
EditTextPreference preference = (EditTextPreference) findPreference(KEY_URL);
|
||||
preference.setText(getString(R.string.settings_url_default_value));
|
||||
return false;
|
||||
}
|
||||
int port = Uri.parse(userUrl).getPort();
|
||||
if (URLUtil.isValidUrl(userUrl) && (port >= -1 && port <= 65535)
|
||||
if (URLUtil.isValidUrl(userUrl) && (port == -1 || (port > 0 && port <= 65535))
|
||||
&& (URLUtil.isHttpUrl(userUrl) || URLUtil.isHttpsUrl(userUrl))) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -38,10 +38,7 @@ public class ProtocolFormatter {
|
||||
if (alarm != null) {
|
||||
builder.appendQueryParameter("alarm", alarm);
|
||||
}
|
||||
int port = serverUrl.getPort();
|
||||
if (port == -1) {
|
||||
builder.encodedAuthority(serverUrl.getHost() + ":" + 5055);
|
||||
}
|
||||
|
||||
return builder.build().toString();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
<string name="settings_id_title">Device identifier</string>
|
||||
<string name="settings_url_title">Server URL</string>
|
||||
<string name="settings_url_summary">Tracking server URL</string>
|
||||
<string name="settings_url_default_value" translatable="false">http://demo.traccar.org</string>
|
||||
<string name="settings_url_default_value" translatable="false">http://demo.traccar.org:5055</string>
|
||||
<string name="settings_interval_title">Frequency</string>
|
||||
<string name="settings_interval_summary">Reporting interval in seconds</string>
|
||||
<string name="settings_distance_title">Distance</string>
|
||||
|
||||
@@ -22,7 +22,7 @@ public class ProtocolFormatterTest {
|
||||
Position position = new Position("123456789012345", new Location("gps"), 0);
|
||||
position.setTime(new Date(0));
|
||||
|
||||
String url = ProtocolFormatter.formatRequest("http://localhost", position);
|
||||
String url = ProtocolFormatter.formatRequest("http://localhost:5055", position);
|
||||
assertEquals("http://localhost:5055?id=123456789012345×tamp=0&lat=0.0&lon=0.0&speed=0.0&bearing=0.0&altitude=0.0&batt=0.0", url);
|
||||
}
|
||||
|
||||
|
||||
Ссылка в новой задаче
Block a user