Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry Kunin <dkunin@mapswith.me>2013-06-09 21:50:55 +0400
committerAlex Zolotarev <alex@maps.me>2015-09-23 01:56:28 +0300
commita1317df958b3e0ae972eb1ba2e44ea4cfa2eea8d (patch)
tree2e4649b28ea2c64979eea130d07f8c353b823e9a
parente2a23b915c03ad0292470c6b4996e00380d885b6 (diff)
[android] Balloon after rendering initialization (ge0, geo).
*TODO the same for "mapswithme".
-rw-r--r--android/jni/com/mapswithme/maps/Framework.cpp25
-rw-r--r--android/src/com/mapswithme/maps/MWMActivity.java25
-rw-r--r--android/src/com/mapswithme/maps/MapObjectActivity.java6
-rw-r--r--android/src/com/mapswithme/maps/MapObjectFragment.java16
-rw-r--r--map/framework.cpp16
5 files changed, 67 insertions, 21 deletions
diff --git a/android/jni/com/mapswithme/maps/Framework.cpp b/android/jni/com/mapswithme/maps/Framework.cpp
index 9dfb3d5ab5..0f9fac949e 100644
--- a/android/jni/com/mapswithme/maps/Framework.cpp
+++ b/android/jni/com/mapswithme/maps/Framework.cpp
@@ -765,19 +765,27 @@ namespace android
url_api::Request request;
// if we have only one point
- // and import is successful
- // => show balloon
- if (m_work.SetViewportByURL(url, request)
- && request.m_points.size() == 1)
+ // and import is successful - show balloon
+ if (m_work.SetViewportByURL(url, request) && request.m_points.size() == 1)
{
-
//we need it only for one-point-call
+ url_api::Point const point = request.m_points.front();
+
m2::PointD pt(MercatorBounds::LonToX(request.m_viewportLon),
MercatorBounds::LatToY(request.m_viewportLat));
+ ActivatePopup(pt, point.m_name, "", IMAGE_ARROW);
- ActivatePopup(pt, request.m_points.front().m_name, "", IMAGE_ARROW);
- m_work.DrawPlacemark(pt);
- m_work.Invalidate();
+ if (!strings::StartsWith(url, "mapswithme"))
+ {
+ // ge0, geo
+ m_work.DrawPlacemark(pt);
+ m_work.Invalidate();
+ }
+
+ url_scheme::ApiPoint const apiPoint {point.m_lat, point.m_lon, point.m_name, point.m_id};
+
+ LOG(LERROR, ("POINT setting listener", apiPoint.m_title, apiPoint.m_url));
+ m_bmBaloon.get()->setOnClickListener(bind(&Framework::OnAcitvateApiPoint, this, _1, apiPoint));
return true;
}
@@ -797,6 +805,7 @@ namespace android
void Framework::OnAcitvateApiPoint(gui::Element * e, url_scheme::ApiPoint const & apiPoint)
{
+ LOG(LERROR, ("POINT on api point listener", apiPoint.m_title, apiPoint.m_url));
m_apiPointActivatedListener(apiPoint);
}
diff --git a/android/src/com/mapswithme/maps/MWMActivity.java b/android/src/com/mapswithme/maps/MWMActivity.java
index 4ab1f8e178..fd957bf1bb 100644
--- a/android/src/com/mapswithme/maps/MWMActivity.java
+++ b/android/src/com/mapswithme/maps/MWMActivity.java
@@ -48,6 +48,7 @@ import com.nvidia.devtech.NvEventQueueActivity;
import java.io.Serializable;
import java.util.Locale;
+import java.util.Stack;
public class MWMActivity extends NvEventQueueActivity
implements LocationService.Listener, OnApiPointActivatedListener,
@@ -72,6 +73,9 @@ public class MWMActivity extends NvEventQueueActivity
private View mTitleBar;
private ImageView mAppIcon;
private TextView mAppTitle;
+ // Map tasks that we run AFTER rendering initialized
+ private Stack<MapTask> mTasks = new Stack<MWMActivity.MapTask>();
+
//showDialog(int, Bundle) available only form API 8
@@ -186,6 +190,9 @@ public class MWMActivity extends NvEventQueueActivity
checkBuyProDialog();
}
});
+
+ while (!mTasks.isEmpty())
+ mTasks.pop().run(this);
}
private Activity getActivity() { return this; }
@@ -573,11 +580,12 @@ public class MWMActivity extends NvEventQueueActivity
Framework.setOnBookmarkActivatedListener(this);
Framework.setOnPoiActivatedListener(this);
Framework.setOnMyPositionActivatedListener(this);
+ Framework.setOnApiPointActivatedListener(this);
Intent intent = getIntent();
// We need check for tasks both in onCreate and onNewIntent
// because of bug in OS: https://code.google.com/p/android/issues/detail?id=38629
- handleTask(intent);
+ addTask(intent);
}
@Override
@@ -586,6 +594,7 @@ public class MWMActivity extends NvEventQueueActivity
Framework.clearOnBookmarkActivatedListener();
Framework.clearOnPoiActivatedListener();
Framework.clearOnMyPositionActivatedListener();
+ Framework.clearOnApiPointActivatedListener();
super.onDestroy();
}
@@ -594,15 +603,15 @@ public class MWMActivity extends NvEventQueueActivity
protected void onNewIntent(Intent intent)
{
super.onNewIntent(intent);
- handleTask(intent);
+ addTask(intent);
}
- private void handleTask(Intent intent)
+ private void addTask(Intent intent)
{
if (intent != null && intent.hasExtra(EXTRA_TASK))
{
MapTask mapTask = (MapTask) intent.getSerializableExtra(EXTRA_TASK);
- mapTask.run(this);
+ mTasks.add(mapTask);
intent.removeExtra(EXTRA_TASK);
}
}
@@ -805,7 +814,6 @@ public class MWMActivity extends NvEventQueueActivity
mAppIcon.setImageDrawable(request.getIcon(this));
mTitleBar.setVisibility(View.VISIBLE);
- Framework.setOnApiPointActivatedListener(this);
marginTopForMap = (int) getResources().getDimension(R.dimen.abs__action_bar_default_height);
}
@@ -813,7 +821,6 @@ public class MWMActivity extends NvEventQueueActivity
{
// hide title
mTitleBar.setVisibility(View.GONE);
- Framework.clearOnApiPointActivatedListener();
}
//we use <merge> so we not sure of type here
if (mapLp instanceof MarginLayoutParams)
@@ -1047,7 +1054,11 @@ public class MWMActivity extends NvEventQueueActivity
@Override
public void onApiPointActivated(final double lat, final double lon, final String name, final String id)
{
- MWMRequest.getCurrentRequest().setPointData(lat, lon, name, id);
+ if (MWMRequest.hasRequest())
+ MWMRequest.getCurrentRequest().setPointData(lat, lon, name, id);
+ // This is case for "mwm" scheme,
+ // if point is from "geo" or "ge0" - this is wrong. So we check here.
+
runOnUiThread(new Runnable()
{
@Override
diff --git a/android/src/com/mapswithme/maps/MapObjectActivity.java b/android/src/com/mapswithme/maps/MapObjectActivity.java
index 5b94614deb..bb1f93f543 100644
--- a/android/src/com/mapswithme/maps/MapObjectActivity.java
+++ b/android/src/com/mapswithme/maps/MapObjectActivity.java
@@ -119,7 +119,11 @@ public class MapObjectActivity extends FragmentActivity
}
else if (type == MapObjectType.API_POINT)
{
- mFragment.setForApiPoint(MWMRequest.getCurrentRequest());
+ final String name = intent.getStringExtra(EXTRA_NAME);
+ final double lat = intent.getDoubleExtra(EXTRA_LAT, 0);
+ final double lon = intent.getDoubleExtra(EXTRA_LON, 0);
+
+ mFragment.setForApiPoint(name, lat, lon);
}
else if (type == MapObjectType.POI)
{
diff --git a/android/src/com/mapswithme/maps/MapObjectFragment.java b/android/src/com/mapswithme/maps/MapObjectFragment.java
index 702a532ed0..87406054b0 100644
--- a/android/src/com/mapswithme/maps/MapObjectFragment.java
+++ b/android/src/com/mapswithme/maps/MapObjectFragment.java
@@ -95,15 +95,21 @@ public class MapObjectFragment extends Fragment
mType = MapObjectType.BOOKMARK;
}
- public void setForApiPoint(MWMRequest request)
+ public void setForApiPoint(String name, double lat, double lon)
{
UiUtils.show(mAddToBookmarks);
UiUtils.hide(mEditBmk);
- UiUtils.show(mOpenWith);
- setTexts(request.getName(), null, null, request.getLat(), request.getLon());
- mOpenWith.setCompoundDrawables(UiUtils
- .setCompoundDrawableBounds(request.getIcon(getActivity()), R.dimen.icon_size, getResources()), null, null, null);
+ if (MWMRequest.hasRequest())
+ {
+ UiUtils.show(mOpenWith);
+ mOpenWith.setCompoundDrawables(UiUtils
+ .setCompoundDrawableBounds(MWMRequest.getCurrentRequest().getIcon(getActivity()), R.dimen.icon_size, getResources()), null, null, null);
+ }
+ else
+ UiUtils.hide(mOpenWith);
+
+ setTexts(name, null, null, lat, lon);
mType = MapObjectType.API_POINT;
}
diff --git a/map/framework.cpp b/map/framework.cpp
index dc9ae8d65c..e5d1255830 100644
--- a/map/framework.cpp
+++ b/map/framework.cpp
@@ -1458,6 +1458,22 @@ bool Framework::SetViewportByURL(string const & url, url_api::Request & request)
m2::RectD view(MercatorBounds::LonToX(z.minX()), MercatorBounds::LatToY(z.minY()),
MercatorBounds::LonToX(z.maxX()), MercatorBounds::LatToY(z.maxY()));
SetViewPortSync(view);
+
+ // Populate request if request has only one point
+ // with this one point to show balloon.
+ // @todo: refacotor to more general model, Point and ApiPoint must not exist together.
+ if (m_ParsedMapApi.GetPoints().size() == 1)
+ {
+ url_scheme::ApiPoint const apiPoint = m_ParsedMapApi.GetPoints().front();
+ url_api::Point point;
+
+ request.m_viewportLat = point.m_lat = apiPoint.m_lat;
+ request.m_viewportLon = point.m_lon = apiPoint.m_lon;
+ point.m_name = apiPoint.m_title; point.m_id = apiPoint.m_url;
+
+ request.m_points.push_back(point);
+ }
+
return true;
}
}