diff --git a/OsmAnd-api/src/net/osmand/aidlapi/favorite/AFavorite.java b/OsmAnd-api/src/net/osmand/aidlapi/favorite/AFavorite.java index 1e645d2fae..ed2dabe064 100644 --- a/OsmAnd-api/src/net/osmand/aidlapi/favorite/AFavorite.java +++ b/OsmAnd-api/src/net/osmand/aidlapi/favorite/AFavorite.java @@ -11,6 +11,7 @@ public class AFavorite extends AidlParams { private double lon; private String name; private String description; + private String address; private String category; private String color; private boolean visible; @@ -58,6 +59,8 @@ public class AFavorite extends AidlParams { return description; } + public String getAddress() { return description; } + public String getCategory() { return category; } @@ -76,6 +79,7 @@ public class AFavorite extends AidlParams { bundle.putDouble("lon", lon); bundle.putString("name", name); bundle.putString("description", description); + bundle.putString("address", address); bundle.putString("category", category); bundle.putString("color", color); bundle.putBoolean("visible", visible); @@ -87,6 +91,7 @@ public class AFavorite extends AidlParams { lon = bundle.getDouble("lon"); name = bundle.getString("name"); description = bundle.getString("description"); + address = bundle.getString("address"); category = bundle.getString("category"); color = bundle.getString("color"); visible = bundle.getBoolean("visible"); diff --git a/OsmAnd/src/net/osmand/aidl/OsmandAidlApi.java b/OsmAnd/src/net/osmand/aidl/OsmandAidlApi.java index 5e606801ef..3bdf3862a7 100644 --- a/OsmAnd/src/net/osmand/aidl/OsmandAidlApi.java +++ b/OsmAnd/src/net/osmand/aidl/OsmandAidlApi.java @@ -967,7 +967,7 @@ public class OsmandAidlApi { return false; } - boolean updateFavorite(String prevName, String prevCategory, double prevLat, double prevLon, String newName, String newCategory, String newDescription, double newLat, double newLon) { + boolean updateFavorite(String prevName, String prevCategory, double prevLat, double prevLon, String newName, String newCategory, String newDescription, String newAddress, double newLat, double newLon) { FavouritesDbHelper favoritesHelper = app.getFavorites(); List favorites = favoritesHelper.getFavouritePoints(); for (FavouritePoint f : favorites) { @@ -977,8 +977,8 @@ public class OsmandAidlApi { favoritesHelper.editFavourite(f, newLat, newLon); } if (!newName.equals(f.getName()) || !newDescription.equals(f.getDescription()) || - !newCategory.equals(f.getCategory())) { - favoritesHelper.editFavouriteName(f, newName, newCategory, newDescription); + !newCategory.equals(f.getCategory()) || !newAddress.equals(f.getAddress())) { + favoritesHelper.editFavouriteName(f, newName, newCategory, newDescription,newAddress); } refreshMap(); return true; diff --git a/OsmAnd/src/net/osmand/aidl/OsmandAidlService.java b/OsmAnd/src/net/osmand/aidl/OsmandAidlService.java index 38966b37f0..f1c9493fc8 100644 --- a/OsmAnd/src/net/osmand/aidl/OsmandAidlService.java +++ b/OsmAnd/src/net/osmand/aidl/OsmandAidlService.java @@ -311,7 +311,7 @@ public class OsmandAidlService extends Service implements AidlCallbackListener { AFavorite newFav = params.getFavoriteNew(); if (prevFav != null && newFav != null) { return api.updateFavorite(prevFav.getName(), prevFav.getCategory(), prevFav.getLat(), prevFav.getLon(), - newFav.getName(), newFav.getCategory(), newFav.getDescription(), newFav.getLat(), newFav.getLon()); + newFav.getName(), newFav.getCategory(), newFav.getDescription(), newFav.getAddress(), newFav.getLat(), newFav.getLon()); } } return false; diff --git a/OsmAnd/src/net/osmand/aidl/OsmandAidlServiceV2.java b/OsmAnd/src/net/osmand/aidl/OsmandAidlServiceV2.java index 1a4f675d52..01be4752b9 100644 --- a/OsmAnd/src/net/osmand/aidl/OsmandAidlServiceV2.java +++ b/OsmAnd/src/net/osmand/aidl/OsmandAidlServiceV2.java @@ -314,7 +314,7 @@ public class OsmandAidlServiceV2 extends Service implements AidlCallbackListener AFavorite newFav = params.getFavoriteNew(); if (prevFav != null && newFav != null) { return api.updateFavorite(prevFav.getName(), prevFav.getCategory(), prevFav.getLat(), prevFav.getLon(), - newFav.getName(), newFav.getCategory(), newFav.getDescription(), newFav.getLat(), newFav.getLon()); + newFav.getName(), newFav.getCategory(), newFav.getDescription(), newFav.getAddress(), newFav.getLat(), newFav.getLon()); } } return false; diff --git a/OsmAnd/src/net/osmand/aidl/favorite/AFavorite.java b/OsmAnd/src/net/osmand/aidl/favorite/AFavorite.java index b7fc057249..376a958add 100644 --- a/OsmAnd/src/net/osmand/aidl/favorite/AFavorite.java +++ b/OsmAnd/src/net/osmand/aidl/favorite/AFavorite.java @@ -9,16 +9,18 @@ public class AFavorite implements Parcelable { private double lon; private String name; private String description; + private String address; private String category; private String color; private boolean visible; - public AFavorite(double lat, double lon, String name, String description, + public AFavorite(double lat, double lon, String name, String description, String address, String category, String color, boolean visible) { this.lat = lat; this.lon = lon; this.name = name; this.description = description; + this.address = address; this.category = category; this.color = color; this.visible = visible; @@ -56,6 +58,8 @@ public class AFavorite implements Parcelable { return description; } + public String getAddress() { return address; } + public String getCategory() { return category; } @@ -74,6 +78,7 @@ public class AFavorite implements Parcelable { out.writeDouble(lon); out.writeString(name); out.writeString(description); + out.writeString(address); out.writeString(category); out.writeString(color); out.writeByte((byte) (visible ? 1 : 0)); @@ -84,6 +89,7 @@ public class AFavorite implements Parcelable { lon = in.readDouble(); name = in.readString(); description = in.readString(); + address = in.readString(); category = in.readString(); color = in.readString(); visible = in.readByte() != 0; diff --git a/OsmAnd/src/net/osmand/plus/FavouritesDbHelper.java b/OsmAnd/src/net/osmand/plus/FavouritesDbHelper.java index 7873b3b2cb..c7b2ae6255 100644 --- a/OsmAnd/src/net/osmand/plus/FavouritesDbHelper.java +++ b/OsmAnd/src/net/osmand/plus/FavouritesDbHelper.java @@ -487,11 +487,12 @@ public class FavouritesDbHelper { return builder.toString(); } - public boolean editFavouriteName(FavouritePoint p, String newName, String category, String descr) { + public boolean editFavouriteName(FavouritePoint p, String newName, String category, String descr, String address) { String oldCategory = p.getCategory(); p.setName(newName); p.setCategory(category); p.setDescription(descr); + p.setAddress(address); if (!oldCategory.equals(category)) { FavoriteGroup old = flatGroups.get(oldCategory); if (old != null) { diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java index bfc8838ef0..6b11c35b29 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java @@ -1042,7 +1042,7 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL } FavoritePointEditor favoritePointEditor = getFavoritePointEditor(); if (favoritePointEditor != null) { - favoritePointEditor.add(getLatLon(), title, originObjectName); + favoritePointEditor.add(getLatLon(), title, getStreetStr(), originObjectName); } } }); diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/FavoritePointEditor.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/FavoritePointEditor.java index edff9ef6fb..db68cef5c5 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/FavoritePointEditor.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/FavoritePointEditor.java @@ -27,7 +27,7 @@ public class FavoritePointEditor extends PointEditor { return favorite; } - public void add(LatLon latLon, String title, String originObjectName) { + public void add(LatLon latLon, String title, String address, String originObjectName) { MapActivity mapActivity = getMapActivity(); if (latLon == null || mapActivity == null) { return; @@ -39,6 +39,7 @@ public class FavoritePointEditor extends PointEditor { } favorite = new FavouritePoint(latLon.getLatitude(), latLon.getLongitude(), title, lastCategory); favorite.setDescription(""); + favorite.setAddress(address); favorite.setOriginObjectName(originObjectName); FavoritePointEditorFragmentNew.showInstance(mapActivity); } @@ -61,6 +62,7 @@ public class FavoritePointEditor extends PointEditor { favorite = new FavouritePoint(latLon.getLatitude(), latLon.getLongitude(), title, categoryName); favorite.setDescription(""); + favorite.setAddress(title); favorite.setOriginObjectName(originObjectName); FavoritePointEditorFragmentNew.showAutoFillInstance(mapActivity, autoFill); diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/FavoritePointEditorFragment.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/FavoritePointEditorFragment.java index d3f6ea52c6..fe05bf4296 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/FavoritePointEditorFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/FavoritePointEditorFragment.java @@ -192,12 +192,13 @@ public class FavoritePointEditorFragment extends PointEditorFragment { final FavouritePoint point = new FavouritePoint(favorite.getLatitude(), favorite.getLongitude(), getNameTextValue(), getCategoryTextValue()); point.setDescription(getDescriptionTextValue()); + point.setAddress(getAddressTextValue()); AlertDialog.Builder builder = FavouritesDbHelper.checkDuplicates(point, helper, getMapActivity()); if (favorite.getName().equals(point.getName()) && favorite.getCategory().equals(point.getCategory()) && - Algorithms.stringsEqual(favorite.getDescription(), point.getDescription())) { - + Algorithms.stringsEqual(favorite.getDescription(), point.getDescription()) && + Algorithms.stringsEqual(favorite.getAddress(),point.getAddress())) { if (needDismiss) { dismiss(false); } @@ -208,25 +209,25 @@ public class FavoritePointEditorFragment extends PointEditorFragment { builder.setPositiveButton(R.string.shared_string_ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { - doSave(favorite, point.getName(), point.getCategory(), point.getDescription(), needDismiss); + doSave(favorite, point.getName(), point.getCategory(), point.getDescription(),point.getAddress(), needDismiss); } }); builder.create().show(); } else { - doSave(favorite, point.getName(), point.getCategory(), point.getDescription(), needDismiss); + doSave(favorite, point.getName(), point.getCategory(), point.getDescription(), point.getAddress(), needDismiss); } saved = true; } } - private void doSave(FavouritePoint favorite, String name, String category, String description, boolean needDismiss) { + private void doSave(FavouritePoint favorite, String name, String category, String description, String address, boolean needDismiss) { FavouritesDbHelper helper = getHelper(); FavoritePointEditor editor = getFavoritePointEditor(); if (editor != null && helper != null) { if (editor.isNew()) { - doAddFavorite(name, category, description); + doAddFavorite(name, category, description,address); } else { - helper.editFavouriteName(favorite, name, category, description); + helper.editFavouriteName(favorite, name, category, description,address); } } MapActivity mapActivity = getMapActivity(); @@ -245,7 +246,7 @@ public class FavoritePointEditorFragment extends PointEditorFragment { } } - private void doAddFavorite(String name, String category, String description) { + private void doAddFavorite(String name, String category, String description, String address) { OsmandApplication app = getMyApplication(); FavouritesDbHelper helper = getHelper(); FavouritePoint favorite = getFavorite(); @@ -253,6 +254,7 @@ public class FavoritePointEditorFragment extends PointEditorFragment { favorite.setName(name); favorite.setCategory(category); favorite.setDescription(description); + favorite.setAddress(address); app.getSettings().LAST_FAV_CATEGORY_ENTERED.set(category); helper.addFavourite(favorite); } diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/FavoritePointEditorFragmentNew.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/FavoritePointEditorFragmentNew.java index 091b93f9a0..b29d0e7be8 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/FavoritePointEditorFragmentNew.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/FavoritePointEditorFragmentNew.java @@ -244,6 +244,7 @@ public class FavoritePointEditorFragmentNew extends PointEditorFragmentNew { final FavouritePoint point = new FavouritePoint(favorite.getLatitude(), favorite.getLongitude(), getNameTextValue(), getCategoryTextValue()); point.setDescription(getDescriptionTextValue()); + point.setAddress(getAddressTextValue()); point.setColor(color); point.setBackgroundType(backgroundType); point.setIconId(iconId); @@ -259,6 +260,7 @@ public class FavoritePointEditorFragmentNew extends PointEditorFragmentNew { final FavouritePoint point = new FavouritePoint(favorite.getLatitude(), favorite.getLongitude(), getNameTextValue(), getCategoryTextValue()); point.setDescription(getDescriptionTextValue()); + point.setAddress(getAddressTextValue()); point.setColor(color); point.setBackgroundType(backgroundType); point.setIconId(iconId); @@ -276,13 +278,13 @@ public class FavoritePointEditorFragmentNew extends PointEditorFragmentNew { builder.setPositiveButton(R.string.shared_string_ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { - doSave(favorite, point.getName(), point.getCategory(), point.getDescription(), + doSave(favorite, point.getName(), point.getCategory(), point.getDescription(), point.getAddress(), point.getColor(), point.getBackgroundType(), point.getIconId(), needDismiss); } }); builder.create().show(); } else { - doSave(favorite, point.getName(), point.getCategory(), point.getDescription(), + doSave(favorite, point.getName(), point.getCategory(), point.getDescription(), point.getAddress(), point.getColor(), point.getBackgroundType(), point.getIconId(), needDismiss); } saved = true; @@ -295,10 +297,11 @@ public class FavoritePointEditorFragmentNew extends PointEditorFragmentNew { favorite.getName().equals(point.getName()) && favorite.getCategory().equals(point.getCategory()) && favorite.getBackgroundType().equals(point.getBackgroundType()) && - Algorithms.stringsEqual(favorite.getDescription(), point.getDescription()); + Algorithms.stringsEqual(favorite.getDescription(), point.getDescription()) && + Algorithms.stringsEqual(favorite.getAddress(), point.getAddress()); } - private void doSave(FavouritePoint favorite, String name, String category, String description, + private void doSave(FavouritePoint favorite, String name, String category, String description, String address, @ColorInt int color, BackgroundType backgroundType, @DrawableRes int iconId, boolean needDismiss) { FavouritesDbHelper helper = getHelper(); FavoritePointEditor editor = getFavoritePointEditor(); @@ -306,7 +309,7 @@ public class FavoritePointEditorFragmentNew extends PointEditorFragmentNew { if (editor.isNew()) { doAddFavorite(name, category, description, color, backgroundType, iconId); } else { - doEditFavorite(favorite, name, category, description, color, backgroundType, iconId, helper); + doEditFavorite(favorite, name, category, description, address, color, backgroundType, iconId, helper); } } MapActivity mapActivity = getMapActivity(); @@ -325,7 +328,7 @@ public class FavoritePointEditorFragmentNew extends PointEditorFragmentNew { } } - private void doEditFavorite(FavouritePoint favorite, String name, String category, String description, + private void doEditFavorite(FavouritePoint favorite, String name, String category, String description, String address, @ColorInt int color, BackgroundType backgroundType, @DrawableRes int iconId, FavouritesDbHelper helper) { OsmandApplication app = getMyApplication(); @@ -334,7 +337,7 @@ public class FavoritePointEditorFragmentNew extends PointEditorFragmentNew { favorite.setColor(color); favorite.setBackgroundType(backgroundType); favorite.setIconId(iconId); - helper.editFavouriteName(favorite, name, category, description); + helper.editFavouriteName(favorite, name, category, description, address); } } @@ -408,7 +411,7 @@ public class FavoritePointEditorFragmentNew extends PointEditorFragmentNew { @Override public String getAddressInitValue() { FavouritePoint favourite = getFavorite(); - return favorite != null ? favorite.getAddress() : ""; + return favourite != null ? favourite.getAddress() : ""; } @Override diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/PointEditorFragment.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/PointEditorFragment.java index 44e9e8546e..c24a29ff71 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/PointEditorFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/PointEditorFragment.java @@ -373,6 +373,12 @@ public abstract class PointEditorFragment extends BaseOsmAndFragment { return Algorithms.isEmpty(res) ? null : res; } + public String getAddressTextValue() { + EditText addressEdit = (EditText) view.findViewById(R.id.address_edit); + String res = addressEdit.getText().toString().trim(); + return Algorithms.isEmpty(res) ? null : res; + } + protected Drawable getPaintedIcon(int iconId, int color) { return getPaintedContentIcon(iconId, color); } diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/PointEditorFragmentNew.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/PointEditorFragmentNew.java index 792aa08e84..4cf98456be 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/PointEditorFragmentNew.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/PointEditorFragmentNew.java @@ -241,9 +241,9 @@ public abstract class PointEditorFragmentNew extends BaseOsmAndFragment { addDelDescription.setTextColor(getResources().getColor(activeColorResId)); addAddressBtn.setTextColor(getResources().getColor(activeColorResId)); addAddressBtn.setCompoundDrawablesWithIntrinsicBounds( - app.getUIUtilities().getIcon(R.drawable.ic_action_location_off, activeColorResId),null,null,null); + app.getUIUtilities().getIcon(R.drawable.ic_action_location_16, activeColorResId),null,null,null); addDelDescription.setCompoundDrawablesWithIntrinsicBounds( - app.getUIUtilities().getIcon(R.drawable.ic_action_description, activeColorResId),null,null,null); + app.getUIUtilities().getIcon(R.drawable.ic_action_description_16, activeColorResId),null,null,null); addDelDescription.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { @@ -251,7 +251,7 @@ public abstract class PointEditorFragmentNew extends BaseOsmAndFragment { descriptionCaption.setVisibility(View.VISIBLE); addDelDescription.setText(view.getResources().getString(R.string.delete_description)); addDelDescription.setCompoundDrawablesWithIntrinsicBounds( - app.getUIUtilities().getIcon(R.drawable.ic_action_delete_item, + app.getUIUtilities().getIcon(R.drawable.ic_action_trash_basket_16, activeColorResId),null,null,null); View descriptionEdit = view.findViewById(R.id.description_edit); descriptionEdit.requestFocus(); @@ -260,7 +260,7 @@ public abstract class PointEditorFragmentNew extends BaseOsmAndFragment { descriptionCaption.setVisibility(View.GONE); addDelDescription.setText(view.getResources().getString(R.string.add_description)); addDelDescription.setCompoundDrawablesWithIntrinsicBounds( - app.getUIUtilities().getIcon(R.drawable.ic_action_location_off, + app.getUIUtilities().getIcon(R.drawable.ic_action_description_16, activeColorResId),null,null,null); AndroidUtils.hideSoftKeyboard(requireActivity(), descriptionEdit); descriptionEdit.clearFocus(); @@ -275,7 +275,7 @@ public abstract class PointEditorFragmentNew extends BaseOsmAndFragment { addAddressBtn.setText(view.getResources().getString(R.string.delete_address)); View addressEdit = view.findViewById(R.id.address_edit); addressEdit.requestFocus(); - AndroidUtils.softKeyboardDelayed(addressEdit); + AndroidUtils.softKeyboardDelayed(requireActivity(),addressEdit); } else { addressCaption.setVisibility(View.GONE); addAddressBtn.setText(view.getResources().getString(R.string.add_address)); @@ -848,6 +848,12 @@ public abstract class PointEditorFragmentNew extends BaseOsmAndFragment { return Algorithms.isEmpty(res) ? null : res; } + String getAddressTextValue() { + EditText addressEdit = view.findViewById(R.id.address_edit); + String res = addressEdit.getText().toString().trim(); + return Algorithms.isEmpty(res) ? null : res; + } + protected Drawable getPaintedIcon(int iconId, int color) { return getPaintedContentIcon(iconId, color); }