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);
}
}
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;
}
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 double deviateDistance;
public boolean deviationDirectionRight;
public Location pointA;
public Location pointB;
}

View file

@ -501,6 +501,16 @@ public class MapUtils {
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,6 +67,12 @@
android:layout_marginRight="@dimen/map_button_margin"
android:src="@drawable/ic_action_test_light"/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:orientation="vertical">
<TextView
android:id="@+id/waypoint_dist"
android:layout_width="60dp"
@ -78,6 +84,21 @@
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
android:layout_width="0dp"
android:layout_height="wrap_content"

View file

@ -48,6 +48,17 @@
android:maxLines="1"
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
android:id="@+id/waypoint_desc_text"
android:layout_width="0dp"

View file

@ -144,17 +144,9 @@ public class DashWaypointsFragment extends DashLocationFragment {
boolean target = helper.getPointToNavigate() == point;
int id;
if (!target) {
if (getMyApplication().getSettings().isLightContent()) {
id = R.drawable.widget_intermediate_day;
id = R.drawable.list_intermediate;
} else {
id = R.drawable.widget_intermediate_night;
}
} else {
if (getMyApplication().getSettings().isLightContent()) {
id = R.drawable.widget_target_day;
} else {
id = R.drawable.widget_target_night;
}
id = R.drawable.list_destination;
}
((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;
PointDescription pd = point.getPointDescription(app);
if (Algorithms.isEmpty(pd.getName())) {
@ -155,20 +187,9 @@ public class WaypointDialogHelper {
if (descr.equals(pointDescription)) {
pointDescription = "";
}
if (dist > 0) {
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)) {
if (dist > 0 && !Algorithms.isEmpty(pointDescription)) {
pointDescription = "" + pointDescription;
}
} else {
textDist.setText("");
}
if (descText != null) {
descText.setText(pointDescription);
}

View file

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

View file

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

View file

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