Fix direction and distance indication
This commit is contained in:
parent
b112939f1e
commit
018c86c0fb
2 changed files with 26 additions and 10 deletions
|
@ -55,8 +55,10 @@
|
||||||
android:id="@+id/marker_direction_icon"
|
android:id="@+id/marker_direction_icon"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
android:layout_marginEnd="4dp"
|
android:layout_marginEnd="4dp"
|
||||||
android:layout_marginRight="4dp"
|
android:layout_marginRight="4dp"
|
||||||
|
android:layout_marginTop="1sp"
|
||||||
tools:src="@drawable/ic_direction_arrow"/>
|
tools:src="@drawable/ic_direction_arrow"/>
|
||||||
|
|
||||||
<android.support.v7.widget.AppCompatTextView
|
<android.support.v7.widget.AppCompatTextView
|
||||||
|
@ -68,6 +70,7 @@
|
||||||
tools:text="213 m"/>
|
tools:text="213 m"/>
|
||||||
|
|
||||||
<android.support.v7.widget.AppCompatTextView
|
<android.support.v7.widget.AppCompatTextView
|
||||||
|
android:id="@+id/marker_divider_point"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text=" • "
|
android:text=" • "
|
||||||
|
|
|
@ -27,7 +27,6 @@ import net.osmand.plus.OsmAndLocationProvider.OsmAndLocationListener;
|
||||||
import net.osmand.plus.OsmandApplication;
|
import net.osmand.plus.OsmandApplication;
|
||||||
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.base.MapViewTrackingUtilities;
|
|
||||||
import net.osmand.plus.dashboard.DashLocationFragment;
|
import net.osmand.plus.dashboard.DashLocationFragment;
|
||||||
import net.osmand.plus.helpers.AndroidUiHelper;
|
import net.osmand.plus.helpers.AndroidUiHelper;
|
||||||
import net.osmand.plus.views.OsmandMapTileView;
|
import net.osmand.plus.views.OsmandMapTileView;
|
||||||
|
@ -57,6 +56,7 @@ public class MarkerMenuOnMapFragment extends Fragment implements OsmAndCompassLi
|
||||||
|
|
||||||
private ImageView arrowIv;
|
private ImageView arrowIv;
|
||||||
private TextView distanceTv;
|
private TextView distanceTv;
|
||||||
|
private View dividerPoint;
|
||||||
|
|
||||||
public void setMarker(MapMarker marker) {
|
public void setMarker(MapMarker marker) {
|
||||||
this.marker = marker;
|
this.marker = marker;
|
||||||
|
@ -88,6 +88,7 @@ public class MarkerMenuOnMapFragment extends Fragment implements OsmAndCompassLi
|
||||||
|
|
||||||
arrowIv = (ImageView) mainView.findViewById(R.id.marker_direction_icon);
|
arrowIv = (ImageView) mainView.findViewById(R.id.marker_direction_icon);
|
||||||
distanceTv = (TextView) mainView.findViewById(R.id.marker_distance);
|
distanceTv = (TextView) mainView.findViewById(R.id.marker_distance);
|
||||||
|
dividerPoint = mainView.findViewById(R.id.marker_divider_point);
|
||||||
|
|
||||||
String descr;
|
String descr;
|
||||||
if ((descr = marker.groupName) != null) {
|
if ((descr = marker.groupName) != null) {
|
||||||
|
@ -251,20 +252,32 @@ public class MarkerMenuOnMapFragment extends Fragment implements OsmAndCompassLi
|
||||||
if (location == null) {
|
if (location == null) {
|
||||||
location = mapActivity.getMyApplication().getLocationProvider().getLastKnownLocation();
|
location = mapActivity.getMyApplication().getLocationProvider().getLastKnownLocation();
|
||||||
}
|
}
|
||||||
MapViewTrackingUtilities utilities = mapActivity.getMapViewTrackingUtilities();
|
if (location != null) {
|
||||||
|
mark(View.VISIBLE, arrowIv, distanceTv, dividerPoint);
|
||||||
boolean useCenter = !(utilities.isMapLinkedToLocation() && location != null);
|
DashLocationFragment.updateLocationView(false,
|
||||||
LatLon loc = useCenter ? mapActivity.getMapLocation() : new LatLon(location.getLatitude(), location.getLongitude());
|
new LatLon(location.getLatitude(), location.getLongitude()),
|
||||||
float head = useCenter ? -mapActivity.getMapRotate() : heading != null ? heading : 99;
|
heading != null ? heading : 0f,
|
||||||
|
arrowIv,
|
||||||
DashLocationFragment.updateLocationView(useCenter, loc, head, arrowIv,
|
distanceTv,
|
||||||
R.drawable.ic_direction_arrow, 0, distanceTv, marker.point,
|
marker.getLatitude(),
|
||||||
DashLocationFragment.getScreenOrientation(mapActivity), mapActivity.getMyApplication(), mapActivity, true);
|
marker.getLongitude(),
|
||||||
|
DashLocationFragment.getScreenOrientation(mapActivity),
|
||||||
|
mapActivity.getMyApplication(),
|
||||||
|
mapActivity);
|
||||||
|
} else {
|
||||||
|
mark(View.GONE, arrowIv, distanceTv, dividerPoint);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void mark(int visibility, View... views) {
|
||||||
|
for (View v : views) {
|
||||||
|
v.setVisibility(visibility);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void enterMenuMode() {
|
private void enterMenuMode() {
|
||||||
final MapActivity mapActivity = getMapActivity();
|
final MapActivity mapActivity = getMapActivity();
|
||||||
if (mapActivity != null) {
|
if (mapActivity != null) {
|
||||||
|
|
Loading…
Reference in a new issue