diff --git a/android/jni/com/mapswithme/maps/Framework.cpp b/android/jni/com/mapswithme/maps/Framework.cpp index 581c6a017e..ef02c9c5d2 100644 --- a/android/jni/com/mapswithme/maps/Framework.cpp +++ b/android/jni/com/mapswithme/maps/Framework.cpp @@ -1175,13 +1175,15 @@ Java_com_mapswithme_maps_Framework_nativeGetBestRouter(JNIEnv * env, jclass, } JNIEXPORT void JNICALL -Java_com_mapswithme_maps_Framework_nativeAddRoutePoint(JNIEnv * env, jclass, jstring name, - jint markType, jint intermediateIndex, +Java_com_mapswithme_maps_Framework_nativeAddRoutePoint(JNIEnv * env, jclass, jstring title, + jstring subtitle, jint markType, + jint intermediateIndex, jboolean isMyPosition, jdouble lat, jdouble lon) { RouteMarkData data; - data.m_name = jni::ToNativeString(env, name); + data.m_title = jni::ToNativeString(env, title); + data.m_subTitle = jni::ToNativeString(env, subtitle); data.m_pointType = static_cast(markType); data.m_intermediateIndex = static_cast(intermediateIndex); data.m_isMyPosition = static_cast(isMyPosition); @@ -1217,16 +1219,19 @@ Java_com_mapswithme_maps_Framework_nativeGetRoutePoints(JNIEnv * env, jclass) static jclass const pointClazz = jni::GetGlobalClassRef(env, "com/mapswithme/maps/routing/RouteMarkData"); - // Java signature : RouteMarkData(String name, @RoutePointInfo.RouteMarkType int pointType, + // Java signature : RouteMarkData(String title, String subtitle, + // @RoutePointInfo.RouteMarkType int pointType, // int intermediateIndex, boolean isVisible, boolean isMyPosition, // boolean isPassed, double lat, double lon) static jmethodID const pointConstructor = jni::GetConstructorID(env, pointClazz, - "(Ljava/lang/String;IIZZZDD)V"); + "(Ljava/lang/String;Ljava/lang/String;IIZZZDD)V"); return jni::ToJavaArray(env, pointClazz, points, [&](JNIEnv * env, RouteMarkData const & data) { - jni::TScopedLocalRef const name(env, jni::ToJavaString(env, data.m_name)); + jni::TScopedLocalRef const title(env, jni::ToJavaString(env, data.m_title)); + jni::TScopedLocalRef const subtitle(env, jni::ToJavaString(env, data.m_subTitle)); return env->NewObject(pointClazz, pointConstructor, - name.get(), static_cast(data.m_pointType), + title.get(), subtitle.get(), + static_cast(data.m_pointType), static_cast(data.m_intermediateIndex), static_cast(data.m_isVisible), static_cast(data.m_isMyPosition), diff --git a/android/src/com/mapswithme/maps/Framework.java b/android/src/com/mapswithme/maps/Framework.java index 06ddd1cf1e..0c20cd4396 100644 --- a/android/src/com/mapswithme/maps/Framework.java +++ b/android/src/com/mapswithme/maps/Framework.java @@ -274,7 +274,7 @@ public class Framework public static native int nativeGetBestRouter(double srcLat, double srcLon, double dstLat, double dstLon); - public static native void nativeAddRoutePoint(String name, + public static native void nativeAddRoutePoint(String title, String subtitle, @RoutePointInfo.RouteMarkType int markType, int intermediateIndex, boolean isMyPosition, double lat, double lon); diff --git a/android/src/com/mapswithme/maps/routing/RouteMarkData.java b/android/src/com/mapswithme/maps/routing/RouteMarkData.java index fb893df588..8b8889ca49 100644 --- a/android/src/com/mapswithme/maps/routing/RouteMarkData.java +++ b/android/src/com/mapswithme/maps/routing/RouteMarkData.java @@ -1,11 +1,16 @@ package com.mapswithme.maps.routing; +import android.support.annotation.Nullable; + /** * Represents RouteMarkData from core. */ public class RouteMarkData { - public final String mName; + @Nullable + public final String mTitle; + @Nullable + public final String mSubtitle; @RoutePointInfo.RouteMarkType public final int mPointType; public final int mIntermediateIndex; @@ -15,11 +20,13 @@ public class RouteMarkData public final double mLat; public final double mLon; - public RouteMarkData(String name, @RoutePointInfo.RouteMarkType int pointType, + public RouteMarkData(@Nullable String title, @Nullable String subtitle, + @RoutePointInfo.RouteMarkType int pointType, int intermediateIndex, boolean isVisible, boolean isMyPosition, boolean isPassed, double lat, double lon) { - mName = name; + mTitle = title; + mSubtitle = subtitle; mPointType = pointType; mIntermediateIndex = intermediateIndex; mIsVisible = isVisible; diff --git a/android/src/com/mapswithme/maps/routing/RoutingController.java b/android/src/com/mapswithme/maps/routing/RoutingController.java index 233bfa735a..40dee3a4f0 100644 --- a/android/src/com/mapswithme/maps/routing/RoutingController.java +++ b/android/src/com/mapswithme/maps/routing/RoutingController.java @@ -471,7 +471,9 @@ public class RoutingController implements TaxiManager.TaxiListener public void addStop(@NonNull MapObject mapObject) { - Framework.nativeAddRoutePoint(""/* name */, RoutePointInfo.ROUTE_MARK_INTERMEDIATE, + // TODO(@alexzatsepin): set correct title and subtitle. + Framework.nativeAddRoutePoint(""/* title */, ""/* subtitle */, + RoutePointInfo.ROUTE_MARK_INTERMEDIATE, 0/* intermediateIndex */, MapObject.isOfType(MapObject.MY_POSITION, mapObject), mapObject.getLat(), mapObject.getLon()); @@ -521,8 +523,8 @@ public class RoutingController implements TaxiManager.TaxiListener private MapObject toMapObject(@NonNull RouteMarkData point) { return new MapObject("", 0L, 0, point.mIsMyPosition ? MapObject.MY_POSITION : MapObject.POI, - point.mName, null, null, null, point.mLat, point.mLon, null, null, null, null, - null, null); + point.mTitle, null, point.mSubtitle, null, point.mLat, point.mLon, null, + null, null, null, null, null); } public boolean isStopPointAllowed() @@ -752,8 +754,9 @@ public class RoutingController implements TaxiManager.TaxiListener { if (startPoint != null) { - Framework.nativeAddRoutePoint(""/* name */, RoutePointInfo.ROUTE_MARK_START, - 0/* intermediateIndex */, + // TODO(@alexzatsepin): set correct title and subtitle. + Framework.nativeAddRoutePoint(""/* title */, ""/* subtitle */, + RoutePointInfo.ROUTE_MARK_START, 0/* intermediateIndex */, MapObject.isOfType(MapObject.MY_POSITION, startPoint), startPoint.getLat(), startPoint.getLon()); if (mContainer != null) @@ -762,8 +765,9 @@ public class RoutingController implements TaxiManager.TaxiListener if (endPoint != null) { - Framework.nativeAddRoutePoint(""/* name */, RoutePointInfo.ROUTE_MARK_FINISH, - 0/* intermediateIndex */, + // TODO(@alexzatsepin): set correct title and subtitle. + Framework.nativeAddRoutePoint(""/* title */, ""/* subtitle */, + RoutePointInfo.ROUTE_MARK_FINISH, 0/* intermediateIndex */, MapObject.isOfType(MapObject.MY_POSITION, endPoint), endPoint.getLat(), endPoint.getLon()); if (mContainer != null) @@ -813,8 +817,9 @@ public class RoutingController implements TaxiManager.TaxiListener boolean isSamePoint = MapObject.same(startPoint, point); if (point != null) { - Framework.nativeAddRoutePoint(""/* name */, RoutePointInfo.ROUTE_MARK_START, - 0/* intermediateIndex */, + // TODO(@alexzatsepin): set correct title and subtitle. + Framework.nativeAddRoutePoint(""/* title */, ""/* subtitle */, + RoutePointInfo.ROUTE_MARK_START, 0/* intermediateIndex */, MapObject.isOfType(MapObject.MY_POSITION, point), point.getLat(), point.getLon()); startPoint = getStartPoint(); @@ -866,8 +871,9 @@ public class RoutingController implements TaxiManager.TaxiListener boolean isSamePoint = MapObject.same(endPoint, point); if (point != null) { - Framework.nativeAddRoutePoint(""/* name */, RoutePointInfo.ROUTE_MARK_FINISH, - 0/* intermediateIndex */, + // TODO(@alexzatsepin): set correct title and subtitle. + Framework.nativeAddRoutePoint(""/* title */, ""/* subtitle */, + RoutePointInfo.ROUTE_MARK_FINISH, 0/* intermediateIndex */, MapObject.isOfType(MapObject.MY_POSITION, point), point.getLat(), point.getLon()); endPoint = getEndPoint(); diff --git a/iphone/Maps/Core/Routing/MWMRoutePoint.h b/iphone/Maps/Core/Routing/MWMRoutePoint.h index 61fdedf46a..fc695945e3 100644 --- a/iphone/Maps/Core/Routing/MWMRoutePoint.h +++ b/iphone/Maps/Core/Routing/MWMRoutePoint.h @@ -8,9 +8,11 @@ typedef NS_ENUM(NSUInteger, MWMRoutePointType) { - (instancetype)initWithLastLocationAndType:(MWMRoutePointType)type; -@property(copy, nonatomic, readonly) NSString * name; +@property(copy, nonatomic, readonly) NSString * title; +@property(copy, nonatomic, readonly) NSString * subtitle; @property(nonatomic, readonly) BOOL isMyPosition; @property(nonatomic, readonly) MWMRoutePointType type; +@property(nonatomic, readonly) int8_t intermediateIndex; @property(nonatomic, readonly) double latitude; @property(nonatomic, readonly) double longitude; diff --git a/iphone/Maps/Core/Routing/MWMRoutePoint.mm b/iphone/Maps/Core/Routing/MWMRoutePoint.mm index c27af2e0e2..3af5b0dd14 100644 --- a/iphone/Maps/Core/Routing/MWMRoutePoint.mm +++ b/iphone/Maps/Core/Routing/MWMRoutePoint.mm @@ -24,9 +24,11 @@ if (self) { _point = lastLocation.mercator; - _name = L(@"p2p_your_location"); + _title = L(@"p2p_your_location"); + _subtitle = L(@""); _isMyPosition = YES; _type = type; + _intermediateIndex = 0; } return self; } @@ -38,9 +40,11 @@ if (self) { _point = point.m_org; - _name = @(point.m_name.c_str()); + _title = @(point.m_name.c_str()); + _subtitle = L(@""); _isMyPosition = NO; _type = type; + _intermediateIndex = 0; } return self; } @@ -51,8 +55,10 @@ if (self) { _point = point.m_position; - _name = @(point.m_name.c_str()); + _title = @(point.m_title.c_str()); + _subtitle = @(point.m_subTitle.c_str()); _isMyPosition = point.m_isMyPosition; + _intermediateIndex = point.m_intermediateIndex; switch (point.m_pointType) { case RouteMarkType::Start: _type = MWMRoutePointTypeStart; break; @@ -71,12 +77,14 @@ _point = point; switch (type) { - case MWMRoutePointTypeStart: _name = @"Source"; break; - case MWMRoutePointTypeIntermediate: _name = @"Intermediate"; break; - case MWMRoutePointTypeFinish: _name = @"Destination"; break; + case MWMRoutePointTypeStart: _title = @"Source"; break; + case MWMRoutePointTypeIntermediate: _title = @"Intermediate"; break; + case MWMRoutePointTypeFinish: _title = @"Destination"; break; } + _subtitle = L(@""); _isMyPosition = NO; _type = type; + _intermediateIndex = 0; } return self; } @@ -94,6 +102,9 @@ } pt.m_position = self.point; pt.m_isMyPosition = static_cast(self.isMyPosition); + pt.m_title = self.title.UTF8String; + pt.m_subTitle = self.subtitle.UTF8String; + pt.m_intermediateIndex = self.intermediateIndex; return pt; } diff --git a/map/routing_mark.cpp b/map/routing_mark.cpp index 05b7c61fda..b1c332bc64 100644 --- a/map/routing_mark.cpp +++ b/map/routing_mark.cpp @@ -1,15 +1,34 @@ #include "map/routing_mark.hpp" +#include "drape_frontend/color_constants.hpp" +#include "drape_frontend/visual_params.hpp" + #include -RouteMarkPoint::RouteMarkPoint(m2::PointD const & ptOrg, - UserMarkContainer * container) +namespace +{ +static std::string const kRouteMarkPrimaryText = "RouteMarkPrimaryText"; +static std::string const kRouteMarkPrimaryTextOutline = "RouteMarkPrimaryTextOutline"; +static std::string const kRouteMarkSecondaryText = "RouteMarkSecondaryText"; +static std::string const kRouteMarkSecondaryTextOutline = "RouteMarkSecondaryTextOutline"; + +float const kRouteMarkPrimaryTextSize = 11.0f; +float const kRouteMarkSecondaryTextSize = 10.0f; +float const kRouteMarkSecondaryOffsetY = 2.0f; +} // namespace + +RouteMarkPoint::RouteMarkPoint(m2::PointD const & ptOrg, UserMarkContainer * container) : UserMark(ptOrg, container) { + float const vs = static_cast(df::VisualParams::Instance().GetVisualScale()); m_titleDecl.m_anchor = dp::Top; - m_titleDecl.m_primaryTextFont.m_color = dp::Color::Black(); - m_titleDecl.m_primaryTextFont.m_outlineColor = dp::Color::White(); - m_titleDecl.m_primaryTextFont.m_size = 22; + m_titleDecl.m_primaryTextFont.m_color = df::GetColorConstant(kRouteMarkPrimaryText); + m_titleDecl.m_primaryTextFont.m_outlineColor = df::GetColorConstant(kRouteMarkPrimaryTextOutline); + m_titleDecl.m_primaryTextFont.m_size = kRouteMarkPrimaryTextSize * vs; + m_titleDecl.m_secondaryTextFont.m_color = df::GetColorConstant(kRouteMarkSecondaryText); + m_titleDecl.m_secondaryTextFont.m_outlineColor = df::GetColorConstant(kRouteMarkSecondaryTextOutline); + m_titleDecl.m_secondaryTextFont.m_size = kRouteMarkSecondaryTextSize * vs; + m_titleDecl.m_secondaryOffset = m2::PointF(0, kRouteMarkSecondaryOffsetY * vs); m_markData.m_position = ptOrg; } @@ -54,13 +73,16 @@ void RouteMarkPoint::SetMarkData(RouteMarkData && data) { SetDirty(); m_markData = std::move(data); - m_titleDecl.m_primaryText = m_markData.m_name; + m_titleDecl.m_primaryText = m_markData.m_title; + if (!m_titleDecl.m_primaryText.empty()) + m_titleDecl.m_secondaryText = m_markData.m_subTitle; + else + m_titleDecl.m_secondaryText.clear(); } drape_ptr RouteMarkPoint::GetTitleDecl() const { - drape_ptr titleDecl = make_unique_dp(m_titleDecl); - return titleDecl; + return make_unique_dp(m_titleDecl); } std::string RouteMarkPoint::GetSymbolName() const diff --git a/map/routing_mark.hpp b/map/routing_mark.hpp index 35e71626a8..bf86425e34 100644 --- a/map/routing_mark.hpp +++ b/map/routing_mark.hpp @@ -13,7 +13,8 @@ enum class RouteMarkType : uint8_t struct RouteMarkData { - std::string m_name; + std::string m_title; + std::string m_subTitle; RouteMarkType m_pointType = RouteMarkType::Start; int8_t m_intermediateIndex = 0; bool m_isVisible = true;