Merge remote-tracking branch 'origin/master'

This commit is contained in:
Weblate 2016-01-23 10:28:01 +01:00
commit 8ab2ef287d
10 changed files with 119 additions and 65 deletions

View file

@ -645,6 +645,11 @@ public class BinaryMapPoiReaderAdapter {
arp.pointB = locations.get(i); arp.pointB = locations.get(i);
} }
} }
if (arp != null && arp.deviateDistance != 0 && arp.pointA != null && arp.pointB != null) {
arp.deviationDirectionRight = MapUtils.rightSide(l.getLatitude(), l.getLongitude(),
arp.pointA.getLatitude(), arp.pointA.getLongitude(),
arp.pointB.getLatitude(), arp.pointB.getLongitude());
}
return arp; return arp;
} }
private Amenity readPoiPoint(int left31, int right31, int top31, int bottom31, private Amenity readPoiPoint(int left31, int right31, int top31, int bottom31,

View file

@ -38,6 +38,7 @@ public class Amenity extends MapObject {
public static class AmenityRoutePoint { public static class AmenityRoutePoint {
public double deviateDistance; public double deviateDistance;
public boolean deviationDirectionRight;
public Location pointA; public Location pointA;
public Location pointB; public Location pointB;
} }

View file

@ -167,7 +167,7 @@ public class MapUtils {
} }
public static double get31LatitudeY(int tileY){ public static double get31LatitudeY(int tileY){
return MapUtils.getLatitudeFromTile(21, tileY /1024f); return MapUtils.getLatitudeFromTile(21, tileY / 1024f);
} }
@ -501,6 +501,16 @@ public class MapUtils {
return multiple; return multiple;
} }
public static boolean rightSide(double lat, double lon,
double aLat, double aLon,
double bLat, double bLon) {
double ax = aLon - lon;
double ay = aLat - lat;
double bx = bLon - lon;
double by = bLat - lat;
double sa = ax * by - bx * ay;
return sa < 0;
}
} }

View file

@ -67,16 +67,37 @@
android:layout_marginRight="@dimen/map_button_margin" android:layout_marginRight="@dimen/map_button_margin"
android:src="@drawable/ic_action_test_light"/> android:src="@drawable/ic_action_test_light"/>
<TextView <LinearLayout
android:id="@+id/waypoint_dist" android:layout_width="wrap_content"
android:layout_width="60dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center_vertical" android:layout_gravity="center"
android:layout_marginLeft="4dp" android:orientation="vertical">
android:maxLines="2"
android:textColor="@color/wpt_distance_color" <TextView
android:textSize="@dimen/default_desc_text_size" android:id="@+id/waypoint_dist"
android:textStyle="bold"/> android:layout_width="60dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="4dp"
android:maxLines="2"
android:textColor="@color/wpt_distance_color"
android:textSize="@dimen/default_desc_text_size"
android:textStyle="bold"/>
<TextView
android:id="@+id/waypoint_deviation"
android:layout_width="60dp"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_marginLeft="4dp"
android:drawablePadding="2dp"
android:maxLines="1"
android:textColor="@color/wpt_distance_color"
android:textSize="@dimen/default_sub_text_size"
android:textStyle="bold"
android:visibility="gone"/>
</LinearLayout>
<FrameLayout <FrameLayout
android:layout_width="0dp" android:layout_width="0dp"

View file

@ -48,6 +48,17 @@
android:maxLines="1" android:maxLines="1"
android:textSize="@dimen/default_sub_text_size"/> android:textSize="@dimen/default_sub_text_size"/>
<TextView
android:id="@+id/waypoint_deviation"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:textColor="@color/secondary_text_dark"
android:layout_marginLeft="6dp"
android:drawablePadding="2dp"
android:maxLines="1"
android:textSize="@dimen/default_sub_text_size"/>
<TextView <TextView
android:id="@+id/waypoint_desc_text" android:id="@+id/waypoint_desc_text"
android:layout_width="0dp" android:layout_width="0dp"

View file

