Merge pull request #8168 from osmandapp/personal_favs_refactor
Personal favs refactor
This commit is contained in:
commit
fa84c5acf9
47 changed files with 489 additions and 571 deletions
2
OsmAnd/libs/.gitignore
vendored
2
OsmAnd/libs/.gitignore
vendored
|
@ -3,4 +3,4 @@ x86/
|
|||
armeabi-v7a/
|
||||
mips/
|
||||
arm64-v8a/
|
||||
x86_64/
|
||||
x86_64/
|
||||
|
|
|
@ -112,7 +112,7 @@
|
|||
android:layout_marginLeft="@dimen/dashFavIconMargin"
|
||||
android:background="?attr/dashboard_button"
|
||||
android:src="@drawable/ic_action_test_light"
|
||||
android:visibility="invisible"/>
|
||||
android:visibility="gone"/>
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/options"
|
||||
|
|
|
@ -846,7 +846,7 @@ public class OsmandAidlApi {
|
|||
FavouritesDbHelper favoritesHelper = app.getFavorites();
|
||||
List<FavouritesDbHelper.FavoriteGroup> groups = favoritesHelper.getFavoriteGroups();
|
||||
for (FavouritesDbHelper.FavoriteGroup g : groups) {
|
||||
if (g.name.equals(name)) {
|
||||
if (g.getName().equals(name)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -862,7 +862,7 @@ public class OsmandAidlApi {
|
|||
FavouritesDbHelper favoritesHelper = app.getFavorites();
|
||||
List<FavouritesDbHelper.FavoriteGroup> groups = favoritesHelper.getFavoriteGroups();
|
||||
for (FavouritesDbHelper.FavoriteGroup g : groups) {
|
||||
if (g.name.equals(name)) {
|
||||
if (g.getName().equals(name)) {
|
||||
favoritesHelper.deleteGroup(g);
|
||||
return true;
|
||||
}
|
||||
|
@ -874,7 +874,7 @@ public class OsmandAidlApi {
|
|||
FavouritesDbHelper favoritesHelper = app.getFavorites();
|
||||
List<FavouritesDbHelper.FavoriteGroup> groups = favoritesHelper.getFavoriteGroups();
|
||||
for (FavouritesDbHelper.FavoriteGroup g : groups) {
|
||||
if (g.name.equals(prevGroupName)) {
|
||||
if (g.getName().equals(prevGroupName)) {
|
||||
int color = 0;
|
||||
if (!Algorithms.isEmpty(colorTag)) {
|
||||
color = ColorDialogs.getColorByTag(colorTag);
|
||||
|
|
|
@ -3,25 +3,36 @@ package net.osmand.data;
|
|||
import java.io.Serializable;
|
||||
|
||||
import android.content.Context;
|
||||
import android.support.annotation.DrawableRes;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.StringRes;
|
||||
|
||||
import net.osmand.GPXUtilities.WptPt;
|
||||
import net.osmand.plus.FavouritesDbHelper;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.util.Algorithms;
|
||||
|
||||
|
||||
public class FavouritePoint implements Serializable, LocationPoint {
|
||||
private static final long serialVersionUID = 729654300829771466L;
|
||||
|
||||
protected static final String HIDDEN = "hidden";
|
||||
private static final String HIDDEN = "hidden";
|
||||
private static final String ADDRESS_EXTENSION = "address";
|
||||
|
||||
|
||||
|
||||
protected String name = "";
|
||||
protected String description;
|
||||
protected String category = "";
|
||||
protected String address = "";
|
||||
private String originObjectName = "";
|
||||
private double latitude;
|
||||
private double longitude;
|
||||
private int color;
|
||||
private boolean visible = true;
|
||||
private SpecialPointType specialPointType = null;
|
||||
|
||||
public FavouritePoint(){
|
||||
public FavouritePoint() {
|
||||
}
|
||||
|
||||
public FavouritePoint(double latitude, double longitude, String name, String category) {
|
||||
|
@ -32,6 +43,7 @@ public class FavouritePoint implements Serializable, LocationPoint {
|
|||
name = "";
|
||||
}
|
||||
this.name = name;
|
||||
initPersonalType();
|
||||
}
|
||||
|
||||
public FavouritePoint(FavouritePoint favouritePoint) {
|
||||
|
@ -43,23 +55,47 @@ public class FavouritePoint implements Serializable, LocationPoint {
|
|||
this.description = favouritePoint.description;
|
||||
this.visible = favouritePoint.visible;
|
||||
this.originObjectName = favouritePoint.originObjectName;
|
||||
this.address = favouritePoint.address;
|
||||
initPersonalType();
|
||||
}
|
||||
|
||||
private void initPersonalType() {
|
||||
if(FavouritesDbHelper.FavoriteGroup.PERSONAL_CATEGORY.equals(category)) {
|
||||
for(SpecialPointType p : SpecialPointType.values()) {
|
||||
if(p.typeName.equals(this.name)) {
|
||||
this.specialPointType = p;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public SpecialPointType getSpecialPointType() {
|
||||
return specialPointType;
|
||||
}
|
||||
|
||||
public int getColor() {
|
||||
return color;
|
||||
}
|
||||
|
||||
public PointDescription getPointDescription() {
|
||||
return new PointDescription(PointDescription.POINT_TYPE_FAVORITE, getName());
|
||||
|
||||
public String getAddress() {
|
||||
return address;
|
||||
}
|
||||
|
||||
public boolean isPersonal() {
|
||||
return false;
|
||||
public void setAddress(String address) {
|
||||
this.address = address;
|
||||
}
|
||||
|
||||
public boolean isAddressSpecified() {
|
||||
return !Algorithms.isEmpty(address);
|
||||
}
|
||||
|
||||
public boolean isSpecialPoint() {
|
||||
return specialPointType != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PointDescription getPointDescription(Context ctx) {
|
||||
return getPointDescription();
|
||||
public PointDescription getPointDescription(@NonNull Context ctx) {
|
||||
return new PointDescription(PointDescription.POINT_TYPE_FAVORITE, getDisplayName(ctx));
|
||||
}
|
||||
|
||||
public void setColor(int color) {
|
||||
|
@ -82,6 +118,13 @@ public class FavouritePoint implements Serializable, LocationPoint {
|
|||
this.originObjectName = originObjectName;
|
||||
}
|
||||
|
||||
public int getOverlayIconId() {
|
||||
if (isSpecialPoint()) {
|
||||
return specialPointType.getIconId();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public double getLatitude() {
|
||||
return latitude;
|
||||
}
|
||||
|
@ -101,12 +144,20 @@ public class FavouritePoint implements Serializable, LocationPoint {
|
|||
public String getCategory() {
|
||||
return category;
|
||||
}
|
||||
|
||||
public String getCategoryDisplayName(@NonNull Context ctx) {
|
||||
return FavouritesDbHelper.FavoriteGroup.getDisplayName(ctx, category);
|
||||
}
|
||||
|
||||
public void setCategory(String category) {
|
||||
this.category = category;
|
||||
initPersonalType();
|
||||
}
|
||||
|
||||
public String getName(Context ctx) {
|
||||
public String getDisplayName(@NonNull Context ctx) {
|
||||
if (isSpecialPoint()) {
|
||||
return specialPointType.getHumanString(ctx);
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
||||
|
@ -116,6 +167,7 @@ public class FavouritePoint implements Serializable, LocationPoint {
|
|||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
initPersonalType();
|
||||
}
|
||||
|
||||
public String getDescription () {
|
||||
|
@ -125,7 +177,8 @@ public class FavouritePoint implements Serializable, LocationPoint {
|
|||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Favourite " + getName(); //$NON-NLS-1$
|
||||
|
@ -182,28 +235,55 @@ public class FavouritePoint implements Serializable, LocationPoint {
|
|||
return result;
|
||||
}
|
||||
|
||||
public static FavouritePoint fromWpt(@NonNull Context ctx, @NonNull WptPt pt) {
|
||||
|
||||
public enum SpecialPointType {
|
||||
HOME("home", R.string.home_button, R.drawable.ic_action_home_dark),
|
||||
WORK("work", R.string.work_button, R.drawable.ic_action_work),
|
||||
PARKING("parking", R.string.map_widget_parking, R.drawable.ic_action_parking_dark);
|
||||
|
||||
private String typeName;
|
||||
@StringRes
|
||||
private int resId;
|
||||
@DrawableRes
|
||||
private int iconId;
|
||||
|
||||
SpecialPointType(@NonNull String typeName, @StringRes int resId, @DrawableRes int iconId) {
|
||||
this.typeName = typeName;
|
||||
this.resId = resId;
|
||||
this.iconId = iconId;
|
||||
}
|
||||
|
||||
public String getCategory() { return FavouritesDbHelper.FavoriteGroup.PERSONAL_CATEGORY; }
|
||||
|
||||
public String getName() {
|
||||
return typeName;
|
||||
}
|
||||
|
||||
public int getIconId() {
|
||||
return iconId;
|
||||
}
|
||||
|
||||
public String getHumanString(@NonNull Context ctx) {
|
||||
return ctx.getString(resId);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static FavouritePoint fromWpt(@NonNull WptPt pt) {
|
||||
String name = pt.name;
|
||||
String categoryName = pt.category != null ? pt.category : "";
|
||||
if (name == null) {
|
||||
name = "";
|
||||
}
|
||||
FavouritePoint fp;
|
||||
if (pt.getExtensionsToRead().containsKey(PersonalFavouritePoint.PERSONAL)) {
|
||||
try {
|
||||
fp = new PersonalFavouritePoint(ctx, name, pt.lat, pt.lon);
|
||||
} catch (IllegalArgumentException e) {
|
||||
fp = new FavouritePoint(pt.lat, pt.lon, name, categoryName);
|
||||
}
|
||||
} else {
|
||||
fp = new FavouritePoint(pt.lat, pt.lon, name, categoryName);
|
||||
}
|
||||
fp.setDescription(pt.desc);
|
||||
if (pt.comment != null) {
|
||||
fp.setOriginObjectName(pt.comment);
|
||||
}
|
||||
fp.setColor(pt.getColor(0));
|
||||
fp.setVisible(!pt.getExtensionsToRead().containsKey(HIDDEN));
|
||||
fp.setAddress(pt.getExtensionsToRead().get(ADDRESS_EXTENSION));
|
||||
return fp;
|
||||
}
|
||||
|
||||
|
@ -214,6 +294,9 @@ public class FavouritePoint implements Serializable, LocationPoint {
|
|||
if (!isVisible()) {
|
||||
pt.getExtensionsToWrite().put(HIDDEN, "true");
|
||||
}
|
||||
if (isAddressSpecified()) {
|
||||
pt.getExtensionsToWrite().put(ADDRESS_EXTENSION, getAddress());
|
||||
}
|
||||
if (getColor() != 0) {
|
||||
pt.setColor(getColor());
|
||||
}
|
||||
|
|
|
@ -1,115 +0,0 @@
|
|||
package net.osmand.data;
|
||||
|
||||
import android.content.Context;
|
||||
import android.support.annotation.DrawableRes;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.StringRes;
|
||||
|
||||
import net.osmand.GPXUtilities.WptPt;
|
||||
import net.osmand.plus.R;
|
||||
|
||||
public class PersonalFavouritePoint extends FavouritePoint {
|
||||
|
||||
private Context ctx;
|
||||
|
||||
private PointType type;
|
||||
static final String PERSONAL = "personal";
|
||||
|
||||
public enum PointType {
|
||||
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 typeName;
|
||||
@StringRes
|
||||
private int resId;
|
||||
private int order;
|
||||
@DrawableRes
|
||||
private int iconId;
|
||||
|
||||
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 typeName;
|
||||
}
|
||||
|
||||
public int getOrder() {
|
||||
return order;
|
||||
}
|
||||
|
||||
public static PointType valueOfTypeName(@NonNull String typeName) {
|
||||
for (PointType pt : values()) {
|
||||
if (pt.typeName.equals(typeName)) {
|
||||
return pt;
|
||||
}
|
||||
}
|
||||
throw new IllegalArgumentException("Illegal PointType typeName");
|
||||
}
|
||||
|
||||
public int getIconId() {
|
||||
return iconId;
|
||||
}
|
||||
|
||||
public String getHumanString(@NonNull Context ctx) {
|
||||
return ctx.getString(resId);
|
||||
}
|
||||
}
|
||||
|
||||
public PersonalFavouritePoint(@NonNull Context ctx, @NonNull PointType type, double latitude, double longitude) {
|
||||
super(latitude, longitude, type.typeName, PERSONAL);
|
||||
this.ctx = ctx;
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
PersonalFavouritePoint(@NonNull Context ctx, @NonNull String typeName, double latitude, double longitude) throws IllegalArgumentException {
|
||||
this(ctx, PointType.valueOfTypeName(typeName), latitude, longitude);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PointDescription getPointDescription() {
|
||||
return new PointDescription(PointDescription.POINT_TYPE_LOCATION, getDescription());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPersonal() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public PointType getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return type.getHumanString(ctx);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setName(String name) {
|
||||
throw new IllegalArgumentException("Personal name is readonly");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCategory() {
|
||||
return ctx.getString(R.string.personal_category_name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCategory(String category) {
|
||||
throw new IllegalArgumentException("Personal category is readonly");
|
||||
}
|
||||
|
||||
@Override
|
||||
public WptPt toWpt() {
|
||||
WptPt pt = super.toWpt();
|
||||
pt.getExtensionsToWrite().put(PERSONAL, "true");
|
||||
pt.name = type.typeName;
|
||||
pt.desc = getDescription();
|
||||
return pt;
|
||||
}
|
||||
}
|
|
@ -3,7 +3,6 @@ package net.osmand.plus;
|
|||
import android.content.Context;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.annotation.StringRes;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
|
||||
import net.osmand.GPXUtilities;
|
||||
|
@ -12,7 +11,6 @@ import net.osmand.GPXUtilities.WptPt;
|
|||
import net.osmand.PlatformUtil;
|
||||
import net.osmand.data.FavouritePoint;
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.data.PersonalFavouritePoint;
|
||||
import net.osmand.plus.GeocodingLookupService.AddressLookupRequest;
|
||||
import net.osmand.plus.MapMarkersHelper.MapMarkersGroup;
|
||||
import net.osmand.plus.api.SQLiteAPI.SQLiteConnection;
|
||||
|
@ -35,15 +33,14 @@ import java.util.Map;
|
|||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import static net.osmand.data.PersonalFavouritePoint.PointType.HOME;
|
||||
import static net.osmand.data.PersonalFavouritePoint.PointType.PARKING;
|
||||
import static net.osmand.data.PersonalFavouritePoint.PointType.WORK;
|
||||
|
||||
public class FavouritesDbHelper {
|
||||
|
||||
public interface FavoritesListener {
|
||||
|
||||
void onFavoritesLoaded();
|
||||
void onFavoriteAddressResolved(@NonNull FavouritePoint favouritePoint);
|
||||
|
||||
void onFavoriteDataUpdated(@NonNull FavouritePoint favouritePoint);
|
||||
}
|
||||
|
||||
private static final org.apache.commons.logging.Log log = PlatformUtil.getLog(FavouritesDbHelper.class);
|
||||
|
@ -54,7 +51,6 @@ public class FavouritesDbHelper {
|
|||
public static final String FILE_TO_BACKUP = "favourites_bak.gpx"; //$NON-NLS-1$
|
||||
|
||||
private List<FavouritePoint> cachedFavoritePoints = new ArrayList<>();
|
||||
private List<FavouritePoint> cachedPersonalFavoritePoints = new ArrayList<>();
|
||||
private List<FavoriteGroup> favoriteGroups = new ArrayList<>();
|
||||
private Map<String, FavoriteGroup> flatGroups = new LinkedHashMap<>();
|
||||
private final OsmandApplication context;
|
||||
|
@ -70,11 +66,63 @@ public class FavouritesDbHelper {
|
|||
}
|
||||
|
||||
public static class FavoriteGroup {
|
||||
public String name;
|
||||
public boolean visible = true;
|
||||
public int color;
|
||||
public boolean personal = false;
|
||||
public List<FavouritePoint> points = new ArrayList<FavouritePoint>();
|
||||
public static final String PERSONAL_CATEGORY = "personal";
|
||||
private String name;
|
||||
private boolean visible = true;
|
||||
private int color;
|
||||
private List<FavouritePoint> points = new ArrayList<>();
|
||||
|
||||
public boolean isPersonal() {
|
||||
return isPersonal(name);
|
||||
}
|
||||
|
||||
private static boolean isPersonal(String name) {
|
||||
return PERSONAL_CATEGORY.equals(name);
|
||||
}
|
||||
|
||||
public static boolean isPersonalCategoryDisplayName(Context ctx, String name){
|
||||
return name.equals(ctx.getString(R.string.personal_category_name));
|
||||
}
|
||||
|
||||
public static String getDisplayName(Context ctx, String name) {
|
||||
if (isPersonal(name)) {
|
||||
return ctx.getString(R.string.personal_category_name);
|
||||
} else if (name.isEmpty()) {
|
||||
return ctx.getString(R.string.shared_string_favorites);
|
||||
} else {
|
||||
return name;
|
||||
}
|
||||
}
|
||||
|
||||
public List<FavouritePoint> getPoints() {
|
||||
return points;
|
||||
}
|
||||
|
||||
public int getColor() {
|
||||
return color;
|
||||
}
|
||||
|
||||
public boolean isVisible() {
|
||||
return visible;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public String getDisplayName(Context ctx) {
|
||||
return getDisplayName(ctx, name);
|
||||
}
|
||||
|
||||
public static String convertDisplayNameToGroupIdName(Context context, String name) {
|
||||
if (isPersonalCategoryDisplayName(context,name)) {
|
||||
return PERSONAL_CATEGORY;
|
||||
}
|
||||
if (name.equals(context.getString(R.string.shared_string_favorites))) {
|
||||
return "";
|
||||
}
|
||||
return name;
|
||||
}
|
||||
}
|
||||
|
||||
public void loadFavorites() {
|
||||
|
@ -116,28 +164,12 @@ public class FavouritesDbHelper {
|
|||
});
|
||||
}
|
||||
|
||||
public FavouritePoint getWorkPoint() {
|
||||
return getPersonalPoint(WORK);
|
||||
}
|
||||
|
||||
public FavouritePoint getHomePoint() {
|
||||
return getPersonalPoint(HOME);
|
||||
}
|
||||
|
||||
public FavouritePoint getParkingPoint() {
|
||||
return getPersonalPoint(PARKING);
|
||||
}
|
||||
|
||||
public void deleteParkingPoint() {
|
||||
deleteFavourite(getParkingPoint());
|
||||
}
|
||||
|
||||
private FavouritePoint getPersonalPoint(PersonalFavouritePoint.PointType pointType) {
|
||||
for (FavouritePoint fp : cachedPersonalFavoritePoints) {
|
||||
if (((PersonalFavouritePoint) fp).getType() == pointType) {
|
||||
return fp;
|
||||
}
|
||||
public FavouritePoint getSpecialPoint(FavouritePoint.SpecialPointType pointType) {
|
||||
for (FavouritePoint fp : cachedFavoritePoints) {
|
||||
if (fp.getSpecialPointType() == pointType) {
|
||||
return fp;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -167,7 +199,7 @@ public class FavouritesDbHelper {
|
|||
private void runSyncWithMarkers(FavoriteGroup favGroup) {
|
||||
MapMarkersHelper helper = context.getMapMarkersHelper();
|
||||
MapMarkersGroup group = helper.getMarkersGroup(favGroup);
|
||||
if(group != null) {
|
||||
if (group != null) {
|
||||
helper.runSynchronization(group);
|
||||
}
|
||||
}
|
||||
|
@ -175,7 +207,7 @@ public class FavouritesDbHelper {
|
|||
private boolean removeFromMarkers(FavoriteGroup favGroup) {
|
||||
MapMarkersHelper helper = context.getMapMarkersHelper();
|
||||
MapMarkersGroup group = helper.getMarkersGroup(favGroup);
|
||||
if(group != null) {
|
||||
if (group != null) {
|
||||
helper.removeMarkersGroup(group);
|
||||
return true;
|
||||
}
|
||||
|
@ -229,9 +261,6 @@ public class FavouritesDbHelper {
|
|||
runSyncWithMarkers(group);
|
||||
}
|
||||
cachedFavoritePoints.remove(p);
|
||||
if (p.isPersonal()) {
|
||||
cachedPersonalFavoritePoints.remove(p);
|
||||
}
|
||||
}
|
||||
if (saveImmediately) {
|
||||
saveCurrentPointsIntoFile();
|
||||
|
@ -239,43 +268,15 @@ public class FavouritesDbHelper {
|
|||
return true;
|
||||
}
|
||||
|
||||
public void setHomePoint(@NonNull LatLon latLon, @Nullable String description) {
|
||||
FavouritePoint homePoint = getHomePoint();
|
||||
if (homePoint != null) {
|
||||
editFavourite(homePoint, latLon.getLatitude(), latLon.getLongitude(), description);
|
||||
public void setSpecialPoint(@NonNull LatLon latLon, FavouritePoint.SpecialPointType specialType, @Nullable String address) {
|
||||
FavouritePoint point = getSpecialPoint(specialType);
|
||||
if (point != null) {
|
||||
editFavourite(point, latLon.getLatitude(), latLon.getLongitude(), address);
|
||||
} else {
|
||||
homePoint = new PersonalFavouritePoint(context, HOME, latLon.getLatitude(), latLon.getLongitude());
|
||||
homePoint.setDescription(description);
|
||||
addFavourite(homePoint);
|
||||
point = new FavouritePoint(latLon.getLatitude(), latLon.getLongitude(), specialType.getName(), specialType.getCategory());
|
||||
point.setAddress(address);
|
||||
addFavourite(point);
|
||||
}
|
||||
if (description == null) {
|
||||
lookupAddress(homePoint);
|
||||
}
|
||||
}
|
||||
|
||||
public void setWorkPoint(@NonNull LatLon latLon, @Nullable String description) {
|
||||
FavouritePoint workPoint = getWorkPoint();
|
||||
if (workPoint != null) {
|
||||
editFavourite(workPoint, latLon.getLatitude(), latLon.getLongitude(), description);
|
||||
} else {
|
||||
workPoint = new PersonalFavouritePoint(context, WORK, latLon.getLatitude(), latLon.getLongitude());
|
||||
workPoint.setDescription(description);
|
||||
addFavourite(workPoint);
|
||||
}
|
||||
if (description == null) {
|
||||
lookupAddress(workPoint);
|
||||
}
|
||||
}
|
||||
|
||||
public void setParkingPoint(@NonNull LatLon latLon) {
|
||||
FavouritePoint parkingPoint = getParkingPoint();
|
||||
if (parkingPoint != null) {
|
||||
editFavourite(parkingPoint, latLon.getLatitude(), latLon.getLongitude(), null);
|
||||
} else {
|
||||
parkingPoint = new PersonalFavouritePoint(context, PARKING, latLon.getLatitude(), latLon.getLongitude());
|
||||
addFavourite(parkingPoint);
|
||||
}
|
||||
lookupAddress(parkingPoint);
|
||||
}
|
||||
|
||||
public boolean addFavourite(FavouritePoint p) {
|
||||
|
@ -286,6 +287,9 @@ public class FavouritesDbHelper {
|
|||
if (p.getName().equals("") && flatGroups.containsKey(p.getCategory())) {
|
||||
return true;
|
||||
}
|
||||
if (!p.isAddressSpecified()) {
|
||||
lookupAddress(p);
|
||||
}
|
||||
context.getSettings().SHOW_FAVORITES.set(true);
|
||||
FavoriteGroup group = getOrCreateGroup(p, 0);
|
||||
|
||||
|
@ -295,9 +299,6 @@ public class FavouritesDbHelper {
|
|||
group.points.add(p);
|
||||
cachedFavoritePoints.add(p);
|
||||
}
|
||||
if (p.isPersonal()) {
|
||||
cachedPersonalFavoritePoints.add(p);
|
||||
}
|
||||
if (saveImmediately) {
|
||||
sortAll();
|
||||
saveCurrentPointsIntoFile();
|
||||
|
@ -307,24 +308,7 @@ public class FavouritesDbHelper {
|
|||
return true;
|
||||
}
|
||||
|
||||
public void lookupAddressAllPersonalPoints() {
|
||||
if (!context.isApplicationInitializing()) {
|
||||
FavouritePoint workPoint = getWorkPoint();
|
||||
if (workPoint != null) {
|
||||
lookupAddress(workPoint);
|
||||
}
|
||||
FavouritePoint homePoint = getHomePoint();
|
||||
if (homePoint != null) {
|
||||
lookupAddress(homePoint);
|
||||
}
|
||||
FavouritePoint parkingPoint = getParkingPoint();
|
||||
if (parkingPoint != null) {
|
||||
lookupAddress(parkingPoint);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void lookupAddress(@NonNull final FavouritePoint p) {
|
||||
public void lookupAddress(@NonNull final FavouritePoint p) {
|
||||
AddressLookupRequest request = addressRequestMap.get(p);
|
||||
double latitude = p.getLatitude();
|
||||
double longitude = p.getLongitude();
|
||||
|
@ -332,21 +316,21 @@ public class FavouritesDbHelper {
|
|||
cancelAddressRequest(p);
|
||||
request = new AddressLookupRequest(new LatLon(latitude, longitude),
|
||||
new GeocodingLookupService.OnAddressLookupResult() {
|
||||
@Override
|
||||
public void geocodingDone(String address) {
|
||||
addressRequestMap.remove(p);
|
||||
editFavouriteDescription(p, address);
|
||||
context.runInUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
for (FavoritesListener listener : listeners) {
|
||||
listener.onFavoriteAddressResolved(p);
|
||||
}
|
||||
}
|
||||
});
|
||||
public void geocodingDone(String address) {
|
||||
addressRequestMap.remove(p);
|
||||
editAddressDescription(p, address);
|
||||
context.runInUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
for (FavoritesListener listener : listeners) {
|
||||
listener.onFavoriteDataUpdated(p);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}, null);
|
||||
}
|
||||
}, null);
|
||||
addressRequestMap.put(p, request);
|
||||
context.getGeocodingLookupService().lookupAddress(request);
|
||||
}
|
||||
|
@ -454,27 +438,23 @@ public class FavouritesDbHelper {
|
|||
return true;
|
||||
}
|
||||
|
||||
public boolean editFavouriteDescription(FavouritePoint p, String description) {
|
||||
p.setDescription(description);
|
||||
private void editAddressDescription(@NonNull FavouritePoint p, @Nullable String address) {
|
||||
p.setAddress(address);
|
||||
saveCurrentPointsIntoFile();
|
||||
runSyncWithMarkers(getOrCreateGroup(p, 0));
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean editFavourite(FavouritePoint p, double lat, double lon) {
|
||||
public boolean editFavourite(@NonNull FavouritePoint p, double lat, double lon) {
|
||||
return editFavourite(p, lat, lon, null);
|
||||
}
|
||||
|
||||
private boolean editFavourite(@NonNull FavouritePoint p, double lat, double lon, @Nullable String description) {
|
||||
cancelAddressRequest(p);
|
||||
p.setLatitude(lat);
|
||||
p.setLongitude(lon);
|
||||
saveCurrentPointsIntoFile();
|
||||
runSyncWithMarkers(getOrCreateGroup(p, 0));
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean editFavourite(FavouritePoint p, double lat, double lon, String description) {
|
||||
cancelAddressRequest(p);
|
||||
p.setLatitude(lat);
|
||||
p.setLongitude(lon);
|
||||
p.setDescription(description);
|
||||
if (description != null) {
|
||||
p.setDescription(description);
|
||||
}
|
||||
saveCurrentPointsIntoFile();
|
||||
runSyncWithMarkers(getOrCreateGroup(p, 0));
|
||||
return true;
|
||||
|
@ -498,7 +478,7 @@ public class FavouritesDbHelper {
|
|||
private void backup(File backupFile, File externalFile) {
|
||||
try {
|
||||
File f = new File(backupFile.getParentFile(), backupFile.getName());
|
||||
BZip2CompressorOutputStream out = new BZip2CompressorOutputStream( new FileOutputStream(f));
|
||||
BZip2CompressorOutputStream out = new BZip2CompressorOutputStream(new FileOutputStream(f));
|
||||
FileInputStream fis = new FileInputStream(externalFile);
|
||||
Algorithms.streamCopy(fis, out);
|
||||
fis.close();
|
||||
|
@ -512,7 +492,6 @@ public class FavouritesDbHelper {
|
|||
return saveExternalFile(null);
|
||||
}
|
||||
|
||||
|
||||
private Exception saveExternalFile(Set<String> deleted) {
|
||||
Map<String, FavouritePoint> all = new LinkedHashMap<String, FavouritePoint>();
|
||||
loadGPXFile(getExternalFile(), all);
|
||||
|
@ -531,7 +510,6 @@ public class FavouritesDbHelper {
|
|||
return saveFile(favoritePoints, getExternalFile());
|
||||
}
|
||||
|
||||
|
||||
private String getKey(FavouritePoint p) {
|
||||
return p.getName() + DELIMETER + p.getCategory();
|
||||
}
|
||||
|
@ -582,7 +560,6 @@ public class FavouritesDbHelper {
|
|||
return GPXUtilities.writeGpxFile(f, gpx);
|
||||
}
|
||||
|
||||
|
||||
public GPXFile asGpxFile() {
|
||||
return asGpxFile(cachedFavoritePoints);
|
||||
}
|
||||
|
@ -595,13 +572,13 @@ public class FavouritesDbHelper {
|
|||
return gpx;
|
||||
}
|
||||
|
||||
|
||||
public void addEmptyCategory(String name) {
|
||||
private void addEmptyCategory(String name) {
|
||||
addEmptyCategory(name, 0, true);
|
||||
}
|
||||
|
||||
public void addEmptyCategory(String name, int color) {
|
||||
addEmptyCategory(name, color, true);
|
||||
if (FavoriteGroup.isPersonalCategoryDisplayName(context,name))
|
||||
addEmptyCategory(name, color, true);
|
||||
}
|
||||
|
||||
public void addEmptyCategory(String name, int color, boolean visible) {
|
||||
|
@ -627,26 +604,6 @@ public class FavouritesDbHelper {
|
|||
return fp;
|
||||
}
|
||||
|
||||
public List<FavouritePoint> getNonPersonalVisibleFavouritePoints() {
|
||||
List<FavouritePoint> fp = new ArrayList<>();
|
||||
for (FavouritePoint p : getNonPersonalFavouritePoints()) {
|
||||
if (p.isVisible()) {
|
||||
fp.add(p);
|
||||
}
|
||||
}
|
||||
return fp;
|
||||
}
|
||||
|
||||
public List<FavouritePoint> getNonPersonalFavouritePoints() {
|
||||
List<FavouritePoint> fp = new ArrayList<>();
|
||||
for (FavouritePoint p : cachedFavoritePoints) {
|
||||
if (!p.isPersonal()) {
|
||||
fp.add(p);
|
||||
}
|
||||
}
|
||||
return fp;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public FavouritePoint getVisibleFavByLatLon(@NonNull LatLon latLon) {
|
||||
for (FavouritePoint fav : cachedFavoritePoints) {
|
||||
|
@ -657,7 +614,6 @@ public class FavouritesDbHelper {
|
|||
return null;
|
||||
}
|
||||
|
||||
|
||||
public List<FavoriteGroup> getFavoriteGroups() {
|
||||
return favoriteGroups;
|
||||
}
|
||||
|
@ -680,9 +636,9 @@ public class FavouritesDbHelper {
|
|||
}
|
||||
}
|
||||
|
||||
public FavoriteGroup getGroup(String name) {
|
||||
if (flatGroups.containsKey(name)) {
|
||||
return flatGroups.get(name);
|
||||
public FavoriteGroup getGroup(String nameId) {
|
||||
if (flatGroups.containsKey(nameId)) {
|
||||
return flatGroups.get(nameId);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
@ -700,18 +656,12 @@ public class FavouritesDbHelper {
|
|||
return null;
|
||||
}
|
||||
|
||||
|
||||
public void recalculateCachedFavPoints() {
|
||||
List<FavouritePoint> allPoints = new ArrayList<>();
|
||||
List<FavouritePoint> personalPoints = new ArrayList<>();
|
||||
for (FavoriteGroup f : favoriteGroups) {
|
||||
if (f.personal) {
|
||||
personalPoints.addAll(f.points);
|
||||
}
|
||||
allPoints.addAll(f.points);
|
||||
}
|
||||
cachedFavoritePoints = allPoints;
|
||||
cachedPersonalFavoritePoints = personalPoints;
|
||||
}
|
||||
|
||||
public void sortAll() {
|
||||
|
@ -721,7 +671,7 @@ public class FavouritesDbHelper {
|
|||
|
||||
@Override
|
||||
public int compare(FavoriteGroup lhs, FavoriteGroup rhs) {
|
||||
return lhs.personal ? -1 : rhs.personal ? 1 : collator.compare(lhs.name, rhs.name);
|
||||
return lhs.isPersonal() ? -1 : rhs.isPersonal() ? 1 : collator.compare(lhs.name, rhs.name);
|
||||
}
|
||||
});
|
||||
Comparator<FavouritePoint> favoritesComparator = getComparator();
|
||||
|
@ -731,9 +681,6 @@ public class FavouritesDbHelper {
|
|||
if (cachedFavoritePoints != null) {
|
||||
Collections.sort(cachedFavoritePoints, favoritesComparator);
|
||||
}
|
||||
if (cachedPersonalFavoritePoints != null) {
|
||||
Collections.sort(cachedPersonalFavoritePoints, favoritesComparator);
|
||||
}
|
||||
}
|
||||
|
||||
public static Comparator<FavouritePoint> getComparator() {
|
||||
|
@ -743,15 +690,6 @@ public class FavouritesDbHelper {
|
|||
|
||||
@Override
|
||||
public int compare(FavouritePoint o1, FavouritePoint o2) {
|
||||
if (o1.isPersonal() && o2.isPersonal()) {
|
||||
int x = ((PersonalFavouritePoint) o1).getType().getOrder();
|
||||
int y = ((PersonalFavouritePoint) o2).getType().getOrder();
|
||||
return Algorithms.compare(x, y);
|
||||
} else if (o1.isPersonal()) {
|
||||
return -1;
|
||||
} else if (o2.isPersonal()) {
|
||||
return 1;
|
||||
}
|
||||
String s1 = o1.getName();
|
||||
String s2 = o2.getName();
|
||||
int i1 = Algorithms.extractIntegerNumber(s1);
|
||||
|
@ -787,7 +725,7 @@ public class FavouritesDbHelper {
|
|||
return false;
|
||||
}
|
||||
for (WptPt p : res.getPoints()) {
|
||||
FavouritePoint fp = FavouritePoint.fromWpt(context, p);
|
||||
FavouritePoint fp = FavouritePoint.fromWpt(p);
|
||||
if (fp != null) {
|
||||
points.put(getKey(fp), fp);
|
||||
}
|
||||
|
@ -852,7 +790,6 @@ public class FavouritesDbHelper {
|
|||
group.name = p.getCategory();
|
||||
group.visible = p.isVisible();
|
||||
group.color = p.getColor();
|
||||
group.personal = p.isPersonal();
|
||||
flatGroups.put(group.name, group);
|
||||
favoriteGroups.add(group);
|
||||
if (group.color == 0) {
|
||||
|
|
|
@ -535,7 +535,7 @@ public class MapMarkersHelper {
|
|||
}
|
||||
|
||||
private MapMarkersGroup createFavMarkerGroup(FavoriteGroup favGroup) {
|
||||
return new MapMarkersGroup(favGroup.name, favGroup.name, MapMarkersGroup.FAVORITES_TYPE);
|
||||
return new MapMarkersGroup(favGroup.getName(), favGroup.getName(), MapMarkersGroup.FAVORITES_TYPE);
|
||||
}
|
||||
|
||||
private String getMarkerGroupId(File gpx) {
|
||||
|
@ -543,7 +543,7 @@ public class MapMarkersHelper {
|
|||
}
|
||||
|
||||
private String getMarkerGroupId(FavoriteGroup group) {
|
||||
return group.name;
|
||||
return group.getName();
|
||||
}
|
||||
|
||||
@NonNull
|
||||
|
@ -914,7 +914,6 @@ public class MapMarkersHelper {
|
|||
MapMarker marker = new MapMarker(point, pointDescription, colorIndex, false, 0);
|
||||
if (group != null) {
|
||||
marker.id = group.getId() + marker.getName(ctx) + MapUtils.createShortLinkString(marker.point.getLatitude(), marker.point.getLongitude(), 15);
|
||||
// TODO ???????
|
||||
if (markersDbHelper.getMarker(marker.id) != null) {
|
||||
continue;
|
||||
}
|
||||
|
@ -1162,13 +1161,13 @@ public class MapMarkersHelper {
|
|||
if (favGroup == null) {
|
||||
return;
|
||||
}
|
||||
group.visible = favGroup.visible;
|
||||
group.visible = favGroup.isVisible();
|
||||
if (!group.isVisible() || group.isDisabled()) {
|
||||
removeGroupActiveMarkers(group, true);
|
||||
return;
|
||||
}
|
||||
|
||||
for (FavouritePoint fp : favGroup.points) {
|
||||
for (FavouritePoint fp : favGroup.getPoints()) {
|
||||
addNewMarkerIfNeeded(group, groupMarkers, new LatLon(fp.getLatitude(), fp.getLongitude()), fp.getName(), fp, null);
|
||||
}
|
||||
|
||||
|
|
|
@ -23,6 +23,7 @@ import net.osmand.IndexConstants;
|
|||
import net.osmand.StateChangedListener;
|
||||
import net.osmand.ValueHolder;
|
||||
import net.osmand.aidl.OsmandAidlApi;
|
||||
import net.osmand.data.FavouritePoint;
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.data.PointDescription;
|
||||
import net.osmand.map.ITileSource;
|
||||
|
@ -283,10 +284,10 @@ public class OsmandSettings {
|
|||
workPoint = new LatLon(lat, lon);
|
||||
}
|
||||
if (homePoint != null) {
|
||||
favorites.setHomePoint(homePoint, null);
|
||||
favorites.setSpecialPoint(homePoint, FavouritePoint.SpecialPointType.HOME, null);
|
||||
}
|
||||
if (workPoint != null) {
|
||||
favorites.setWorkPoint(workPoint, null);
|
||||
favorites.setSpecialPoint(workPoint, FavouritePoint.SpecialPointType.WORK, null);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -18,7 +18,6 @@ import android.view.ViewGroup.LayoutParams;
|
|||
import android.widget.AdapterView;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.EditText;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
@ -61,7 +60,7 @@ public class EditFavoriteGroupDialogFragment extends MenuBottomSheetDialogFragme
|
|||
if (group == null) {
|
||||
return;
|
||||
}
|
||||
items.add(new TitleItem(Algorithms.isEmpty(group.name) ? app.getString(R.string.shared_string_favorites) : group.name));
|
||||
items.add(new TitleItem(Algorithms.isEmpty(group.getName()) ? app.getString(R.string.shared_string_favorites) : group.getName()));
|
||||
|
||||
BaseBottomSheetItem editNameItem = new SimpleBottomSheetItem.Builder()
|
||||
.setIcon(getContentIcon(R.drawable.ic_action_edit_dark))
|
||||
|
@ -76,7 +75,7 @@ public class EditFavoriteGroupDialogFragment extends MenuBottomSheetDialogFragme
|
|||
b.setTitle(R.string.favorite_category_name);
|
||||
final EditText nameEditText = new EditText(activity);
|
||||
nameEditText.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
|
||||
nameEditText.setText(group.name);
|
||||
nameEditText.setText(group.getName());
|
||||
LinearLayout container = new LinearLayout(activity);
|
||||
int sidePadding = AndroidUtils.dpToPx(activity, 24f);
|
||||
int topPadding = AndroidUtils.dpToPx(activity, 4f);
|
||||
|
@ -88,10 +87,10 @@ public class EditFavoriteGroupDialogFragment extends MenuBottomSheetDialogFragme
|
|||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
String name = nameEditText.getText().toString();
|
||||
boolean nameChanged = !Algorithms.objectEquals(group.name, name);
|
||||
boolean nameChanged = !Algorithms.objectEquals(group.getName(), name);
|
||||
if (nameChanged) {
|
||||
app.getFavorites()
|
||||
.editFavouriteGroup(group, name, group.color, group.visible);
|
||||
.editFavouriteGroup(group, name, group.getColor(), group.isVisible());
|
||||
updateParentFragment();
|
||||
}
|
||||
dismiss();
|
||||
|
@ -135,9 +134,9 @@ public class EditFavoriteGroupDialogFragment extends MenuBottomSheetDialogFragme
|
|||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||
Integer color = colorAdapter.getItem(position);
|
||||
if (color != null) {
|
||||
if (color != group.color) {
|
||||
if (color != group.getColor()) {
|
||||
app.getFavorites()
|
||||
.editFavouriteGroup(group, group.name, color, group.visible);
|
||||
.editFavouriteGroup(group, group.getName(), color, group.isVisible());
|
||||
updateParentFragment();
|
||||
}
|
||||
}
|
||||
|
@ -153,16 +152,16 @@ public class EditFavoriteGroupDialogFragment extends MenuBottomSheetDialogFragme
|
|||
items.add(changeColorItem);
|
||||
|
||||
BaseBottomSheetItem showOnMapItem = new BottomSheetItemWithCompoundButton.Builder()
|
||||
.setChecked(group.visible)
|
||||
.setChecked(group.isVisible())
|
||||
.setIcon(getContentIcon(R.drawable.ic_map))
|
||||
.setTitle(getString(R.string.shared_string_show_on_map))
|
||||
.setLayoutId(R.layout.bottom_sheet_item_with_switch)
|
||||
.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
boolean visible = !group.visible;
|
||||
boolean visible = !group.isVisible();
|
||||
app.getFavorites()
|
||||
.editFavouriteGroup(group, group.name, group.color, visible);
|
||||
.editFavouriteGroup(group, group.getName(), group.getColor(), visible);
|
||||
updateParentFragment();
|
||||
dismiss();
|
||||
}
|
||||
|
@ -170,7 +169,7 @@ public class EditFavoriteGroupDialogFragment extends MenuBottomSheetDialogFragme
|
|||
.create();
|
||||
items.add(showOnMapItem);
|
||||
|
||||
if (group.points.size() > 0) {
|
||||
if (group.getPoints().size() > 0) {
|
||||
items.add(new DividerHalfItem(getContext()));
|
||||
|
||||
final MapMarkersHelper markersHelper = app.getMapMarkersHelper();
|
||||
|
@ -240,7 +239,7 @@ public class EditFavoriteGroupDialogFragment extends MenuBottomSheetDialogFragme
|
|||
}
|
||||
|
||||
private void updateColorView(ImageView colorImageView) {
|
||||
int color = group.color == 0 ? getResources().getColor(R.color.color_favorite) : group.color;
|
||||
int color = group.getColor() == 0 ? getResources().getColor(R.color.color_favorite) : group.getColor();
|
||||
if (color == 0) {
|
||||
colorImageView.setImageDrawable(getContentIcon(R.drawable.ic_action_circle));
|
||||
} else {
|
||||
|
|
|
@ -230,7 +230,7 @@ public class FavoritesListFragment extends OsmAndListFragment implements SearchA
|
|||
}
|
||||
((TextView) row.findViewById(R.id.group_name)).setText(favorite.getCategory());
|
||||
|
||||
icon.setImageDrawable(FavoriteImageDrawable.getOrCreate(activity, favorite.getColor(), false));
|
||||
icon.setImageDrawable(FavoriteImageDrawable.getOrCreate(activity, favorite.getColor(), false, favorite));
|
||||
|
||||
app.getUIUtilities().updateLocationView(cache, direction, distanceText,
|
||||
favorite.getLatitude(), favorite.getLongitude());
|
||||
|
|
|
@ -328,14 +328,14 @@ public class FavoritesSearchFragment extends DialogFragment {
|
|||
Set<?> flt = filter;
|
||||
for (FavoriteGroup key : gs) {
|
||||
if (flt == null || flt.contains(key)) {
|
||||
for (FavouritePoint p : key.points) {
|
||||
for (FavouritePoint p : key.getPoints()) {
|
||||
if (p.isVisible()) {
|
||||
points.add(p);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
ArrayList<FavouritePoint> list = new ArrayList<>();
|
||||
for (FavouritePoint p : key.points) {
|
||||
for (FavouritePoint p : key.getPoints()) {
|
||||
if (p.isVisible() && flt.contains(p)) {
|
||||
list.add(p);
|
||||
}
|
||||
|
@ -456,8 +456,8 @@ public class FavoritesSearchFragment extends DialogFragment {
|
|||
TextView title = (TextView) view.findViewById(R.id.title);
|
||||
TextView subtitle = (TextView) view.findViewById(R.id.subtitle);
|
||||
|
||||
imageView.setImageDrawable(FavoriteImageDrawable.getOrCreate(activity, point.getColor(), false));
|
||||
title.setText(point.getName());
|
||||
imageView.setImageDrawable(FavoriteImageDrawable.getOrCreate(activity, point.getColor(), false, point));
|
||||
title.setText(point.getDisplayName(app));
|
||||
|
||||
int dist = (int) (MapUtils.getDistance(point.getLatitude(), point.getLongitude(),
|
||||
location.getLatitude(), location.getLongitude()));
|
||||
|
@ -468,7 +468,7 @@ public class FavoritesSearchFragment extends DialogFragment {
|
|||
distanceText.setText(distance);
|
||||
distanceText.setTextColor(app.getResources().getColor(R.color.color_distance));
|
||||
|
||||
subtitle.setText(point.getCategory().length() == 0 ? app.getString(R.string.shared_string_favorites) : point.getCategory());
|
||||
subtitle.setText(point.getCategory().length() == 0 ? app.getString(R.string.shared_string_favorites) : point.getCategoryDisplayName(app));
|
||||
}
|
||||
}
|
||||
View divider = view.findViewById(R.id.divider);
|
||||
|
@ -517,15 +517,15 @@ public class FavoritesSearchFragment extends DialogFragment {
|
|||
String cs = constraint.toString().toLowerCase();
|
||||
for (FavoriteGroup g : helper.getFavoriteGroups()) {
|
||||
String gName;
|
||||
if (Algorithms.isEmpty(g.name)) {
|
||||
if (Algorithms.isEmpty(g.getName())) {
|
||||
gName = favorites;
|
||||
} else {
|
||||
gName = g.name.toLowerCase();
|
||||
gName = g.getName().toLowerCase();
|
||||
}
|
||||
if (g.visible && gName.contains(cs)) {
|
||||
if (g.isVisible() && gName.contains(cs)) {
|
||||
filter.add(g);
|
||||
} else {
|
||||
for (FavouritePoint fp : g.points) {
|
||||
for (FavouritePoint fp : g.getPoints()) {
|
||||
if (fp.isVisible() && fp.getName().toLowerCase().contains(cs)) {
|
||||
filter.add(fp);
|
||||
}
|
||||
|
|
|
@ -37,7 +37,6 @@ import android.widget.Toast;
|
|||
import net.osmand.AndroidUtils;
|
||||
import net.osmand.data.FavouritePoint;
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.data.PersonalFavouritePoint;
|
||||
import net.osmand.data.PointDescription;
|
||||
import net.osmand.plus.FavouritesDbHelper;
|
||||
import net.osmand.plus.FavouritesDbHelper.FavoriteGroup;
|
||||
|
@ -118,7 +117,7 @@ public class FavoritesTreeFragment extends OsmandExpandableListFragment implemen
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onFavoriteAddressResolved(@NonNull FavouritePoint favouritePoint) {
|
||||
public void onFavoriteDataUpdated(@NonNull FavouritePoint favouritePoint) {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -208,14 +207,14 @@ public class FavoritesTreeFragment extends OsmandExpandableListFragment implemen
|
|||
listView.setOnGroupCollapseListener(new ExpandableListView.OnGroupCollapseListener() {
|
||||
@Override
|
||||
public void onGroupCollapse(int groupPosition) {
|
||||
String groupName = favouritesAdapter.getGroup(groupPosition).name;
|
||||
String groupName = favouritesAdapter.getGroup(groupPosition).getName();
|
||||
getGroupExpandedPreference(groupName).set(false);
|
||||
}
|
||||
});
|
||||
listView.setOnGroupExpandListener(new ExpandableListView.OnGroupExpandListener() {
|
||||
@Override
|
||||
public void onGroupExpand(int groupPosition) {
|
||||
String groupName = favouritesAdapter.getGroup(groupPosition).name;
|
||||
String groupName = favouritesAdapter.getGroup(groupPosition).getName();
|
||||
getGroupExpandedPreference(groupName).set(true);
|
||||
}
|
||||
});
|
||||
|
@ -231,7 +230,7 @@ public class FavoritesTreeFragment extends OsmandExpandableListFragment implemen
|
|||
int selection = listView.getHeaderViewsCount();
|
||||
for (int i = 0; i < groupPos; i++) {
|
||||
selection++; // because of group header
|
||||
if (getGroupExpandedPreference(favouritesAdapter.getGroup(i).name).get()) {
|
||||
if (getGroupExpandedPreference(favouritesAdapter.getGroup(i).getName()).get()) {
|
||||
selection += favouritesAdapter.getChildrenCount(i);
|
||||
}
|
||||
}
|
||||
|
@ -313,16 +312,16 @@ public class FavoritesTreeFragment extends OsmandExpandableListFragment implemen
|
|||
FavoriteGroup group = favouritesAdapter.getGroup(groupPosition);
|
||||
ch.setChecked(!ch.isChecked());
|
||||
if (ch.isChecked()) {
|
||||
Set<FavouritePoint> set = favoritesSelected.get(group.name);
|
||||
Set<FavouritePoint> set = favoritesSelected.get(group.getName());
|
||||
if (set != null) {
|
||||
set.add(model);
|
||||
} else {
|
||||
set = new LinkedHashSet<>();
|
||||
set.add(model);
|
||||
favoritesSelected.put(group.name, set);
|
||||
favoritesSelected.put(group.getName(), set);
|
||||
}
|
||||
} else {
|
||||
Set<FavouritePoint> set = favoritesSelected.get(group.name);
|
||||
Set<FavouritePoint> set = favoritesSelected.get(group.getName());
|
||||
if (set != null) {
|
||||
set.remove(model);
|
||||
}
|
||||
|
@ -450,7 +449,7 @@ public class FavoritesTreeFragment extends OsmandExpandableListFragment implemen
|
|||
List<PointDescription> names = new ArrayList<>();
|
||||
for (Map.Entry<String, Set<FavouritePoint>> entry : favoritesSelected.entrySet()) {
|
||||
FavoriteGroup favGr = helper.getGroup(entry.getKey());
|
||||
if (entry.getValue().size() == favGr.points.size()) {
|
||||
if (entry.getValue().size() == favGr.getPoints().size()) {
|
||||
markersHelper.addOrEnableGroup(favGr);
|
||||
} else {
|
||||
for (FavouritePoint fp : entry.getValue()) {
|
||||
|
@ -538,8 +537,8 @@ public class FavoritesTreeFragment extends OsmandExpandableListFragment implemen
|
|||
StringBuilder html = new StringBuilder();
|
||||
html.append("<h1>My Favorites</h1>");
|
||||
for (FavoriteGroup group : groups) {
|
||||
html.append("<h3>" + group.name + "</h3>");
|
||||
for (FavouritePoint fp : group.points) {
|
||||
html.append("<h3>" + group.getName() + "</h3>");
|
||||
for (FavouritePoint fp : group.getPoints()) {
|
||||
String url = "geo:" + ((float) fp.getLatitude()) + "," + ((float) fp.getLongitude()) + "?m=" + fp.getName();
|
||||
html.append("<p>" + fp.getName() + " - " + "<a href=\"" + url + "\">geo:"
|
||||
+ ((float) fp.getLatitude()) + "," + ((float) fp.getLongitude()) + "</a><br>");
|
||||
|
@ -588,7 +587,7 @@ public class FavoritesTreeFragment extends OsmandExpandableListFragment implemen
|
|||
@Override
|
||||
protected Void doInBackground(Void... params) {
|
||||
if (group != null) {
|
||||
helper.saveFile(group.points, dst);
|
||||
helper.saveFile(group.getPoints(), dst);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -680,7 +679,7 @@ public class FavoritesTreeFragment extends OsmandExpandableListFragment implemen
|
|||
|
||||
private void initListExpandedState() {
|
||||
for (int i = 0; i < favouritesAdapter.getGroupCount(); i++) {
|
||||
String groupName = favouritesAdapter.getGroup(i).name;
|
||||
String groupName = favouritesAdapter.getGroup(i).getName();
|
||||
if (getGroupExpandedPreference(groupName).get()) {
|
||||
listView.expandGroup(i);
|
||||
} else {
|
||||
|
@ -705,8 +704,9 @@ public class FavoritesTreeFragment extends OsmandExpandableListFragment implemen
|
|||
selectedGroupPos = groupPos;
|
||||
selectedChildPos = childPos;
|
||||
LatLon location = new LatLon(point.getLatitude(), point.getLongitude());
|
||||
String pointType = PointDescription.POINT_TYPE_FAVORITE;
|
||||
FavoritesActivity.showOnMap(requireActivity(), this, location.getLatitude(), location.getLongitude(),
|
||||
settings.getLastKnownMapZoom(), new PointDescription(PointDescription.POINT_TYPE_FAVORITE, point.getName()), true, point);
|
||||
settings.getLastKnownMapZoom(), new PointDescription(pointType, point.getDisplayName(app)), true, point);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -753,10 +753,10 @@ public class FavoritesTreeFragment extends OsmandExpandableListFragment implemen
|
|||
boolean empty = true;
|
||||
if (flt == null || flt.contains(key)) {
|
||||
empty = false;
|
||||
favoriteGroups.put(key, new ArrayList<>(key.points));
|
||||
favoriteGroups.put(key, new ArrayList<>(key.getPoints()));
|
||||
} else {
|
||||
ArrayList<FavouritePoint> list = new ArrayList<>();
|
||||
for (FavouritePoint p : key.points) {
|
||||
for (FavouritePoint p : key.getPoints()) {
|
||||
if (flt.contains(p)) {
|
||||
list.add(p);
|
||||
empty = false;
|
||||
|
@ -765,7 +765,7 @@ public class FavoritesTreeFragment extends OsmandExpandableListFragment implemen
|
|||
favoriteGroups.put(key, list);
|
||||
}
|
||||
if (!empty) {
|
||||
if (key.visible) {
|
||||
if (key.isVisible()) {
|
||||
groups.add(key);
|
||||
} else {
|
||||
disablesGroups.add(key);
|
||||
|
@ -829,12 +829,12 @@ public class FavoritesTreeFragment extends OsmandExpandableListFragment implemen
|
|||
OsmandApplication app = getMyApplication();
|
||||
boolean light = app.getSettings().isLightContent();
|
||||
final FavoriteGroup model = getGroup(groupPosition);
|
||||
boolean visible = model.visible;
|
||||
boolean visible = model.isVisible();
|
||||
int enabledColor = light ? R.color.text_color_primary_light : R.color.text_color_primary_dark;
|
||||
int disabledColor = light ? R.color.text_color_secondary_light : R.color.text_color_secondary_dark;
|
||||
row.findViewById(R.id.group_divider).setVisibility(groupPosition == 0 ? View.GONE : View.VISIBLE);
|
||||
int color = model.color == 0 || model.color == Color.BLACK ? getResources().getColor(R.color.color_favorite) : model.color;
|
||||
if (!model.personal) {
|
||||
int color = model.getColor() == 0 || model.getColor() == Color.BLACK ? getResources().getColor(R.color.color_favorite) : model.getColor();
|
||||
if (!model.isPersonal()) {
|
||||
setCategoryIcon(app, app.getUIUtilities().getPaintedIcon(
|
||||
R.drawable.ic_action_fav_dark, visible ? (color | 0xff000000) : getResources().getColor(disabledColor)),
|
||||
groupPosition, isExpanded, row, light);
|
||||
|
@ -848,7 +848,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.name);
|
||||
label.setText(model.getName().length() == 0 ? getString(R.string.shared_string_favorites) : model.getDisplayName(app));
|
||||
|
||||
if (selectionMode) {
|
||||
final CheckBox ch = (CheckBox) row.findViewById(R.id.toggle_item);
|
||||
|
@ -858,21 +858,21 @@ public class FavoritesTreeFragment extends OsmandExpandableListFragment implemen
|
|||
ch.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
List<FavouritePoint> fvs = model.points;
|
||||
List<FavouritePoint> fvs = model.getPoints();
|
||||
if (ch.isChecked()) {
|
||||
groupsToDelete.add(model);
|
||||
if (fvs != null) {
|
||||
Set<FavouritePoint> set = favoritesSelected.get(model.name);
|
||||
Set<FavouritePoint> set = favoritesSelected.get(model.getName());
|
||||
if (set != null) {
|
||||
set.addAll(model.points);
|
||||
set.addAll(model.getPoints());
|
||||
} else {
|
||||
set = new LinkedHashSet<>(model.points);
|
||||
favoritesSelected.put(model.name, set);
|
||||
set = new LinkedHashSet<>(model.getPoints());
|
||||
favoritesSelected.put(model.getName(), set);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
groupsToDelete.remove(model);
|
||||
favoritesSelected.remove(model.name);
|
||||
favoritesSelected.remove(model.getName());
|
||||
}
|
||||
favouritesAdapter.notifyDataSetInvalidated();
|
||||
updateSelectionMode(actionMode);
|
||||
|
@ -886,14 +886,14 @@ public class FavoritesTreeFragment extends OsmandExpandableListFragment implemen
|
|||
}
|
||||
final View ch = row.findViewById(R.id.options);
|
||||
if (!selectionMode) {
|
||||
if (!model.personal) {
|
||||
if (!model.isPersonal()) {
|
||||
((ImageView) ch).setImageDrawable(getMyApplication().getUIUtilities().getThemedIcon(R.drawable.ic_overflow_menu_white));
|
||||
ch.setVisibility(View.VISIBLE);
|
||||
ch.setContentDescription(getString(R.string.shared_string_settings));
|
||||
ch.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
EditFavoriteGroupDialogFragment.showInstance(getChildFragmentManager(), model.name);
|
||||
EditFavoriteGroupDialogFragment.showInstance(getChildFragmentManager(), model.getName());
|
||||
}
|
||||
|
||||
});
|
||||
|
@ -946,21 +946,15 @@ public class FavoritesTreeFragment extends OsmandExpandableListFragment implemen
|
|||
int dist = (int) (MapUtils.getDistance(model.getLatitude(), model.getLongitude(),
|
||||
lastKnownMapLocation.getLatitude(), lastKnownMapLocation.getLongitude()));
|
||||
String distance = OsmAndFormatter.getFormattedDistance(dist, getMyApplication()) + " ";
|
||||
name.setText(model.getName(), TextView.BufferType.SPANNABLE);
|
||||
name.setText(model.getDisplayName(app), TextView.BufferType.SPANNABLE);
|
||||
name.setTypeface(Typeface.DEFAULT, visible ? Typeface.NORMAL : Typeface.ITALIC);
|
||||
name.setTextColor(getResources().getColor(visible ? enabledColor : disabledColor));
|
||||
distanceText.setText(distance);
|
||||
if (model instanceof PersonalFavouritePoint) {
|
||||
String distanceWithAddress = String.format(getString(R.string.distance_and_address), distance.trim(), model.getDescription() != null ? model.getDescription() : "");
|
||||
distanceText.setText(distanceWithAddress);
|
||||
icon.setImageDrawable(FavoriteImageDrawable.getOrCreate(getActivity(),
|
||||
visible ? model.getColor() : getResources().getColor(disabledIconColor), false,
|
||||
((PersonalFavouritePoint) model).getType()));
|
||||
name.setText((model.getName()));
|
||||
} else {
|
||||
icon.setImageDrawable(FavoriteImageDrawable.getOrCreate(getActivity(),
|
||||
visible ? model.getColor() : getResources().getColor(disabledIconColor), false));
|
||||
if (model.isAddressSpecified()) {
|
||||
distanceText.setText(String.format(getString(R.string.distance_and_address), distance.trim(), model.getAddress()));
|
||||
}
|
||||
icon.setImageDrawable(FavoriteImageDrawable.getOrCreate(getActivity(),
|
||||
visible ? model.getColor() : getResources().getColor(disabledIconColor), false, model));
|
||||
if (visible) {
|
||||
distanceText.setTextColor(getResources().getColor(R.color.color_distance));
|
||||
} else {
|
||||
|
@ -979,26 +973,26 @@ public class FavoritesTreeFragment extends OsmandExpandableListFragment implemen
|
|||
final CheckBox ch = (CheckBox) row.findViewById(R.id.toggle_item);
|
||||
if (selectionMode) {
|
||||
ch.setVisibility(View.VISIBLE);
|
||||
ch.setChecked(favoritesSelected.get(group.name) != null && favoritesSelected.get(group.name).contains(model));
|
||||
ch.setChecked(favoritesSelected.get(group.getName()) != null && favoritesSelected.get(group.getName()).contains(model));
|
||||
row.findViewById(R.id.favourite_icon).setVisibility(View.GONE);
|
||||
ch.setOnClickListener(new View.OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (ch.isChecked()) {
|
||||
Set<FavouritePoint> set = favoritesSelected.get(group.name);
|
||||
Set<FavouritePoint> set = favoritesSelected.get(group.getName());
|
||||
if (set != null) {
|
||||
set.add(model);
|
||||
} else {
|
||||
set = new LinkedHashSet<>();
|
||||
set.add(model);
|
||||
favoritesSelected.put(group.name, set);
|
||||
favoritesSelected.put(group.getName(), set);
|
||||
}
|
||||
} else {
|
||||
Set<FavouritePoint> set = favoritesSelected.get(group.name);
|
||||
Set<FavouritePoint> set = favoritesSelected.get(group.getName());
|
||||
if (set != null) {
|
||||
groupsToDelete.remove(group);
|
||||
getGroupPosition(group.name);
|
||||
getGroupPosition(group.getName());
|
||||
set.remove(model);
|
||||
favouritesAdapter.notifyDataSetInvalidated();
|
||||
}
|
||||
|
@ -1028,7 +1022,7 @@ public class FavoritesTreeFragment extends OsmandExpandableListFragment implemen
|
|||
public int getGroupPosition(String groupName) {
|
||||
for (int i = 0; i < getGroupCount(); i++) {
|
||||
FavoriteGroup group = getGroup(i);
|
||||
if (group.name.equals(groupName)) {
|
||||
if (group.getName().equals(groupName)) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
@ -1052,10 +1046,10 @@ public class FavoritesTreeFragment extends OsmandExpandableListFragment implemen
|
|||
Set<Object> filter = new HashSet<>();
|
||||
String cs = constraint.toString().toLowerCase();
|
||||
for (FavoriteGroup g : helper.getFavoriteGroups()) {
|
||||
if (g.name.toLowerCase().contains(cs)) {
|
||||
if (g.getName().toLowerCase().contains(cs)) {
|
||||
filter.add(g);
|
||||
} else {
|
||||
for (FavouritePoint fp : g.points) {
|
||||
for (FavouritePoint fp : g.getPoints()) {
|
||||
if (fp.getName().toLowerCase().contains(cs)) {
|
||||
filter.add(fp);
|
||||
}
|
||||
|
|
|
@ -426,7 +426,6 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
|
|||
if (dashboardOnMap != null) {
|
||||
dashboardOnMap.updateLocation(true, true, false);
|
||||
}
|
||||
app.getFavorites().lookupAddressAllPersonalPoints();
|
||||
app.getTargetPointsHelper().lookupAddessAll();
|
||||
app.getMapMarkersHelper().lookupAddressAll();
|
||||
}
|
||||
|
|
|
@ -9,7 +9,6 @@ import android.graphics.Color;
|
|||
import android.graphics.ColorFilter;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.Paint.Style;
|
||||
import android.graphics.PixelFormat;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.graphics.PorterDuffColorFilter;
|
||||
import android.graphics.Rect;
|
||||
|
@ -18,7 +17,8 @@ import android.support.annotation.NonNull;
|
|||
import android.support.v4.content.ContextCompat;
|
||||
import android.support.v4.content.res.ResourcesCompat;
|
||||
|
||||
import net.osmand.data.PersonalFavouritePoint.PointType;
|
||||
import net.osmand.GPXUtilities;
|
||||
import net.osmand.data.FavouritePoint;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.UiUtilities;
|
||||
|
||||
|
@ -44,12 +44,13 @@ public class FavoriteImageDrawable extends Drawable {
|
|||
private ColorFilter grayFilter;
|
||||
private Drawable personalPointBitmap;
|
||||
|
||||
public FavoriteImageDrawable(Context ctx, int color, boolean withShadow, boolean synced, PointType pointType) {
|
||||
private FavoriteImageDrawable(Context ctx, int color, boolean withShadow, boolean synced, FavouritePoint point) {
|
||||
this.withShadow = withShadow;
|
||||
this.synced = synced;
|
||||
Resources res = ctx.getResources();
|
||||
if (pointType != null) {
|
||||
personalPointBitmap = UiUtilities.tintDrawable(ResourcesCompat.getDrawable(res, pointType.getIconId(), null),
|
||||
int overlayIconId = point != null ? point.getOverlayIconId() : 0;
|
||||
if (overlayIconId != 0) {
|
||||
personalPointBitmap = UiUtilities.tintDrawable(ResourcesCompat.getDrawable(res, overlayIconId, null),
|
||||
ContextCompat.getColor(ctx, R.color.icon_color_default_light));
|
||||
}
|
||||
int col = color == 0 || color == Color.BLACK ? res.getColor(R.color.color_favorite) : color;
|
||||
|
@ -144,32 +145,38 @@ public class FavoriteImageDrawable extends Drawable {
|
|||
paintIcon.setColorFilter(cf);
|
||||
}
|
||||
|
||||
private static TreeMap<Integer, FavoriteImageDrawable> cache = new TreeMap<>();
|
||||
private static TreeMap<String, FavoriteImageDrawable> cache = new TreeMap<>();
|
||||
|
||||
public static FavoriteImageDrawable getOrCreate(Context a, int color, boolean withShadow, boolean synced, PointType pointType) {
|
||||
int pointTypeId = 0;
|
||||
if (pointType != null)
|
||||
pointTypeId = pointType.ordinal();
|
||||
private static FavoriteImageDrawable getOrCreate(Context a, int color, boolean withShadow, boolean synced, FavouritePoint point) {
|
||||
String pointName = "";
|
||||
if (point != null && point.isSpecialPoint()) {
|
||||
pointName = point.getName();
|
||||
}
|
||||
color = color | 0xff000000;
|
||||
int hash = (color << 4) + ((withShadow ? 1 : 0) << 2) + ((synced ? 3 : 0) << 2) + pointTypeId;
|
||||
FavoriteImageDrawable drawable = cache.get(hash);
|
||||
int hash = (color << 4) + ((withShadow ? 1 : 0) << 2) + ((synced ? 3 : 0) << 2);
|
||||
String uniqueId = hash + pointName;
|
||||
FavoriteImageDrawable drawable = cache.get(uniqueId);
|
||||
if (drawable == null) {
|
||||
drawable = new FavoriteImageDrawable(a, color, withShadow, synced, pointType);
|
||||
drawable = new FavoriteImageDrawable(a, color, withShadow, synced, point);
|
||||
drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight());
|
||||
cache.put(hash, drawable);
|
||||
cache.put(uniqueId, drawable);
|
||||
}
|
||||
return drawable;
|
||||
}
|
||||
|
||||
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, FavouritePoint point) {
|
||||
return getOrCreate(a, color, withShadow, false, point);
|
||||
}
|
||||
|
||||
public static FavoriteImageDrawable getOrCreate(Context a, int color, boolean withShadow) {
|
||||
public static FavoriteImageDrawable getOrCreate(Context a, int color, boolean withShadow, GPXUtilities.WptPt pt) {
|
||||
return getOrCreate(a, color, withShadow, false, null);
|
||||
}
|
||||
|
||||
public static FavoriteImageDrawable getOrCreateSyncedIcon(Context a, int color) {
|
||||
public static FavoriteImageDrawable getOrCreateSyncedIcon(Context a, int color, FavouritePoint point) {
|
||||
return getOrCreate(a, color, false, true, point);
|
||||
}
|
||||
|
||||
public static FavoriteImageDrawable getOrCreateSyncedIcon(Context a, int color, GPXUtilities.WptPt pt) {
|
||||
return getOrCreate(a, color, false, true, null);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -77,7 +77,7 @@ public class DashFavoritesFragment extends DashLocationFragment {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onFavoriteAddressResolved(@NonNull FavouritePoint favouritePoint) {
|
||||
public void onFavoriteDataUpdated(@NonNull FavouritePoint favouritePoint) {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -131,19 +131,19 @@ public class DashFavoritesFragment extends DashLocationFragment {
|
|||
view.findViewById(R.id.divider).setVisibility(View.VISIBLE);
|
||||
ImageView groupImage = (ImageView)view.findViewById(R.id.group_image);
|
||||
if (point.getCategory().length() > 0) {
|
||||
((TextView) view.findViewById(R.id.group_name)).setText(point.getCategory());
|
||||
((TextView) view.findViewById(R.id.group_name)).setText(point.getCategoryDisplayName(getMyApplication()));
|
||||
groupImage.setImageDrawable(getMyApplication().getUIUtilities().getThemedIcon(R.drawable.ic_small_group));
|
||||
} else {
|
||||
groupImage.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
((ImageView) view.findViewById(R.id.favourite_icon)).setImageDrawable(FavoriteImageDrawable.getOrCreate(
|
||||
getActivity(), point.getColor(), false));
|
||||
getActivity(), point.getColor(), false, point));
|
||||
DashLocationView dv = new DashLocationView(direction, label, new LatLon(point.getLatitude(),
|
||||
point.getLongitude()));
|
||||
distances.add(dv);
|
||||
|
||||
name.setText(point.getName());
|
||||
name.setText(point.getDisplayName(getMyApplication()));
|
||||
name.setTypeface(Typeface.DEFAULT, point.isVisible() ? Typeface.NORMAL : Typeface.ITALIC);
|
||||
view.findViewById(R.id.navigate_to).setVisibility(View.VISIBLE);
|
||||
|
||||
|
@ -153,7 +153,7 @@ public class DashFavoritesFragment extends DashLocationFragment {
|
|||
public void onClick(View view) {
|
||||
DirectionsDialogs.directionsToDialogAndLaunchMap(getActivity(), point.getLatitude(),
|
||||
point.getLongitude(),
|
||||
new PointDescription(PointDescription.POINT_TYPE_FAVORITE, point.getName()));
|
||||
new PointDescription(PointDescription.POINT_TYPE_FAVORITE, point.getDisplayName(getMyApplication())));
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -161,7 +161,7 @@ public class DashFavoritesFragment extends DashLocationFragment {
|
|||
@Override
|
||||
public void onClick(View view) {
|
||||
getMyApplication().getSettings().setMapLocationToShow(point.getLatitude(), point.getLongitude(),
|
||||
15, new PointDescription(PointDescription.POINT_TYPE_FAVORITE, point.getName()), true,
|
||||
15, new PointDescription(PointDescription.POINT_TYPE_FAVORITE, point.getDisplayName(getMyApplication())), true,
|
||||
point); //$NON-NLS-1$
|
||||
MapActivity.launchMapActivityMoveToTop(getActivity());
|
||||
}
|
||||
|
|
|
@ -82,7 +82,7 @@ public class FavoriteDialogs {
|
|||
if (helper.editFavourite(fp, point.getLatitude(), point.getLongitude())) {
|
||||
if (activity instanceof MapActivity) {
|
||||
((MapActivity) activity).getContextMenu()
|
||||
.show(new LatLon(point.getLatitude(), point.getLongitude()), fp.getPointDescription(), fp);
|
||||
.show(new LatLon(point.getLatitude(), point.getLongitude()), fp.getPointDescription(activity), fp);
|
||||
}
|
||||
}
|
||||
if (activity instanceof MapActivity) {
|
||||
|
@ -123,7 +123,7 @@ public class FavoriteDialogs {
|
|||
List<FavoriteGroup> gs = helper.getFavoriteGroups();
|
||||
final String[] list = new String[gs.size()];
|
||||
for (int i = 0; i < list.length; i++) {
|
||||
list[i] = gs.get(i).name;
|
||||
list[i] = gs.get(i).getName();
|
||||
}
|
||||
cat.setAdapter(new ArrayAdapter<String>(activity, R.layout.list_textview, list));
|
||||
|
||||
|
|
|
@ -3,12 +3,14 @@ package net.osmand.plus.helpers;
|
|||
import android.content.Context;
|
||||
import android.graphics.drawable.Drawable;
|
||||
|
||||
import net.osmand.GPXUtilities;
|
||||
import net.osmand.Location;
|
||||
import net.osmand.binary.BinaryMapRouteReaderAdapter.RouteRegion;
|
||||
import net.osmand.binary.BinaryMapRouteReaderAdapter.RouteTypeRule;
|
||||
import net.osmand.binary.RouteDataObject;
|
||||
import net.osmand.data.Amenity;
|
||||
import net.osmand.data.Amenity.AmenityRoutePoint;
|
||||
import net.osmand.data.FavouritePoint;
|
||||
import net.osmand.data.LocationPoint;
|
||||
import net.osmand.data.PointDescription;
|
||||
import net.osmand.osm.PoiType;
|
||||
|
@ -769,9 +771,10 @@ public class WaypointHelper {
|
|||
return iconsCache.getIcon(R.drawable.list_destination, 0);
|
||||
}
|
||||
|
||||
} else if (type == FAVORITES || type == WAYPOINTS) {
|
||||
return FavoriteImageDrawable.getOrCreate(uiCtx, point.getColor(), false);
|
||||
|
||||
} else if (type == FAVORITES ) {
|
||||
return FavoriteImageDrawable.getOrCreate(uiCtx, point.getColor(), false, (FavouritePoint) point);
|
||||
} else if (type == WAYPOINTS) {
|
||||
return FavoriteImageDrawable.getOrCreate(uiCtx, point.getColor(), false, (GPXUtilities.WptPt) point);
|
||||
} else if (type == ALARMS) {
|
||||
//assign alarm list icons manually for now
|
||||
String typeString = ((AlarmInfo) point).getType().toString();
|
||||
|
|
|
@ -184,7 +184,11 @@ public abstract class MenuController extends BaseMenuController implements Colla
|
|||
if (object instanceof Amenity) {
|
||||
menuController = new AmenityMenuController(mapActivity, pointDescription, (Amenity) object);
|
||||
} else if (object instanceof FavouritePoint) {
|
||||
menuController = new FavouritePointMenuController(mapActivity, pointDescription, (FavouritePoint) object);
|
||||
if (pointDescription.isParking()) {
|
||||
menuController = new ParkingPositionMenuController(mapActivity, pointDescription);
|
||||
} else {
|
||||
menuController = new FavouritePointMenuController(mapActivity, pointDescription, (FavouritePoint) object);
|
||||
}
|
||||
} else if (object instanceof SearchHistoryHelper.HistoryEntry) {
|
||||
menuController = new HistoryMenuController(mapActivity, pointDescription, (SearchHistoryHelper.HistoryEntry) object);
|
||||
} else if (object instanceof TargetPoint) {
|
||||
|
|
|
@ -90,11 +90,11 @@ public class FavouritePointMenuBuilder extends MenuBuilder {
|
|||
|
||||
private void buildGroupFavouritesView(View view) {
|
||||
FavoriteGroup favoriteGroup = app.getFavorites().getGroup(fav);
|
||||
List<FavouritePoint> groupFavourites = favoriteGroup.points;
|
||||
List<FavouritePoint> groupFavourites = favoriteGroup.getPoints();
|
||||
if (groupFavourites.size() > 0) {
|
||||
int color = favoriteGroup.color == 0 || favoriteGroup.color == Color.BLACK ? view.getResources().getColor(R.color.color_favorite) : favoriteGroup.color;
|
||||
int color = favoriteGroup.getColor() == 0 || favoriteGroup.getColor() == Color.BLACK ? view.getResources().getColor(R.color.color_favorite) : favoriteGroup.getColor();
|
||||
int disabledColor = light ? R.color.text_color_secondary_light : R.color.text_color_secondary_dark;
|
||||
color = favoriteGroup.visible ? (color | 0xff000000) : view.getResources().getColor(disabledColor);
|
||||
color = favoriteGroup.isVisible() ? (color | 0xff000000) : view.getResources().getColor(disabledColor);
|
||||
String name = view.getContext().getString(R.string.context_menu_points_of_group);
|
||||
buildRow(view, app.getUIUtilities().getPaintedIcon(R.drawable.ic_action_folder, color), null, name, 0, null,
|
||||
true, getCollapsableFavouritesView(view.getContext(), true, favoriteGroup, fav),
|
||||
|
@ -160,12 +160,12 @@ public class FavouritePointMenuBuilder extends MenuBuilder {
|
|||
private CollapsableView getCollapsableFavouritesView(final Context context, boolean collapsed, @NonNull final FavoriteGroup group, FavouritePoint selectedPoint) {
|
||||
LinearLayout view = (LinearLayout) buildCollapsableContentView(context, collapsed, true);
|
||||
|
||||
List<FavouritePoint> points = group.points;
|
||||
List<FavouritePoint> points = group.getPoints();
|
||||
for (int i = 0; i < points.size() && i < 10; i++) {
|
||||
final FavouritePoint point = points.get(i);
|
||||
boolean selected = selectedPoint != null && selectedPoint.equals(point);
|
||||
TextViewEx button = buildButtonInCollapsableView(context, selected, false);
|
||||
String name = point.getName();
|
||||
String name = point.getDisplayName(context);
|
||||
button.setText(name);
|
||||
|
||||
if (!selected) {
|
||||
|
@ -173,7 +173,7 @@ public class FavouritePointMenuBuilder extends MenuBuilder {
|
|||
@Override
|
||||
public void onClick(View v) {
|
||||
LatLon latLon = new LatLon(point.getLatitude(), point.getLongitude());
|
||||
PointDescription pointDescription = new PointDescription(PointDescription.POINT_TYPE_FAVORITE, point.getName());
|
||||
PointDescription pointDescription = new PointDescription(PointDescription.POINT_TYPE_FAVORITE, point.getDisplayName(context));
|
||||
mapActivity.getContextMenu().show(latLon, pointDescription, point);
|
||||
}
|
||||
});
|
||||
|
@ -187,7 +187,7 @@ public class FavouritePointMenuBuilder extends MenuBuilder {
|
|||
button.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
FavoritesActivity.openFavoritesGroup(context, group.name);
|
||||
FavoritesActivity.openFavoritesGroup(context, group.getName());
|
||||
}
|
||||
});
|
||||
view.addView(button);
|
||||
|
|
|
@ -117,7 +117,8 @@ public class FavouritePointMenuController extends MenuController {
|
|||
public Drawable getRightIcon() {
|
||||
MapActivity mapActivity = getMapActivity();
|
||||
if (mapActivity != null) {
|
||||
return FavoriteImageDrawable.getOrCreate(mapActivity.getMyApplication(), fav.getColor(), false);
|
||||
return FavoriteImageDrawable.getOrCreate(mapActivity.getMyApplication(), fav.getColor(),
|
||||
false, fav);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
@ -128,6 +129,17 @@ public class FavouritePointMenuController extends MenuController {
|
|||
return mapMarker == null;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public String getNameStr() {
|
||||
MapActivity mapActivity = getMapActivity();
|
||||
if (mapActivity != null) {
|
||||
return fav.getDisplayName(mapActivity);
|
||||
} else {
|
||||
return super.getNameStr();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Drawable getSecondLineTypeIcon() {
|
||||
return getIcon(R.drawable.ic_action_group_name_16, isLight() ? R.color.icon_color_default_light : R.color.ctx_menu_bottom_view_icon_dark);
|
||||
|
@ -145,7 +157,7 @@ public class FavouritePointMenuController extends MenuController {
|
|||
|
||||
@Override
|
||||
public boolean isFavButtonEnabled() {
|
||||
return !fav.isPersonal();
|
||||
return !fav.isSpecialPoint();
|
||||
}
|
||||
|
||||
@NonNull
|
||||
|
@ -154,7 +166,7 @@ public class FavouritePointMenuController extends MenuController {
|
|||
MapActivity mapActivity = getMapActivity();
|
||||
if (mapActivity != null) {
|
||||
return fav.getCategory().length() == 0 ?
|
||||
mapActivity.getString(R.string.shared_string_favorites) : fav.getCategory();
|
||||
mapActivity.getString(R.string.shared_string_favorites) : fav.getCategoryDisplayName(mapActivity);
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
|
|
|
@ -82,7 +82,7 @@ public class WptPtMenuController extends MenuController {
|
|||
MapActivity mapActivity = getMapActivity();
|
||||
if (mapActivity != null) {
|
||||
return FavoriteImageDrawable.getOrCreate(mapActivity.getMyApplication(),
|
||||
wpt.getColor(ContextCompat.getColor(mapActivity, R.color.gpx_color_point)), false);
|
||||
wpt.getColor(ContextCompat.getColor(mapActivity, R.color.gpx_color_point)), false, wpt);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -186,8 +186,8 @@ public class EditCategoryDialogFragment extends DialogFragment {
|
|||
Bundle bundle = new Bundle();
|
||||
bundle.putString(KEY_CTX_EDIT_CAT_EDITOR_TAG, editorTag);
|
||||
bundle.putString(KEY_CTX_EDIT_CAT_NEW, Boolean.valueOf(false).toString());
|
||||
bundle.putString(KEY_CTX_EDIT_CAT_NAME, group.name);
|
||||
bundle.putString(KEY_CTX_EDIT_CAT_COLOR, "" + group.color);
|
||||
bundle.putString(KEY_CTX_EDIT_CAT_NAME, group.getName());
|
||||
bundle.putString(KEY_CTX_EDIT_CAT_COLOR, "" + group.getColor());
|
||||
fragment.setArguments(bundle);
|
||||
return fragment;
|
||||
}
|
||||
|
|
|
@ -25,6 +25,7 @@ import net.osmand.plus.dialogs.FavoriteDialogs;
|
|||
import net.osmand.plus.mapcontextmenu.MapContextMenu;
|
||||
import net.osmand.util.Algorithms;
|
||||
|
||||
|
||||
public class FavoritePointEditorFragment extends PointEditorFragment {
|
||||
|
||||
@Nullable
|
||||
|
@ -146,9 +147,9 @@ public class FavoritePointEditorFragment extends PointEditorFragment {
|
|||
public void setCategory(String name, int color) {
|
||||
FavouritesDbHelper helper = getHelper();
|
||||
if (helper != null) {
|
||||
FavoriteGroup group = helper.getGroup(name);
|
||||
FavoriteGroup group = helper.getGroup(FavouritesDbHelper.FavoriteGroup.convertDisplayNameToGroupIdName(requireContext(), name));
|
||||
this.group = group;
|
||||
super.setCategory(name, group.color);
|
||||
super.setCategory(name, group.getColor());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -248,7 +249,7 @@ public class FavoritePointEditorFragment extends PointEditorFragment {
|
|||
MapContextMenu menu = mapActivity.getContextMenu();
|
||||
LatLon latLon = new LatLon(favorite.getLatitude(), favorite.getLongitude());
|
||||
if (menu.getLatLon() != null && menu.getLatLon().equals(latLon)) {
|
||||
menu.update(latLon, favorite.getPointDescription(), favorite);
|
||||
menu.update(latLon, favorite.getPointDescription(mapActivity), favorite);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -309,7 +310,7 @@ public class FavoritePointEditorFragment extends PointEditorFragment {
|
|||
@Override
|
||||
public String getCategoryInitValue() {
|
||||
FavouritePoint favorite = getFavorite();
|
||||
return favorite == null || favorite.getCategory().length() == 0 ? getDefaultCategoryName() : favorite.getCategory();
|
||||
return favorite == null || favorite.getCategory().length() == 0 ? getDefaultCategoryName() : favorite.getCategoryDisplayName(requireContext());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -320,7 +321,7 @@ public class FavoritePointEditorFragment extends PointEditorFragment {
|
|||
|
||||
@Override
|
||||
public Drawable getNameIcon() {
|
||||
return FavoriteImageDrawable.getOrCreate(getMapActivity(), getPointColor(), false);
|
||||
return FavoriteImageDrawable.getOrCreate(getMapActivity(), getPointColor(), false, getFavorite());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -333,7 +334,7 @@ public class FavoritePointEditorFragment extends PointEditorFragment {
|
|||
int color = 0;
|
||||
FavoriteGroup group = getGroup();
|
||||
if (group != null) {
|
||||
color = group.color;
|
||||
color = group.getColor();
|
||||
}
|
||||
if (color == 0) {
|
||||
color = defaultColor;
|
||||
|
|
|
@ -33,6 +33,9 @@ import net.osmand.plus.base.BaseOsmAndFragment;
|
|||
import net.osmand.plus.widgets.AutoCompleteTextViewEx;
|
||||
import net.osmand.util.Algorithms;
|
||||
|
||||
import static net.osmand.plus.FavouritesDbHelper.FavoriteGroup.PERSONAL_CATEGORY;
|
||||
import static net.osmand.plus.FavouritesDbHelper.FavoriteGroup.isPersonalCategoryDisplayName;
|
||||
|
||||
public abstract class PointEditorFragment extends BaseOsmAndFragment {
|
||||
|
||||
private View view;
|
||||
|
@ -354,7 +357,13 @@ public abstract class PointEditorFragment extends BaseOsmAndFragment {
|
|||
public String getCategoryTextValue() {
|
||||
AutoCompleteTextViewEx categoryEdit = (AutoCompleteTextViewEx) view.findViewById(R.id.category_edit);
|
||||
String name = categoryEdit.getText().toString().trim();
|
||||
return name.equals(getDefaultCategoryName()) ? "" : name;
|
||||
if (isPersonalCategoryDisplayName(requireContext(), name)) {
|
||||
return PERSONAL_CATEGORY;
|
||||
}
|
||||
if(name.equals(getDefaultCategoryName())) {
|
||||
return "";
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
||||
public String getDescriptionTextValue() {
|
||||
|
|
|
@ -26,6 +26,8 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import static net.osmand.plus.FavouritesDbHelper.FavoriteGroup.PERSONAL_CATEGORY;
|
||||
|
||||
public class SelectCategoryDialogFragment extends DialogFragment {
|
||||
|
||||
public static final String TAG = SelectCategoryDialogFragment.class.getSimpleName();
|
||||
|
@ -85,9 +87,7 @@ public class SelectCategoryDialogFragment extends DialogFragment {
|
|||
} else {
|
||||
List<FavouritesDbHelper.FavoriteGroup> gs = helper.getFavoriteGroups();
|
||||
for (final FavouritesDbHelper.FavoriteGroup category : gs) {
|
||||
if (!category.personal) {
|
||||
addCategory(activity, ll, category.name, category.color);
|
||||
}
|
||||
addCategory(activity, ll, category.getDisplayName(getContext()), category.getColor());
|
||||
}
|
||||
}
|
||||
View itemView = activity.getLayoutInflater().inflate(R.layout.favorite_category_dialog_item, null);
|
||||
|
@ -132,7 +132,7 @@ public class SelectCategoryDialogFragment extends DialogFragment {
|
|||
@Override
|
||||
public void onClick(View v) {
|
||||
FragmentActivity a = getActivity();
|
||||
if (a != null && a instanceof MapActivity) {
|
||||
if (a instanceof MapActivity) {
|
||||
PointEditor pointEditor = ((MapActivity) a).getContextMenu().getPointEditor(editorTag);
|
||||
if (pointEditor != null) {
|
||||
pointEditor.setCategory(categoryName, categoryColor);
|
||||
|
|
|
@ -364,7 +364,7 @@ public class WptPtEditorFragment extends PointEditorFragment {
|
|||
|
||||
@Override
|
||||
public Drawable getNameIcon() {
|
||||
return FavoriteImageDrawable.getOrCreate(getMapActivity(), getPointColor(), false);
|
||||
return FavoriteImageDrawable.getOrCreate(getMapActivity(), getPointColor(), false, wpt);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -48,7 +48,8 @@ public class FavouritesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
|||
} else {
|
||||
favouritesViewHolder.description.setText(favouritePoint.getCategory());
|
||||
}
|
||||
favouritesViewHolder.favouriteImage.setImageDrawable(FavoriteImageDrawable.getOrCreate(app, favouritePoint.getColor(), false));
|
||||
favouritesViewHolder.favouriteImage.setImageDrawable(
|
||||
FavoriteImageDrawable.getOrCreate(app, favouritePoint.getColor(), false, favouritePoint));
|
||||
app.getUIUtilities().updateLocationView(cache, favouritesViewHolder.arrowImage, favouritesViewHolder.distance,
|
||||
favouritePoint.getLatitude(), favouritePoint.getLongitude());
|
||||
}
|
||||
|
|
|
@ -77,7 +77,7 @@ public class FavouritesBottomSheetMenuFragment extends MenuBottomSheetDialogFrag
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onFavoriteAddressResolved(@NonNull FavouritePoint favouritePoint) {
|
||||
public void onFavoriteDataUpdated(@NonNull FavouritePoint favouritePoint) {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -131,9 +131,9 @@ public class FavouritesBottomSheetMenuFragment extends MenuBottomSheetDialogFrag
|
|||
|
||||
private void loadFavorites() {
|
||||
favouritePoints.clear();
|
||||
favouritePoints.addAll(getMyApplication().getFavorites().getNonPersonalVisibleFavouritePoints());
|
||||
favouritePoints.addAll(getMyApplication().getFavorites().getVisibleFavouritePoints());
|
||||
if (favouritePoints.isEmpty()) {
|
||||
favouritePoints.addAll(getMyApplication().getFavorites().getNonPersonalFavouritePoints());
|
||||
favouritePoints.addAll(getMyApplication().getFavorites().getFavouritePoints());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -147,24 +147,25 @@ public class FavouritesBottomSheetMenuFragment extends MenuBottomSheetDialogFrag
|
|||
}
|
||||
|
||||
private void selectFavorite(FavouritePoint point) {
|
||||
TargetPointsHelper targetPointsHelper = getMyApplication().getTargetPointsHelper();
|
||||
FavouritesDbHelper favorites = getMyApplication().getFavorites();
|
||||
OsmandApplication app = getMyApplication();
|
||||
TargetPointsHelper targetPointsHelper = app.getTargetPointsHelper();
|
||||
FavouritesDbHelper favorites = app.getFavorites();
|
||||
LatLon ll = new LatLon(point.getLatitude(), point.getLongitude());
|
||||
switch (pointType) {
|
||||
case START:
|
||||
targetPointsHelper.setStartPoint(ll, true, point.getPointDescription());
|
||||
targetPointsHelper.setStartPoint(ll, true, point.getPointDescription(app));
|
||||
break;
|
||||
case TARGET:
|
||||
targetPointsHelper.navigateToPoint(ll, true, -1, point.getPointDescription());
|
||||
targetPointsHelper.navigateToPoint(ll, true, -1, point.getPointDescription(app));
|
||||
break;
|
||||
case INTERMEDIATE:
|
||||
targetPointsHelper.navigateToPoint(ll, true, targetPointsHelper.getIntermediatePoints().size(), point.getPointDescription());
|
||||
targetPointsHelper.navigateToPoint(ll, true, targetPointsHelper.getIntermediatePoints().size(), point.getPointDescription(app));
|
||||
break;
|
||||
case HOME:
|
||||
favorites.setHomePoint(ll, null);
|
||||
favorites.setSpecialPoint(ll, FavouritePoint.SpecialPointType.HOME, null);
|
||||
break;
|
||||
case WORK:
|
||||
favorites.setWorkPoint(ll, null);
|
||||
favorites.setSpecialPoint(ll, FavouritePoint.SpecialPointType.WORK, null);
|
||||
break;
|
||||
}
|
||||
MapRouteInfoMenu routeMenu = getMapRouteInfoMenu();
|
||||
|
|
|
@ -42,7 +42,7 @@ public class AddFavouritesGroupBottomSheetDialogFragment extends AddGroupBottomS
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onFavoriteAddressResolved(@NonNull FavouritePoint favouritePoint) {
|
||||
public void onFavoriteDataUpdated(@NonNull FavouritePoint favouritePoint) {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -52,8 +52,8 @@ public class AddFavouritesGroupBottomSheetDialogFragment extends AddGroupBottomS
|
|||
@Override
|
||||
protected void onItemClick(int position) {
|
||||
FavoriteGroup group = favouritesDbHelper.getFavoriteGroups().get(position - 1);
|
||||
if (!group.visible) {
|
||||
favouritesDbHelper.editFavouriteGroup(group, group.name, group.color, true);
|
||||
if (!group.isVisible()) {
|
||||
favouritesDbHelper.editFavouriteGroup(group, group.getName(), group.getColor(), true);
|
||||
}
|
||||
getMyApplication().getMapMarkersHelper().addOrEnableGroup(group);
|
||||
dismiss();
|
||||
|
|
|
@ -76,7 +76,7 @@ public class MapMarkersActiveFragment extends Fragment implements OsmAndCompassL
|
|||
? app.getFavorites().getVisibleFavByLatLon(marker.point)
|
||||
: marker.favouritePoint;
|
||||
if (fav != null) {
|
||||
showMap(marker.point, fav.getPointDescription(), fav);
|
||||
showMap(marker.point, fav.getPointDescription(mapActivity), fav);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -236,7 +236,7 @@ public class MapMarkersGroupsFragment extends Fragment implements OsmAndCompassL
|
|||
? app.getFavorites().getVisibleFavByLatLon(marker.point)
|
||||
: marker.favouritePoint;
|
||||
if (fav != null) {
|
||||
showMap(marker.point, fav.getPointDescription(), fav);
|
||||
showMap(marker.point, fav.getPointDescription(mapActivity), fav);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -66,7 +66,7 @@ public class CoordinateInputAdapter extends RecyclerView.Adapter<MapMarkerItemVi
|
|||
WptPt wpt = getItem(position);
|
||||
|
||||
holder.iconDirection.setVisibility(View.VISIBLE);
|
||||
holder.icon.setImageDrawable(FavoriteImageDrawable.getOrCreate(app, wpt.getColor(), false));
|
||||
holder.icon.setImageDrawable(FavoriteImageDrawable.getOrCreate(app, wpt.getColor(), false, wpt));
|
||||
holder.mainLayout.setBackgroundColor(getResolvedColor(nightTheme ? R.color.list_background_color_dark : R.color.list_background_color_light));
|
||||
holder.title.setTextColor(getResolvedColor(nightTheme ? R.color.text_color_primary_dark : R.color.text_color_primary_light));
|
||||
holder.divider.setBackgroundColor(getResolvedColor(nightTheme ? R.color.coordinate_input_edit_text_normal_dark : R.color.divider_color_light));
|
||||
|
|
|
@ -3,13 +3,8 @@ package net.osmand.plus.mapmarkers.adapters;
|
|||
import android.content.Context;
|
||||
import android.graphics.Color;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import net.osmand.plus.FavouritesDbHelper.FavoriteGroup;
|
||||
import net.osmand.plus.UiUtilities;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.R;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -32,10 +27,10 @@ public class FavouritesGroupsAdapter extends GroupsAdapter {
|
|||
} else if (holder instanceof MapMarkersGroupViewHolder) {
|
||||
FavoriteGroup favoriteGroup = getItem(position);
|
||||
MapMarkersGroupViewHolder markersGroupViewHolder = (MapMarkersGroupViewHolder) holder;
|
||||
int color = favoriteGroup.color == 0 || favoriteGroup.color == Color.BLACK ? app.getResources().getColor(R.color.color_favorite) : favoriteGroup.color;
|
||||
int color = favoriteGroup.getColor() == 0 || favoriteGroup.getColor() == Color.BLACK ? app.getResources().getColor(R.color.color_favorite) : favoriteGroup.getColor();
|
||||
markersGroupViewHolder.icon.setImageDrawable(iconsCache.getPaintedIcon(R.drawable.ic_action_folder, color | 0xff000000));
|
||||
markersGroupViewHolder.name.setText(favoriteGroup.name.length() == 0 ? app.getString(R.string.shared_string_favorites) : favoriteGroup.name);
|
||||
markersGroupViewHolder.numberCount.setText(String.valueOf(favoriteGroup.points.size()));
|
||||
markersGroupViewHolder.name.setText(favoriteGroup.getName().length() == 0 ? app.getString(R.string.shared_string_favorites) : favoriteGroup.getName());
|
||||
markersGroupViewHolder.numberCount.setText(String.valueOf(favoriteGroup.getPoints().size()));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1110,7 +1110,7 @@ public class TrackPointFragment extends OsmandExpandableListFragment implements
|
|||
} else {
|
||||
description.setVisibility(View.GONE);
|
||||
}
|
||||
icon.setImageDrawable(FavoriteImageDrawable.getOrCreate(getActivity(), groupColor, false));
|
||||
icon.setImageDrawable(FavoriteImageDrawable.getOrCreate(getActivity(), groupColor, false, wpt));
|
||||
|
||||
} else {
|
||||
boolean showAll = gpxItem == null;
|
||||
|
|
|
@ -15,6 +15,7 @@ import android.widget.CheckBox;
|
|||
import android.widget.TextView;
|
||||
import android.widget.TimePicker;
|
||||
|
||||
import net.osmand.data.FavouritePoint;
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.plus.ApplicationMode;
|
||||
import net.osmand.plus.ContextMenuAdapter;
|
||||
|
@ -119,12 +120,6 @@ public class ParkingPositionPlugin extends OsmandPlugin {
|
|||
return parkingStartTime.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disable(OsmandApplication app) {
|
||||
super.disable(app);
|
||||
app.getFavorites().deleteParkingPoint();
|
||||
}
|
||||
|
||||
public boolean clearParkingPosition() {
|
||||
parkingLat.resetToDefault();
|
||||
parkingLon.resetToDefault();
|
||||
|
@ -298,7 +293,10 @@ public class ParkingPositionPlugin extends OsmandPlugin {
|
|||
showDeleteEventWarning(activity);
|
||||
cancelParking();
|
||||
if (activity instanceof MapActivity) {
|
||||
app.getFavorites().deleteParkingPoint();
|
||||
FavouritePoint pnt = app.getFavorites().getSpecialPoint(FavouritePoint.SpecialPointType.PARKING);
|
||||
if(pnt != null) {
|
||||
app.getFavorites().deleteFavourite(pnt);
|
||||
}
|
||||
((MapActivity) activity).getContextMenu().close();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -150,21 +150,12 @@ public class FavoriteAction extends QuickAction {
|
|||
|
||||
FavouritesDbHelper.FavoriteGroup group = helper.getFavoriteGroups().get(0);
|
||||
|
||||
if (group.name.isEmpty() && group.color == 0) {
|
||||
int color = group.getColor() == 0 ? activity.getResources().getColor(R.color.color_favorite) : group.getColor();
|
||||
categoryEdit.setText(group.getDisplayName(activity));
|
||||
categoryImage.setColorFilter(color);
|
||||
|
||||
group.name = activity.getString(R.string.shared_string_favorites);
|
||||
|
||||
categoryEdit.setText(activity.getString(R.string.shared_string_favorites));
|
||||
categoryImage.setColorFilter(activity.getResources().getColor(R.color.color_favorite));
|
||||
|
||||
} else {
|
||||
|
||||
categoryEdit.setText(group.name);
|
||||
categoryImage.setColorFilter(group.color);
|
||||
}
|
||||
|
||||
getParams().put(KEY_CATEGORY_NAME, group.name);
|
||||
getParams().put(KEY_CATEGORY_COLOR, String.valueOf(group.color));
|
||||
getParams().put(KEY_CATEGORY_NAME, group.getName());
|
||||
getParams().put(KEY_CATEGORY_COLOR, String.valueOf(group.getColor()));
|
||||
|
||||
} else {
|
||||
|
||||
|
|
|
@ -5,7 +5,6 @@ import android.app.Activity;
|
|||
import android.content.Intent;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Typeface;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v4.app.ActivityCompat;
|
||||
|
@ -26,7 +25,6 @@ import net.osmand.AndroidUtils;
|
|||
import net.osmand.Location;
|
||||
import net.osmand.data.FavouritePoint;
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.data.PersonalFavouritePoint;
|
||||
import net.osmand.data.PointDescription;
|
||||
import net.osmand.plus.FavouritesDbHelper;
|
||||
import net.osmand.plus.MapMarkersHelper;
|
||||
|
@ -37,7 +35,6 @@ import net.osmand.plus.R;
|
|||
import net.osmand.plus.TargetPointsHelper;
|
||||
import net.osmand.plus.TargetPointsHelper.TargetPoint;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.base.FavoriteImageDrawable;
|
||||
import net.osmand.plus.base.MenuBottomSheetDialogFragment;
|
||||
import net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem;
|
||||
import net.osmand.plus.base.bottomsheetmenu.HorizontalRecyclerBottomSheetItem;
|
||||
|
@ -252,11 +249,11 @@ public class AddPointBottomSheetDialog extends MenuBottomSheetDialogFragment {
|
|||
break;
|
||||
case HOME:
|
||||
app.showShortToastMessage(R.string.add_home);
|
||||
app.getFavorites().setHomePoint(ll, null);
|
||||
app.getFavorites().setSpecialPoint(ll, FavouritePoint.SpecialPointType.HOME, null);
|
||||
break;
|
||||
case WORK:
|
||||
app.showShortToastMessage(R.string.add_work);
|
||||
app.getFavorites().setWorkPoint(ll, null);
|
||||
app.getFavorites().setSpecialPoint(ll, FavouritePoint.SpecialPointType.WORK, null);
|
||||
break;
|
||||
}
|
||||
} else if (pointType == PointType.START) {
|
||||
|
@ -361,11 +358,11 @@ public class AddPointBottomSheetDialog extends MenuBottomSheetDialogFragment {
|
|||
|
||||
private void loadFavoritesItems(List<Object> items, FavouritesDbHelper helper) {
|
||||
items.clear();
|
||||
addMainScrollItems(items, helper);
|
||||
addMainScrollItems(items);
|
||||
items.addAll(helper.getVisibleFavouritePoints());
|
||||
}
|
||||
|
||||
private void addMainScrollItems(List<Object> items, FavouritesDbHelper favorites) {
|
||||
private void addMainScrollItems(List<Object> items) {
|
||||
items.add(FAVORITES);
|
||||
}
|
||||
|
||||
|
@ -379,7 +376,7 @@ public class AddPointBottomSheetDialog extends MenuBottomSheetDialogFragment {
|
|||
if (helper.isFavoritesLoaded()) {
|
||||
loadFavoritesItems(items, helper);
|
||||
} else {
|
||||
addMainScrollItems(items, helper);
|
||||
addMainScrollItems(items);
|
||||
helper.addListener(new FavouritesDbHelper.FavoritesListener() {
|
||||
|
||||
private void reloadFavoritesItems() {
|
||||
|
@ -396,7 +393,7 @@ public class AddPointBottomSheetDialog extends MenuBottomSheetDialogFragment {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onFavoriteAddressResolved(@NonNull FavouritePoint favouritePoint) {
|
||||
public void onFavoriteDataUpdated(@NonNull FavouritePoint favouritePoint) {
|
||||
reloadFavoritesItems();
|
||||
}
|
||||
});
|
||||
|
@ -454,13 +451,13 @@ public class AddPointBottomSheetDialog extends MenuBottomSheetDialogFragment {
|
|||
helper.navigateToPoint(ll, true, helper.getIntermediatePoints().size(), name);
|
||||
break;
|
||||
case HOME:
|
||||
favorites.setHomePoint(ll, null);
|
||||
favorites.setSpecialPoint(ll, FavouritePoint.SpecialPointType.HOME, null);
|
||||
break;
|
||||
case WORK:
|
||||
favorites.setWorkPoint(ll, null);
|
||||
favorites.setSpecialPoint(ll, FavouritePoint.SpecialPointType.WORK, null);
|
||||
break;
|
||||
case PARKING:
|
||||
favorites.setParkingPoint(ll);
|
||||
favorites.setSpecialPoint(ll, FavouritePoint.SpecialPointType.PARKING, null);
|
||||
break;
|
||||
}
|
||||
dismiss();
|
||||
|
@ -476,22 +473,22 @@ public class AddPointBottomSheetDialog extends MenuBottomSheetDialogFragment {
|
|||
if (item instanceof FavouritePoint) {
|
||||
FavouritePoint point = (FavouritePoint) item;
|
||||
ll = new LatLon(point.getLatitude(), point.getLongitude());
|
||||
name = point.getPointDescription();
|
||||
name = point.getPointDescription(requireActivity());
|
||||
} else if (item instanceof PointType) {
|
||||
MapActivity mapActivity = (MapActivity) getActivity();
|
||||
if (mapActivity != null) {
|
||||
FavouritesDbHelper favorites = mapActivity.getMyApplication().getFavorites();
|
||||
FavouritePoint point = null;
|
||||
if (item == PointType.HOME) {
|
||||
point = favorites.getHomePoint();
|
||||
point = favorites.getSpecialPoint(FavouritePoint.SpecialPointType.HOME);
|
||||
} else if (item == PointType.WORK) {
|
||||
point = favorites.getWorkPoint();
|
||||
point = favorites.getSpecialPoint(FavouritePoint.SpecialPointType.WORK);
|
||||
} else if (item == PointType.PARKING) {
|
||||
point = favorites.getParkingPoint();
|
||||
point = favorites.getSpecialPoint(FavouritePoint.SpecialPointType.PARKING);
|
||||
}
|
||||
if (point != null) {
|
||||
ll = new LatLon(point.getLatitude(), point.getLongitude());
|
||||
name = point.getPointDescription();
|
||||
name = point.getPointDescription(mapActivity);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -600,18 +597,15 @@ public class AddPointBottomSheetDialog extends MenuBottomSheetDialogFragment {
|
|||
return items.get(position);
|
||||
}
|
||||
|
||||
public void setItemClickListener(OnClickListener listener) {
|
||||
void setItemClickListener(OnClickListener listener) {
|
||||
this.listener = listener;
|
||||
}
|
||||
}
|
||||
|
||||
private class FavoritesItemsAdapter extends ScrollItemsAdapter {
|
||||
|
||||
private FavouritesDbHelper favorites;
|
||||
|
||||
FavoritesItemsAdapter(OsmandApplication app, List<Object> items) {
|
||||
super(app, items);
|
||||
favorites = app.getFavorites();
|
||||
}
|
||||
|
||||
@NonNull
|
||||
|
@ -645,26 +639,27 @@ public class AddPointBottomSheetDialog extends MenuBottomSheetDialogFragment {
|
|||
favoriteViewHolder.icon.setImageDrawable(getContentIcon(R.drawable.ic_action_fav_dark));
|
||||
favoriteViewHolder.description.setVisibility(View.GONE);
|
||||
} else {
|
||||
if (item instanceof PersonalFavouritePoint) {
|
||||
PersonalFavouritePoint point = (PersonalFavouritePoint) item;
|
||||
boolean light = app.getSettings().isLightContent();
|
||||
int iconColor = light ? R.color.icon_color_default_light : R.color.icon_color_default_dark;
|
||||
favoriteViewHolder.icon.setImageDrawable(app.getUIUtilities().getIcon(point.getType().getIconId(), iconColor));
|
||||
favoriteViewHolder.title.setText(point.getName());
|
||||
favoriteViewHolder.description.setText(point.getDescription());
|
||||
} else if (item instanceof FavouritePoint) {
|
||||
if (item instanceof FavouritePoint) {
|
||||
FavouritePoint point = (FavouritePoint) item;
|
||||
favoriteViewHolder.title.setText(point.getName());
|
||||
if (point.getCategory().equals("")) {
|
||||
favoriteViewHolder.description.setText(R.string.shared_string_favorites);
|
||||
favoriteViewHolder.title.setText(point.getDisplayName(app));
|
||||
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(
|
||||
((FavouritePoint) item).getSpecialPointType().getIconId(), iconColor));
|
||||
favoriteViewHolder.description.setText(point.getDescription());
|
||||
} else {
|
||||
favoriteViewHolder.description.setText(point.getCategory());
|
||||
if (point.getCategory().equals("")) {
|
||||
favoriteViewHolder.description.setText(R.string.shared_string_favorites);
|
||||
} else {
|
||||
favoriteViewHolder.description.setText(point.getCategory());
|
||||
}
|
||||
int pointColor = point.getColor();
|
||||
int color = pointColor == 0 || pointColor == Color.BLACK ? ContextCompat.getColor(app, R.color.color_favorite) : pointColor;
|
||||
favoriteViewHolder.icon.setImageDrawable(app.getUIUtilities().getPaintedIcon(R.drawable.ic_action_fav_dark, color));
|
||||
}
|
||||
int pointColor = point.getColor();
|
||||
int color = pointColor == 0 || pointColor == Color.BLACK ? ContextCompat.getColor(app, R.color.color_favorite) : pointColor;
|
||||
favoriteViewHolder.icon.setImageDrawable(app.getUIUtilities().getPaintedIcon(R.drawable.ic_action_fav_dark, color));
|
||||
favoriteViewHolder.description.setVisibility(View.VISIBLE);
|
||||
}
|
||||
favoriteViewHolder.description.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -275,10 +275,10 @@ public class MapRouteInfoMenu implements IRouteInformationListener, CardListener
|
|||
targets.navigateToPoint(latlon, true, targets.getIntermediatePoints().size());
|
||||
break;
|
||||
case HOME:
|
||||
favorites.setHomePoint(latlon, null);
|
||||
favorites.setSpecialPoint(latlon, FavouritePoint.SpecialPointType.HOME, null);
|
||||
break;
|
||||
case WORK:
|
||||
favorites.setWorkPoint(latlon, null);
|
||||
favorites.setSpecialPoint(latlon, FavouritePoint.SpecialPointType.WORK, null);
|
||||
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, name);
|
||||
favorites.setSpecialPoint(l, FavouritePoint.SpecialPointType.HOME, name);
|
||||
break;
|
||||
case WORK:
|
||||
favorites.setWorkPoint(l, name);
|
||||
favorites.setSpecialPoint(l, FavouritePoint.SpecialPointType.WORK, name);
|
||||
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, null);
|
||||
favorites.setSpecialPoint(point, FavouritePoint.SpecialPointType.HOME, null);
|
||||
break;
|
||||
case WORK:
|
||||
favorites.setWorkPoint(point, null);
|
||||
favorites.setSpecialPoint(point, FavouritePoint.SpecialPointType.WORK, null);
|
||||
break;
|
||||
}
|
||||
updateMenu();
|
||||
|
@ -2245,7 +2245,7 @@ public class MapRouteInfoMenu implements IRouteInformationListener, CardListener
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onFavoriteAddressResolved(@NonNull FavouritePoint favouritePoint) {
|
||||
public void onFavoriteDataUpdated(@NonNull FavouritePoint favouritePoint) {
|
||||
updateMenu();
|
||||
}
|
||||
|
||||
|
|
|
@ -27,13 +27,13 @@ public class HomeWorkCard extends BaseCard {
|
|||
protected void updateContent() {
|
||||
final TargetPointsHelper targetPointsHelper = mapActivity.getMyApplication().getTargetPointsHelper();
|
||||
final FavouritesDbHelper favorites = getMyApplication().getFavorites();
|
||||
final FavouritePoint homePoint = favorites.getHomePoint();
|
||||
final FavouritePoint workPoint = favorites.getWorkPoint();
|
||||
final FavouritePoint homePoint = favorites.getSpecialPoint(FavouritePoint.SpecialPointType.HOME);
|
||||
final FavouritePoint workPoint = favorites.getSpecialPoint(FavouritePoint.SpecialPointType.WORK);
|
||||
|
||||
TextView homeDescr = view.findViewById(R.id.home_button_descr);
|
||||
final TextView workDescr = view.findViewById(R.id.work_button_descr);
|
||||
homeDescr.setText(homePoint != null ? homePoint.getDescription() : mapActivity.getString(R.string.shared_string_add));
|
||||
workDescr.setText(workPoint != null ? workPoint.getDescription() : mapActivity.getString(R.string.shared_string_add));
|
||||
homeDescr.setText(homePoint != null ? homePoint.getAddress() : mapActivity.getString(R.string.shared_string_add));
|
||||
workDescr.setText(workPoint != null ? workPoint.getAddress() : mapActivity.getString(R.string.shared_string_add));
|
||||
|
||||
View homeButton = view.findViewById(R.id.home_button);
|
||||
homeButton.setOnClickListener(new View.OnClickListener() {
|
||||
|
@ -43,7 +43,7 @@ public class HomeWorkCard extends BaseCard {
|
|||
AddPointBottomSheetDialog.showInstance(mapActivity, PointType.HOME);
|
||||
} else {
|
||||
targetPointsHelper.navigateToPoint(new LatLon(homePoint.getLatitude(), homePoint.getLongitude()),
|
||||
true, -1, homePoint.getPointDescription());
|
||||
true, -1, homePoint.getPointDescription(mapActivity));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -63,7 +63,7 @@ public class HomeWorkCard extends BaseCard {
|
|||
AddPointBottomSheetDialog.showInstance(mapActivity, PointType.WORK);
|
||||
} else {
|
||||
targetPointsHelper.navigateToPoint(new LatLon(workPoint.getLatitude(), workPoint.getLongitude()),
|
||||
true, -1, workPoint.getPointDescription());
|
||||
true, -1, workPoint.getPointDescription(mapActivity));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -409,10 +409,10 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
|
|||
hide();
|
||||
} else if (word.getType() == ObjectType.FAVORITE_GROUP) {
|
||||
FavouritesDbHelper.FavoriteGroup group = (FavouritesDbHelper.FavoriteGroup) word.getResult().object;
|
||||
if (group.points.size() > 1) {
|
||||
if (group.getPoints().size() > 1) {
|
||||
double left = 0, right = 0;
|
||||
double top = 0, bottom = 0;
|
||||
for (FavouritePoint p : group.points) {
|
||||
for (FavouritePoint p : group.getPoints()) {
|
||||
if (left == 0) {
|
||||
left = p.getLongitude();
|
||||
right = p.getLongitude();
|
||||
|
@ -429,8 +429,8 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
|
|||
hideToolbar();
|
||||
MapActivity.launchMapActivityMoveToTop(getActivity());
|
||||
hide();
|
||||
} else if (group.points.size() == 1) {
|
||||
FavouritePoint p = group.points.get(0);
|
||||
} else if (group.getPoints().size() == 1) {
|
||||
FavouritePoint p = group.getPoints().get(0);
|
||||
app.getSettings().setMapLocationToShow(p.getLatitude(), p.getLongitude(), word.getResult().preferredZoom);
|
||||
hideToolbar();
|
||||
MapActivity.launchMapActivityMoveToTop(getActivity());
|
||||
|
|
|
@ -11,7 +11,6 @@ import net.osmand.data.FavouritePoint;
|
|||
import net.osmand.data.LatLon;
|
||||
import net.osmand.data.PointDescription;
|
||||
import net.osmand.data.QuadRect;
|
||||
import net.osmand.data.WptLocationPoint;
|
||||
import net.osmand.osm.AbstractPoiType;
|
||||
import net.osmand.osm.MapPoiTypes;
|
||||
import net.osmand.osm.PoiCategory;
|
||||
|
@ -236,16 +235,16 @@ public class QuickSearchHelper implements ResourceListener {
|
|||
String baseGroupName = app.getString(R.string.shared_string_favorites);
|
||||
List<FavoriteGroup> groups = app.getFavorites().getFavoriteGroups();
|
||||
for (FavoriteGroup group : groups) {
|
||||
if (group.visible) {
|
||||
if (group.isVisible()) {
|
||||
SearchResult sr = new SearchResult(phrase);
|
||||
sr.localeName = Algorithms.isEmpty(group.name) ? baseGroupName : group.name;
|
||||
sr.localeName = Algorithms.isEmpty(group.getName()) ? baseGroupName : group.getName();
|
||||
sr.object = group;
|
||||
sr.priority = SEARCH_FAVORITE_CATEGORY_PRIORITY;
|
||||
sr.objectType = ObjectType.FAVORITE_GROUP;
|
||||
sr.preferredZoom = 17;
|
||||
if (phrase.getNameStringMatcher().matches(sr.localeName)) {
|
||||
if (group.points.size() < 5) {
|
||||
for (FavouritePoint point : group.points) {
|
||||
if (group.getPoints().size() < 5) {
|
||||
for (FavouritePoint point : group.getPoints()) {
|
||||
SearchResult srp = new SearchResult(phrase);
|
||||
srp.localeName = point.getName();
|
||||
srp.object = point;
|
||||
|
@ -295,7 +294,7 @@ public class QuickSearchHelper implements ResourceListener {
|
|||
continue;
|
||||
}
|
||||
SearchResult sr = new SearchResult(phrase);
|
||||
sr.localeName = point.getName();
|
||||
sr.localeName = point.getDisplayName(app);
|
||||
sr.object = point;
|
||||
sr.priority = SEARCH_FAVORITE_OBJECT_PRIORITY;
|
||||
sr.objectType = ObjectType.FAVORITE;
|
||||
|
@ -303,7 +302,7 @@ public class QuickSearchHelper implements ResourceListener {
|
|||
sr.preferredZoom = 17;
|
||||
if (phrase.isLastWord(ObjectType.FAVORITE_GROUP)) {
|
||||
FavoriteGroup group = (FavoriteGroup) phrase.getLastSelectedWord().getResult().object;
|
||||
if (group != null && !point.getCategory().equals(group.name)) {
|
||||
if (group != null && !point.getCategory().equals(group.getName())) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -194,9 +194,10 @@ public abstract class QuickSearchListFragment extends OsmAndListFragment {
|
|||
List<FavouritePoint> favs = app.getFavorites().getFavouritePoints();
|
||||
for (FavouritePoint f : favs) {
|
||||
if (entryLatLon.equals(new LatLon(f.getLatitude(), f.getLongitude()))
|
||||
&& pointDescription.getName().equals(f.getName())) {
|
||||
&& (pointDescription.getName().equals(f.getName()) ||
|
||||
pointDescription.getName().equals(f.getDisplayName(app)))) {
|
||||
object = f;
|
||||
pointDescription = f.getPointDescription();
|
||||
pointDescription = f.getPointDescription(app);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -204,7 +205,7 @@ public abstract class QuickSearchListFragment extends OsmAndListFragment {
|
|||
break;
|
||||
case FAVORITE:
|
||||
FavouritePoint fav = (FavouritePoint) object;
|
||||
pointDescription = fav.getPointDescription();
|
||||
pointDescription = fav.getPointDescription(app);
|
||||
break;
|
||||
case VILLAGE:
|
||||
case CITY:
|
||||
|
|
|
@ -214,7 +214,7 @@ public class QuickSearchListItem {
|
|||
case FAVORITE:
|
||||
FavouritePoint fav = (FavouritePoint) searchResult.object;
|
||||
return fav.getCategory().length() == 0 ?
|
||||
app.getString(R.string.shared_string_favorites) : fav.getCategory();
|
||||
app.getString(R.string.shared_string_favorites) : fav.getCategoryDisplayName(app);
|
||||
case FAVORITE_GROUP:
|
||||
return app.getString(R.string.shared_string_my_favorites);
|
||||
case REGION:
|
||||
|
@ -355,10 +355,10 @@ public class QuickSearchListItem {
|
|||
return getIcon(app, R.drawable.ic_action_world_globe);
|
||||
case FAVORITE:
|
||||
FavouritePoint fav = (FavouritePoint) searchResult.object;
|
||||
return FavoriteImageDrawable.getOrCreate(app, fav.getColor(), false);
|
||||
return FavoriteImageDrawable.getOrCreate(app, fav.getColor(), false, fav);
|
||||
case FAVORITE_GROUP:
|
||||
FavoriteGroup group = (FavoriteGroup) searchResult.object;
|
||||
int color = group.color == 0 || group.color == Color.BLACK ? app.getResources().getColor(R.color.color_favorite) : group.color;
|
||||
int color = group.getColor() == 0 || group.getColor() == Color.BLACK ? app.getResources().getColor(R.color.color_favorite) : group.getColor();
|
||||
return app.getUIUtilities().getPaintedIcon(R.drawable.ic_action_fav_dark, color | 0xff000000);
|
||||
case REGION:
|
||||
return getIcon(app, R.drawable.ic_world_globe_dark);
|
||||
|
@ -372,7 +372,7 @@ public class QuickSearchListItem {
|
|||
}
|
||||
case WPT:
|
||||
WptPt wpt = (WptPt) searchResult.object;
|
||||
return FavoriteImageDrawable.getOrCreate(app, wpt.getColor(), false);
|
||||
return FavoriteImageDrawable.getOrCreate(app, wpt.getColor(), false, wpt);
|
||||
case UNKNOWN_NAME_FILTER:
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -111,7 +111,7 @@ public class FavouritesLayer extends OsmandMapLayer implements ContextMenuLayer.
|
|||
if (this.settings.SHOW_FAVORITES.get() && favorites.isFavoritesLoaded()) {
|
||||
if (tileBox.getZoom() >= startZoom) {
|
||||
float iconSize = FavoriteImageDrawable.getOrCreate(view.getContext(), 0,
|
||||
true).getIntrinsicWidth() * 3 / 2.5f;
|
||||
true, (FavouritePoint) null).getIntrinsicWidth() * 3 / 2.5f;
|
||||
QuadTree<QuadRect> boundIntersections = initBoundIntersections(tileBox);
|
||||
|
||||
// request to load
|
||||
|
@ -121,7 +121,7 @@ public class FavouritesLayer extends OsmandMapLayer implements ContextMenuLayer.
|
|||
for (FavoriteGroup group : favorites.getFavoriteGroups()) {
|
||||
List<Pair<FavouritePoint, MapMarker>> fullObjects = new ArrayList<>();
|
||||
boolean synced = mapMarkersHelper.getMarkersGroup(group) != null;
|
||||
for (FavouritePoint o : group.points) {
|
||||
for (FavouritePoint o : group.getPoints()) {
|
||||
double lat = o.getLatitude();
|
||||
double lon = o.getLongitude();
|
||||
if (o.isVisible() && o != contextMenuLayer.getMoveableObject()
|
||||
|
@ -175,10 +175,10 @@ public class FavouritesLayer extends OsmandMapLayer implements ContextMenuLayer.
|
|||
FavoriteImageDrawable fid;
|
||||
boolean history = false;
|
||||
if (marker != null) {
|
||||
fid = FavoriteImageDrawable.getOrCreateSyncedIcon(view.getContext(), o.getColor());
|
||||
fid = FavoriteImageDrawable.getOrCreateSyncedIcon(view.getContext(), o.getColor(), o);
|
||||
history = marker.history;
|
||||
} else {
|
||||
fid = FavoriteImageDrawable.getOrCreate(view.getContext(), o.getColor(), true);
|
||||
fid = FavoriteImageDrawable.getOrCreate(view.getContext(), o.getColor(), true, o);
|
||||
}
|
||||
fid.drawBitmapInCenter(canvas, x, y, history);
|
||||
}
|
||||
|
@ -200,7 +200,7 @@ public class FavouritesLayer extends OsmandMapLayer implements ContextMenuLayer.
|
|||
|
||||
private void getFavFromPoint(RotatedTileBox tb, List<? super FavouritePoint> res, int r, int ex, int ey,
|
||||
FavouritePoint n) {
|
||||
if (n.isVisible()) {
|
||||
if (n.isVisible()) {
|
||||
int x = (int) tb.getPixXFromLatLon(n.getLatitude(), n.getLongitude());
|
||||
int y = (int) tb.getPixYFromLatLon(n.getLatitude(), n.getLongitude());
|
||||
if (calculateBelongs(ex, ey, x, y, r)) {
|
||||
|
@ -291,6 +291,7 @@ public class FavouritesLayer extends OsmandMapLayer implements ContextMenuLayer.
|
|||
boolean result = false;
|
||||
if (o instanceof FavouritePoint) {
|
||||
favorites.editFavourite((FavouritePoint) o, position.getLatitude(), position.getLongitude());
|
||||
favorites.lookupAddress((FavouritePoint) o);
|
||||
result = true;
|
||||
}
|
||||
if (callback != null) {
|
||||
|
|
|
@ -358,7 +358,7 @@ public class GPXLayer extends OsmandMapLayer implements ContextMenuLayer.IContex
|
|||
private void drawSelectedFilesPoints(Canvas canvas, RotatedTileBox tileBox, List<SelectedGpxFile> selectedGPXFiles) {
|
||||
if (tileBox.getZoom() >= startZoom) {
|
||||
float iconSize = FavoriteImageDrawable.getOrCreate(view.getContext(), 0,
|
||||
true).getIntrinsicWidth() * 3 / 2.5f;
|
||||
true, (WptPt) null).getIntrinsicWidth() * 3 / 2.5f;
|
||||
QuadTree<QuadRect> boundIntersections = initBoundIntersections(tileBox);
|
||||
|
||||
List<LatLon> fullObjectsLatLon = new ArrayList<>();
|
||||
|
@ -484,10 +484,10 @@ public class GPXLayer extends OsmandMapLayer implements ContextMenuLayer.IContex
|
|||
FavoriteImageDrawable fid;
|
||||
boolean history = false;
|
||||
if (marker != null) {
|
||||
fid = FavoriteImageDrawable.getOrCreateSyncedIcon(view.getContext(), pointColor);
|
||||
fid = FavoriteImageDrawable.getOrCreateSyncedIcon(view.getContext(), pointColor, o);
|
||||
history = marker.history;
|
||||
} else {
|
||||
fid = FavoriteImageDrawable.getOrCreate(view.getContext(), pointColor, true);
|
||||
fid = FavoriteImageDrawable.getOrCreate(view.getContext(), pointColor, true, o);
|
||||
}
|
||||
fid.drawBitmapInCenter(canvas, x, y, history);
|
||||
}
|
||||
|
|
|
@ -546,7 +546,8 @@ public class MapMarkersLayer extends OsmandMapLayer implements IContextMenuProvi
|
|||
if (!unknownLocation && selectMarkerOnSingleTap) {
|
||||
o.add(marker);
|
||||
} else {
|
||||
if (isMarkerOnFavorite(marker) || isMarkerOnWaypoint(marker)) {
|
||||
if (isMarkerOnFavorite(marker) && app.getSettings().SHOW_FAVORITES.get()
|
||||
|| isMarkerOnWaypoint(marker) && app.getSettings().SHOW_WPT.get()) {
|
||||
continue;
|
||||
}
|
||||
Amenity mapObj = getMapObjectByMarker(marker);
|
||||
|
|
Loading…
Reference in a new issue