Add address extension to gpx

This commit is contained in:
Dima-1 2020-01-08 16:17:31 +02:00
parent 19419d7d55
commit c823231d7e
3 changed files with 8 additions and 7 deletions

View file

@ -17,6 +17,7 @@ public class FavouritePoint implements Serializable, LocationPoint {
private static final long serialVersionUID = 729654300829771466L; private static final long serialVersionUID = 729654300829771466L;
private static final String HIDDEN = "hidden"; private static final String HIDDEN = "hidden";
private static final String ADDRESS_EXTENSION = "address";
@ -294,6 +295,7 @@ public class FavouritePoint implements Serializable, LocationPoint {
} }
fp.setColor(pt.getColor(0)); fp.setColor(pt.getColor(0));
fp.setVisible(!pt.getExtensionsToRead().containsKey(HIDDEN)); fp.setVisible(!pt.getExtensionsToRead().containsKey(HIDDEN));
fp.setAddress(pt.getExtensionsToRead().get(ADDRESS_EXTENSION));
return fp; return fp;
} }
@ -304,6 +306,9 @@ public class FavouritePoint implements Serializable, LocationPoint {
if (!isVisible()) { if (!isVisible()) {
pt.getExtensionsToWrite().put(HIDDEN, "true"); pt.getExtensionsToWrite().put(HIDDEN, "true");
} }
if (isAddressSpecified()) {
pt.getExtensionsToWrite().put(ADDRESS_EXTENSION, getAddress());
}
if (getColor() != 0) { if (getColor() != 0) {
pt.setColor(getColor()); pt.setColor(getColor());
} }

View file

@ -44,7 +44,6 @@ import net.osmand.plus.FavouritesDbHelper.FavoritesListener;
import net.osmand.plus.MapMarkersHelper; import net.osmand.plus.MapMarkersHelper;
import net.osmand.plus.OsmAndFormatter; import net.osmand.plus.OsmAndFormatter;
import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandPlugin;
import net.osmand.plus.OsmandSettings; import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.base.FavoriteImageDrawable; import net.osmand.plus.base.FavoriteImageDrawable;
@ -53,7 +52,6 @@ import net.osmand.plus.helpers.AndroidUiHelper;
import net.osmand.plus.helpers.FontCache; import net.osmand.plus.helpers.FontCache;
import net.osmand.plus.myplaces.FavoritesActivity; import net.osmand.plus.myplaces.FavoritesActivity;
import net.osmand.plus.myplaces.FavoritesFragmentStateHolder; import net.osmand.plus.myplaces.FavoritesFragmentStateHolder;
import net.osmand.plus.parkingpoint.ParkingPositionPlugin;
import net.osmand.util.Algorithms; import net.osmand.util.Algorithms;
import net.osmand.util.MapUtils; import net.osmand.util.MapUtils;
@ -953,9 +951,7 @@ public class FavoritesTreeFragment extends OsmandExpandableListFragment implemen
name.setTextColor(getResources().getColor(visible ? enabledColor : disabledColor)); name.setTextColor(getResources().getColor(visible ? enabledColor : disabledColor));
distanceText.setText(distance); distanceText.setText(distance);
if (model.isAddressSpecified()) { if (model.isAddressSpecified()) {
String distanceWithAddress = String.format(getString(R.string.distance_and_address), distance.trim(), distanceText.setText(String.format(getString(R.string.distance_and_address), distance.trim(), model.getAddress()));
model.getDescription() != null ? model.getDescription() : "");
distanceText.setText(distanceWithAddress);
} }
icon.setImageDrawable(FavoriteImageDrawable.getOrCreate(getActivity(), icon.setImageDrawable(FavoriteImageDrawable.getOrCreate(getActivity(),
visible ? model.getColor() : getResources().getColor(disabledIconColor), false, model)); visible ? model.getColor() : getResources().getColor(disabledIconColor), false, model));

View file

@ -32,8 +32,8 @@ public class HomeWorkCard extends BaseCard {
TextView homeDescr = view.findViewById(R.id.home_button_descr); TextView homeDescr = view.findViewById(R.id.home_button_descr);
final TextView workDescr = view.findViewById(R.id.work_button_descr); final TextView workDescr = view.findViewById(R.id.work_button_descr);
homeDescr.setText(homePoint != null ? homePoint.getDescription() : mapActivity.getString(R.string.shared_string_add)); homeDescr.setText(homePoint != null ? homePoint.getAddress() : mapActivity.getString(R.string.shared_string_add));
workDescr.setText(workPoint != null ? workPoint.getDescription() : mapActivity.getString(R.string.shared_string_add)); workDescr.setText(workPoint != null ? workPoint.getAddress() : mapActivity.getString(R.string.shared_string_add));
View homeButton = view.findViewById(R.id.home_button); View homeButton = view.findViewById(R.id.home_button);
homeButton.setOnClickListener(new View.OnClickListener() { homeButton.setOnClickListener(new View.OnClickListener() {