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) {
|
public String getCategoryDisplayName(@NonNull Context ctx) {
|
||||||
if (category.equals(PERSONAL_CATEGORY)) {
|
return FavouritesDbHelper.FavoriteGroup.getDisplayName(ctx);
|
||||||
return ctx.getString(R.string.personal_category_name);
|
|
||||||
} else {
|
|
||||||
return category;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCategory(String category) {
|
public void setCategory(String category) {
|
||||||
|
@ -259,7 +255,7 @@ public class FavouritePoint implements Serializable, LocationPoint {
|
||||||
this.iconId = iconId;
|
this.iconId = iconId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getCategory() { return PERSONAL_CATEGORY; }
|
public String getCategory() { return FavouritesDbHelper.FavoriteGroup.PERSONAL_CATEGORY; }
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return typeName;
|
return typeName;
|
||||||
|
|
|
@ -73,7 +73,19 @@ public class FavouritesDbHelper {
|
||||||
public List<FavouritePoint> points = new ArrayList<>();
|
public List<FavouritePoint> points = new ArrayList<>();
|
||||||
|
|
||||||
public boolean isPersonal() {
|
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() {
|
public List<FavouritePoint> getPoints() {
|
||||||
|
@ -92,12 +104,8 @@ public class FavouritesDbHelper {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName(Context ctx) {
|
public String getDisplayName(Context ctx) {
|
||||||
if (isPersonal()) {
|
return getDisplayName(name, ctx);
|
||||||
return ctx.getString(R.string.personal_category_name);
|
|
||||||
} else {
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String convertDisplayNameToGroupIdName(Context context, String name) {
|
public String convertDisplayNameToGroupIdName(Context context, String name) {
|
||||||
|
@ -260,7 +268,7 @@ public class FavouritesDbHelper {
|
||||||
if (point != null) {
|
if (point != null) {
|
||||||
editFavourite(point, latLon.getLatitude(), latLon.getLongitude(), address);
|
editFavourite(point, latLon.getLatitude(), latLon.getLongitude(), address);
|
||||||
} else {
|
} 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);
|
point.setAddress(address);
|
||||||
addFavourite(point);
|
addFavourite(point);
|
||||||
}
|
}
|
||||||
|
|
|
@ -850,7 +850,7 @@ public class FavoritesTreeFragment extends OsmandExpandableListFragment implemen
|
||||||
} else {
|
} else {
|
||||||
label.setTypeface(Typeface.DEFAULT, Typeface.ITALIC);
|
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) {
|
if (selectionMode) {
|
||||||
final CheckBox ch = (CheckBox) row.findViewById(R.id.toggle_item);
|
final CheckBox ch = (CheckBox) row.findViewById(R.id.toggle_item);
|
||||||
|
|
|
@ -87,7 +87,7 @@ public class SelectCategoryDialogFragment extends DialogFragment {
|
||||||
} else {
|
} else {
|
||||||
List<FavouritesDbHelper.FavoriteGroup> gs = helper.getFavoriteGroups();
|
List<FavouritesDbHelper.FavoriteGroup> gs = helper.getFavoriteGroups();
|
||||||
for (final FavouritesDbHelper.FavoriteGroup category : gs) {
|
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);
|
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.os.Bundle;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
|
||||||
|
import net.osmand.data.FavouritePoint;
|
||||||
import net.osmand.plus.OsmandPlugin;
|
import net.osmand.plus.OsmandPlugin;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import net.osmand.plus.activities.MapActivity;
|
import net.osmand.plus.activities.MapActivity;
|
||||||
|
@ -72,7 +73,8 @@ public class ParkingTypeBottomSheetDialogFragment extends MenuBottomSheetDialogF
|
||||||
plugin.showContextMenuIfNeeded(mapActivity, true);
|
plugin.showContextMenuIfNeeded(mapActivity, true);
|
||||||
mapActivity.refreshMap();
|
mapActivity.refreshMap();
|
||||||
}
|
}
|
||||||
mapActivity.getMyApplication().getFavorites().setParkingPoint(plugin.getParkingPosition());
|
mapActivity.getMyApplication().getFavorites().setSpecialPoint(
|
||||||
|
plugin.getParkingPosition(), FavouritePoint.SpecialPointType.PARKING, null);
|
||||||
}
|
}
|
||||||
dismiss();
|
dismiss();
|
||||||
}
|
}
|
||||||
|
|
|
@ -643,12 +643,11 @@ public class AddPointBottomSheetDialog extends MenuBottomSheetDialogFragment {
|
||||||
if (item instanceof FavouritePoint) {
|
if (item instanceof FavouritePoint) {
|
||||||
FavouritePoint point = (FavouritePoint) item;
|
FavouritePoint point = (FavouritePoint) item;
|
||||||
favoriteViewHolder.title.setText(point.getDisplayName(app));
|
favoriteViewHolder.title.setText(point.getDisplayName(app));
|
||||||
// TODO HW: similar to overlay icon id
|
if (((FavouritePoint) item).getSpecialPointType() != null) {
|
||||||
if (((FavouritePoint) item).isPersonalPoint()) {
|
|
||||||
int iconColor = app.getSettings().isLightContent()
|
int iconColor = app.getSettings().isLightContent()
|
||||||
? R.color.icon_color_default_light : R.color.icon_color_default_dark;
|
? R.color.icon_color_default_light : R.color.icon_color_default_dark;
|
||||||
favoriteViewHolder.icon.setImageDrawable(app.getUIUtilities().getIcon(
|
favoriteViewHolder.icon.setImageDrawable(app.getUIUtilities().getIcon(
|
||||||
FavouritesDbHelper.getPersonalIconId(point.getName()), iconColor));
|
((FavouritePoint) item).getSpecialPointType().getIconId(), iconColor));
|
||||||
favoriteViewHolder.description.setText(point.getDescription());
|
favoriteViewHolder.description.setText(point.getDescription());
|
||||||
} else {
|
} else {
|
||||||
if (point.getCategory().equals("")) {
|
if (point.getCategory().equals("")) {
|
||||||
|
|
Loading…
Reference in a new issue