Fix all remarks, fix block edit personal favorite points, add delete parking point when parking plugin is disabled

This commit is contained in:
Dima-1 2019-12-10 15:03:26 +02:00
parent eaf6ae30fc
commit 6e4b7d5464
18 changed files with 133 additions and 159 deletions

View file

@ -1,6 +1,7 @@
package net.osmand.data;
import android.content.Context;
import android.support.annotation.DrawableRes;
import android.support.annotation.NonNull;
import android.support.annotation.StringRes;
@ -12,39 +13,46 @@ public class PersonalFavouritePoint extends FavouritePoint {
private Context ctx;
private PointType type;
public static final String PERSONAL = "personal";
static final String PERSONAL = "personal";
public enum PointType {
HOME("home", R.string.home_button, 1),
WORK("work", R.string.work_button, 2),
PARKING("parking", R.string.map_widget_parking, 3);
HOME("home", R.string.home_button, 1, R.drawable.ic_action_home_dark),
WORK("work", R.string.work_button, 2, R.drawable.ic_action_work),
PARKING("parking", R.string.map_widget_parking, 3, R.drawable.ic_action_parking_dark);
private String pointName;
private String typeName;
@StringRes
private int resId;
private int order;
@DrawableRes
private int iconID;
PointType(String pointName, @StringRes int resId, int order) {
this.pointName = pointName;
PointType(@NonNull String typeName, @StringRes int resId, int order, @DrawableRes int iconID) {
this.typeName = typeName;
this.resId = resId;
this.order = order;
this.iconID = iconID;
}
public String getName() {
return pointName;
return typeName;
}
public int getOrder() {
return order;
}
public static PointType valueOfPointName(@NonNull String typeName){
public static PointType valueOfTypeName(@NonNull String typeName) {
for (PointType pt:values()) {
if(pt.pointName.equals(typeName))
if (pt.typeName.equals(typeName))
return pt;
}
throw new IllegalArgumentException("Illegal PointType pointName");
throw new IllegalArgumentException("Illegal PointType typeName");
}
public int getIconID() {
return iconID;
}
public String getHumanString(@NonNull Context ctx) {
@ -53,13 +61,13 @@ public class PersonalFavouritePoint extends FavouritePoint {
}
public PersonalFavouritePoint(@NonNull Context ctx, @NonNull PointType type, double latitude, double longitude) {
super(latitude, longitude, type.pointName, PERSONAL);
super(latitude, longitude, type.typeName, PERSONAL);
this.ctx = ctx;
this.type = type;
}
public PersonalFavouritePoint(@NonNull Context ctx, @NonNull String pointName, double latitude, double longitude) throws IllegalArgumentException {
this(ctx, PointType.valueOfPointName(pointName), latitude, longitude);
PersonalFavouritePoint(@NonNull Context ctx, @NonNull String typeName, double latitude, double longitude) throws IllegalArgumentException {
this(ctx, PointType.valueOfTypeName(typeName), latitude, longitude);
}
@Override
@ -100,7 +108,7 @@ public class PersonalFavouritePoint extends FavouritePoint {
public WptPt toWpt() {
WptPt pt = super.toWpt();
pt.getExtensionsToWrite().put(PERSONAL, "true");
pt.name = type.pointName;
pt.name = type.typeName;
pt.desc = getDescription();
return pt;
}

View file

@ -12,7 +12,6 @@ import net.osmand.data.LatLon;
import net.osmand.GPXUtilities.GPXFile;
import net.osmand.GPXUtilities.WptPt;
import net.osmand.data.PersonalFavouritePoint;
import net.osmand.data.PointDescription;
import net.osmand.plus.MapMarkersHelper.MapMarkersGroup;
import net.osmand.plus.api.SQLiteAPI.SQLiteConnection;
import net.osmand.plus.api.SQLiteAPI.SQLiteCursor;
@ -115,27 +114,6 @@ public class FavouritesDbHelper {
});
}
public boolean hasWorkPoint() {
return hasPersonalPoint(WORK);
}
public boolean hasHomePoint() {
return hasPersonalPoint(HOME);
}
public boolean hasParkingPoint() {
return hasPersonalPoint(PARKING);
}
private boolean hasPersonalPoint(PersonalFavouritePoint.PointType pointType) {
for (FavouritePoint fp : cachedPersonalFavoritePoints) {
if (((PersonalFavouritePoint) fp).getType() == pointType) {
return true;
}
}
return false;
}
public FavouritePoint getWorkPoint() {
return getPersonalPoint(WORK);
}
@ -148,6 +126,10 @@ public class FavouritesDbHelper {
return getPersonalPoint(PARKING);
}
public void deleteParkingPoint() {
deleteFavourite(getParkingPoint());
}
private FavouritePoint getPersonalPoint(PersonalFavouritePoint.PointType pointType) {
for (FavouritePoint fp : cachedPersonalFavoritePoints) {
if (((PersonalFavouritePoint) fp).getType() == pointType) {
@ -245,6 +227,9 @@ public class FavouritesDbHelper {
runSyncWithMarkers(group);
}
cachedFavoritePoints.remove(p);
if (p.isPersonal()) {
cachedPersonalFavoritePoints.remove(p);
}
}
if (saveImmediately) {
saveCurrentPointsIntoFile();
@ -252,49 +237,46 @@ public class FavouritesDbHelper {
return true;
}
public void setHomePoint(@NonNull LatLon latLon, @NonNull PointDescription description) {
if (hasHomePoint()) {
getHomePoint().setDescription(description.getName());
editFavourite(getHomePoint(), latLon.getLatitude(), latLon.getLongitude());
public void setHomePoint(@NonNull LatLon latLon) {
FavouritePoint homePoint = getHomePoint();
if (homePoint != null) {
editFavourite(homePoint, latLon.getLatitude(), latLon.getLongitude());
} else {
FavouritePoint cachedHomePoint = new PersonalFavouritePoint(context, HOME,
latLon.getLatitude(), latLon.getLongitude());
cachedHomePoint.setDescription(description.getName());
cachedPersonalFavoritePoints.add(cachedHomePoint);
addFavourite(cachedHomePoint);
}
lookupAllPersonalPointsAddresses();
lookupAddressAllPersonalPoints();
}
public void setWorkPoint(@NonNull LatLon latLon, @NonNull PointDescription description) {
if (hasWorkPoint()) {
getWorkPoint().setDescription(description.getName());
editFavourite(getWorkPoint(), latLon.getLatitude(), latLon.getLongitude());
public void setWorkPoint(@NonNull LatLon latLon) {
FavouritePoint workPoint = getWorkPoint();
if (workPoint != null) {
editFavourite(workPoint, latLon.getLatitude(), latLon.getLongitude());
} else {
FavouritePoint cachedWorkPoint = new PersonalFavouritePoint(context, WORK,
latLon.getLatitude(), latLon.getLongitude());
cachedWorkPoint.setDescription(description.getName());
cachedPersonalFavoritePoints.add(cachedWorkPoint);
addFavourite(cachedWorkPoint);
}
lookupAllPersonalPointsAddresses();
lookupAddressAllPersonalPoints();
}
public void setParkingPoint(@NonNull LatLon latLon, @NonNull PointDescription description) {
if (hasParkingPoint()) {
getParkingPoint().setDescription(description.getName());
editFavourite(getParkingPoint(), latLon.getLatitude(), latLon.getLongitude());
public void setParkingPoint(@NonNull LatLon latLon) {
FavouritePoint parkingPoint = getParkingPoint();
if (parkingPoint != null) {
editFavourite(parkingPoint, latLon.getLatitude(), latLon.getLongitude());
} else {
FavouritePoint cachedParkingPoint = new PersonalFavouritePoint(context, PARKING,
latLon.getLatitude(), latLon.getLongitude());
cachedParkingPoint.setDescription(description.getName());
cachedPersonalFavoritePoints.add(cachedParkingPoint);
addFavourite(cachedParkingPoint);
}
lookupAllPersonalPointsAddresses();
lookupAddressAllPersonalPoints();
}
public boolean addFavourite(FavouritePoint p) {
if (p instanceof PersonalFavouritePoint) {
cachedPersonalFavoritePoints.add(p);
}
return addFavourite(p, true);
}
@ -320,7 +302,7 @@ public class FavouritesDbHelper {
return true;
}
private void lookupAllPersonalPointsAddresses() {
public void lookupAddressAllPersonalPoints() {
if (!context.isApplicationInitializing()) {
lookupAddressForHomePoint();
lookupAddressForWorkPoint();
@ -328,7 +310,7 @@ public class FavouritesDbHelper {
}
}
void lookupAddressForWorkPoint() {
private void lookupAddressForWorkPoint() {
final TargetPointsHelper targetPointsHelper = context.getTargetPointsHelper();
final FavouritePoint workPoint = getWorkPoint();
if (workPoint != null && (workPointRequest == null ||
@ -338,6 +320,7 @@ public class FavouritesDbHelper {
new LatLon(workPoint.getLatitude(), workPoint.getLongitude()), new GeocodingLookupService.OnAddressLookupResult() {
@Override
public void geocodingDone(String address) {
workPointRequest = null;
workPoint.setDescription(address);
targetPointsHelper.updateRouteAndRefresh(false);
}
@ -346,7 +329,7 @@ public class FavouritesDbHelper {
}
}
void lookupAddressForHomePoint() {
private void lookupAddressForHomePoint() {
final TargetPointsHelper targetPointsHelper = context.getTargetPointsHelper();
final FavouritePoint homePoint = getHomePoint();
if (homePoint != null && (homePointRequest == null ||
@ -365,7 +348,7 @@ public class FavouritesDbHelper {
}
}
void lookupAddressForParkingPoint() {
private void lookupAddressForParkingPoint() {
final TargetPointsHelper targetPointsHelper = context.getTargetPointsHelper();
final FavouritePoint parkingPoint = getParkingPoint();
if (parkingPoint != null && (parkingPointRequest == null ||

View file

@ -262,10 +262,10 @@ public class OsmandSettings {
void migrateHomeWorkParkingToFavorites() {
FavouritesDbHelper favorites = ctx.getFavorites();
if (getHomePoint() != null) {
favorites.setHomePoint(getHomePoint(), getHomePointDescription());
favorites.setHomePoint(getHomePoint());
}
if (getWorkPoint() != null) {
favorites.setWorkPoint(getWorkPoint(), getWorkPointDescription());
favorites.setWorkPoint(getWorkPoint());
}
}

View file

@ -150,15 +150,11 @@ public class TargetPointsHelper {
}
public void lookupAddessAll() {
FavouritesDbHelper favorites = ctx.getFavorites();
lookupAddressForPointToNavigate();
lookupAddessForStartPoint();
for (TargetPoint targetPoint : intermediatePoints) {
lookupAddressForIntermediatePoint(targetPoint);
}
favorites.lookupAddressForHomePoint();
favorites.lookupAddressForWorkPoint();
favorites.lookupAddressForParkingPoint();
lookupAddressForMyLocationPoint();
}

View file

@ -45,7 +45,6 @@ import net.osmand.plus.FavouritesDbHelper.FavoritesListener;
import net.osmand.plus.MapMarkersHelper;
import net.osmand.plus.OsmAndFormatter;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandPlugin;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R;
import net.osmand.plus.base.FavoriteImageDrawable;
@ -54,7 +53,6 @@ import net.osmand.plus.helpers.AndroidUiHelper;
import net.osmand.plus.helpers.FontCache;
import net.osmand.plus.myplaces.FavoritesActivity;
import net.osmand.plus.myplaces.FavoritesFragmentStateHolder;
import net.osmand.plus.parkingpoint.ParkingPositionPlugin;
import net.osmand.util.Algorithms;
import net.osmand.util.MapUtils;
@ -741,9 +739,7 @@ public class FavoritesTreeFragment extends OsmandExpandableListFragment implemen
Filter myFilter;
private Set<?> filter;
public void synchronizeGroups() {
ParkingPositionPlugin plugin = OsmandPlugin.getEnabledPlugin(ParkingPositionPlugin.class);
boolean parkingPluginEnable = plugin != null;
void synchronizeGroups() {
favoriteGroups.clear();
groups.clear();
List<FavoriteGroup> disablesGroups = new ArrayList<>();
@ -752,37 +748,14 @@ public class FavoritesTreeFragment extends OsmandExpandableListFragment implemen
for (FavoriteGroup key : gs) {
boolean empty = true;
if (flt == null || flt.contains(key)) {
if (key.name.equals(PersonalFavouritePoint.PERSONAL)) {
ArrayList<FavouritePoint> list = new ArrayList<>();
for (FavouritePoint p : key.points) {
if (p.getName().equals(PersonalFavouritePoint.PointType.PARKING.name())) {
if (parkingPluginEnable) {
list.add(p);
empty = false;
}
} else {
list.add(p);
empty = false;
}
}
favoriteGroups.put(key, list);
} else {
empty = false;
favoriteGroups.put(key, new ArrayList<>(key.points));
}
} else {
ArrayList<FavouritePoint> list = new ArrayList<>();
for (FavouritePoint p : key.points) {
if (flt.contains(p)) {
if (p.getName().equals(PersonalFavouritePoint.PointType.PARKING.name())) {
if (parkingPluginEnable) {
list.add(p);
empty = false;
}
} else {
list.add(p);
empty = false;
}
list.add(p);
empty = false;
}
}
favoriteGroups.put(key, list);
@ -978,7 +951,7 @@ public class FavoritesTreeFragment extends OsmandExpandableListFragment implemen
distanceText.setText(distanceWithAddress);
icon.setImageDrawable(FavoriteImageDrawable.getOrCreate(getActivity(),
visible ? model.getColor() : getResources().getColor(disabledIconColor), false,
((PersonalFavouritePoint) model).getType().getOrder() - 1));
((PersonalFavouritePoint) model).getType()));
name.setText((model.getName()));
} else {
icon.setImageDrawable(FavoriteImageDrawable.getOrCreate(getActivity(),

View file

@ -425,6 +425,7 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
if (dashboardOnMap != null) {
dashboardOnMap.updateLocation(true, true, false);
}
app.getFavorites().lookupAddressAllPersonalPoints();
app.getTargetPointsHelper().lookupAddessAll();
app.getMapMarkersHelper().lookupAddressAll();
}

View file

@ -18,7 +18,7 @@ import android.support.annotation.NonNull;
import android.support.v4.content.ContextCompat;
import android.support.v4.content.res.ResourcesCompat;
import net.osmand.data.PersonalFavouritePoint;
import net.osmand.data.PersonalFavouritePoint.PointType;
import net.osmand.plus.R;
import net.osmand.plus.UiUtilities;
@ -26,10 +26,8 @@ import java.util.TreeMap;
public class FavoriteImageDrawable extends Drawable {
private static final int MAX_PERSONAL_POINT = PersonalFavouritePoint.PointType.values().length;
private boolean withShadow;
private boolean synced;
private int position;
private boolean history;
private Bitmap favIcon;
private Bitmap favBackground;
@ -44,20 +42,16 @@ public class FavoriteImageDrawable extends Drawable {
private Paint paintInnerCircle = new Paint();
private ColorFilter colorFilter;
private ColorFilter grayFilter;
private Drawable[] personalPointBitmaps;
private Drawable personalPointBitmaps;
public FavoriteImageDrawable(Context ctx, int color, boolean withShadow, boolean synced) {
public FavoriteImageDrawable(Context ctx, int color, boolean withShadow, boolean synced, PointType pointType) {
this.withShadow = withShadow;
this.synced = synced;
Resources res = ctx.getResources();
personalPointBitmaps = new Drawable[]{
UiUtilities.tintDrawable(ResourcesCompat.getDrawable(res, R.drawable.ic_action_home_dark, null),
ContextCompat.getColor(ctx, R.color.icon_color_default_light)),
UiUtilities.tintDrawable(ResourcesCompat.getDrawable(res, R.drawable.ic_action_work, null),
ContextCompat.getColor(ctx, R.color.icon_color_default_light)),
UiUtilities.tintDrawable(ResourcesCompat.getDrawable(res, R.drawable.ic_action_parking_dark, null),
ContextCompat.getColor(ctx, R.color.icon_color_default_light))
};
if (pointType != null) {
personalPointBitmaps = UiUtilities.tintDrawable(ResourcesCompat.getDrawable(res, pointType.getIconID(), null),
ContextCompat.getColor(ctx, R.color.icon_color_default_light));
}
int col = color == 0 || color == Color.BLACK ? res.getColor(R.color.color_favorite) : color;
favIcon = BitmapFactory.decodeResource(res, R.drawable.map_favorite);
favBackground = BitmapFactory.decodeResource(res, R.drawable.map_white_favorite_shield);
@ -72,11 +66,6 @@ public class FavoriteImageDrawable extends Drawable {
grayFilter = new PorterDuffColorFilter(res.getColor(R.color.color_favorite_gray), PorterDuff.Mode.MULTIPLY);
}
public FavoriteImageDrawable(Context ctx, int color, boolean withShadow, boolean synced, int position) {
this(ctx, color, withShadow, synced);
this.position = position;
}
private void initSimplePaint(Paint paint, int color) {
paint.setAntiAlias(true);
paint.setStyle(Style.FILL_AND_STROKE);
@ -91,8 +80,8 @@ public class FavoriteImageDrawable extends Drawable {
//bs.inset((int) (4 * density), (int) (4 * density));
bs.inset(bs.width() / 4, bs.height() / 4);
listDrawable.setBounds(bs);
for (Drawable drawable : personalPointBitmaps) {
drawable.setBounds(bounds);
if (personalPointBitmaps != null) {
personalPointBitmaps.setBounds(bounds);
}
}
}
@ -119,8 +108,8 @@ public class FavoriteImageDrawable extends Drawable {
} else if (withShadow) {
canvas.drawBitmap(favBackground, bs.exactCenterX() - favBackground.getWidth() / 2f, bs.exactCenterY() - favBackground.getHeight() / 2f, paintBackground);
canvas.drawBitmap(favIcon, bs.exactCenterX() - favIcon.getWidth() / 2f, bs.exactCenterY() - favIcon.getHeight() / 2f, paintIcon);
} else if (position < MAX_PERSONAL_POINT) {
personalPointBitmaps[position].draw(canvas);
} else if (personalPointBitmaps != null) {
personalPointBitmaps.draw(canvas);
} else {
int min = Math.min(bs.width(), bs.height());
int r = (min * 4 / 10);
@ -157,27 +146,30 @@ public class FavoriteImageDrawable extends Drawable {
private static TreeMap<Integer, FavoriteImageDrawable> cache = new TreeMap<>();
public static FavoriteImageDrawable getOrCreate(Context a, int color, boolean withShadow, boolean synced, int position) {
public static FavoriteImageDrawable getOrCreate(Context a, int color, boolean withShadow, boolean synced, PointType pointType) {
int order = 0;
if (pointType != null)
order = pointType.getOrder();
color = color | 0xff000000;
int hash = (color << 3) + (withShadow ? 1 : 0) + (synced ? 3 : 0) + (position + 4);
int hash = (color << 4) + (withShadow ? 0b0100 : 0) + (synced ? 0b1100 : 0) + order;
FavoriteImageDrawable drawable = cache.get(hash);
if (drawable == null) {
drawable = new FavoriteImageDrawable(a, color, withShadow, synced, position);
drawable = new FavoriteImageDrawable(a, color, withShadow, synced, pointType);
drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight());
cache.put(hash, drawable);
}
return drawable;
}
public static FavoriteImageDrawable getOrCreate(Context a, int color, boolean withShadow, int position) {
return getOrCreate(a, color, withShadow, false, position);
public static FavoriteImageDrawable getOrCreate(Context a, int color, boolean withShadow, PointType pointType) {
return getOrCreate(a, color, withShadow, false, pointType);
}
public static FavoriteImageDrawable getOrCreate(Context a, int color, boolean withShadow) {
return getOrCreate(a, color, withShadow, false, MAX_PERSONAL_POINT);
return getOrCreate(a, color, withShadow, false, null);
}
public static FavoriteImageDrawable getOrCreateSyncedIcon(Context a, int color) {
return getOrCreate(a, color, false, true, MAX_PERSONAL_POINT);
return getOrCreate(a, color, false, true, null);
}
}

View file

@ -871,6 +871,14 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL
return R.string.shared_string_add;
}
boolean isFavButtonEnabled() {
MenuController menuController = getMenuController();
if (menuController != null) {
return menuController.isFavButtonEnabled();
}
return true;
}
public int getWaypointActionIconId() {
return waypointActionIconId;
}

View file

@ -561,12 +561,16 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
R.color.ctx_menu_buttons_icon_color));
((TextView) view.findViewById(R.id.context_menu_fav_text_view)).setText(menu.getFavActionStringId());
View favView = view.findViewById(R.id.context_menu_fav_view);
favView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
menu.buttonFavoritePressed();
}
});
if (menu.isFavButtonEnabled()) {
favView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
menu.buttonFavoritePressed();
}
});
} else {
deactivate(favView);
}
final ImageView imageWaypoint = (ImageView) view.findViewById(R.id.context_menu_route_image_view);
imageWaypoint.setImageDrawable(getIcon(menu.getWaypointActionIconId(),

View file

@ -504,6 +504,10 @@ public abstract class MenuController extends BaseMenuController implements Colla
return R.string.shared_string_add;
}
public boolean isFavButtonEnabled() {
return true;
}
public int getWaypointActionIconId() {
return R.drawable.map_action_flag_dark;
}

View file

@ -143,6 +143,11 @@ public class FavouritePointMenuController extends MenuController {
return R.string.shared_string_edit;
}
@Override
public boolean isFavButtonEnabled() {
return !fav.isPersonal();
}
@NonNull
@Override
public String getTypeStr() {

View file

@ -78,10 +78,8 @@ public class SelectCategoryDialogFragment extends DialogFragment {
if (gpxFile != null) {
if (gpxCategories != null) {
for (Map.Entry<String, Integer> e : gpxCategories.entrySet()) {
if (!e.getKey().equals(getContext().getString(R.string.personal_category_name))) {
String categoryName = e.getKey();
addCategory(activity, ll, categoryName, e.getValue());
}
String categoryName = e.getKey();
addCategory(activity, ll, categoryName, e.getValue());
}
}
} else {

View file

@ -155,10 +155,10 @@ public class FavouritesBottomSheetMenuFragment extends MenuBottomSheetDialogFrag
targetPointsHelper.navigateToPoint(ll, true, targetPointsHelper.getIntermediatePoints().size(), point.getPointDescription());
break;
case HOME:
favorites.setHomePoint(ll, point.getPointDescription());
favorites.setHomePoint(ll);
break;
case WORK:
favorites.setWorkPoint(ll, point.getPointDescription());
favorites.setWorkPoint(ll);
break;
}
MapRouteInfoMenu routeMenu = getMapRouteInfoMenu();

View file

@ -118,7 +118,13 @@ public class ParkingPositionPlugin extends OsmandPlugin {
public long getStartParkingTime() {
return parkingStartTime.get();
}
@Override
public void disable(OsmandApplication app) {
super.disable(app);
app.getFavorites().deleteParkingPoint();
}
public boolean clearParkingPosition() {
parkingLat.resetToDefault();
parkingLon.resetToDefault();
@ -292,6 +298,7 @@ public class ParkingPositionPlugin extends OsmandPlugin {
showDeleteEventWarning(activity);
cancelParking();
if (activity instanceof MapActivity) {
app.getFavorites().deleteParkingPoint();
((MapActivity) activity).getContextMenu().close();
}
}

View file

@ -4,8 +4,6 @@ import android.app.Dialog;
import android.os.Bundle;
import android.view.View;
import net.osmand.data.PersonalFavouritePoint;
import net.osmand.data.PointDescription;
import net.osmand.plus.OsmandPlugin;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
@ -74,8 +72,7 @@ public class ParkingTypeBottomSheetDialogFragment extends MenuBottomSheetDialogF
plugin.showContextMenuIfNeeded(mapActivity, true);
mapActivity.refreshMap();
}
mapActivity.getMyApplication().getFavorites().setParkingPoint(plugin.getParkingPosition(),
new PointDescription(PointDescription.POINT_TYPE_FAVORITE, PersonalFavouritePoint.PointType.PARKING.name()));
mapActivity.getMyApplication().getFavorites().setParkingPoint(plugin.getParkingPosition());
}
dismiss();
}

View file

@ -251,11 +251,11 @@ public class AddPointBottomSheetDialog extends MenuBottomSheetDialogFragment {
break;
case HOME:
app.showShortToastMessage(R.string.add_intermediate_point);
app.getFavorites().setHomePoint(ll, new PointDescription(PointDescription.POINT_TYPE_FAVORITE, ""));
app.getFavorites().setHomePoint(ll);
break;
case WORK:
app.showShortToastMessage(R.string.add_intermediate_point);
app.getFavorites().setWorkPoint(ll, new PointDescription(PointDescription.POINT_TYPE_FAVORITE, ""));
app.getFavorites().setWorkPoint(ll);
break;
}
} else if (pointType == PointType.START) {
@ -369,13 +369,13 @@ public class AddPointBottomSheetDialog extends MenuBottomSheetDialogFragment {
private void addMainScrollItems(List<Object> items, FavouritesDbHelper favorites) {
items.add(FAVORITES);
if (favorites.hasHomePoint()) {
if (favorites.getHomePoint() != null) {
items.add(PointType.HOME);
}
if (favorites.hasWorkPoint()) {
if (favorites.getWorkPoint() != null) {
items.add(PointType.WORK);
}
if (favorites.hasParkingPoint()) {
if (favorites.getParkingPoint() != null) {
items.add(PointType.PARKING);
}
}
@ -647,7 +647,7 @@ public class AddPointBottomSheetDialog extends MenuBottomSheetDialogFragment {
point = favorites.getParkingPoint();
}
favoriteViewHolder.icon.setImageDrawable(FavoriteImageDrawable.getOrCreate(getActivity(),
getResources().getColor(disabledIconColor), false, (pointType.ordinal())));
getResources().getColor(disabledIconColor), false, pointType));
favoriteViewHolder.title.setText(point.getName());
favoriteViewHolder.description.setText(point != null
? point.getPointDescription().getSimpleName(app, false)

View file

@ -275,10 +275,10 @@ public class MapRouteInfoMenu implements IRouteInformationListener, CardListener
targets.navigateToPoint(latlon, true, targets.getIntermediatePoints().size());
break;
case HOME:
favorites.setHomePoint(latlon, new PointDescription(PointDescription.POINT_TYPE_FAVORITE, ""));
favorites.setHomePoint(latlon);
break;
case WORK:
favorites.setWorkPoint(latlon, new PointDescription(PointDescription.POINT_TYPE_FAVORITE, ""));
favorites.setWorkPoint(latlon);
break;
}
if (selectFromMapWaypoints) {
@ -1802,10 +1802,10 @@ public class MapRouteInfoMenu implements IRouteInformationListener, CardListener
targets.navigateToPoint(l, true, targets.getIntermediatePoints().size(), pd);
break;
case HOME:
favorites.setHomePoint(l, new PointDescription(PointDescription.POINT_TYPE_FAVORITE, ""));
favorites.setHomePoint(l);
break;
case WORK:
favorites.setWorkPoint(l, new PointDescription(PointDescription.POINT_TYPE_FAVORITE, ""));
favorites.setWorkPoint(l);
break;
}
updateMenu();
@ -1862,10 +1862,10 @@ public class MapRouteInfoMenu implements IRouteInformationListener, CardListener
targets.navigateToPoint(point, true, targets.getIntermediatePoints().size(), m.getPointDescription(mapActivity));
break;
case HOME:
favorites.setHomePoint(point, m.getPointDescription(mapActivity));
favorites.setHomePoint(point);
break;
case WORK:
favorites.setWorkPoint(point, m.getPointDescription(mapActivity));
favorites.setWorkPoint(point);
break;
}
updateMenu();

View file

@ -102,8 +102,6 @@ public class QuickSearchListItem {
case LOCATION:
LatLon latLon = searchResult.location;
return PointDescription.getLocationNamePlain(app, latLon.getLatitude(), latLon.getLongitude());
case FAVORITE:
return ((FavouritePoint) searchResult.object).getName();
}
return searchResult.localeName;
}