Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
4769d8e745
24 changed files with 533 additions and 76 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 |
44
OsmAnd/res/layout/waypoint_reached.xml
Normal file
44
OsmAnd/res/layout/waypoint_reached.xml
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:id="@+id/package_delivered_layout">
|
||||||
|
|
||||||
|
<ImageView android:id="@+id/waypoint_icon"
|
||||||
|
android:layout_marginLeft="8dp"
|
||||||
|
android:src="@drawable/list_favorite"
|
||||||
|
android:layout_width="25dp"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
android:layout_height="wrap_content"/>
|
||||||
|
|
||||||
|
<TextView android:id="@+id/waypoint_text"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginLeft="8dp"
|
||||||
|
android:singleLine="true"
|
||||||
|
android:ellipsize="end"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:textSize="18sp"/>
|
||||||
|
|
||||||
|
<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"/>
|
||||||
|
|
||||||
|
|
||||||
|
</LinearLayout>
|
|
@ -42,4 +42,5 @@
|
||||||
<string name="start_tour">Start tour</string>
|
<string name="start_tour">Start tour</string>
|
||||||
<string name="download_tour">Download tour</string>
|
<string name="download_tour">Download tour</string>
|
||||||
<string name="sherpafy_app_name">Sherpafy</string>
|
<string name="sherpafy_app_name">Sherpafy</string>
|
||||||
|
<string name="waypoint_reached_msg">See waypoint information</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -1941,4 +1941,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;
|
||||||
|
@ -96,6 +97,25 @@ 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;
|
||||||
|
|
|
@ -19,6 +19,7 @@ import net.osmand.access.AccessibleAlertBuilder;
|
||||||
import net.osmand.access.AccessibleToast;
|
import net.osmand.access.AccessibleToast;
|
||||||
import net.osmand.plus.access.AccessibilityMode;
|
import net.osmand.plus.access.AccessibilityMode;
|
||||||
import net.osmand.plus.activities.DayNightHelper;
|
import net.osmand.plus.activities.DayNightHelper;
|
||||||
|
import net.osmand.plus.activities.MapActivity;
|
||||||
import net.osmand.plus.activities.SavingTrackHelper;
|
import net.osmand.plus.activities.SavingTrackHelper;
|
||||||
import net.osmand.plus.activities.SettingsActivity;
|
import net.osmand.plus.activities.SettingsActivity;
|
||||||
import net.osmand.plus.api.SQLiteAPI;
|
import net.osmand.plus.api.SQLiteAPI;
|
||||||
|
@ -108,6 +109,7 @@ public class OsmandApplication extends Application {
|
||||||
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();
|
||||||
|
@ -838,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,6 +25,8 @@ 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;
|
||||||
|
@ -63,6 +69,49 @@ public class TargetPointsHelper {
|
||||||
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);
|
||||||
|
@ -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,6 +301,7 @@ public class MapActivity extends AccessibleActivity {
|
||||||
}
|
}
|
||||||
|
|
||||||
settings.MAP_ACTIVITY_ENABLED.set(true);
|
settings.MAP_ACTIVITY_ENABLED.set(true);
|
||||||
|
app.setMapActivity(this);
|
||||||
checkExternalStorage();
|
checkExternalStorage();
|
||||||
showAndHideMapPosition();
|
showAndHideMapPosition();
|
||||||
|
|
||||||
|
@ -559,6 +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.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 < 160) {
|
if (ds < 160) {
|
||||||
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;
|
||||||
|
@ -25,6 +26,7 @@ import net.osmand.plus.routing.AlarmInfo.AlarmInfoType;
|
||||||
import net.osmand.plus.routing.RouteCalculationResult.NextDirectionInfo;
|
import net.osmand.plus.routing.RouteCalculationResult.NextDirectionInfo;
|
||||||
import net.osmand.plus.routing.RouteProvider.GPXRouteParamsBuilder;
|
import net.osmand.plus.routing.RouteProvider.GPXRouteParamsBuilder;
|
||||||
import net.osmand.plus.routing.RouteProvider.RouteService;
|
import net.osmand.plus.routing.RouteProvider.RouteService;
|
||||||
|
import net.osmand.plus.sherpafy.WaypointDialogHelper;
|
||||||
import net.osmand.plus.voice.CommandPlayer;
|
import net.osmand.plus.voice.CommandPlayer;
|
||||||
import net.osmand.router.RouteCalculationProgress;
|
import net.osmand.router.RouteCalculationProgress;
|
||||||
import net.osmand.router.RouteSegmentResult;
|
import net.osmand.router.RouteSegmentResult;
|
||||||
|
@ -318,16 +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.addWptDialog(wpt.get(0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
251
OsmAnd/src/net/osmand/plus/sherpafy/WaypointDialogHelper.java
Normal file
251
OsmAnd/src/net/osmand/plus/sherpafy/WaypointDialogHelper.java
Normal file
|
@ -0,0 +1,251 @@
|
||||||
|
package net.osmand.plus.sherpafy;
|
||||||
|
|
||||||
|
import android.app.AlertDialog;
|
||||||
|
import android.app.Dialog;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.DialogInterface;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.graphics.Color;
|
||||||
|
import android.os.AsyncTask;
|
||||||
|
import android.os.SystemClock;
|
||||||
|
import android.text.Spannable;
|
||||||
|
import android.text.style.ForegroundColorSpan;
|
||||||
|
import android.util.TypedValue;
|
||||||
|
import android.view.Gravity;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.*;
|
||||||
|
import net.osmand.Location;
|
||||||
|
import net.osmand.data.LatLon;
|
||||||
|
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.base.FavoriteImageDrawable;
|
||||||
|
import net.osmand.plus.views.MapControlsLayer;
|
||||||
|
import net.osmand.util.MapUtils;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by Denis on 25.07.2014.
|
||||||
|
*/
|
||||||
|
public class WaypointDialogHelper {
|
||||||
|
private MapActivity mapActivity;
|
||||||
|
private OsmandApplication app;
|
||||||
|
private FrameLayout mainLayout;
|
||||||
|
private TargetPointsHelper targetPointsHelper;
|
||||||
|
|
||||||
|
public static boolean OVERLAP_LAYOUT = true;
|
||||||
|
private long uiModified;
|
||||||
|
private View closePointDialog;
|
||||||
|
|
||||||
|
public WaypointDialogHelper(MapActivity mapActivity) {
|
||||||
|
this.app = mapActivity.getMyApplication();
|
||||||
|
targetPointsHelper = this.app.getTargetPointsHelper();
|
||||||
|
this.mapActivity = 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void createView(View localView, final LocationPoint point) {
|
||||||
|
TextView text = (TextView) localView.findViewById(R.id.waypoint_text);
|
||||||
|
text.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View view) {
|
||||||
|
itemClick(point);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
((ImageView) localView.findViewById(R.id.waypoint_icon)).setImageDrawable(FavoriteImageDrawable.getOrCreate(mapActivity, point.getColor()));
|
||||||
|
Location lastKnownMapLocation = app.getLocationProvider().getLastKnownLocation();
|
||||||
|
// LatLon lastKnownMapLocation = app.getSettings().getLastKnownMapLocation();
|
||||||
|
String distance;
|
||||||
|
if (lastKnownMapLocation != null) {
|
||||||
|
int dist = (int) (MapUtils.getDistance(point.getLatitude(), point.getLongitude(),
|
||||||
|
lastKnownMapLocation.getLatitude(), lastKnownMapLocation.getLongitude()));
|
||||||
|
distance = OsmAndFormatter.getFormattedDistance(dist, app) + " ";
|
||||||
|
} else {
|
||||||
|
distance = "";
|
||||||
|
}
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void itemClick(LocationPoint point) {
|
||||||
|
final Intent favorites = new Intent(mapActivity, app.getAppCustomization().getFavoritesActivity());
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeDialog() {
|
||||||
|
if (closePointDialog != null) {
|
||||||
|
mainLayout.removeView(closePointDialog);
|
||||||
|
closePointDialog = null;
|
||||||
|
shiftButtons(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private FrameLayout.LayoutParams getDialogLayoutParams() {
|
||||||
|
FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.WRAP_CONTENT);
|
||||||
|
params.gravity = Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL;
|
||||||
|
return params;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean checkIfDialogExists() {
|
||||||
|
if (mainLayout == null) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mainLayout.findViewById(R.id.package_delivered_layout) != null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void shiftButtons(int height) {
|
||||||
|
MapControlsLayer mapControls = mapActivity.getMapLayers().getMapControlsLayer();
|
||||||
|
if (mapControls != null) {
|
||||||
|
mapControls.shiftLayout(height);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void waitBeforeLayoutIsResized(View reachedView) {
|
||||||
|
//this async task is needed because layout height is not set
|
||||||
|
// right after you add it so we need to w8 some time
|
||||||
|
new AsyncTask<View, Void, Void>() {
|
||||||
|
int height;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Void doInBackground(View... params) {
|
||||||
|
for (int i = 0; i < 10; i++) {
|
||||||
|
SystemClock.sleep(50);
|
||||||
|
height = params[0].getHeight();
|
||||||
|
if (params[0].getHeight() > 0) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void onPostExecute(Void result) {
|
||||||
|
if (height > 0 && OVERLAP_LAYOUT) {
|
||||||
|
shiftButtons(height);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}.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();
|
||||||
|
}
|
||||||
|
}
|
|
@ -3,12 +3,14 @@ package net.osmand.plus.views;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import android.view.ViewParent;
|
||||||
import net.osmand.data.RotatedTileBox;
|
import net.osmand.data.RotatedTileBox;
|
||||||
import net.osmand.plus.OsmandSettings;
|
import net.osmand.plus.OsmandSettings;
|
||||||
import net.osmand.plus.OsmandSettings.CommonPreference;
|
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;
|
||||||
|
@ -59,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
|
||||||
|
@ -176,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) {
|
||||||
|
@ -189,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 {
|
||||||
|
@ -300,4 +306,21 @@ public class MapControlsLayer extends OsmandMapLayer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void shiftLayout(int height) {
|
||||||
|
FrameLayout parent = (FrameLayout) mapActivity.getMapView().getParent();
|
||||||
|
parent.requestLayout();
|
||||||
|
for(MapControls mc : allControls) {
|
||||||
|
if(mc.isBottom()){
|
||||||
|
mc.setExtraVerticalMargin(height);
|
||||||
|
if( mc.isVisible()) {
|
||||||
|
mc.forceHide(parent);
|
||||||
|
mc.show(parent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public WaypointDialogHelper getWaypointDialogHelper() {
|
||||||
|
return waypointDialogHelper;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
package net.osmand.plus.views.controls;
|
package net.osmand.plus.views.controls;
|
||||||
|
|
||||||
import net.osmand.data.RotatedTileBox;
|
import net.osmand.data.RotatedTileBox;
|
||||||
|
import net.osmand.plus.R;
|
||||||
import net.osmand.plus.activities.MapActivity;
|
import net.osmand.plus.activities.MapActivity;
|
||||||
|
import net.osmand.plus.sherpafy.WaypointDialogHelper;
|
||||||
import net.osmand.plus.views.OsmandMapLayer.DrawSettings;
|
import net.osmand.plus.views.OsmandMapLayer.DrawSettings;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.graphics.Canvas;
|
import android.graphics.Canvas;
|
||||||
|
@ -31,6 +33,7 @@ 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;
|
||||||
|
@ -57,11 +60,14 @@ public abstract class MapControls {
|
||||||
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);
|
||||||
|
@ -92,15 +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;
|
||||||
}
|
}
|
||||||
parent.addView(button, params);
|
button.setLayoutParams(params);
|
||||||
|
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);
|
||||||
|
@ -170,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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -193,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