Implemented waypoint dialog
This commit is contained in:
parent
903263e42d
commit
36ef4d8307
23 changed files with 432 additions and 210 deletions
|
@ -2,7 +2,7 @@ package net.osmand.data;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
public class FavouritePoint implements Serializable {
|
public class FavouritePoint implements Serializable, LocationPoint {
|
||||||
private static final long serialVersionUID = 729654300829771466L;
|
private static final long serialVersionUID = 729654300829771466L;
|
||||||
private String name;
|
private String name;
|
||||||
private String category = "";
|
private String category = "";
|
||||||
|
@ -16,6 +16,8 @@ public class FavouritePoint implements Serializable {
|
||||||
public FavouritePoint(){
|
public FavouritePoint(){
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public FavouritePoint(double latitude, double longitude, String name, String category) {
|
public FavouritePoint(double latitude, double longitude, String name, String category) {
|
||||||
this.latitude = latitude;
|
this.latitude = latitude;
|
||||||
this.longitude = longitude;
|
this.longitude = longitude;
|
||||||
|
|
16
OsmAnd-java/src/net/osmand/data/LocationPoint.java
Normal file
16
OsmAnd-java/src/net/osmand/data/LocationPoint.java
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
package net.osmand.data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by Натали on 01.08.2014.
|
||||||
|
*/
|
||||||
|
public interface LocationPoint {
|
||||||
|
|
||||||
|
public double getLatitude();
|
||||||
|
|
||||||
|
public double getLongitude();
|
||||||
|
|
||||||
|
public String getName();
|
||||||
|
|
||||||
|
public int getColor();
|
||||||
|
|
||||||
|
}
|
|
@ -11,5 +11,4 @@
|
||||||
split.density=false
|
split.density=false
|
||||||
# Project target.
|
# Project target.
|
||||||
target=android-19
|
target=android-19
|
||||||
android.library.reference.1=../SherlockBar
|
|
||||||
dex.force.jumbo=true
|
dex.force.jumbo=true
|
||||||
|
|
BIN
OsmAnd/res/drawable-hdpi/ic_action_core_overflow_dark.png
Normal file
BIN
OsmAnd/res/drawable-hdpi/ic_action_core_overflow_dark.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 342 B |
BIN
OsmAnd/res/drawable-mdpi/ic_action_core_overflow_dark.png
Normal file
BIN
OsmAnd/res/drawable-mdpi/ic_action_core_overflow_dark.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 216 B |
BIN
OsmAnd/res/drawable-xhdpi/ic_action_core_overflow_dark.png
Normal file
BIN
OsmAnd/res/drawable-xhdpi/ic_action_core_overflow_dark.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 355 B |
BIN
OsmAnd/res/drawable-xxhdpi/ic_action_core_overflow_dark.png
Normal file
BIN
OsmAnd/res/drawable-xxhdpi/ic_action_core_overflow_dark.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 617 B |
|
@ -1,35 +1,44 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:id="@+id/package_delivered_layout"
|
android:id="@+id/package_delivered_layout">
|
||||||
android:background="@color/color_black"
|
|
||||||
android:weightSum="1">
|
|
||||||
|
|
||||||
<ImageView android:layout_marginLeft="8dp"
|
<ImageView android:id="@+id/waypoint_icon"
|
||||||
android:src="@drawable/list_favorite"
|
android:layout_marginLeft="8dp"
|
||||||
android:layout_width="wrap_content"
|
android:src="@drawable/list_favorite"
|
||||||
android:layout_gravity="center_vertical"
|
android:layout_width="25dp"
|
||||||
android:layout_height="wrap_content"/>
|
android:layout_gravity="center_vertical"
|
||||||
|
android:layout_height="wrap_content"/>
|
||||||
|
|
||||||
<TextView android:id="@+id/waypoint_text"
|
<TextView android:id="@+id/waypoint_text"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginLeft="8dp"
|
android:layout_marginLeft="8dp"
|
||||||
android:singleLine="true"
|
android:singleLine="true"
|
||||||
android:ellipsize="end"
|
android:ellipsize="end"
|
||||||
android:layout_gravity="center_vertical"
|
android:layout_gravity="center_vertical"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:textSize="16sp"
|
android:textSize="18sp"/>
|
||||||
android:text="@string/waypoint_reached_msg"/>
|
|
||||||
|
<ImageButton android:id="@+id/all_points"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
android:visibility="gone"
|
||||||
|
style="@style/Widget.Sherlock.ActionButton"
|
||||||
|
android:src="@drawable/ic_action_core_overflow_dark"/>
|
||||||
|
|
||||||
|
<ImageButton android:id="@+id/info_close"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
android:layout_marginRight="4dp"
|
||||||
|
style="@style/Widget.Sherlock.ActionButton"
|
||||||
|
android:focusable="false"
|
||||||
|
android:src="@drawable/ic_action_gremove_dark"/>
|
||||||
|
|
||||||
<Button android:id="@+id/info_close"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginLeft="8dp"
|
|
||||||
android:layout_marginRight="4dp"
|
|
||||||
android:text="@string/close"/>
|
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
|
@ -1935,4 +1935,5 @@ Afghanistan, Albania, Algeria, Andorra, Angola, Anguilla, Antigua and Barbuda, A
|
||||||
<string name="av_photo_play_sound">Play sound on photo shot</string>
|
<string name="av_photo_play_sound">Play sound on photo shot</string>
|
||||||
<string name="av_photo_play_sound_descr">Choose whether to play a sound when shooting photos</string>
|
<string name="av_photo_play_sound_descr">Choose whether to play a sound when shooting photos</string>
|
||||||
<string name="navigation_intent_invalid">Invalid format: %s</string>
|
<string name="navigation_intent_invalid">Invalid format: %s</string>
|
||||||
|
<string name="hide_all_waypoints">Remove all</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -29,6 +29,7 @@ import java.util.TimeZone;
|
||||||
|
|
||||||
import net.osmand.Location;
|
import net.osmand.Location;
|
||||||
import net.osmand.PlatformUtil;
|
import net.osmand.PlatformUtil;
|
||||||
|
import net.osmand.data.LocationPoint;
|
||||||
import net.osmand.util.Algorithms;
|
import net.osmand.util.Algorithms;
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
|
@ -81,7 +82,7 @@ public class GPXUtilities {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class WptPt extends GPXExtensions {
|
public static class WptPt extends GPXExtensions implements LocationPoint {
|
||||||
public double lat;
|
public double lat;
|
||||||
public double lon;
|
public double lon;
|
||||||
public String name = null;
|
public String name = null;
|
||||||
|
@ -95,7 +96,26 @@ public class GPXUtilities {
|
||||||
|
|
||||||
public WptPt() {
|
public WptPt() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getColor() {
|
||||||
|
return getColor(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public double getLatitude() {
|
||||||
|
return lat;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public double getLongitude() {
|
||||||
|
return lon;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
public WptPt(double lat, double lon, long time, double ele, double speed, double hdop) {
|
public WptPt(double lat, double lon, long time, double ele, double speed, double hdop) {
|
||||||
this.lat = lat;
|
this.lat = lat;
|
||||||
|
|
|
@ -78,7 +78,6 @@ public class OsmandApplication extends Application {
|
||||||
public static final String EXCEPTION_PATH = "exception.log"; //$NON-NLS-1$
|
public static final String EXCEPTION_PATH = "exception.log"; //$NON-NLS-1$
|
||||||
private static final org.apache.commons.logging.Log LOG = PlatformUtil.getLog(OsmandApplication.class);
|
private static final org.apache.commons.logging.Log LOG = PlatformUtil.getLog(OsmandApplication.class);
|
||||||
|
|
||||||
public MapActivity mapActivity;
|
|
||||||
|
|
||||||
ResourceManager resourceManager = null;
|
ResourceManager resourceManager = null;
|
||||||
PoiFiltersHelper poiFilters = null;
|
PoiFiltersHelper poiFilters = null;
|
||||||
|
@ -106,10 +105,11 @@ public class OsmandApplication extends Application {
|
||||||
|
|
||||||
private boolean applicationInitializing = false;
|
private boolean applicationInitializing = false;
|
||||||
private Locale prefferedLocale = null;
|
private Locale prefferedLocale = null;
|
||||||
|
|
||||||
SQLiteAPI sqliteAPI;
|
SQLiteAPI sqliteAPI;
|
||||||
BRouterServiceConnection bRouterServiceConnection;
|
BRouterServiceConnection bRouterServiceConnection;
|
||||||
|
|
||||||
|
MapActivity mapActivity;
|
||||||
@Override
|
@Override
|
||||||
public void onCreate() {
|
public void onCreate() {
|
||||||
long timeToStart = System.currentTimeMillis();
|
long timeToStart = System.currentTimeMillis();
|
||||||
|
@ -840,4 +840,12 @@ public class OsmandApplication extends Application {
|
||||||
getNavigationService().addUsageIntent(intent);
|
getNavigationService().addUsageIntent(intent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public MapActivity getMapActivity() {
|
||||||
|
return mapActivity;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMapActivity(MapActivity mapActivity) {
|
||||||
|
this.mapActivity = mapActivity;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,11 +2,15 @@ package net.osmand.plus;
|
||||||
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.Comparator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.concurrent.CopyOnWriteArrayList;
|
||||||
|
|
||||||
import net.osmand.Location;
|
import net.osmand.Location;
|
||||||
import net.osmand.StateChangedListener;
|
import net.osmand.StateChangedListener;
|
||||||
import net.osmand.data.LatLon;
|
import net.osmand.data.LatLon;
|
||||||
|
import net.osmand.data.LocationPoint;
|
||||||
import net.osmand.plus.routing.RoutingHelper;
|
import net.osmand.plus.routing.RoutingHelper;
|
||||||
import net.osmand.plus.routing.RouteProvider.RouteService;
|
import net.osmand.plus.routing.RouteProvider.RouteService;
|
||||||
import net.osmand.util.MapUtils;
|
import net.osmand.util.MapUtils;
|
||||||
|
@ -21,7 +25,9 @@ public class TargetPointsHelper {
|
||||||
private RoutingHelper routingHelper;
|
private RoutingHelper routingHelper;
|
||||||
private List<StateChangedListener<Void>> listeners = new ArrayList<StateChangedListener<Void>>();
|
private List<StateChangedListener<Void>> listeners = new ArrayList<StateChangedListener<Void>>();
|
||||||
private OsmandApplication ctx;
|
private OsmandApplication ctx;
|
||||||
|
private List<LocationPoint> visibleLocationPoints = new CopyOnWriteArrayList<LocationPoint>();
|
||||||
|
private long locationPointsModified;
|
||||||
|
|
||||||
public TargetPointsHelper(OsmandApplication ctx){
|
public TargetPointsHelper(OsmandApplication ctx){
|
||||||
this.ctx = ctx;
|
this.ctx = ctx;
|
||||||
this.settings = ctx.getSettings();
|
this.settings = ctx.getSettings();
|
||||||
|
@ -62,7 +68,50 @@ public class TargetPointsHelper {
|
||||||
public List<LatLon> getIntermediatePoints() {
|
public List<LatLon> getIntermediatePoints() {
|
||||||
return intermediatePoints;
|
return intermediatePoints;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<LocationPoint> getVisibleLocationPoints() {
|
||||||
|
return visibleLocationPoints;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addVisibleLocationPoint(LocationPoint lp) {
|
||||||
|
this.visibleLocationPoints.add(lp);
|
||||||
|
this.locationPointsModified = System.currentTimeMillis();
|
||||||
|
sortVisibleLocationPoints();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeAllVisiblePoints() {
|
||||||
|
this.locationPointsModified = System.currentTimeMillis();
|
||||||
|
visibleLocationPoints.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void sortVisibleLocationPoints() {
|
||||||
|
final Location lastLocation = ctx.getLocationProvider().getLastKnownLocation();
|
||||||
|
if(lastLocation != null) {
|
||||||
|
Collections.sort(this.visibleLocationPoints, new Comparator<LocationPoint>() {
|
||||||
|
@Override
|
||||||
|
public int compare(LocationPoint locationPoint, LocationPoint locationPoint2) {
|
||||||
|
double d1 = MapUtils.getDistance(lastLocation.getLatitude(), lastLocation.getLongitude(),
|
||||||
|
locationPoint.getLatitude(), locationPoint.getLongitude());
|
||||||
|
double d2 = MapUtils.getDistance(lastLocation.getLatitude(), lastLocation.getLongitude(),
|
||||||
|
locationPoint2.getLatitude(), locationPoint2.getLongitude());
|
||||||
|
return Double.compare(d1, d2);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
this.locationPointsModified = System.currentTimeMillis();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getLocationPointsModified() {
|
||||||
|
return locationPointsModified;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeVisibleLocationPoint(LocationPoint lp) {
|
||||||
|
this.visibleLocationPoints.remove(lp);
|
||||||
|
this.locationPointsModified = System.currentTimeMillis();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public List<LatLon> getIntermediatePointsWithTarget() {
|
public List<LatLon> getIntermediatePointsWithTarget() {
|
||||||
List<LatLon> res = new ArrayList<LatLon>();
|
List<LatLon> res = new ArrayList<LatLon>();
|
||||||
res.addAll(intermediatePoints);
|
res.addAll(intermediatePoints);
|
||||||
|
@ -71,7 +120,7 @@ public class TargetPointsHelper {
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<String> getIntermediatePointNamesWithTarget() {
|
public List<String> getIntermediatePointNamesWithTarget() {
|
||||||
List<String> res = new ArrayList<String>();
|
List<String> res = new ArrayList<String>();
|
||||||
res.addAll(intermediatePointNames);
|
res.addAll(intermediatePointNames);
|
||||||
|
@ -87,7 +136,7 @@ public class TargetPointsHelper {
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clear the local and persistent waypoints list and destination.
|
* Clear the local and persistent waypoints list and destination.
|
||||||
*/
|
*/
|
||||||
|
@ -108,8 +157,8 @@ public class TargetPointsHelper {
|
||||||
*/
|
*/
|
||||||
public void makeWayPointDestination(boolean updateRoute, int index){
|
public void makeWayPointDestination(boolean updateRoute, int index){
|
||||||
pointToNavigate = intermediatePoints.remove(index);
|
pointToNavigate = intermediatePoints.remove(index);
|
||||||
settings.setPointToNavigate(pointToNavigate.getLatitude(), pointToNavigate.getLongitude(),
|
settings.setPointToNavigate(pointToNavigate.getLatitude(), pointToNavigate.getLongitude(),
|
||||||
intermediatePointNames.remove(index));
|
intermediatePointNames.remove(index));
|
||||||
settings.deleteIntermediatePoint(index);
|
settings.deleteIntermediatePoint(index);
|
||||||
updateRouteAndReferesh(updateRoute);
|
updateRouteAndReferesh(updateRoute);
|
||||||
}
|
}
|
||||||
|
@ -122,13 +171,13 @@ public class TargetPointsHelper {
|
||||||
if(sz > 0) {
|
if(sz > 0) {
|
||||||
settings.deleteIntermediatePoint(sz- 1);
|
settings.deleteIntermediatePoint(sz- 1);
|
||||||
pointToNavigate = intermediatePoints.remove(sz - 1);
|
pointToNavigate = intermediatePoints.remove(sz - 1);
|
||||||
settings.setPointToNavigate(pointToNavigate.getLatitude(), pointToNavigate.getLongitude(),
|
settings.setPointToNavigate(pointToNavigate.getLatitude(), pointToNavigate.getLongitude(),
|
||||||
intermediatePointNames.remove(sz - 1));
|
intermediatePointNames.remove(sz - 1));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
settings.deleteIntermediatePoint(index);
|
settings.deleteIntermediatePoint(index);
|
||||||
intermediatePoints.remove(index);
|
intermediatePoints.remove(index);
|
||||||
intermediatePointNames.remove(index);
|
intermediatePointNames.remove(index);
|
||||||
}
|
}
|
||||||
updateRouteAndReferesh(updateRoute);
|
updateRouteAndReferesh(updateRoute);
|
||||||
}
|
}
|
||||||
|
@ -153,7 +202,7 @@ public class TargetPointsHelper {
|
||||||
settings.getIntermediatePoints(), loc);
|
settings.getIntermediatePoints(), loc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private Location wrap(LatLon l) {
|
private Location wrap(LatLon l) {
|
||||||
if(l == null) {
|
if(l == null) {
|
||||||
|
@ -164,12 +213,12 @@ public class TargetPointsHelper {
|
||||||
loc.setLongitude(l.getLongitude());
|
loc.setLongitude(l.getLongitude());
|
||||||
return loc;
|
return loc;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addListener(StateChangedListener<Void> l) {
|
public void addListener(StateChangedListener<Void> l) {
|
||||||
listeners.add(l);
|
listeners.add(l);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void updateListeners() {
|
private void updateListeners() {
|
||||||
for(StateChangedListener<Void> l : listeners) {
|
for(StateChangedListener<Void> l : listeners) {
|
||||||
l.stateChanged(null);
|
l.stateChanged(null);
|
||||||
|
@ -184,15 +233,15 @@ public class TargetPointsHelper {
|
||||||
readFromSettings(settings);
|
readFromSettings(settings);
|
||||||
updateRouteAndReferesh(updateRoute);
|
updateRouteAndReferesh(updateRoute);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void clearStartPoint(boolean updateRoute) {
|
public void clearStartPoint(boolean updateRoute) {
|
||||||
settings.clearPointToStart();
|
settings.clearPointToStart();
|
||||||
readFromSettings(settings);
|
readFromSettings(settings);
|
||||||
updateRouteAndReferesh(updateRoute);
|
updateRouteAndReferesh(updateRoute);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void reorderAllTargetPoints(List<LatLon> point,
|
public void reorderAllTargetPoints(List<LatLon> point,
|
||||||
List<String> names, boolean updateRoute){
|
List<String> names, boolean updateRoute){
|
||||||
settings.clearPointToNavigate();
|
settings.clearPointToNavigate();
|
||||||
if (point.size() > 0) {
|
if (point.size() > 0) {
|
||||||
|
@ -206,8 +255,8 @@ public class TargetPointsHelper {
|
||||||
readFromSettings(settings);
|
readFromSettings(settings);
|
||||||
updateRouteAndReferesh(updateRoute);
|
updateRouteAndReferesh(updateRoute);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public boolean hasTooLongDistanceToNavigate() {
|
public boolean hasTooLongDistanceToNavigate() {
|
||||||
if(settings.ROUTER_SERVICE.get() != RouteService.OSMAND) {
|
if(settings.ROUTER_SERVICE.get() != RouteService.OSMAND) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -227,24 +276,24 @@ public class TargetPointsHelper {
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void navigateToPoint(LatLon point, boolean updateRoute, int intermediate){
|
public void navigateToPoint(LatLon point, boolean updateRoute, int intermediate){
|
||||||
navigateToPoint(point, updateRoute, intermediate, null);
|
navigateToPoint(point, updateRoute, intermediate, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void navigateToPoint(LatLon point, boolean updateRoute, int intermediate, String historyName){
|
public void navigateToPoint(LatLon point, boolean updateRoute, int intermediate, String historyName){
|
||||||
if(point != null){
|
if(point != null){
|
||||||
if(intermediate < 0 || intermediate > intermediatePoints.size()) {
|
if(intermediate < 0 || intermediate > intermediatePoints.size()) {
|
||||||
if(intermediate > intermediatePoints.size()) {
|
if(intermediate > intermediatePoints.size()) {
|
||||||
LatLon pn = getPointToNavigate();
|
LatLon pn = getPointToNavigate();
|
||||||
if(pn != null) {
|
if(pn != null) {
|
||||||
settings.insertIntermediatePoint(pn.getLatitude(), pn.getLongitude(), getPointNavigateDescription(),
|
settings.insertIntermediatePoint(pn.getLatitude(), pn.getLongitude(), getPointNavigateDescription(),
|
||||||
intermediatePoints.size());
|
intermediatePoints.size());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
settings.setPointToNavigate(point.getLatitude(), point.getLongitude(), historyName);
|
settings.setPointToNavigate(point.getLatitude(), point.getLongitude(), historyName);
|
||||||
} else {
|
} else {
|
||||||
settings.insertIntermediatePoint(point.getLatitude(), point.getLongitude(), historyName,
|
settings.insertIntermediatePoint(point.getLatitude(), point.getLongitude(), historyName,
|
||||||
intermediate);
|
intermediate);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -254,7 +303,7 @@ public class TargetPointsHelper {
|
||||||
readFromSettings(settings);
|
readFromSettings(settings);
|
||||||
updateRouteAndReferesh(updateRoute);
|
updateRouteAndReferesh(updateRoute);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setStartPoint(LatLon startPoint, boolean updateRoute, String name) {
|
public void setStartPoint(LatLon startPoint, boolean updateRoute, String name) {
|
||||||
if(startPoint != null) {
|
if(startPoint != null) {
|
||||||
settings.setPointToStart(startPoint.getLatitude(), startPoint.getLongitude(), name);
|
settings.setPointToStart(startPoint.getLatitude(), startPoint.getLongitude(), name);
|
||||||
|
@ -264,7 +313,7 @@ public class TargetPointsHelper {
|
||||||
readFromSettings(settings);
|
readFromSettings(settings);
|
||||||
updateRouteAndReferesh(updateRoute);
|
updateRouteAndReferesh(updateRoute);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean checkPointToNavigate(){
|
public boolean checkPointToNavigate(){
|
||||||
if(pointToNavigate == null){
|
if(pointToNavigate == null){
|
||||||
ctx.showToastMessage(R.string.mark_final_location_first);
|
ctx.showToastMessage(R.string.mark_final_location_first);
|
||||||
|
@ -272,7 +321,7 @@ public class TargetPointsHelper {
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean checkPointToNavigateShort(){
|
public boolean checkPointToNavigateShort(){
|
||||||
if(pointToNavigate == null){
|
if(pointToNavigate == null){
|
||||||
ctx.showShortToastMessage(R.string.mark_final_location_first);
|
ctx.showShortToastMessage(R.string.mark_final_location_first);
|
||||||
|
@ -284,6 +333,4 @@ public class TargetPointsHelper {
|
||||||
public Location getPointToStartLocation() {
|
public Location getPointToStartLocation() {
|
||||||
return wrap(getPointToStart());
|
return wrap(getPointToStart());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@ package net.osmand.plus.activities;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import android.content.Intent;
|
||||||
import net.osmand.plus.GpxSelectionHelper;
|
import net.osmand.plus.GpxSelectionHelper;
|
||||||
import net.osmand.plus.OsmandApplication;
|
import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.OsmandSettings;
|
import net.osmand.plus.OsmandSettings;
|
||||||
|
@ -36,6 +37,10 @@ public class FavouritesActivity extends SherlockFragmentActivity {
|
||||||
private static final String FAVOURITES_INFO = "FAVOURITES_INFO";
|
private static final String FAVOURITES_INFO = "FAVOURITES_INFO";
|
||||||
private static final String TRACKS = "TRACKS";
|
private static final String TRACKS = "TRACKS";
|
||||||
private static final String SELECTED_TRACK = "SELECTED_TRACK";
|
private static final String SELECTED_TRACK = "SELECTED_TRACK";
|
||||||
|
public static int FAVORITES_TAB = 0;
|
||||||
|
public static int GPX_TAB = 1;
|
||||||
|
public static int SELECTED_GPX_TAB = 2;
|
||||||
|
public static String TAB_PARAM = "TAB_PARAM";
|
||||||
private TabsAdapter mTabsAdapter;
|
private TabsAdapter mTabsAdapter;
|
||||||
private TabSpec selectedTrack;
|
private TabSpec selectedTrack;
|
||||||
private TabHost tabHost;
|
private TabHost tabHost;
|
||||||
|
@ -85,7 +90,15 @@ public class FavouritesActivity extends SherlockFragmentActivity {
|
||||||
AvailableGPXFragment.class, null);
|
AvailableGPXFragment.class, null);
|
||||||
selectedTrack = mTabsAdapter.addTab(tabHost.newTabSpec(SELECTED_TRACK).setIndicator(getString(R.string.selected_track)),
|
selectedTrack = mTabsAdapter.addTab(tabHost.newTabSpec(SELECTED_TRACK).setIndicator(getString(R.string.selected_track)),
|
||||||
SelectedGPXFragment.class, null);
|
SelectedGPXFragment.class, null);
|
||||||
tabHost.setCurrentTab(tab);
|
Intent intent = getIntent();
|
||||||
|
if(intent != null) {
|
||||||
|
int tt = intent.getIntExtra(TAB_PARAM, -1);
|
||||||
|
if(tt >= 0) {
|
||||||
|
tabHost.setCurrentTab(tt);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
tabHost.setCurrentTab(tab);
|
||||||
|
}
|
||||||
updateSelectedTracks();
|
updateSelectedTracks();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -301,7 +301,7 @@ public class MapActivity extends AccessibleActivity {
|
||||||
}
|
}
|
||||||
|
|
||||||
settings.MAP_ACTIVITY_ENABLED.set(true);
|
settings.MAP_ACTIVITY_ENABLED.set(true);
|
||||||
app.mapActivity = this;
|
app.setMapActivity(this);
|
||||||
checkExternalStorage();
|
checkExternalStorage();
|
||||||
showAndHideMapPosition();
|
showAndHideMapPosition();
|
||||||
|
|
||||||
|
@ -560,7 +560,7 @@ public class MapActivity extends AccessibleActivity {
|
||||||
|
|
||||||
settings.setLastKnownMapZoom(mapView.getZoom());
|
settings.setLastKnownMapZoom(mapView.getZoom());
|
||||||
settings.MAP_ACTIVITY_ENABLED.set(false);
|
settings.MAP_ACTIVITY_ENABLED.set(false);
|
||||||
app.mapActivity = null;
|
app.setMapActivity(null);
|
||||||
app.getResourceManager().interruptRendering();
|
app.getResourceManager().interruptRendering();
|
||||||
app.getResourceManager().setBusyIndicator(null);
|
app.getResourceManager().setBusyIndicator(null);
|
||||||
OsmandPlugin.onMapActivityPause(this);
|
OsmandPlugin.onMapActivityPause(this);
|
||||||
|
|
|
@ -4,29 +4,24 @@ import java.io.File;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
import android.view.Gravity;
|
import android.view.Gravity;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.FrameLayout;
|
import android.widget.FrameLayout;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import net.osmand.data.LatLon;
|
import net.osmand.data.LatLon;
|
||||||
import net.osmand.plus.ApplicationMode;
|
import net.osmand.plus.*;
|
||||||
import net.osmand.plus.GPXUtilities;
|
|
||||||
import net.osmand.plus.GPXUtilities.GPXFile;
|
import net.osmand.plus.GPXUtilities.GPXFile;
|
||||||
import net.osmand.plus.GPXUtilities.Route;
|
import net.osmand.plus.GPXUtilities.Route;
|
||||||
import net.osmand.plus.GPXUtilities.WptPt;
|
import net.osmand.plus.GPXUtilities.WptPt;
|
||||||
import net.osmand.plus.OsmAndFormatter;
|
|
||||||
import net.osmand.plus.OsmandApplication;
|
|
||||||
import net.osmand.plus.OsmandPlugin;
|
|
||||||
import net.osmand.plus.R;
|
|
||||||
import net.osmand.plus.TargetPointsHelper;
|
|
||||||
import net.osmand.plus.activities.MapActivity;
|
import net.osmand.plus.activities.MapActivity;
|
||||||
|
import net.osmand.plus.sherpafy.WaypointDialogHelper;
|
||||||
import net.osmand.plus.views.MapInfoLayer;
|
import net.osmand.plus.views.MapInfoLayer;
|
||||||
import net.osmand.plus.views.OsmandMapLayer;
|
import net.osmand.plus.views.OsmandMapLayer;
|
||||||
import net.osmand.plus.views.OsmandMapTileView;
|
import net.osmand.plus.views.OsmandMapTileView;
|
||||||
import net.osmand.plus.views.mapwidgets.TextInfoWidget;
|
import net.osmand.plus.views.mapwidgets.TextInfoWidget;
|
||||||
import net.osmand.util.MapUtils;
|
import net.osmand.util.MapUtils;
|
||||||
import android.content.Intent;
|
|
||||||
import android.graphics.Paint;
|
import android.graphics.Paint;
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
import android.text.format.DateFormat;
|
import android.text.format.DateFormat;
|
||||||
|
@ -242,6 +237,8 @@ public class RoutePointsPlugin extends OsmandPlugin {
|
||||||
routeStepsControl.setOnClickListener(new View.OnClickListener() {
|
routeStepsControl.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
|
// FavouritesDbHelper fp = map.getMyApplication().getFavorites();
|
||||||
|
// app.getTargetPointsHelper().addVisibleLocationPoint(fp.getFavouritePoints().get(new Random().nextInt(fp.getFavouritePoints().size())));
|
||||||
Intent intent = new Intent(app, RoutePointsActivity.class);
|
Intent intent = new Intent(app, RoutePointsActivity.class);
|
||||||
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
app.startActivity(intent);
|
app.startActivity(intent);
|
||||||
|
@ -252,6 +249,7 @@ public class RoutePointsPlugin extends OsmandPlugin {
|
||||||
return routeStepsControl;
|
return routeStepsControl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public class RoutePoint {
|
public class RoutePoint {
|
||||||
boolean isNextNavigate;
|
boolean isNextNavigate;
|
||||||
int gpxOrder;
|
int gpxOrder;
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package net.osmand.plus.routing;
|
package net.osmand.plus.routing;
|
||||||
|
|
||||||
|
import com.actionbarsherlock.internal.nineoldandroids.animation.ObjectAnimator;
|
||||||
import gnu.trove.list.array.TIntArrayList;
|
import gnu.trove.list.array.TIntArrayList;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -13,6 +14,7 @@ import net.osmand.binary.BinaryMapRouteReaderAdapter.RouteRegion;
|
||||||
import net.osmand.binary.BinaryMapRouteReaderAdapter.RouteTypeRule;
|
import net.osmand.binary.BinaryMapRouteReaderAdapter.RouteTypeRule;
|
||||||
import net.osmand.data.DataTileManager;
|
import net.osmand.data.DataTileManager;
|
||||||
import net.osmand.data.LatLon;
|
import net.osmand.data.LatLon;
|
||||||
|
import net.osmand.data.LocationPoint;
|
||||||
import net.osmand.plus.ApplicationMode;
|
import net.osmand.plus.ApplicationMode;
|
||||||
import net.osmand.plus.GPXUtilities.WptPt;
|
import net.osmand.plus.GPXUtilities.WptPt;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
|
@ -30,7 +32,7 @@ public class RouteCalculationResult {
|
||||||
private final List<RouteDirectionInfo> directions;
|
private final List<RouteDirectionInfo> directions;
|
||||||
private final List<RouteSegmentResult> segments;
|
private final List<RouteSegmentResult> segments;
|
||||||
private final List<AlarmInfo> alarmInfo;
|
private final List<AlarmInfo> alarmInfo;
|
||||||
private final List<WptPt> waypoints;
|
private final List<LocationPoint> waypoints;
|
||||||
private final String errorMessage;
|
private final String errorMessage;
|
||||||
private final int[] listDistance;
|
private final int[] listDistance;
|
||||||
private final int[] intermediatePoints;
|
private final int[] intermediatePoints;
|
||||||
|
@ -59,11 +61,11 @@ public class RouteCalculationResult {
|
||||||
this.directions = new ArrayList<RouteDirectionInfo>();
|
this.directions = new ArrayList<RouteDirectionInfo>();
|
||||||
this.alarmInfo = new ArrayList<AlarmInfo>();
|
this.alarmInfo = new ArrayList<AlarmInfo>();
|
||||||
this.waypointIndexes = new int[0];
|
this.waypointIndexes = new int[0];
|
||||||
this.waypoints = new ArrayList<WptPt>();
|
this.waypoints = new ArrayList<LocationPoint>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public RouteCalculationResult(List<Location> list, List<RouteDirectionInfo> directions, RouteCalculationParams params,
|
public RouteCalculationResult(List<Location> list, List<RouteDirectionInfo> directions, RouteCalculationParams params,
|
||||||
DataTileManager<WptPt> waypointsTm) {
|
DataTileManager<? extends LocationPoint> waypointsTm) {
|
||||||
this.routingTime = 0;
|
this.routingTime = 0;
|
||||||
this.errorMessage = null;
|
this.errorMessage = null;
|
||||||
this.intermediatePoints = new int[params.intermediates == null ? 0 : params.intermediates.size()];
|
this.intermediatePoints = new int[params.intermediates == null ? 0 : params.intermediates.size()];
|
||||||
|
@ -89,12 +91,12 @@ public class RouteCalculationResult {
|
||||||
calculateIntermediateIndexes(params.ctx, this.locations, params.intermediates, localDirections, this.intermediatePoints);
|
calculateIntermediateIndexes(params.ctx, this.locations, params.intermediates, localDirections, this.intermediatePoints);
|
||||||
this.directions = Collections.unmodifiableList(localDirections);
|
this.directions = Collections.unmodifiableList(localDirections);
|
||||||
updateDirectionsTime(this.directions, this.listDistance);
|
updateDirectionsTime(this.directions, this.listDistance);
|
||||||
this.waypoints = new ArrayList<WptPt>();
|
this.waypoints = new ArrayList<LocationPoint>();
|
||||||
this.waypointIndexes = calculateWaypointIndexes(list, waypointsTm, waypoints);
|
this.waypointIndexes = calculateWaypointIndexes(list, waypointsTm, waypoints);
|
||||||
}
|
}
|
||||||
|
|
||||||
public RouteCalculationResult(List<RouteSegmentResult> list, Location start, LatLon end, List<LatLon> intermediates,
|
public RouteCalculationResult(List<RouteSegmentResult> list, Location start, LatLon end, List<LatLon> intermediates,
|
||||||
Context ctx, boolean leftSide, float routingTime) {
|
Context ctx, boolean leftSide, float routingTime,DataTileManager<LocationPoint> waypointsTm) {
|
||||||
this.routingTime = routingTime;
|
this.routingTime = routingTime;
|
||||||
List<RouteDirectionInfo> computeDirections = new ArrayList<RouteDirectionInfo>();
|
List<RouteDirectionInfo> computeDirections = new ArrayList<RouteDirectionInfo>();
|
||||||
this.errorMessage = null;
|
this.errorMessage = null;
|
||||||
|
@ -113,17 +115,18 @@ public class RouteCalculationResult {
|
||||||
this.directions = Collections.unmodifiableList(computeDirections);
|
this.directions = Collections.unmodifiableList(computeDirections);
|
||||||
updateDirectionsTime(this.directions, this.listDistance);
|
updateDirectionsTime(this.directions, this.listDistance);
|
||||||
this.alarmInfo = Collections.unmodifiableList(alarms);
|
this.alarmInfo = Collections.unmodifiableList(alarms);
|
||||||
this.waypointIndexes = new int[0];
|
this.waypoints = new ArrayList<LocationPoint>();
|
||||||
this.waypoints = new ArrayList<WptPt>();
|
|
||||||
|
this.waypointIndexes = calculateWaypointIndexes(this.locations, waypointsTm, waypoints);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<WptPt> getWaypointsToAnnounce(Location loc) {
|
public List<LocationPoint> getWaypointsToAnnounce(Location loc) {
|
||||||
if (currentWaypointGPX != lastWaypointGPX && loc != null) {
|
if (currentWaypointGPX != lastWaypointGPX && loc != null) {
|
||||||
ArrayList<WptPt> points = new ArrayList<WptPt>();
|
ArrayList<LocationPoint> points = new ArrayList<LocationPoint>();
|
||||||
Location next = locations.get(currentRoute);
|
Location next = locations.get(currentRoute);
|
||||||
float dist = loc.distanceTo(next);
|
float dist = loc.distanceTo(next);
|
||||||
while (currentWaypointGPX < lastWaypointGPX) {
|
while (currentWaypointGPX < lastWaypointGPX) {
|
||||||
WptPt w = waypoints.get(currentWaypointGPX);
|
WptPt w = (WptPt) waypoints.get(currentWaypointGPX);
|
||||||
if(MapUtils.getDistance(w.lat, w.lon, next.getLatitude(), next.getLongitude()) > dist + 50) {
|
if(MapUtils.getDistance(w.lat, w.lon, next.getLatitude(), next.getLongitude()) > dist + 50) {
|
||||||
currentWaypointGPX++;
|
currentWaypointGPX++;
|
||||||
} else {
|
} else {
|
||||||
|
@ -131,7 +134,7 @@ public class RouteCalculationResult {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
while (currentWaypointGPX < lastWaypointGPX) {
|
while (currentWaypointGPX < lastWaypointGPX) {
|
||||||
WptPt w = waypoints.get(currentWaypointGPX);
|
WptPt w = (WptPt) waypoints.get(currentWaypointGPX);
|
||||||
if(MapUtils.getDistance(w.lat, w.lon, loc.getLatitude(), next.getLongitude()) < 60) {
|
if(MapUtils.getDistance(w.lat, w.lon, loc.getLatitude(), next.getLongitude()) < 60) {
|
||||||
currentWaypointGPX++;
|
currentWaypointGPX++;
|
||||||
points.add(w);
|
points.add(w);
|
||||||
|
@ -519,27 +522,27 @@ public class RouteCalculationResult {
|
||||||
* PREPARATION
|
* PREPARATION
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
private int[] calculateWaypointIndexes(List<Location> list, DataTileManager<WptPt> waypointsTm, List<WptPt> waypoints) {
|
private int[] calculateWaypointIndexes(List<Location> list, DataTileManager<? extends LocationPoint> waypointsTm, List<LocationPoint> waypoints) {
|
||||||
if(waypointsTm == null || waypointsTm.isEmpty() || list.size() == 0) {
|
if(waypointsTm == null || waypointsTm.isEmpty() || list.size() == 0) {
|
||||||
return new int[0];
|
return new int[0];
|
||||||
}
|
}
|
||||||
TIntArrayList ls = new TIntArrayList();
|
TIntArrayList ls = new TIntArrayList();
|
||||||
Location loc = list.get(0);
|
Location loc = list.get(0);
|
||||||
Location ploc = list.get(0);
|
Location ploc = list.get(0);
|
||||||
Set<WptPt> added = new HashSet<WptPt>();
|
Set<LocationPoint> added = new HashSet<LocationPoint>();
|
||||||
int prev31x = MapUtils.get31TileNumberX(loc.getLatitude());
|
int prev31x = MapUtils.get31TileNumberX(loc.getLatitude());
|
||||||
int prev31y = MapUtils.get31TileNumberY(loc.getLongitude());
|
int prev31y = MapUtils.get31TileNumberY(loc.getLongitude());
|
||||||
for(int j = 1; j < list.size(); j++) {
|
for(int j = 1; j < list.size(); j++) {
|
||||||
loc = list.get(j);
|
loc = list.get(j);
|
||||||
int t31x = MapUtils.get31TileNumberX(loc.getLatitude());
|
int t31x = MapUtils.get31TileNumberX(loc.getLatitude());
|
||||||
int t31y = MapUtils.get31TileNumberY(loc.getLongitude());
|
int t31y = MapUtils.get31TileNumberY(loc.getLongitude());
|
||||||
List<WptPt> ws = waypointsTm.getObjects(Math.min(prev31x, t31x) - Math.abs(t31x - prev31x) / 4,
|
List<? extends LocationPoint> ws = waypointsTm.getObjects(Math.min(prev31x, t31x) - Math.abs(t31x - prev31x) / 4,
|
||||||
Math.min(prev31y, t31y) - Math.abs(t31y - prev31y) / 4,
|
Math.min(prev31y, t31y) - Math.abs(t31y - prev31y) / 4,
|
||||||
Math.max(prev31x, t31x) + Math.abs(t31x - prev31x) / 4,
|
Math.max(prev31x, t31x) + Math.abs(t31x - prev31x) / 4,
|
||||||
Math.max(prev31y, t31y) + Math.abs(t31y - prev31y) / 4);
|
Math.max(prev31y, t31y) + Math.abs(t31y - prev31y) / 4);
|
||||||
for(WptPt w : ws) {
|
for(LocationPoint w : ws) {
|
||||||
if (added.contains(w)) {
|
if (added.contains(w)) {
|
||||||
double ds = MapUtils.getOrthogonalDistance(w.lat, w.lon, ploc.getLatitude(), ploc.getLongitude(), loc.getLatitude(),
|
double ds = MapUtils.getOrthogonalDistance(w.getLatitude(), w.getLongitude(), ploc.getLatitude(), ploc.getLongitude(), loc.getLatitude(),
|
||||||
loc.getLongitude());
|
loc.getLongitude());
|
||||||
if (ds < 80) {
|
if (ds < 80) {
|
||||||
ls.add(j);
|
ls.add(j);
|
||||||
|
|
|
@ -22,10 +22,12 @@ import javax.xml.parsers.DocumentBuilderFactory;
|
||||||
import javax.xml.parsers.FactoryConfigurationError;
|
import javax.xml.parsers.FactoryConfigurationError;
|
||||||
import javax.xml.parsers.ParserConfigurationException;
|
import javax.xml.parsers.ParserConfigurationException;
|
||||||
|
|
||||||
|
import com.actionbarsherlock.internal.nineoldandroids.animation.ObjectAnimator;
|
||||||
import net.osmand.Location;
|
import net.osmand.Location;
|
||||||
import net.osmand.PlatformUtil;
|
import net.osmand.PlatformUtil;
|
||||||
import net.osmand.binary.BinaryMapIndexReader;
|
import net.osmand.binary.BinaryMapIndexReader;
|
||||||
import net.osmand.data.DataTileManager;
|
import net.osmand.data.DataTileManager;
|
||||||
|
import net.osmand.data.FavouritePoint;
|
||||||
import net.osmand.data.LatLon;
|
import net.osmand.data.LatLon;
|
||||||
import net.osmand.plus.ApplicationMode;
|
import net.osmand.plus.ApplicationMode;
|
||||||
import net.osmand.plus.GPXUtilities;
|
import net.osmand.plus.GPXUtilities;
|
||||||
|
@ -775,8 +777,13 @@ public class RouteProvider {
|
||||||
// something really strange better to see that message on the scren
|
// something really strange better to see that message on the scren
|
||||||
return emptyResult();
|
return emptyResult();
|
||||||
} else {
|
} else {
|
||||||
|
DataTileManager mngr = new DataTileManager<Object>(17);
|
||||||
|
List<FavouritePoint> points = params.ctx.getFavorites().getFavouritePoints();
|
||||||
|
for(FavouritePoint point : points){
|
||||||
|
mngr.registerObject(point.getLatitude(), point.getLongitude(), point);
|
||||||
|
}
|
||||||
RouteCalculationResult res = new RouteCalculationResult(result, params.start, params.end,
|
RouteCalculationResult res = new RouteCalculationResult(result, params.start, params.end,
|
||||||
params.intermediates, params.ctx, params.leftSide, ctx.routingTime);
|
params.intermediates, params.ctx, params.leftSide, ctx.routingTime, mngr);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
} catch (RuntimeException e) {
|
} catch (RuntimeException e) {
|
||||||
|
|
|
@ -10,6 +10,7 @@ import net.osmand.binary.BinaryMapRouteReaderAdapter.RouteRegion;
|
||||||
import net.osmand.binary.BinaryMapRouteReaderAdapter.RouteTypeRule;
|
import net.osmand.binary.BinaryMapRouteReaderAdapter.RouteTypeRule;
|
||||||
import net.osmand.binary.RouteDataObject;
|
import net.osmand.binary.RouteDataObject;
|
||||||
import net.osmand.data.LatLon;
|
import net.osmand.data.LatLon;
|
||||||
|
import net.osmand.data.LocationPoint;
|
||||||
import net.osmand.plus.ApplicationMode;
|
import net.osmand.plus.ApplicationMode;
|
||||||
import net.osmand.plus.GPXUtilities.GPXFile;
|
import net.osmand.plus.GPXUtilities.GPXFile;
|
||||||
import net.osmand.plus.GPXUtilities.WptPt;
|
import net.osmand.plus.GPXUtilities.WptPt;
|
||||||
|
@ -78,8 +79,6 @@ public class RoutingHelper {
|
||||||
|
|
||||||
private RouteCalculationProgressCallback progressRoute;
|
private RouteCalculationProgressCallback progressRoute;
|
||||||
|
|
||||||
WaypointDialogHelper dialogHelper;
|
|
||||||
|
|
||||||
// private ProgressBar progress;
|
// private ProgressBar progress;
|
||||||
// private Handler progressHandler;
|
// private Handler progressHandler;
|
||||||
|
|
||||||
|
@ -91,7 +90,6 @@ public class RoutingHelper {
|
||||||
this.app = context;
|
this.app = context;
|
||||||
settings = context.getSettings();
|
settings = context.getSettings();
|
||||||
voiceRouter = new VoiceRouter(this, settings, player);
|
voiceRouter = new VoiceRouter(this, settings, player);
|
||||||
dialogHelper = new WaypointDialogHelper(context);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isFollowingMode() {
|
public boolean isFollowingMode() {
|
||||||
|
@ -322,17 +320,17 @@ public class RoutingHelper {
|
||||||
|
|
||||||
private void announceGpxWaypoints(Location currentLocation) {
|
private void announceGpxWaypoints(Location currentLocation) {
|
||||||
if (currentLocation != null) {
|
if (currentLocation != null) {
|
||||||
List<WptPt> wpt = route.getWaypointsToAnnounce(currentLocation);
|
List<LocationPoint> wpt = route.getWaypointsToAnnounce(currentLocation);
|
||||||
if (wpt.size() > 0) {
|
if (wpt.size() > 0) {
|
||||||
String s = "";
|
String s = "";
|
||||||
for (WptPt w : wpt) {
|
for (LocationPoint w : wpt) {
|
||||||
if(!Algorithms.isEmpty(w.name)) {
|
if(!Algorithms.isEmpty(w.getName())) {
|
||||||
s = w.name +",";
|
s = w.getName() +",";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(!Algorithms.isEmpty(s)) {
|
if(!Algorithms.isEmpty(s)) {
|
||||||
voiceRouter.announceWaypoint(s);
|
voiceRouter.announceWaypoint(s);
|
||||||
dialogHelper.addDialogWithShift(wpt.get(0));
|
// dialogHelper.addWptDialog(wpt.get(0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,18 +1,32 @@
|
||||||
package net.osmand.plus.sherpafy;
|
package net.osmand.plus.sherpafy;
|
||||||
|
|
||||||
|
import android.app.AlertDialog;
|
||||||
|
import android.app.Dialog;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.content.DialogInterface;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.graphics.Color;
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
import android.os.SystemClock;
|
import android.os.SystemClock;
|
||||||
|
import android.text.Spannable;
|
||||||
|
import android.text.style.ForegroundColorSpan;
|
||||||
|
import android.util.TypedValue;
|
||||||
import android.view.Gravity;
|
import android.view.Gravity;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
import android.widget.*;
|
import android.widget.*;
|
||||||
import net.osmand.plus.GPXUtilities;
|
import net.osmand.Location;
|
||||||
import net.osmand.plus.OsmandApplication;
|
import net.osmand.data.LatLon;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.data.LocationPoint;
|
||||||
|
import net.osmand.plus.*;
|
||||||
|
import net.osmand.plus.activities.FavouritesActivity;
|
||||||
import net.osmand.plus.activities.MapActivity;
|
import net.osmand.plus.activities.MapActivity;
|
||||||
|
import net.osmand.plus.base.FavoriteImageDrawable;
|
||||||
import net.osmand.plus.views.MapControlsLayer;
|
import net.osmand.plus.views.MapControlsLayer;
|
||||||
|
import net.osmand.util.MapUtils;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Denis on 25.07.2014.
|
* Created by Denis on 25.07.2014.
|
||||||
|
@ -21,80 +35,116 @@ public class WaypointDialogHelper {
|
||||||
private MapActivity mapActivity;
|
private MapActivity mapActivity;
|
||||||
private OsmandApplication app;
|
private OsmandApplication app;
|
||||||
private FrameLayout mainLayout;
|
private FrameLayout mainLayout;
|
||||||
|
private TargetPointsHelper targetPointsHelper;
|
||||||
|
|
||||||
public static boolean OVERLAP_LAYOUT = true;
|
public static boolean OVERLAP_LAYOUT = true;
|
||||||
|
private long uiModified;
|
||||||
|
private View closePointDialog;
|
||||||
|
|
||||||
public WaypointDialogHelper(OsmandApplication app) {
|
public WaypointDialogHelper(MapActivity mapActivity) {
|
||||||
this.app = app;
|
this.app = mapActivity.getMyApplication();
|
||||||
if (mapActivity != null){
|
targetPointsHelper = this.app.getTargetPointsHelper();
|
||||||
this.mainLayout = (FrameLayout) ((FrameLayout) mapActivity.getLayout()).getChildAt(0);
|
this.mapActivity = mapActivity;
|
||||||
this.mapActivity = app.mapActivity;
|
this.mainLayout = (FrameLayout) ((FrameLayout) mapActivity.getLayout()).getChildAt(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateDialog() {
|
||||||
|
List<LocationPoint> vlp = targetPointsHelper.getVisibleLocationPoints();
|
||||||
|
long locationPointsModified = targetPointsHelper.getLocationPointsModified();
|
||||||
|
if (locationPointsModified != uiModified) {
|
||||||
|
uiModified = locationPointsModified;
|
||||||
|
if (vlp.isEmpty()) {
|
||||||
|
removeDialog();
|
||||||
|
} else {
|
||||||
|
final LocationPoint point = vlp.get(0);
|
||||||
|
boolean created = false;
|
||||||
|
if (closePointDialog == null) {
|
||||||
|
created = true;
|
||||||
|
final LayoutInflater vi = (LayoutInflater) app.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||||
|
closePointDialog = vi.inflate(R.layout.waypoint_reached, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
createView(closePointDialog, point);
|
||||||
|
closePointDialog.setBackgroundColor(mapActivity.getResources().getColor(R.color.color_black));
|
||||||
|
((TextView)closePointDialog.findViewById(R.id.waypoint_text)).setTextColor(Color.WHITE);
|
||||||
|
View all = closePointDialog.findViewById(R.id.all_points);
|
||||||
|
all.setVisibility(vlp.size() <= 1 ? View.GONE : View.VISIBLE);
|
||||||
|
all.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View view) {
|
||||||
|
showAllDialog();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
View btnN = closePointDialog.findViewById(R.id.info_close);
|
||||||
|
btnN.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View view) {
|
||||||
|
targetPointsHelper.removeVisibleLocationPoint(point);
|
||||||
|
updateDialog();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if (created) {
|
||||||
|
mainLayout.addView(closePointDialog, getDialogLayoutParams());
|
||||||
|
waitBeforeLayoutIsResized(closePointDialog);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addDialogWithShift(GPXUtilities.WptPt point) {
|
private void createView(View localView, final LocationPoint point) {
|
||||||
//if map activity is null - try to get it from app again
|
TextView text = (TextView) localView.findViewById(R.id.waypoint_text);
|
||||||
if (mapActivity == null){
|
|
||||||
mapActivity = app.mapActivity;
|
|
||||||
|
|
||||||
if (mapActivity != null){
|
|
||||||
mainLayout = (FrameLayout) ((FrameLayout) mapActivity.getLayout()).getChildAt(0);
|
|
||||||
} else {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.WRAP_CONTENT);
|
|
||||||
params.gravity = Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL;
|
|
||||||
final LayoutInflater vi = (LayoutInflater) app.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
|
||||||
View reachedView = vi.inflate(R.layout.waypoint_reached, null);
|
|
||||||
|
|
||||||
TextView text = (TextView) reachedView.findViewById(R.id.waypoint_text);
|
|
||||||
text.setText(point != null ? point.name : "Point");
|
|
||||||
text.setOnClickListener(new View.OnClickListener() {
|
text.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
final Intent favorites = new Intent(mapActivity, app.getAppCustomization().getFavoritesActivity());
|
itemClick(point);
|
||||||
favorites.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
|
|
||||||
mapActivity.startActivity(favorites);
|
|
||||||
removeDialog(view);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Button btnN = (Button) reachedView.findViewById(R.id.info_close);
|
((ImageView) localView.findViewById(R.id.waypoint_icon)).setImageDrawable(FavoriteImageDrawable.getOrCreate(mapActivity, point.getColor()));
|
||||||
btnN.setOnClickListener(new View.OnClickListener() {
|
Location lastKnownMapLocation = app.getLocationProvider().getLastKnownLocation();
|
||||||
@Override
|
// LatLon lastKnownMapLocation = app.getSettings().getLastKnownMapLocation();
|
||||||
public void onClick(View view) {
|
String distance;
|
||||||
removeDialog(view);
|
if (lastKnownMapLocation != null) {
|
||||||
}
|
int dist = (int) (MapUtils.getDistance(point.getLatitude(), point.getLongitude(),
|
||||||
});
|
lastKnownMapLocation.getLatitude(), lastKnownMapLocation.getLongitude()));
|
||||||
|
distance = OsmAndFormatter.getFormattedDistance(dist, app) + " ";
|
||||||
if (reachedView != null && mainLayout != null) {
|
} else {
|
||||||
mainLayout.addView(reachedView, params);
|
distance = "";
|
||||||
waitBeforeLayoutIsResized(reachedView);
|
}
|
||||||
|
text.setText(distance + point.getName(), TextView.BufferType.SPANNABLE);
|
||||||
|
if (distance.length() > 0) {
|
||||||
|
((Spannable) text.getText()).setSpan(
|
||||||
|
new ForegroundColorSpan(mapActivity.getResources().getColor(R.color.color_distance)), 0, distance.length() - 1,
|
||||||
|
0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeDialog(View child){
|
private void itemClick(LocationPoint point) {
|
||||||
if (child == null || child.getParent() == null) {
|
final Intent favorites = new Intent(mapActivity, app.getAppCustomization().getFavoritesActivity());
|
||||||
return;
|
favorites.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
|
||||||
}
|
favorites.putExtra(FavouritesActivity.TAB_PARAM,
|
||||||
|
point instanceof GPXUtilities.WptPt ? FavouritesActivity.GPX_TAB : FavouritesActivity.FAVORITES_TAB);
|
||||||
|
mapActivity.startActivity(favorites);
|
||||||
|
}
|
||||||
|
|
||||||
View parent = (View) child.getParent();
|
public void removeDialog() {
|
||||||
if (parent == null) {
|
if (closePointDialog != null) {
|
||||||
return;
|
mainLayout.removeView(closePointDialog);
|
||||||
|
closePointDialog = null;
|
||||||
|
shiftButtons(0);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (mainLayout != null) {
|
private FrameLayout.LayoutParams getDialogLayoutParams() {
|
||||||
mainLayout.removeView(parent);
|
FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.WRAP_CONTENT);
|
||||||
if (checkIfDialogExists() && OVERLAP_LAYOUT) {
|
params.gravity = Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL;
|
||||||
shiftButtons();
|
return params;
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean checkIfDialogExists() {
|
private boolean checkIfDialogExists() {
|
||||||
if (mainLayout == null){
|
if (mainLayout == null) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -104,14 +154,10 @@ public class WaypointDialogHelper {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void shiftButtons() {
|
private void shiftButtons(int height) {
|
||||||
if (mainLayout == null || mapActivity == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
MapControlsLayer mapControls = mapActivity.getMapLayers().getMapControlsLayer();
|
MapControlsLayer mapControls = mapActivity.getMapLayers().getMapControlsLayer();
|
||||||
if (mapControls != null){
|
if (mapControls != null) {
|
||||||
mapControls.shiftControl();
|
mapControls.shiftLayout(height);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -136,9 +182,70 @@ public class WaypointDialogHelper {
|
||||||
|
|
||||||
protected void onPostExecute(Void result) {
|
protected void onPostExecute(Void result) {
|
||||||
if (height > 0 && OVERLAP_LAYOUT) {
|
if (height > 0 && OVERLAP_LAYOUT) {
|
||||||
shiftButtons();
|
shiftButtons(height);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}.execute(reachedView);
|
}.execute(reachedView);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void showAllDialog(){
|
||||||
|
final List<LocationPoint> visibleLocationPoints = targetPointsHelper.getVisibleLocationPoints();
|
||||||
|
final ArrayAdapter<LocationPoint> listAdapter = new ArrayAdapter<LocationPoint>(mapActivity, R.layout.waypoint_reached, R.id.title,
|
||||||
|
visibleLocationPoints) {
|
||||||
|
@Override
|
||||||
|
public View getView(final int position, View convertView, ViewGroup parent) {
|
||||||
|
// User super class to create the View
|
||||||
|
View v = convertView;
|
||||||
|
if (v == null) {
|
||||||
|
v = mapActivity.getLayoutInflater().inflate(R.layout.waypoint_reached, null);
|
||||||
|
int vl = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 32, mapActivity.getResources()
|
||||||
|
.getDisplayMetrics());
|
||||||
|
final LinearLayout.LayoutParams ll = new LinearLayout.LayoutParams(vl, vl);
|
||||||
|
ll.setMargins(vl / 4, vl / 4, vl / 4, vl / 4);
|
||||||
|
v.findViewById(R.id.waypoint_icon).setLayoutParams(ll);
|
||||||
|
}
|
||||||
|
createView(v, getItem(position));
|
||||||
|
|
||||||
|
View remove = v.findViewById(R.id.info_close);
|
||||||
|
((ImageButton) remove).setImageDrawable(mapActivity.getResources().getDrawable(
|
||||||
|
app.getSettings().isLightContent()? R.drawable.ic_action_gremove_light:
|
||||||
|
R.drawable.ic_action_gremove_dark));
|
||||||
|
remove.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View view) {
|
||||||
|
LocationPoint point = targetPointsHelper.getVisibleLocationPoints().get(position);
|
||||||
|
remove(point);
|
||||||
|
targetPointsHelper.removeVisibleLocationPoint(point);
|
||||||
|
notifyDataSetChanged();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return v;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
ListView listView = new ListView(mapActivity);
|
||||||
|
listView.setAdapter(listAdapter);
|
||||||
|
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
|
||||||
|
itemClick(visibleLocationPoints.get(i));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Dialog dlg = new Dialog(mapActivity);
|
||||||
|
// dlg.setContentView(listView);
|
||||||
|
// dlg.show();
|
||||||
|
AlertDialog.Builder builder = new AlertDialog.Builder(mapActivity);
|
||||||
|
builder.setView(listView);
|
||||||
|
builder.setPositiveButton(R.string.default_buttons_ok, null);
|
||||||
|
builder.setNegativeButton(mapActivity.getString(R.string.hide_all_waypoints), new DialogInterface.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(DialogInterface dialogInterface, int i) {
|
||||||
|
targetPointsHelper.removeAllVisiblePoints();
|
||||||
|
updateDialog();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
builder.show();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,7 @@ import net.osmand.plus.OsmandSettings.CommonPreference;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import net.osmand.plus.activities.MapActivity;
|
import net.osmand.plus.activities.MapActivity;
|
||||||
import net.osmand.plus.routing.RoutingHelper;
|
import net.osmand.plus.routing.RoutingHelper;
|
||||||
|
import net.osmand.plus.sherpafy.WaypointDialogHelper;
|
||||||
import net.osmand.plus.views.controls.MapRoutePlanControl;
|
import net.osmand.plus.views.controls.MapRoutePlanControl;
|
||||||
import net.osmand.plus.views.controls.MapRoutePreferencesControl;
|
import net.osmand.plus.views.controls.MapRoutePreferencesControl;
|
||||||
import net.osmand.plus.views.controls.MapCancelControl;
|
import net.osmand.plus.views.controls.MapCancelControl;
|
||||||
|
@ -60,10 +61,12 @@ public class MapControlsLayer extends OsmandMapLayer {
|
||||||
private LinearLayout transparencyBarLayout;
|
private LinearLayout transparencyBarLayout;
|
||||||
private static CommonPreference<Integer> settingsToTransparency;
|
private static CommonPreference<Integer> settingsToTransparency;
|
||||||
private OsmandSettings settings;
|
private OsmandSettings settings;
|
||||||
|
private WaypointDialogHelper waypointDialogHelper;
|
||||||
|
|
||||||
public MapControlsLayer(MapActivity activity){
|
public MapControlsLayer(MapActivity activity){
|
||||||
this.mapActivity = activity;
|
this.mapActivity = activity;
|
||||||
settings = activity.getMyApplication().getSettings();
|
settings = activity.getMyApplication().getSettings();
|
||||||
|
waypointDialogHelper = new WaypointDialogHelper(activity);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -177,9 +180,11 @@ public class MapControlsLayer extends OsmandMapLayer {
|
||||||
checkVisibilityAndDraw(showRouteCalculationControls, zoomSideControls, canvas, tileBox, nightMode);
|
checkVisibilityAndDraw(showRouteCalculationControls, zoomSideControls, canvas, tileBox, nightMode);
|
||||||
|
|
||||||
// the last one to check other controls visibility
|
// the last one to check other controls visibility
|
||||||
int vmargin = mapNavigationControl.isVisible() || zoomControls.isVisible() ? zoomControls.getHeight() : 0;
|
int vmargin = mapNavigationControl.isVisible() || zoomControls.isVisible() ?
|
||||||
|
(zoomControls.getHeight() + zoomControls.getTotalVerticalMargin()): 0;
|
||||||
rulerControl.setVerticalMargin(vmargin);
|
rulerControl.setVerticalMargin(vmargin);
|
||||||
checkVisibilityAndDraw(true, rulerControl, canvas, tileBox, nightMode);
|
checkVisibilityAndDraw(true, rulerControl, canvas, tileBox, nightMode);
|
||||||
|
waypointDialogHelper.updateDialog();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updatextColor(int textColor, int shadowColor, MapControls... mc) {
|
private void updatextColor(int textColor, int shadowColor, MapControls... mc) {
|
||||||
|
@ -190,7 +195,7 @@ public class MapControlsLayer extends OsmandMapLayer {
|
||||||
|
|
||||||
private void checkVisibilityAndDraw(boolean visibility, MapControls controls, Canvas canvas,
|
private void checkVisibilityAndDraw(boolean visibility, MapControls controls, Canvas canvas,
|
||||||
RotatedTileBox tileBox, DrawSettings nightMode) {
|
RotatedTileBox tileBox, DrawSettings nightMode) {
|
||||||
if(visibility != controls.isVisible()){
|
if(visibility != controls.isVisible() ){
|
||||||
if(visibility) {
|
if(visibility) {
|
||||||
controls.show((FrameLayout) mapActivity.getMapView().getParent());
|
controls.show((FrameLayout) mapActivity.getMapView().getParent());
|
||||||
} else {
|
} else {
|
||||||
|
@ -301,41 +306,21 @@ public class MapControlsLayer extends OsmandMapLayer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void shiftControl() {
|
public void shiftLayout(int height) {
|
||||||
boolean routePlanningMode = false;
|
|
||||||
RoutingHelper rh = mapActivity.getRoutingHelper();
|
|
||||||
if(rh.isRoutePlanningMode() ) {
|
|
||||||
routePlanningMode = true;
|
|
||||||
} else if((rh.isRouteCalculated() || rh.isRouteBeingCalculated()) &&
|
|
||||||
!rh.isFollowingMode()){
|
|
||||||
routePlanningMode = true;
|
|
||||||
}
|
|
||||||
FrameLayout parent = (FrameLayout) mapActivity.getMapView().getParent();
|
FrameLayout parent = (FrameLayout) mapActivity.getMapView().getParent();
|
||||||
|
parent.requestLayout();
|
||||||
if (routePlanningMode){
|
for(MapControls mc : allControls) {
|
||||||
//hiding controls
|
if(mc.isBottom()){
|
||||||
mapSmallMenuControls.forceHide(parent);
|
mc.setExtraVerticalMargin(height);
|
||||||
mapCancelNavigationControl.forceHide(parent);
|
if( mc.isVisible()) {
|
||||||
mapInfoNavigationControl.forceHide(parent);
|
mc.forceHide(parent);
|
||||||
mapAppModeControl.forceHide(parent);
|
mc.show(parent);
|
||||||
mapNavigationControl.forceHide(parent);
|
}
|
||||||
zoomSideControls.forceHide(parent);
|
}
|
||||||
|
|
||||||
//showing controls again
|
|
||||||
mapSmallMenuControls.show(parent);
|
|
||||||
mapCancelNavigationControl.show(parent);
|
|
||||||
mapInfoNavigationControl.show(parent);
|
|
||||||
mapAppModeControl.show(parent);
|
|
||||||
mapNavigationControl.show(parent);
|
|
||||||
zoomSideControls.show(parent);
|
|
||||||
} else {
|
|
||||||
//hiding controls
|
|
||||||
zoomControls.forceHide(parent);
|
|
||||||
mapMenuControls.forceHide(parent);
|
|
||||||
|
|
||||||
//showing controls again
|
|
||||||
zoomControls.show(parent);
|
|
||||||
mapMenuControls.show(parent);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public WaypointDialogHelper getWaypointDialogHelper() {
|
||||||
|
return waypointDialogHelper;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,7 +33,8 @@ public abstract class MapControls {
|
||||||
protected int width;
|
protected int width;
|
||||||
protected int height;
|
protected int height;
|
||||||
protected Runnable notifyClick;
|
protected Runnable notifyClick;
|
||||||
|
private int extraVerticalMargin;
|
||||||
|
|
||||||
public MapControls(MapActivity mapActivity, Handler showUIHandler, float scaleCoefficient) {
|
public MapControls(MapActivity mapActivity, Handler showUIHandler, float scaleCoefficient) {
|
||||||
this.mapActivity = mapActivity;
|
this.mapActivity = mapActivity;
|
||||||
this.showUIHandler = showUIHandler;
|
this.showUIHandler = showUIHandler;
|
||||||
|
@ -58,12 +59,15 @@ public abstract class MapControls {
|
||||||
applyAttributes(ctx, parent, button, stringId, resourceId, 0);
|
applyAttributes(ctx, parent, button, stringId, resourceId, 0);
|
||||||
return button;
|
return button;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getTotalVerticalMargin() {
|
||||||
|
return extraVerticalMargin + vmargin;
|
||||||
|
}
|
||||||
|
|
||||||
protected Button addButton(FrameLayout parent, int stringId, int resourceId) {
|
protected Button addButton(FrameLayout parent, int stringId, int resourceId) {
|
||||||
return addButton(parent, stringId, resourceId, 0);
|
return addButton(parent, stringId, resourceId, 0);
|
||||||
}
|
}
|
||||||
|
protected Button addButton(FrameLayout parent, int stringId, int resourceId, int extraMargin) {
|
||||||
protected Button addButton(FrameLayout parent, int stringId, int resourceId, int extraMargin) {
|
|
||||||
Context ctx = mapActivity;
|
Context ctx = mapActivity;
|
||||||
Button button = new Button(ctx);
|
Button button = new Button(ctx);
|
||||||
applyAttributes(ctx, parent, button, stringId, resourceId, extraMargin);
|
applyAttributes(ctx, parent, button, stringId, resourceId, extraMargin);
|
||||||
|
@ -94,21 +98,20 @@ public abstract class MapControls {
|
||||||
params.rightMargin = margin + extraMargin;
|
params.rightMargin = margin + extraMargin;
|
||||||
}
|
}
|
||||||
if((gravity & Gravity.BOTTOM) == Gravity.BOTTOM) {
|
if((gravity & Gravity.BOTTOM) == Gravity.BOTTOM) {
|
||||||
params.bottomMargin = vmargin;
|
params.bottomMargin = vmargin + extraVerticalMargin;
|
||||||
} else {
|
} else {
|
||||||
params.topMargin = vmargin;
|
params.topMargin = vmargin + extraVerticalMargin;
|
||||||
}
|
|
||||||
//if there's dialog opened we need to shift elements top
|
|
||||||
View sherpafyDialog = parent.findViewById(R.id.package_delivered_layout);
|
|
||||||
if (sherpafyDialog != null && ((gravity & Gravity.BOTTOM) == Gravity.BOTTOM) && WaypointDialogHelper.OVERLAP_LAYOUT){
|
|
||||||
params.bottomMargin = sherpafyDialog.getHeight();
|
|
||||||
}
|
}
|
||||||
button.setLayoutParams(params);
|
button.setLayoutParams(params);
|
||||||
parent.addView(button);
|
parent.addView(button);
|
||||||
button.setEnabled(true);
|
button.setEnabled(true);
|
||||||
mapActivity.accessibleContent.add(button);
|
mapActivity.accessibleContent.add(button);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getGravity() {
|
||||||
|
return gravity;
|
||||||
|
}
|
||||||
|
|
||||||
protected void removeButton(FrameLayout layout, View b) {
|
protected void removeButton(FrameLayout layout, View b) {
|
||||||
layout.removeView(b);
|
layout.removeView(b);
|
||||||
mapActivity.accessibleContent.remove(b);
|
mapActivity.accessibleContent.remove(b);
|
||||||
|
@ -178,7 +181,7 @@ public abstract class MapControls {
|
||||||
return (Gravity.LEFT & gravity) == Gravity.LEFT;
|
return (Gravity.LEFT & gravity) == Gravity.LEFT;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean isBottom() {
|
public boolean isBottom() {
|
||||||
return (Gravity.BOTTOM & gravity) == Gravity.BOTTOM;
|
return (Gravity.BOTTOM & gravity) == Gravity.BOTTOM;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -201,4 +204,8 @@ public abstract class MapControls {
|
||||||
public boolean onSingleTap(PointF point, RotatedTileBox tileBox) {
|
public boolean onSingleTap(PointF point, RotatedTileBox tileBox) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setExtraVerticalMargin(int extraVerticalMargin) {
|
||||||
|
this.extraVerticalMargin = extraVerticalMargin;
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -193,7 +193,8 @@ public class MapNavigateControl extends MapControls {
|
||||||
|
|
||||||
|
|
||||||
private void drawCount(Canvas canvas, RotatedTileBox tb) {
|
private void drawCount(Canvas canvas, RotatedTileBox tb) {
|
||||||
if (navigateShadow.getBounds().width() == 0 && navigateButton.getWidth() > 0) {
|
if ((navigateShadow.getBounds().width() == 0 && navigateButton.getWidth() > 0 )||
|
||||||
|
navigateShadow.getBounds().bottom != navigateButton.getBottom()) {
|
||||||
navigateShadow.setBounds(navigateButton.getLeft() - 2, navigateButton.getTop()
|
navigateShadow.setBounds(navigateButton.getLeft() - 2, navigateButton.getTop()
|
||||||
- (int) (18 * scaleCoefficient), navigateButton.getRight(), navigateButton.getBottom());
|
- (int) (18 * scaleCoefficient), navigateButton.getRight(), navigateButton.getBottom());
|
||||||
}
|
}
|
||||||
|
|
|
@ -248,6 +248,7 @@ public class MapRouteInfoControl extends MapControls implements IRouteInformatio
|
||||||
@Override
|
@Override
|
||||||
public void hideControls(FrameLayout layout) {
|
public void hideControls(FrameLayout layout) {
|
||||||
removeButton(layout, infoButton);
|
removeButton(layout, infoButton);
|
||||||
|
hideDialog();
|
||||||
controlVisible = false;
|
controlVisible = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue