From efde6d74a5350727b260315920e8eae21decfa98 Mon Sep 17 00:00:00 2001 From: Denis Date: Wed, 12 Nov 2014 14:10:31 +0200 Subject: [PATCH] Press on the favorite - open favorite on map --- .../plus/activities/DashboardActivity.java | 9 +++++++++ .../osmand/plus/activities/MapActivity.java | 19 ++++++++++++++++++- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/OsmAnd/src/net/osmand/plus/activities/DashboardActivity.java b/OsmAnd/src/net/osmand/plus/activities/DashboardActivity.java index e7ca56d44b..a19dcbac3e 100644 --- a/OsmAnd/src/net/osmand/plus/activities/DashboardActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/DashboardActivity.java @@ -73,6 +73,15 @@ public class DashboardActivity extends SherlockFragmentActivity { String distance = OsmAndFormatter.getFormattedDistance(dist, getMyApplication()) + " "; label.setText(distance, TextView.BufferType.SPANNABLE); label.setTypeface(Typeface.DEFAULT, model.isVisible() ? Typeface.NORMAL : Typeface.ITALIC); + view.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + final Intent mapIndent = new Intent(DashboardActivity.this, getMyApplication().getAppCustomization().getMapActivity()); + mapIndent.putExtra(MapActivity.START_LAT, model.getLatitude()); + mapIndent.putExtra(MapActivity.START_LON, model.getLongitude()); + startActivityForResult(mapIndent, 0); + } + }); favorites.addView(view); } } diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java index f41b510533..8b671d56f0 100644 --- a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java @@ -80,6 +80,9 @@ import android.widget.Toast; public class MapActivity extends AccessibleActivity implements VoiceRouter.VoiceMessageListener { + + public static final String START_LAT = "START_LAT"; + public static final String START_LON = "START_LON"; private static final int SHOW_POSITION_MSG_ID = OsmAndConstants.UI_HANDLER_MAP_VIEW + 1; private static final int LONG_KEYPRESS_MSG_ID = OsmAndConstants.UI_HANDLER_MAP_VIEW + 2; @@ -116,6 +119,7 @@ public class MapActivity extends AccessibleActivity implements private KeyguardManager.KeyguardLock keyguardLock = null; private ReleaseWakeLocksRunnable releaseWakeLocksRunnable = new ReleaseWakeLocksRunnable(); private boolean active = false; + private boolean intentLocation = false; private Notification getNotification() { Intent notificationIndent = new Intent(this, getMyApplication().getAppCustomization().getMapActivity()); @@ -222,6 +226,17 @@ public class MapActivity extends AccessibleActivity implements gpxImportHelper = new GpxImportHelper(this, getMyApplication(), getMapView()); mapActions.prepareStartOptionsMenu(); + + Intent intent = getIntent(); + if (intent != null && intent.getExtras() != null) { + double lat = intent.getExtras().getDouble(START_LAT); + double lon = intent.getExtras().getDouble(START_LON); + if(lat != 0 && lon != 0){ + mapView.setLatLon(lat, lon); + mapView.setIntZoom(14); + intentLocation = true; + } + } } public void addLockView(FrameLayout lockView) { @@ -341,10 +356,12 @@ public class MapActivity extends AccessibleActivity implements } app.getLocationProvider().resumeAllUpdates(); - if (settings != null && settings.isLastKnownMapLocation()) { + if (settings != null && settings.isLastKnownMapLocation() && !intentLocation) { LatLon l = settings.getLastKnownMapLocation(); mapView.setLatLon(l.getLatitude(), l.getLongitude()); mapView.setIntZoom(settings.getLastKnownMapZoom()); + } else { + intentLocation = false; } settings.MAP_ACTIVITY_ENABLED.set(true);