commit
34798a612b
6 changed files with 32 additions and 13 deletions
|
@ -8,7 +8,11 @@ import androidx.annotation.StringRes;
|
||||||
|
|
||||||
import net.osmand.GPXUtilities.WptPt;
|
import net.osmand.GPXUtilities.WptPt;
|
||||||
import net.osmand.plus.FavouritesDbHelper;
|
import net.osmand.plus.FavouritesDbHelper;
|
||||||
|
import net.osmand.plus.OsmandApplication;
|
||||||
|
import net.osmand.plus.OsmandSettings.BooleanPreference;
|
||||||
|
import net.osmand.plus.OsmandSettings.OsmandPreference;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
|
import net.osmand.plus.parkingpoint.ParkingPositionPlugin;
|
||||||
import net.osmand.util.Algorithms;
|
import net.osmand.util.Algorithms;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
@ -97,7 +101,7 @@ public class FavouritePoint implements Serializable, LocationPoint {
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getIconEntryName(Context ctx) {
|
public String getIconEntryName(Context ctx) {
|
||||||
return ctx.getResources().getResourceEntryName(getOverlayIconId());
|
return ctx.getResources().getResourceEntryName(getOverlayIconId(ctx));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setIconId(int iconId) {
|
public void setIconId(int iconId) {
|
||||||
|
@ -137,9 +141,9 @@ public class FavouritePoint implements Serializable, LocationPoint {
|
||||||
this.originObjectName = originObjectName;
|
this.originObjectName = originObjectName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getOverlayIconId() {
|
public int getOverlayIconId(Context ctx) {
|
||||||
if (isSpecialPoint()) {
|
if (isSpecialPoint()) {
|
||||||
return specialPointType.getIconId();
|
return specialPointType.getIconId(ctx);
|
||||||
}
|
}
|
||||||
return getIconId();
|
return getIconId();
|
||||||
}
|
}
|
||||||
|
@ -284,7 +288,15 @@ public class FavouritePoint implements Serializable, LocationPoint {
|
||||||
return typeName;
|
return typeName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getIconId() {
|
public int getIconId(@NonNull Context ctx) {
|
||||||
|
if (this == PARKING) {
|
||||||
|
OsmandApplication app = (OsmandApplication) ctx.getApplicationContext();
|
||||||
|
OsmandPreference parkingType = app.getSettings().getPreference(ParkingPositionPlugin.PARKING_TYPE);
|
||||||
|
if (parkingType instanceof BooleanPreference && ((BooleanPreference) parkingType).get()) {
|
||||||
|
return R.drawable.mm_special_parking_time_limited;
|
||||||
|
}
|
||||||
|
return iconId;
|
||||||
|
}
|
||||||
return iconId;
|
return iconId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -290,12 +290,12 @@ public class FavouritesDbHelper {
|
||||||
public void setSpecialPoint(@NonNull LatLon latLon, FavouritePoint.SpecialPointType specialType, @Nullable String address) {
|
public void setSpecialPoint(@NonNull LatLon latLon, FavouritePoint.SpecialPointType specialType, @Nullable String address) {
|
||||||
FavouritePoint point = getSpecialPoint(specialType);
|
FavouritePoint point = getSpecialPoint(specialType);
|
||||||
if (point != null) {
|
if (point != null) {
|
||||||
point.setIconId(specialType.getIconId());
|
point.setIconId(specialType.getIconId(context));
|
||||||
editFavourite(point, latLon.getLatitude(), latLon.getLongitude(), address);
|
editFavourite(point, latLon.getLatitude(), latLon.getLongitude(), address);
|
||||||
} else {
|
} else {
|
||||||
point = new FavouritePoint(latLon.getLatitude(), latLon.getLongitude(), specialType.getName(), specialType.getCategory());
|
point = new FavouritePoint(latLon.getLatitude(), latLon.getLongitude(), specialType.getName(), specialType.getCategory());
|
||||||
point.setAddress(address);
|
point.setAddress(address);
|
||||||
point.setIconId(specialType.getIconId());
|
point.setIconId(specialType.getIconId(context));
|
||||||
addFavourite(point);
|
addFavourite(point);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,7 +48,7 @@ public class FavoriteImageDrawable extends Drawable {
|
||||||
this.synced = synced;
|
this.synced = synced;
|
||||||
Resources res = ctx.getResources();
|
Resources res = ctx.getResources();
|
||||||
UiUtilities uiUtilities = ((OsmandApplication) ctx.getApplicationContext()).getUIUtilities();
|
UiUtilities uiUtilities = ((OsmandApplication) ctx.getApplicationContext()).getUIUtilities();
|
||||||
int overlayIconId = point != null ? point.getOverlayIconId() : 0;
|
int overlayIconId = point != null ? point.getOverlayIconId(ctx) : 0;
|
||||||
int uiIconId;
|
int uiIconId;
|
||||||
if (overlayIconId != 0) {
|
if (overlayIconId != 0) {
|
||||||
favIcon = uiUtilities.getIcon(getMapIconId(ctx, overlayIconId), R.color.color_white);
|
favIcon = uiUtilities.getIcon(getMapIconId(ctx, overlayIconId), R.color.color_white);
|
||||||
|
|
|
@ -18,6 +18,7 @@ import androidx.appcompat.app.AlertDialog;
|
||||||
import androidx.fragment.app.FragmentManager;
|
import androidx.fragment.app.FragmentManager;
|
||||||
|
|
||||||
import net.osmand.data.FavouritePoint;
|
import net.osmand.data.FavouritePoint;
|
||||||
|
import net.osmand.data.FavouritePoint.SpecialPointType;
|
||||||
import net.osmand.data.LatLon;
|
import net.osmand.data.LatLon;
|
||||||
import net.osmand.data.PointDescription;
|
import net.osmand.data.PointDescription;
|
||||||
import net.osmand.plus.ApplicationMode;
|
import net.osmand.plus.ApplicationMode;
|
||||||
|
@ -131,6 +132,10 @@ public class ParkingPositionPlugin extends OsmandPlugin {
|
||||||
parkingEvent.resetToDefault();
|
parkingEvent.resetToDefault();
|
||||||
parkingStartTime.resetToDefault();
|
parkingStartTime.resetToDefault();
|
||||||
parkingPosition = null;
|
parkingPosition = null;
|
||||||
|
FavouritePoint pnt = app.getFavorites().getSpecialPoint(SpecialPointType.PARKING);
|
||||||
|
if (pnt != null) {
|
||||||
|
app.getFavorites().deleteFavourite(pnt);
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -285,7 +290,7 @@ public class ParkingPositionPlugin extends OsmandPlugin {
|
||||||
showDeleteEventWarning(activity);
|
showDeleteEventWarning(activity);
|
||||||
cancelParking();
|
cancelParking();
|
||||||
if (activity instanceof MapActivity) {
|
if (activity instanceof MapActivity) {
|
||||||
FavouritePoint pnt = app.getFavorites().getSpecialPoint(FavouritePoint.SpecialPointType.PARKING);
|
FavouritePoint pnt = app.getFavorites().getSpecialPoint(SpecialPointType.PARKING);
|
||||||
if(pnt != null) {
|
if(pnt != null) {
|
||||||
app.getFavorites().deleteFavourite(pnt);
|
app.getFavorites().deleteFavourite(pnt);
|
||||||
}
|
}
|
||||||
|
@ -305,7 +310,8 @@ public class ParkingPositionPlugin extends OsmandPlugin {
|
||||||
* @param choose
|
* @param choose
|
||||||
*/
|
*/
|
||||||
void showSetTimeLimitDialog(final MapActivity mapActivity, final DialogInterface choose) {
|
void showSetTimeLimitDialog(final MapActivity mapActivity, final DialogInterface choose) {
|
||||||
boolean nightMode = mapActivity.getMyApplication().getDaynightHelper().isNightModeForMapControls();
|
final OsmandApplication app = mapActivity.getMyApplication();
|
||||||
|
boolean nightMode = app.getDaynightHelper().isNightModeForMapControls();
|
||||||
final View setTimeParking = UiUtilities.getInflater(mapActivity, nightMode).inflate(R.layout.parking_set_time_limit, null);
|
final View setTimeParking = UiUtilities.getInflater(mapActivity, nightMode).inflate(R.layout.parking_set_time_limit, null);
|
||||||
AlertDialog.Builder setTime = new AlertDialog.Builder(mapActivity);
|
AlertDialog.Builder setTime = new AlertDialog.Builder(mapActivity);
|
||||||
setTime.setView(setTimeParking);
|
setTime.setView(setTimeParking);
|
||||||
|
|
|
@ -4,7 +4,7 @@ import android.app.Dialog;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
|
||||||
import net.osmand.data.FavouritePoint;
|
import net.osmand.data.FavouritePoint.SpecialPointType;
|
||||||
import net.osmand.plus.OsmandPlugin;
|
import net.osmand.plus.OsmandPlugin;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import net.osmand.plus.activities.MapActivity;
|
import net.osmand.plus.activities.MapActivity;
|
||||||
|
@ -71,10 +71,11 @@ public class ParkingTypeBottomSheetDialogFragment extends MenuBottomSheetDialogF
|
||||||
plugin.addOrRemoveParkingEvent(false);
|
plugin.addOrRemoveParkingEvent(false);
|
||||||
plugin.setParkingPosition(latitude, longitude, false);
|
plugin.setParkingPosition(latitude, longitude, false);
|
||||||
plugin.showContextMenuIfNeeded(mapActivity, true);
|
plugin.showContextMenuIfNeeded(mapActivity, true);
|
||||||
|
|
||||||
mapActivity.refreshMap();
|
mapActivity.refreshMap();
|
||||||
}
|
}
|
||||||
mapActivity.getMyApplication().getFavorites().setSpecialPoint(
|
mapActivity.getMyApplication().getFavorites().setSpecialPoint(
|
||||||
plugin.getParkingPosition(), FavouritePoint.SpecialPointType.PARKING, null);
|
plugin.getParkingPosition(), SpecialPointType.PARKING, null);
|
||||||
}
|
}
|
||||||
dismiss();
|
dismiss();
|
||||||
}
|
}
|
||||||
|
|
|
@ -649,7 +649,7 @@ public class AddPointBottomSheetDialog extends MenuBottomSheetDialogFragment {
|
||||||
int iconColor = app.getSettings().isLightContent()
|
int iconColor = app.getSettings().isLightContent()
|
||||||
? R.color.icon_color_default_light : R.color.icon_color_default_dark;
|
? R.color.icon_color_default_light : R.color.icon_color_default_dark;
|
||||||
favoriteViewHolder.icon.setImageDrawable(app.getUIUtilities().getIcon(
|
favoriteViewHolder.icon.setImageDrawable(app.getUIUtilities().getIcon(
|
||||||
((FavouritePoint) item).getSpecialPointType().getIconId(), iconColor));
|
((FavouritePoint) item).getSpecialPointType().getIconId(app), iconColor));
|
||||||
favoriteViewHolder.description.setText(point.getDescription());
|
favoriteViewHolder.description.setText(point.getDescription());
|
||||||
} else {
|
} else {
|
||||||
if (point.getCategory().equals("")) {
|
if (point.getCategory().equals("")) {
|
||||||
|
|
Loading…
Reference in a new issue