Update point

This commit is contained in:
Victor Shcherb 2014-12-06 22:12:10 +01:00
parent 02233788fd
commit 5df8185b0e
4 changed files with 135 additions and 31 deletions

View file

@ -31,7 +31,7 @@
android:layout_height="wrap_content"
android:stretchColumns="1">
<TableRow android:layout_width="fill_parent">
<TableRow android:layout_width="fill_parent" android:id="@+id/lat_row">
<TextView
android:textSize="20sp"
@ -49,7 +49,7 @@
android:inputType="phone"></EditText>
</TableRow>
<TableRow android:layout_width="fill_parent">
<TableRow android:layout_width="fill_parent" android:id="@+id/lon_row">
<TextView
android:textSize="20sp"
@ -66,8 +66,60 @@
android:layout_marginRight="5dp"
android:inputType="phone"></EditText>
</TableRow>
<TableRow android:layout_width="fill_parent" android:id="@+id/northing_row">
<TableRow android:layout_width="fill_parent">
<TextView
android:textSize="20sp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:text="@string/navigate_point_northing"></TextView>
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/NorthingEdit"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:inputType="phone"></EditText>
</TableRow>
<TableRow android:layout_width="fill_parent" android:id="@+id/easting_row">
<TextView
android:textSize="20sp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:text="@string/navigate_point_easting"></TextView>
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/EastingEdit"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:inputType="phone"></EditText>
</TableRow>
<TableRow android:layout_width="fill_parent" android:id="@+id/zone_row">
<TextView
android:textSize="20sp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:text="@string/navigate_point_zone"></TextView>
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/ZoneEdit"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"></EditText>
</TableRow>
<TableRow android:layout_width="fill_parent" >
<TextView
android:textSize="20sp"

View file

@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<resources>
<string name="app_name">OsmAnd~</string>
<string name="app_name_ver">OsmAnd 1.9.3</string>
<string name="app_version">1.9.3</string>
<string name="app_name_ver">OsmAnd 2.0.0</string>
<string name="app_version">2.0.0</string>
<!--
Note: The above app_version should also provided as the build number prefix ('based-on version') to our dev APKs via the builder configs, e.g.
http://builder.osmand.net:8080/view/OsmAnd%20Builds/job/OsmAnd-main/configure ( Ant, Properties, build.version=${GIT_BRANCH} 1.9.3#${BUILD_NUMBER}M )
@ -18,12 +18,13 @@
<string name="openstreetmap_copyright"><a href="http://www.openstreetmap.org/copyright">&#169; OpenStreetMap</a></string>
<string name="about_content">Data is powered by OpenStreetMap ODbL, &#169; <a href="http://www.openstreetmap.org/copyright">http://www.openstreetmap.org/copyright</a>.
\n\nAll rights belong to OsmAnd app, Copyright &#169; 2010-2014 OsmAnd.
\n\nAll rights belong to OsmAnd app, Copyright &#169; 2010-2015 OsmAnd.
\n\nCredits to all Developers and major Contributors :
\n\tVictor Shcherb - project lead.
\n\tDr. Hardy Mueller - map appearance concept and base renderers, international consistency and testing, usability, app scoping, concepts, documentation, wiki, market research.
\n\tAlexey Pelykh - C++ developer, created native library and made application much snappier.
\n\tDenis Bars - Java developer, worked mostly on new UI and usability from 1.8 version.
\n\tLeonid (xmd5a) - co-author of main OsmAnd rendering, author of UniRS, LightRS styles.
\n\tDusan Kazik - one of the first contributors
\n\tAndre Van Atten - project supporter, active forum participant, one of the first users.

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).
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="navigate_point_zone">Zone</string>
<string name="navigate_point_northing">Northing</string>
<string name="navigate_point_easting">Easting</string>
<string name="download_tab_downloads">Downloads</string>
<string name="download_tab_updates">Updates</string>
<string name="download_tab_local">Local</string>

View file

