forked from organicmaps/organicmaps
Correct distance measure in info box.
This commit is contained in:
parent
fdee892f5e
commit
be45fad130
4 changed files with 83 additions and 47 deletions
|
@ -27,7 +27,7 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:fontFamily="@string/robotoLight" />
|
||||
|
||||
<TextViews
|
||||
<TextView
|
||||
android:id="@+id/info_subtitle"
|
||||
style="@style/Holo.TextAppearance.Medium.Light"
|
||||
android:layout_width="wrap_content"
|
||||
|
|
|
@ -1,49 +1,70 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<android.support.v7.widget.GridLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/info_box_geo"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@drawable/white_rounded_background"
|
||||
android:orientation="vertical"
|
||||
android:padding="10dp"
|
||||
app:columnCount="2" >
|
||||
|
||||
<TextView
|
||||
style="@style/Holo.TextAppearance.Medium.Light"
|
||||
app:layout_column="0"
|
||||
app:layout_gravity="left"
|
||||
app:layout_row="1"
|
||||
android:fontFamily="@string/robotoLight"
|
||||
android:text="@string/placepage_distance"
|
||||
android:textColor="@color/ui_20_text_dark" />
|
||||
<LinearLayout
|
||||
android:id="@+id/info_box_geo_container_dist"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="top"
|
||||
android:orientation="horizontal" >
|
||||
|
||||
<TextView
|
||||
android:id="@+id/info_box_geo_distance"
|
||||
style="@style/Holo.TextAppearance.Medium.Light"
|
||||
app:layout_column="1"
|
||||
app:layout_gravity="right"
|
||||
app:layout_row="1"
|
||||
android:fontFamily="@string/robotoRegular"
|
||||
android:singleLine="true"
|
||||
android:textColor="@color/ui_20_text_green" />
|
||||
<TextView
|
||||
style="@style/Holo.TextAppearance.Medium.Light"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="0"
|
||||
android:fontFamily="@string/robotoLight"
|
||||
android:gravity="left"
|
||||
android:text="@string/placepage_distance"
|
||||
android:textColor="@color/ui_20_text_dark" />
|
||||
|
||||
<TextView
|
||||
style="@style/Holo.TextAppearance.Medium.Light"
|
||||
app:layout_column="0"
|
||||
app:layout_gravity="left"
|
||||
app:layout_row="2"
|
||||
android:fontFamily="@string/robotoLight"
|
||||
android:text="@string/placepage_coordinates"
|
||||
android:textColor="@color/ui_20_text_dark" />
|
||||
<TextView
|
||||
android:id="@+id/info_box_geo_distance"
|
||||
style="@style/Holo.TextAppearance.Medium.Light"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:fontFamily="@string/robotoRegular"
|
||||
android:gravity="right"
|
||||
android:singleLine="true"
|
||||
android:textColor="@color/ui_20_text_green" />
|
||||
</LinearLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/info_box_geo_location"
|
||||
style="@style/Holo.TextAppearance.Medium.Light"
|
||||
app:layout_column="1"
|
||||
app:layout_gravity="right"
|
||||
app:layout_row="2"
|
||||
android:fontFamily="@string/robotoRegular"
|
||||
android:singleLine="true"
|
||||
android:textColor="@color/ui_20_text_green" />
|
||||
<LinearLayout
|
||||
android:id="@+id/info_box_geo_container_coord"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="top"
|
||||
android:orientation="horizontal" >
|
||||
|
||||
</android.support.v7.widget.GridLayout>
|
||||
<TextView
|
||||
style="@style/Holo.TextAppearance.Medium.Light"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="0"
|
||||
android:fontFamily="@string/robotoLight"
|
||||
android:gravity="left"
|
||||
android:text="@string/placepage_coordinates"
|
||||
android:textColor="@color/ui_20_text_dark" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/info_box_geo_location"
|
||||
style="@style/Holo.TextAppearance.Medium.Light"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:fontFamily="@string/robotoRegular"
|
||||
android:gravity="right"
|
||||
android:singleLine="true"
|
||||
android:textColor="@color/ui_20_text_green" />
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
|
@ -932,6 +932,7 @@ public class MWMActivity extends NvEventQueueActivity
|
|||
LocationButtonImageSetter.setButtonViewFromState(ButtonState.HAS_LOCATION, mLocationButton);
|
||||
|
||||
nativeLocationUpdated(l.getTime(), l.getLatitude(), l.getLongitude(), l.getAccuracy(), l.getAltitude(), l.getSpeed(), l.getBearing());
|
||||
mInfoView.updateDistance(l);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -6,7 +6,6 @@ import android.graphics.Color;
|
|||
import android.graphics.drawable.Drawable;
|
||||
import android.location.Location;
|
||||
import android.support.v4.view.GestureDetectorCompat;
|
||||
import android.support.v7.widget.GridLayout;
|
||||
import android.text.TextUtils;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.GestureDetector;
|
||||
|
@ -146,7 +145,7 @@ public class MapInfoView extends LinearLayout
|
|||
{
|
||||
super(context, attrs);
|
||||
|
||||
mInflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
mInflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
mView = mInflater.inflate(R.layout.info_box, this, true);
|
||||
|
||||
mHeaderGroup = (ViewGroup) mView.findViewById(R.id.header);
|
||||
|
@ -340,19 +339,34 @@ public class MapInfoView extends LinearLayout
|
|||
|
||||
private void setUpGeoInformation(MapObject mo)
|
||||
{
|
||||
final GridLayout mGeoLayout = (GridLayout) mBodyContainer.findViewById(R.id.info_box_geo_ref);
|
||||
final LinearLayout mGeoLayout = (LinearLayout) mBodyContainer.findViewById(R.id.info_box_geo_ref);
|
||||
|
||||
final Location lastKnown = MWMApplication.get().getLocationService().getLastKnown();
|
||||
updateDistance(lastKnown);
|
||||
|
||||
final CharSequence distanceText = (lastKnown == null)
|
||||
? getResources().getString(R.string.unknown_current_position)
|
||||
: Framework.getDistanceAndAzimutFromLatLon(
|
||||
mo.getLat(), mo.getLon(), lastKnown.getLatitude(),
|
||||
lastKnown.getLongitude(), 0.0).getDistance();
|
||||
|
||||
UiUtils.findViewSetText(mGeoLayout, R.id.info_box_geo_distance, distanceText);
|
||||
UiUtils.findViewSetText(mGeoLayout, R.id.info_box_geo_location, UiUtils.formatLatLon(mo.getLat(), mo.getLon()));
|
||||
}
|
||||
|
||||
public void updateDistance(Location l)
|
||||
{
|
||||
final LinearLayout mGeoLayout = (LinearLayout) mBodyContainer.findViewById(R.id.info_box_geo_ref);
|
||||
|
||||
if (mGeoLayout != null)
|
||||
{
|
||||
if (l != null)
|
||||
{
|
||||
UiUtils.show(mGeoLayout.findViewById(R.id.info_box_geo_container_dist));
|
||||
final CharSequence distanceText = Framework.getDistanceAndAzimutFromLatLon(
|
||||
mMapObject.getLat(), mMapObject.getLon(), l.getLatitude(), l.getLongitude(), 0.0).getDistance();
|
||||
UiUtils.findViewSetText(mGeoLayout, R.id.info_box_geo_distance, distanceText);
|
||||
}
|
||||
else
|
||||
{
|
||||
UiUtils.hide(mGeoLayout.findViewById(R.id.info_box_geo_container_dist));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void setBodyForPOI(Poi poi)
|
||||
{
|
||||
mBodyContainer.removeAllViews();
|
||||
|
|
Loading…
Add table
Reference in a new issue