Add a warning about invalid input in Coordinate Input

This commit is contained in:
Alexander Sytnyk 2018-02-22 18:10:03 +02:00
parent 0be13829e9
commit 776f5a713a
2 changed files with 15 additions and 4 deletions

View file

@ -9,6 +9,9 @@
3. All your modified/created strings are in the top of the file (to make easier find what\'s translated). 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 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="enter_lon">Enter longitude</string>
<string name="enter_lat">Enter latitude</string>
<string name="enter_lat_and_lon">Enter latitude and longitude</string>
<string name="dd_mm_ss_format">DD°MMSS″</string> <string name="dd_mm_ss_format">DD°MMSS″</string>
<string name="dd_dddddd_format">DD.DDDDDD°</string> <string name="dd_dddddd_format">DD.DDDDDD°</string>
<string name="dd_ddddd_format">DD.DDDDD°</string> <string name="dd_ddddd_format">DD.DDDDD°</string>

View file

@ -829,11 +829,15 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm
private void addMapMarker() { private void addMapMarker() {
final String latitude = getStringCoordinate(true); final String latitude = getStringCoordinate(true);
final String longitude = getStringCoordinate(false); final String longitude = getStringCoordinate(false);
double lat = parseCoordinate(latitude); if (latitude.isEmpty() && longitude.isEmpty()) {
double lon = parseCoordinate(longitude); Toast.makeText(getContext(), R.string.enter_lat_and_lon, Toast.LENGTH_SHORT).show();
if (lat == 0 || lon == 0) { } else if (latitude.isEmpty()) {
Toast.makeText(getContext(), R.string.wrong_input, Toast.LENGTH_SHORT).show(); Toast.makeText(getContext(), R.string.enter_lat, Toast.LENGTH_SHORT).show();
} else if (longitude.isEmpty()) {
Toast.makeText(getContext(), R.string.enter_lon, Toast.LENGTH_SHORT).show();
} else { } else {
double lat = parseCoordinate(latitude);
double lon = parseCoordinate(longitude);
String name = ((EditText) mainView.findViewById(R.id.point_name_et)).getText().toString(); String name = ((EditText) mainView.findViewById(R.id.point_name_et)).getText().toString();
addMapMarker(new LatLon(lat, lon), name); addMapMarker(new LatLon(lat, lon), name);
} }
@ -847,6 +851,10 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm
String thirdPart = ((EditText) mainView.findViewById(latitude String thirdPart = ((EditText) mainView.findViewById(latitude
? R.id.lat_third_input_et : R.id.lon_third_input_et)).getText().toString(); ? R.id.lat_third_input_et : R.id.lon_third_input_et)).getText().toString();
if (firstPart.isEmpty() && secondPart.isEmpty() && thirdPart.isEmpty()) {
return "";
}
int format = getMyApplication().getSettings().COORDS_INPUT_FORMAT.get(); int format = getMyApplication().getSettings().COORDS_INPUT_FORMAT.get();
StringBuilder res = new StringBuilder(); StringBuilder res = new StringBuilder();
if ((latitude && !north) || (!latitude && !east)) { if ((latitude && !north) || (!latitude && !east)) {