diff --git a/OsmAnd/src/net/osmand/data/FavouritePoint.java b/OsmAnd/src/net/osmand/data/FavouritePoint.java index e53f9416b7..bc3dbbcbd9 100644 --- a/OsmAnd/src/net/osmand/data/FavouritePoint.java +++ b/OsmAnd/src/net/osmand/data/FavouritePoint.java @@ -148,11 +148,7 @@ public class FavouritePoint implements Serializable, LocationPoint { } public String getCategoryDisplayName(@NonNull Context ctx) { - if (category.equals(PERSONAL_CATEGORY)) { - return ctx.getString(R.string.personal_category_name); - } else { - return category; - } + return FavouritesDbHelper.FavoriteGroup.getDisplayName(ctx); } public void setCategory(String category) { @@ -259,7 +255,7 @@ public class FavouritePoint implements Serializable, LocationPoint { this.iconId = iconId; } - public String getCategory() { return PERSONAL_CATEGORY; } + public String getCategory() { return FavouritesDbHelper.FavoriteGroup.PERSONAL_CATEGORY; } public String getName() { return typeName; diff --git a/OsmAnd/src/net/osmand/plus/FavouritesDbHelper.java b/OsmAnd/src/net/osmand/plus/FavouritesDbHelper.java index 766b433c7f..ad00812e3b 100644 --- a/OsmAnd/src/net/osmand/plus/FavouritesDbHelper.java +++ b/OsmAnd/src/net/osmand/plus/FavouritesDbHelper.java @@ -73,7 +73,19 @@ public class FavouritesDbHelper { public List points = new ArrayList<>(); public boolean isPersonal() { - return name.equals(PERSONAL_CATEGORY); + return isPersonal(name); + } + + private static boolean isPersonal(String name) { + return PERSONAL_CATEGORY.equals(name); + } + + public static String getDisplayName(String name, Context ctx) { + if (isPersonal(name)) { + return ctx.getString(R.string.personal_category_name); + } else { + return name; + } } public List getPoints() { @@ -92,12 +104,8 @@ public class FavouritesDbHelper { return name; } - public String getName(Context ctx) { - if (isPersonal()) { - return ctx.getString(R.string.personal_category_name); - } else { - return name; - } + public String getDisplayName(Context ctx) { + return getDisplayName(name, ctx); } public String convertDisplayNameToGroupIdName(Context context, String name) { @@ -260,7 +268,7 @@ public class FavouritesDbHelper { if (point != null) { editFavourite(point, latLon.getLatitude(), latLon.getLongitude(), address); } else { - point = new FavouritePoint(latLon.getLatitude(), latLon.getLongitude(), specialType, specialType.getCategory()); + point = new FavouritePoint(latLon.getLatitude(), latLon.getLongitude(), specialType.getName(), specialType.getCategory()); point.setAddress(address); addFavourite(point); } diff --git a/OsmAnd/src/net/osmand/plus/activities/FavoritesTreeFragment.java b/OsmAnd/src/net/osmand/plus/activities/FavoritesTreeFragment.java index ca9e326fb9..f8c8832309 100644 --- a/OsmAnd/src/net/osmand/plus/activities/FavoritesTreeFragment.java +++ b/OsmAnd/src/net/osmand/plus/activities/FavoritesTreeFragment.java @@ -850,7 +850,7 @@ public class FavoritesTreeFragment extends OsmandExpandableListFragment implemen } else { label.setTypeface(Typeface.DEFAULT, Typeface.ITALIC); } - label.setText(model.name.length() == 0 ? getString(R.string.shared_string_favorites) : model.getName(app)); + label.setText(model.name.length() == 0 ? getString(R.string.shared_string_favorites) : model.getDisplayName(app)); if (selectionMode) { final CheckBox ch = (CheckBox) row.findViewById(R.id.toggle_item); diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/SelectCategoryDialogFragment.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/SelectCategoryDialogFragment.java index c137b87045..37de3c9e80 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/SelectCategoryDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/SelectCategoryDialogFragment.java @@ -87,7 +87,7 @@ public class SelectCategoryDialogFragment extends DialogFragment { } else { List gs = helper.getFavoriteGroups(); for (final FavouritesDbHelper.FavoriteGroup category : gs) { - addCategory(activity, ll, category.getName(getContext()), category.color); + addCategory(activity, ll, category.getDisplayName(getContext()), category.color); } } View itemView = activity.getLayoutInflater().inflate(R.layout.favorite_category_dialog_item, null); diff --git a/OsmAnd/src/net/osmand/plus/parkingpoint/ParkingTypeBottomSheetDialogFragment.java b/OsmAnd/src/net/osmand/plus/parkingpoint/ParkingTypeBottomSheetDialogFragment.java index 3b66cc51f8..58ca3422f6 100644 --- a/OsmAnd/src/net/osmand/plus/parkingpoint/ParkingTypeBottomSheetDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/parkingpoint/ParkingTypeBottomSheetDialogFragment.java @@ -4,6 +4,7 @@ import android.app.Dialog; import android.os.Bundle; import android.view.View; +import net.osmand.data.FavouritePoint; import net.osmand.plus.OsmandPlugin; import net.osmand.plus.R; import net.osmand.plus.activities.MapActivity; @@ -72,7 +73,8 @@ public class ParkingTypeBottomSheetDialogFragment extends MenuBottomSheetDialogF plugin.showContextMenuIfNeeded(mapActivity, true); mapActivity.refreshMap(); } - mapActivity.getMyApplication().getFavorites().setParkingPoint(plugin.getParkingPosition()); + mapActivity.getMyApplication().getFavorites().setSpecialPoint( + plugin.getParkingPosition(), FavouritePoint.SpecialPointType.PARKING, null); } dismiss(); } diff --git a/OsmAnd/src/net/osmand/plus/routepreparationmenu/AddPointBottomSheetDialog.java b/OsmAnd/src/net/osmand/plus/routepreparationmenu/AddPointBottomSheetDialog.java index 022ecf858c..58aaedbfa9 100644 --- a/OsmAnd/src/net/osmand/plus/routepreparationmenu/AddPointBottomSheetDialog.java +++ b/OsmAnd/src/net/osmand/plus/routepreparationmenu/AddPointBottomSheetDialog.java @@ -643,12 +643,11 @@ public class AddPointBottomSheetDialog extends MenuBottomSheetDialogFragment { if (item instanceof FavouritePoint) { FavouritePoint point = (FavouritePoint) item; favoriteViewHolder.title.setText(point.getDisplayName(app)); - // TODO HW: similar to overlay icon id - if (((FavouritePoint) item).isPersonalPoint()) { + if (((FavouritePoint) item).getSpecialPointType() != null) { int iconColor = app.getSettings().isLightContent() ? R.color.icon_color_default_light : R.color.icon_color_default_dark; favoriteViewHolder.icon.setImageDrawable(app.getUIUtilities().getIcon( - FavouritesDbHelper.getPersonalIconId(point.getName()), iconColor)); + ((FavouritePoint) item).getSpecialPointType().getIconId(), iconColor)); favoriteViewHolder.description.setText(point.getDescription()); } else { if (point.getCategory().equals("")) {