@ -144,17 +144,9 @@ public class DashWaypointsFragment extends DashLocationFragment {
boolean target = helper.getPointToNavigate() == point; boolean target = helper.getPointToNavigate() == point;
int id; int id;
if (!target) { if (!target) {
if (getMyApplication().getSettings().isLightContent()) { id = R.drawable.list_intermediate;
id = R.drawable.widget_intermediate_day;
} else {
id = R.drawable.widget_intermediate_night;
}
} else { } else {
if (getMyApplication().getSettings().isLightContent()) { id = R.drawable.list_destination;
id = R.drawable.widget_target_day;
} else {
id = R.drawable.widget_target_night;
}
} }
((ImageView) view.findViewById(R.id.favourite_icon)).setImageDrawable(getMyApplication().getIconsCache() ((ImageView) view.findViewById(R.id.favourite_icon)).setImageDrawable(getMyApplication().getIconsCache()

View file

@ -118,6 +118,38 @@ public class WaypointDialogHelper {
} }
} }
if (dist > 0) {
textDist.setText(OsmAndFormatter.getFormattedDistance(dist, app));
} else {
textDist.setText("");
}
TextView textDeviation = (TextView) localView.findViewById(R.id.waypoint_deviation);
if (textDeviation != null) {
if (dist > 0 && ps.deviationDistance > 0) {
String devStr = "+" + OsmAndFormatter.getFormattedDistance(ps.deviationDistance, app);
textDeviation.setText(devStr);
int colorId = R.color.wpt_distance_color;
if (!topBar) {
colorId = nightMode ? R.color.secondary_text_dark : R.color.secondary_text_light;
AndroidUtils.setTextSecondaryColor(activity, textDeviation, nightMode);
}
if (ps.deviationDirectionRight) {
textDeviation.setCompoundDrawablesWithIntrinsicBounds(
app.getIconsCache().getIcon(R.drawable.ic_small_turn_right, colorId),
null, null, null);
} else {
textDeviation.setCompoundDrawablesWithIntrinsicBounds(
app.getIconsCache().getIcon(R.drawable.ic_small_turn_left, colorId),
null, null, null);
}
textDeviation.setVisibility(View.VISIBLE);
} else {
textDeviation.setText("");
textDeviation.setVisibility(View.GONE);
}
}
String descr; String descr;
PointDescription pd = point.getPointDescription(app); PointDescription pd = point.getPointDescription(app);
if (Algorithms.isEmpty(pd.getName())) { if (Algorithms.isEmpty(pd.getName())) {
@ -155,20 +187,9 @@ public class WaypointDialogHelper {
if (descr.equals(pointDescription)) { if (descr.equals(pointDescription)) {
pointDescription = ""; pointDescription = "";
} }
if (dist > 0 && !Algorithms.isEmpty(pointDescription)) {
if (dist > 0) { pointDescription = "" + pointDescription;
String dd = OsmAndFormatter.getFormattedDistance(dist, app);
if (ps.deviationDistance > 0) {
dd += (topBar ? "\n" : " ") + "+" + OsmAndFormatter.getFormattedDistance(ps.deviationDistance, app);
}
textDist.setText(dd);
if (!Algorithms.isEmpty(pointDescription)) {
pointDescription = "" + pointDescription;
}
} else {
textDist.setText("");
} }
if (descText != null) { if (descText != null) {
descText.setText(pointDescription); descText.setText(pointDescription);
} }

View file

@ -10,6 +10,7 @@ import java.util.EnumSet;
import java.util.List; import java.util.List;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import net.osmand.FloatMath;
import net.osmand.Location; import net.osmand.Location;
import net.osmand.binary.BinaryMapRouteReaderAdapter.RouteRegion; import net.osmand.binary.BinaryMapRouteReaderAdapter.RouteRegion;
import net.osmand.binary.BinaryMapRouteReaderAdapter.RouteTypeRule; import net.osmand.binary.BinaryMapRouteReaderAdapter.RouteTypeRule;
@ -485,7 +486,7 @@ public class WaypointHelper {
} }
} }
private float dist(LocationPoint l, List<Location> locations, int[] ind) { private float dist(LocationPoint l, List<Location> locations, int[] ind, boolean[] devDirRight) {
float dist = Float.POSITIVE_INFINITY; float dist = Float.POSITIVE_INFINITY;
// Special iterations because points stored by pairs! // Special iterations because points stored by pairs!
for (int i = 1; i < locations.size(); i++) { for (int i = 1; i < locations.size(); i++) {
@ -500,6 +501,14 @@ public class WaypointHelper {
dist = (float) ld; dist = (float) ld;
} }
} }
if (ind != null && dist < Float.POSITIVE_INFINITY) {
int i = ind[0];
devDirRight[0] = MapUtils.rightSide(l.getLatitude(), l.getLongitude(),
locations.get(i - 1).getLatitude(), locations.get(i - 1).getLongitude(),
locations.get(i).getLatitude(), locations.get(i).getLongitude());
}
return dist; return dist;
} }
@ -539,6 +548,7 @@ public class WaypointHelper {
if (i >= 0) { if (i >= 0) {
LocationPointWrapper lwp = new LocationPointWrapper(route, POI, new AmenityLocationPoint(a), LocationPointWrapper lwp = new LocationPointWrapper(route, POI, new AmenityLocationPoint(a),
(float) rp.deviateDistance, i); (float) rp.deviateDistance, i);
lwp.deviationDirectionRight = rp.deviationDirectionRight;
lwp.setAnnounce(announcePOI()); lwp.setAnnounce(announcePOI());
locationPoints.add(lwp); locationPoints.add(lwp);
} }
@ -582,11 +592,13 @@ public class WaypointHelper {
List<? extends LocationPoint> points, boolean announce) { List<? extends LocationPoint> points, boolean announce) {
List<Location> immutableAllLocations = rt.getImmutableAllLocations(); List<Location> immutableAllLocations = rt.getImmutableAllLocations();
int[] ind = new int[1]; int[] ind = new int[1];
boolean[] devDirRight = new boolean[1];
for (LocationPoint p : points) { for (LocationPoint p : points) {
float dist = dist(p, immutableAllLocations, ind); float dist = dist(p, immutableAllLocations, ind, devDirRight);
int rad = getSearchDeviationRadius(type); int rad = getSearchDeviationRadius(type);
if (dist <= rad) { if (dist <= rad) {
LocationPointWrapper lpw = new LocationPointWrapper(rt, type, p, dist, ind[0]); LocationPointWrapper lpw = new LocationPointWrapper(rt, type, p, dist, ind[0]);
lpw.deviationDirectionRight = devDirRight[0];
lpw.setAnnounce(announce); lpw.setAnnounce(announce);
locationPoints.add(lpw); locationPoints.add(lpw);
} }
@ -635,6 +647,7 @@ public class WaypointHelper {
public static class LocationPointWrapper { public static class LocationPointWrapper {
LocationPoint point; LocationPoint point;
float deviationDistance; float deviationDistance;
boolean deviationDirectionRight;
int routeIndex; int routeIndex;
boolean announce = true; boolean announce = true;
RouteCalculationResult route; RouteCalculationResult route;
@ -659,6 +672,10 @@ public class WaypointHelper {
return deviationDistance; return deviationDistance;
} }
public boolean isDeviationDirectionRight() {
return deviationDirectionRight;
}
public LocationPoint getPoint() { public LocationPoint getPoint() {
return point; return point;
} }
@ -689,17 +706,9 @@ public class WaypointHelper {
return iconsCache.getIcon(R.drawable.list_startpoint, 0, 0f); return iconsCache.getIcon(R.drawable.list_startpoint, 0, 0f);
} }
} else if (((TargetPoint) point).intermediate) { } else if (((TargetPoint) point).intermediate) {
if (!nightMode) { return iconsCache.getIcon(R.drawable.list_intermediate, 0, 0f);
return iconsCache.getIcon(R.drawable.widget_intermediate_day, 0, 0f);
} else {
return iconsCache.getIcon(R.drawable.widget_intermediate_night, 0, 0f);
}
} else { } else {
if (!nightMode) { return iconsCache.getIcon(R.drawable.list_destination, 0, 0f);
return iconsCache.getIcon(R.drawable.widget_target_day, 0, 0f);
} else {
return iconsCache.getIcon(R.drawable.widget_target_night, 0, 0f);
}
} }
} else if (type == FAVORITES || type == WAYPOINTS) { } else if (type == FAVORITES || type == WAYPOINTS) {

View file

@ -81,17 +81,9 @@ public class TargetPointMenuController extends MenuController {
if (targetPoint.start) { if (targetPoint.start) {
return getIconOrig(R.drawable.list_startpoint); return getIconOrig(R.drawable.list_startpoint);
} else if (!targetPoint.intermediate) { } else if (!targetPoint.intermediate) {
if (isLight()) { return getIconOrig(R.drawable.list_destination);
return getIconOrig(R.drawable.widget_target_day);
} else {
return getIconOrig(R.drawable.widget_target_night);
}
} else { } else {
if (isLight()) { return getIconOrig(R.drawable.list_intermediate);
return getIconOrig(R.drawable.widget_intermediate_day);
} else {
return getIconOrig(R.drawable.widget_intermediate_night);
}
} }
} }

View file

@ -237,11 +237,7 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
}); });
ImageView viaIcon = (ImageView) parentView.findViewById(R.id.viaIcon); ImageView viaIcon = (ImageView) parentView.findViewById(R.id.viaIcon);
if (isLight()) { viaIcon.setImageDrawable(getIconOrig(R.drawable.list_intermediate));
viaIcon.setImageDrawable(getIconOrig(R.drawable.widget_intermediate_day));
} else {
viaIcon.setImageDrawable(getIconOrig(R.drawable.widget_intermediate_night));
}
} }
private void updateToSpinner(final View parentView) { private void updateToSpinner(final View parentView) {
@ -282,11 +278,7 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
private void updateToIcon(View parentView) { private void updateToIcon(View parentView) {
ImageView toIcon = (ImageView) parentView.findViewById(R.id.toIcon); ImageView toIcon = (ImageView) parentView.findViewById(R.id.toIcon);
if (isLight()) { toIcon.setImageDrawable(getIconOrig(R.drawable.list_destination));
toIcon.setImageDrawable(getIconOrig(R.drawable.widget_target_day));
} else {
toIcon.setImageDrawable(getIconOrig(R.drawable.widget_target_night));
}
} }
private void updateFromSpinner(final View parentView) { private void updateFromSpinner(final View parentView) {