@ -26,6 +26,7 @@ import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.ArrayAdapter;
import android.widget.EditText;
import android.widget.Spinner;
import android.widget.TextView;
@ -34,13 +35,20 @@ import com.actionbarsherlock.view.Menu;
import com.actionbarsherlock.view.MenuInflater;
import com.actionbarsherlock.view.MenuItem;
import com.actionbarsherlock.view.MenuItem.OnMenuItemClickListener;
import com.jwetherell.openmap.common.LatLonPoint;
import com.jwetherell.openmap.common.UTMPoint;
public class NavigatePointFragment extends SherlockFragment implements SearchActivityChild {
int currentFormat = Location.FORMAT_DEGREES;
public static final String SEARCH_LAT = SearchActivity.SEARCH_LAT;
public static final String SEARCH_LON = SearchActivity.SEARCH_LON;
public static final String SEARCH_NORTHING = "NORTHING";
public static final String SEARCH_EASTING = "EASTING";
public static final String SEARCH_ZONE = "ZONE";
private static final int UTM_FORMAT = 3;
private static final String SELECTION = "SELECTION";
private static final int NAVIGATE_TO = 1;
private static final int ADD_WAYPOINT = 2;
@ -71,7 +79,8 @@ public class NavigatePointFragment extends SherlockFragment implements SearchAct
loc = app.getSettings().getLastKnownMapLocation();
}
initUI(loc.getLatitude(), loc.getLongitude());
if(savedInstanceState != null && savedInstanceState.containsKey(SEARCH_LAT) && savedInstanceState.containsKey(SEARCH_LON)) {
if(savedInstanceState != null && savedInstanceState.containsKey(SEARCH_LAT) && savedInstanceState.containsKey(SEARCH_LON) &&
currentFormat != UTM_FORMAT) {
String lat = savedInstanceState.getString(SEARCH_LAT);
String lon = savedInstanceState.getString(SEARCH_LON);
if(lat != null && lon != null && lat.length() > 0 && lon.length() > 0) {
@ -164,36 +173,64 @@ public class NavigatePointFragment extends SherlockFragment implements SearchAct
public void locationUpdate(LatLon loc) {
if (view != null) {
if (loc != null) {
updateUI(loc.getLatitude(), loc.getLongitude());
showCurrentFormat(loc);
} else {
updateUI(0, 0);
showCurrentFormat(new LatLon(0, 0));
}
}
}
public void updateUI(double latitude, double longitude) {
latitude = MapUtils.checkLatitude(latitude);
longitude = MapUtils.checkLongitude(longitude);
final TextView latEdit = ((TextView)view.findViewById(R.id.LatitudeEdit));
final TextView lonEdit = ((TextView)view.findViewById(R.id.LongitudeEdit));
latEdit.setText(convert(latitude, currentFormat));
lonEdit.setText(convert(longitude, currentFormat));
protected void showCurrentFormat( LatLon loc) {
final EditText latEdit = ((EditText)view.findViewById(R.id.LatitudeEdit));
final EditText lonEdit = ((EditText)view.findViewById(R.id.LongitudeEdit));
boolean utm = currentFormat == UTM_FORMAT;
view.findViewById(R.id.easting_row).setVisibility(utm ? View.VISIBLE : View.GONE);
view.findViewById(R.id.northing_row).setVisibility(utm ? View.VISIBLE : View.GONE);
view.findViewById(R.id.zone_row).setVisibility(utm ? View.VISIBLE : View.GONE);
view.findViewById(R.id.lat_row).setVisibility(!utm ? View.VISIBLE : View.GONE);
view.findViewById(R.id.lon_row).setVisibility(!utm ? View.VISIBLE : View.GONE);
if(currentFormat == UTM_FORMAT) {
final EditText northingEdit = ((EditText)view.findViewById(R.id.NorthingEdit));
final EditText eastingEdit = ((EditText)view.findViewById(R.id.EastingEdit));
final EditText zoneEdit = ((EditText)view.findViewById(R.id.ZoneEdit));
UTMPoint pnt = new UTMPoint(new LatLonPoint(loc.getLatitude(), loc.getLongitude()));
zoneEdit.setText(pnt.zone_number + ""+pnt.zone_letter);
northingEdit.setText(((long)pnt.northing)+"");
eastingEdit.setText(((long)pnt.easting)+"");
} else {
latEdit.setText(convert(MapUtils.checkLatitude(loc.getLatitude()), currentFormat));
lonEdit.setText(convert(MapUtils.checkLongitude(loc.getLongitude()), currentFormat));
}
}
protected LatLon parseLocation() {
LatLon loc ;
if(currentFormat == UTM_FORMAT) {
double northing = Double.parseDouble(((EditText)view.findViewById(R.id.NorthingEdit)).getText().toString());
double easting = Double.parseDouble(((EditText)view.findViewById(R.id.EastingEdit)).getText().toString());
String zone = ((EditText)view.findViewById(R.id.ZoneEdit)).getText().toString();
char c = zone.charAt(zone.length() -1);
int z = Integer.parseInt(zone.substring(0, zone.length() - 1));
UTMPoint upoint = new UTMPoint(northing, easting, z, c);
LatLonPoint ll = upoint.toLatLonPoint();
loc = new LatLon(ll.getLatitude(), ll.getLongitude());
} else {
double lat = convert(((EditText) view.findViewById(R.id.LatitudeEdit)).getText().toString());
double lon = convert(((EditText) view.findViewById(R.id.LongitudeEdit)).getText().toString());
loc = new LatLon(lat, lon);
}
return loc;
}
public void initUI(double latitude, double longitude){
latitude = MapUtils.checkLatitude(latitude);
longitude = MapUtils.checkLongitude(longitude);
final TextView latEdit = ((TextView)view.findViewById(R.id.LatitudeEdit));
final TextView lonEdit = ((TextView)view.findViewById(R.id.LongitudeEdit));
currentFormat = Location.FORMAT_DEGREES;
latEdit.setText(convert(latitude, Location.FORMAT_DEGREES));
lonEdit.setText(convert(longitude, Location.FORMAT_DEGREES));
showCurrentFormat(new LatLon(latitude, longitude));
final Spinner format = ((Spinner)view.findViewById(R.id.Format));
ArrayAdapter<String> adapter = new ArrayAdapter<String>(getSherlockActivity(), android.R.layout.simple_spinner_item, new String[] {
getString(R.string.navigate_point_format_D),
getString(R.string.navigate_point_format_DM),
getString(R.string.navigate_point_format_DMS)
getString(R.string.navigate_point_format_DMS),
"UTM"
});
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
format.setAdapter(adapter);
@ -210,14 +247,14 @@ public class NavigatePointFragment extends SherlockFragment implements SearchAct
newFormat = Location.FORMAT_MINUTES;
} else if(getString(R.string.navigate_point_format_DMS).equals(itm)){
newFormat = Location.FORMAT_SECONDS;
} else if (position == UTM_FORMAT) {
newFormat = UTM_FORMAT;
}
currentFormat = newFormat;
try {
double lat = convert(((TextView) view.findViewById(R.id.LatitudeEdit)).getText().toString());
double lon = convert(((TextView) view.findViewById(R.id.LongitudeEdit)).getText().toString());
LatLon loc = parseLocation();
currentFormat = newFormat;
((TextView) view.findViewById(R.id.ValidateTextView)).setVisibility(View.INVISIBLE);
latEdit.setText(convert(lat, newFormat));
lonEdit.setText(convert(lon, newFormat));
showCurrentFormat(loc);
} catch (RuntimeException e) {
((TextView) view.findViewById(R.id.ValidateTextView)).setVisibility(View.VISIBLE);
((TextView) view.findViewById(R.id.ValidateTextView)).setText(R.string.invalid_locations);
@ -226,10 +263,18 @@ public class NavigatePointFragment extends SherlockFragment implements SearchAct
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
}
});
addPasteListeners();
}
protected void addPasteListeners() {
final EditText latEdit = ((EditText)view.findViewById(R.id.LatitudeEdit));
final EditText lonEdit = ((EditText)view.findViewById(R.id.LongitudeEdit));
TextWatcher textWatcher = new TextWatcher() {
String pasteString = null;
@Override
@ -302,10 +347,13 @@ public class NavigatePointFragment extends SherlockFragment implements SearchAct
lonEdit.addTextChangedListener(textWatcher);
}
public void select(int mode){
try {
double lat = convert(((TextView) view.findViewById(R.id.LatitudeEdit)).getText().toString());
double lon = convert(((TextView) view.findViewById(R.id.LongitudeEdit)).getText().toString());
LatLon loc = parseLocation();
double lat = loc.getLatitude();
double lon = loc.getLongitude();
if(mode == ADD_TO_FAVORITE) {
Bundle b = new Bundle();
Dialog dlg = FavoriteDialogs.createAddFavouriteDialog(getActivity(), b);