Refactor wpt/fav point icon
This commit is contained in:
parent
543313bd4f
commit
4b23864c27
6 changed files with 25 additions and 20 deletions
|
@ -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;
|
||||
|
|
|
@ -73,7 +73,19 @@ public class FavouritesDbHelper {
|
|||
public List<FavouritePoint> 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<FavouritePoint> 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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -87,7 +87,7 @@ public class SelectCategoryDialogFragment extends DialogFragment {
|
|||
} else {
|
||||
List<FavouritesDbHelper.FavoriteGroup> 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);
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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("")) {
|
||||
|
|
Loading…
Reference in a new issue