forked from organicmaps/organicmaps
Place page info refactoring.
This commit is contained in:
parent
217906acee
commit
12ae209ce8
15 changed files with 396 additions and 367 deletions
|
@ -1336,8 +1336,9 @@ JNIEXPORT jobject JNICALL
|
|||
Java_com_mapswithme_maps_Framework_nativeDeleteBookmarkFromMapObject(JNIEnv * env, jclass)
|
||||
{
|
||||
place_page::Info & info = g_framework->GetPlacePageInfo();
|
||||
bookmarks_helper::RemoveBookmark(info.m_bac.m_categoryIndex, info.m_bac.m_bookmarkIndex);
|
||||
info.m_bac = {};
|
||||
auto const & bac = info.GetBookmarkAndCategory();
|
||||
bookmarks_helper::RemoveBookmark(bac.m_categoryIndex, bac.m_bookmarkIndex);
|
||||
info.SetBac({});
|
||||
return usermark_helper::CreateMapObject(env, info);
|
||||
}
|
||||
|
||||
|
@ -1345,8 +1346,9 @@ JNIEXPORT void JNICALL
|
|||
Java_com_mapswithme_maps_Framework_nativeOnBookmarkCategoryChanged(JNIEnv * env, jclass, jint cat, jint bmk)
|
||||
{
|
||||
place_page::Info & info = g_framework->GetPlacePageInfo();
|
||||
info.m_bac.m_categoryIndex = cat;
|
||||
info.m_bac.m_bookmarkIndex = bmk;
|
||||
ASSERT_GREATER_OR_EQUAL(bmk, 0, ());
|
||||
ASSERT_GREATER_OR_EQUAL(cat, 0, ());
|
||||
info.SetBac({static_cast<size_t>(bmk), static_cast<size_t>(cat)});
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
|
|
|
@ -668,7 +668,7 @@ Java_com_mapswithme_maps_downloader_MapManager_nativeEnableDownloadOn3g(JNIEnv *
|
|||
JNIEXPORT jstring JNICALL
|
||||
Java_com_mapswithme_maps_downloader_MapManager_nativeGetSelectedCountry(JNIEnv * env, jclass clazz)
|
||||
{
|
||||
storage::TCountryId const & res = g_framework->GetPlacePageInfo().m_countryId;
|
||||
storage::TCountryId const & res = g_framework->GetPlacePageInfo().GetCountryId();
|
||||
return (res == storage::kInvalidCountryId ? nullptr : jni::ToJavaString(env, res));
|
||||
}
|
||||
|
||||
|
|
|
@ -123,7 +123,7 @@ JNIEXPORT jobject JNICALL Java_com_mapswithme_maps_widget_placepage_Sponsored_na
|
|||
jni::ToJavaString(env, ppInfo.GetSponsoredUrl()),
|
||||
jni::ToJavaString(env, ppInfo.GetSponsoredDescriptionUrl()),
|
||||
jni::ToJavaString(env, ppInfo.GetSponsoredReviewUrl()),
|
||||
(jint)ppInfo.m_sponsoredType);
|
||||
(jint)ppInfo.GetSponsoredType());
|
||||
}
|
||||
|
||||
// static void nativeRequestPrice(String id, String currencyCode);
|
||||
|
|
|
@ -85,7 +85,7 @@ jobject CreateMapObject(JNIEnv * env, place_page::Info const & info)
|
|||
jni::TScopedLocalRef localAdInfo(env, CreateLocalAdInfo(env, info));
|
||||
|
||||
jni::TScopedLocalRef routingPointInfo(env, nullptr);
|
||||
if (info.m_isRoutePoint)
|
||||
if (info.IsRoutePoint())
|
||||
routingPointInfo.reset(CreateRoutePointInfo(env, info));
|
||||
|
||||
if (info.IsBookmark())
|
||||
|
@ -99,36 +99,32 @@ jobject CreateMapObject(JNIEnv * env, place_page::Info const & info)
|
|||
static jmethodID const ctorId =
|
||||
jni::GetConstructorID(env, g_bookmarkClazz,
|
||||
"(Ljava/lang/String;JIIILjava/lang/String;Ljava/"
|
||||
"lang/String;Ljava/lang/String;"
|
||||
"lang/String;Ljava/lang/String;Ljava/lang/String;"
|
||||
"[Lcom/mapswithme/maps/ads/Banner;[ILjava/lang/String;"
|
||||
"Lcom/mapswithme/maps/ads/LocalAdInfo;"
|
||||
"Lcom/mapswithme/maps/routing/RoutePointInfo;)V");
|
||||
|
||||
auto const & bac = info.GetBookmarkAndCategory();
|
||||
BookmarkCategory * cat = g_framework->NativeFramework()->GetBmCategory(bac.m_categoryIndex);
|
||||
BookmarkData const & data =
|
||||
static_cast<Bookmark const *>(cat->GetUserMark(bac.m_bookmarkIndex))->GetData();
|
||||
|
||||
BookmarkData const & data = info.GetBookmarkData();
|
||||
jni::TScopedLocalRef jMwmName(env, jni::ToJavaString(env, info.GetID().GetMwmName()));
|
||||
jni::TScopedLocalRef jName(env, jni::ToJavaString(env, data.GetName()));
|
||||
jni::TScopedLocalRef jTitle(env, jni::ToJavaString(env, info.GetTitle()));
|
||||
jni::TScopedLocalRef jSecondaryTitle(env, jni::ToJavaString(env, info.GetSecondaryTitle()));
|
||||
jni::TScopedLocalRef jSubtitle(env, jni::ToJavaString(env, info.GetSubtitle()));
|
||||
jni::TScopedLocalRef jAddress(env, jni::ToJavaString(env, info.GetAddress()));
|
||||
|
||||
jni::TScopedLocalRef jBookingSearchUrl(env, jni::ToJavaString(env, info.GetBookingSearchUrl()));
|
||||
jobject mapObject =
|
||||
env->NewObject(g_bookmarkClazz, ctorId, jMwmName.get(), info.GetID().GetMwmVersion(),
|
||||
info.GetID().m_index, static_cast<jint>(info.m_bac.m_categoryIndex),
|
||||
static_cast<jint>(info.m_bac.m_bookmarkIndex), jName.get(), jTitle.get(),
|
||||
jSecondaryTitle.get(), jbanners.get(),
|
||||
jTaxiTypes.get(), jBookingSearchUrl.get(), localAdInfo.get(), routingPointInfo.get());
|
||||
jobject mapObject = env->NewObject(
|
||||
g_bookmarkClazz, ctorId, jMwmName.get(), info.GetID().GetMwmVersion(), info.GetID().m_index,
|
||||
static_cast<jint>(bac.m_categoryIndex), static_cast<jint>(bac.m_bookmarkIndex),
|
||||
jTitle.get(), jSecondaryTitle.get(), jSubtitle.get(), jAddress.get(), jbanners.get(),
|
||||
jTaxiTypes.get(), jBookingSearchUrl.get(), localAdInfo.get(), routingPointInfo.get());
|
||||
if (info.IsFeature())
|
||||
InjectMetadata(env, g_mapObjectClazz, mapObject, info.GetMetadata());
|
||||
return mapObject;
|
||||
}
|
||||
|
||||
ms::LatLon const ll = info.GetLatLon();
|
||||
search::AddressInfo const address =
|
||||
g_framework->NativeFramework()->GetAddressInfoAtPoint(info.GetMercator());
|
||||
|
||||
// TODO(yunikkk): object can be POI + API + search result + bookmark simultaneously.
|
||||
// TODO(yunikkk): Should we pass localized strings here and in other methods as byte arrays?
|
||||
if (info.IsMyPosition())
|
||||
|
@ -136,25 +132,24 @@ jobject CreateMapObject(JNIEnv * env, place_page::Info const & info)
|
|||
return CreateMapObject(env, info.GetID().GetMwmName(), info.GetID().GetMwmVersion(),
|
||||
info.GetID().m_index, kMyPosition, info.GetTitle(),
|
||||
info.GetSecondaryTitle(), info.GetSubtitle(), ll.lat, ll.lon,
|
||||
address.FormatAddress(), {}, "", jbanners.get(),
|
||||
jTaxiTypes.get(), info.GetBookingSearchUrl(), localAdInfo.get(), routingPointInfo.get());
|
||||
info.GetAddress(), {}, "", jbanners.get(), jTaxiTypes.get(),
|
||||
info.GetBookingSearchUrl(), localAdInfo.get(), routingPointInfo.get());
|
||||
}
|
||||
|
||||
if (info.HasApiUrl())
|
||||
{
|
||||
return CreateMapObject(env, info.GetID().GetMwmName(), info.GetID().GetMwmVersion(),
|
||||
info.GetID().m_index, kApiPoint, info.GetTitle(),
|
||||
info.GetSecondaryTitle(), info.GetSubtitle(), ll.lat, ll.lon,
|
||||
address.FormatAddress(), info.GetMetadata(), info.GetApiUrl(),
|
||||
jbanners.get(), jTaxiTypes.get(), info.GetBookingSearchUrl(),
|
||||
localAdInfo.get(), routingPointInfo.get());
|
||||
return CreateMapObject(
|
||||
env, info.GetID().GetMwmName(), info.GetID().GetMwmVersion(), info.GetID().m_index,
|
||||
kApiPoint, info.GetTitle(), info.GetSecondaryTitle(), info.GetSubtitle(), ll.lat, ll.lon,
|
||||
info.GetAddress(), info.GetMetadata(), info.GetApiUrl(), jbanners.get(), jTaxiTypes.get(),
|
||||
info.GetBookingSearchUrl(), localAdInfo.get(), routingPointInfo.get());
|
||||
}
|
||||
|
||||
return CreateMapObject(env, info.GetID().GetMwmName(), info.GetID().GetMwmVersion(),
|
||||
info.GetID().m_index, kPoi, info.GetTitle(), info.GetSecondaryTitle(),
|
||||
info.GetSubtitle(), ll.lat, ll.lon, address.FormatAddress(),
|
||||
info.IsFeature() ? info.GetMetadata() : Metadata(), "", jbanners.get(),
|
||||
jTaxiTypes.get(), info.GetBookingSearchUrl(), localAdInfo.get(), routingPointInfo.get());
|
||||
return CreateMapObject(
|
||||
env, info.GetID().GetMwmName(), info.GetID().GetMwmVersion(), info.GetID().m_index, kPoi,
|
||||
info.GetTitle(), info.GetSecondaryTitle(), info.GetSubtitle(), ll.lat, ll.lon,
|
||||
info.GetAddress(), info.IsFeature() ? info.GetMetadata() : Metadata(), "", jbanners.get(),
|
||||
jTaxiTypes.get(), info.GetBookingSearchUrl(), localAdInfo.get(), routingPointInfo.get());
|
||||
}
|
||||
|
||||
jobjectArray ToBannersArray(JNIEnv * env, vector<ads::Banner> const & banners)
|
||||
|
@ -197,7 +192,7 @@ jobject CreateRoutePointInfo(JNIEnv * env, place_page::Info const & info)
|
|||
{
|
||||
static jclass const clazz = jni::GetGlobalClassRef(env, "com/mapswithme/maps/routing/RoutePointInfo");
|
||||
static jmethodID const ctorId = jni::GetConstructorID(env, clazz, "(II)V");
|
||||
int const markType = static_cast<int>(info.m_routeMarkType);
|
||||
return env->NewObject(clazz, ctorId, markType, info.m_intermediateIndex);
|
||||
int const markType = static_cast<int>(info.GetRouteMarkType());
|
||||
return env->NewObject(clazz, ctorId, markType, info.GetIntermediateIndex());
|
||||
}
|
||||
} // namespace usermark_helper
|
||||
|
|
|
@ -81,13 +81,4 @@ Java_com_mapswithme_maps_bookmarks_data_Bookmark_nativeEncode2Ge0Url(
|
|||
{
|
||||
return jni::ToJavaString(env, frm()->CodeGe0url(getBookmark(cat, bmk), addName));
|
||||
}
|
||||
|
||||
JNIEXPORT jstring JNICALL
|
||||
Java_com_mapswithme_maps_bookmarks_data_Bookmark_nativeGetAddress(
|
||||
JNIEnv * env, jobject thiz, jint catId, jlong bmkId)
|
||||
{
|
||||
Bookmark const * bmk = getBookmark(catId, bmkId);
|
||||
search::AddressInfo const address = g_framework->NativeFramework()->GetAddressInfoAtPoint(MercatorBounds::FromLatLon(bmk->GetLatLon()));
|
||||
return jni::ToJavaString(env, address.FormatAddress());
|
||||
}
|
||||
} // extern "C"
|
||||
|
|
|
@ -108,7 +108,7 @@ Java_com_mapswithme_maps_bookmarks_data_BookmarkManager_nativeAddBookmarkToLastE
|
|||
size_t const lastEditedCategory = f->LastEditedBMCategory();
|
||||
size_t const createdBookmarkIndex = f->AddBookmark(lastEditedCategory, glbPoint, bmkData);
|
||||
place_page::Info & info = g_framework->GetPlacePageInfo();
|
||||
info.m_bac = {createdBookmarkIndex, lastEditedCategory};
|
||||
info.SetBac({createdBookmarkIndex, lastEditedCategory});
|
||||
return usermark_helper::CreateMapObject(env, info);
|
||||
}
|
||||
|
||||
|
|
|
@ -5,7 +5,6 @@ import android.os.Parcel;
|
|||
import android.support.annotation.IntRange;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.mapswithme.maps.Framework;
|
||||
import com.mapswithme.maps.ads.Banner;
|
||||
|
@ -23,24 +22,22 @@ public class Bookmark extends MapObject
|
|||
private int mBookmarkId;
|
||||
private double mMerX;
|
||||
private double mMerY;
|
||||
@Nullable
|
||||
private final String mObjectTitle;
|
||||
|
||||
public Bookmark(@NonNull String mwmName, long mwmVersion, int featureIndex,
|
||||
@IntRange(from = 0) int categoryId, @IntRange(from = 0) int bookmarkId,
|
||||
String title, @Nullable String secondaryTitle, @Nullable String objectTitle,
|
||||
String title, @Nullable String secondaryTitle, @Nullable String subtitle,
|
||||
@Nullable String address,
|
||||
@Nullable Banner[] banners, @TaxiManager.TaxiType int[] reachableByTaxiTypes,
|
||||
@Nullable String bookingSearchUrl, @Nullable LocalAdInfo localAdInfo,
|
||||
@Nullable RoutePointInfo routePointInfo)
|
||||
{
|
||||
super(mwmName, mwmVersion, featureIndex, BOOKMARK, title, secondaryTitle, "", "", 0, 0, "",
|
||||
super(mwmName, mwmVersion, featureIndex, BOOKMARK, title, secondaryTitle, subtitle, address, 0, 0, "",
|
||||
banners, reachableByTaxiTypes, bookingSearchUrl, localAdInfo, routePointInfo);
|
||||
|
||||
mCategoryId = categoryId;
|
||||
mBookmarkId = bookmarkId;
|
||||
mIcon = getIconInternal();
|
||||
initXY();
|
||||
mObjectTitle = objectTitle;
|
||||
}
|
||||
|
||||
private void initXY()
|
||||
|
@ -59,7 +56,6 @@ public class Bookmark extends MapObject
|
|||
super.writeToParcel(dest, flags);
|
||||
dest.writeInt(mCategoryId);
|
||||
dest.writeInt(mBookmarkId);
|
||||
dest.writeString(mObjectTitle);
|
||||
}
|
||||
|
||||
protected Bookmark(@MapObjectType int type, Parcel source)
|
||||
|
@ -69,13 +65,6 @@ public class Bookmark extends MapObject
|
|||
mBookmarkId = source.readInt();
|
||||
mIcon = getIconInternal();
|
||||
initXY();
|
||||
mObjectTitle = source.readString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAddress()
|
||||
{
|
||||
return nativeGetAddress(mCategoryId, mBookmarkId);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -106,15 +95,6 @@ public class Bookmark extends MapObject
|
|||
return MapObject.BOOKMARK;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSubtitle()
|
||||
{
|
||||
String subtitle = getCategoryName();
|
||||
if (!TextUtils.isEmpty(mObjectTitle) && !mTitle.equals(mObjectTitle))
|
||||
subtitle += " - " + mObjectTitle;
|
||||
return subtitle;
|
||||
}
|
||||
|
||||
public String getCategoryName()
|
||||
{
|
||||
return getCategory().getName();
|
||||
|
@ -144,7 +124,6 @@ public class Bookmark extends MapObject
|
|||
{
|
||||
nativeSetBookmarkParams(mCategoryId, mBookmarkId, title, icon != null ? icon.getType() : "",
|
||||
description);
|
||||
mTitle = title;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -181,8 +160,6 @@ public class Bookmark extends MapObject
|
|||
|
||||
private native double nativeGetScale(@IntRange(from = 0) int catId, @IntRange(from = 0) long bookmarkId);
|
||||
|
||||
private native String nativeGetAddress(@IntRange(from = 0) int catId, @IntRange(from = 0) long bookmarkId);
|
||||
|
||||
private native String nativeEncode2Ge0Url(@IntRange(from = 0) int catId, @IntRange(from = 0) long bookmarkId, boolean addName);
|
||||
|
||||
private native void nativeSetBookmarkParams(@IntRange(from = 0) int catId, @IntRange(from = 0) long bookmarkId, String name, String type, String descr);
|
||||
|
|
|
@ -39,7 +39,7 @@ public class MapObject implements Parcelable
|
|||
@MapObjectType
|
||||
private final int mMapObjectType;
|
||||
|
||||
protected String mTitle;
|
||||
private String mTitle;
|
||||
@Nullable
|
||||
private String mSecondaryTitle;
|
||||
private String mSubtitle;
|
||||
|
|
|
@ -231,12 +231,12 @@ void initFieldsMap()
|
|||
|
||||
- (place_page::Info const &)info { return m_info; }
|
||||
- (FeatureID const &)featureID { return m_info.GetID(); }
|
||||
- (storage::TCountryId const &)countryId { return m_info.m_countryId; }
|
||||
- (storage::TCountryId const &)countryId { return m_info.GetCountryId(); }
|
||||
- (BOOL)isMyPosition { return m_info.IsMyPosition(); }
|
||||
- (BOOL)isBookmark { return m_info.IsBookmark(); }
|
||||
- (BOOL)isApi { return m_info.HasApiUrl(); }
|
||||
- (BOOL)isBooking { return m_info.m_sponsoredType == place_page::SponsoredType::Booking; }
|
||||
- (BOOL)isOpentable { return m_info.m_sponsoredType == place_page::SponsoredType::Opentable; }
|
||||
- (BOOL)isBooking { return m_info.GetSponsoredType() == place_page::SponsoredType::Booking; }
|
||||
- (BOOL)isOpentable { return m_info.GetSponsoredType() == place_page::SponsoredType::Opentable; }
|
||||
- (BOOL)isSponsored { return m_info.IsSponsored(); }
|
||||
- (NSString *)sponsoredId
|
||||
{
|
||||
|
@ -260,7 +260,7 @@ void initFieldsMap()
|
|||
|
||||
#pragma mark - Bookmark editing
|
||||
|
||||
- (void)setBac:(BookmarkAndCategory)bac { m_info.m_bac = bac; }
|
||||
- (void)setBac:(BookmarkAndCategory)bac { m_info.SetBac(bac); }
|
||||
- (BookmarkAndCategory)bac { return m_info.GetBookmarkAndCategory(); }
|
||||
- (NSString *)bookmarkCategory
|
||||
{
|
||||
|
|
|
@ -422,7 +422,7 @@ using namespace place_page;
|
|||
}
|
||||
category->SaveToKMLFile();
|
||||
|
||||
m_info.m_bac = {};
|
||||
m_info.SetBac({});
|
||||
m_sections.erase(remove(m_sections.begin(), m_sections.end(), Sections::Bookmark));
|
||||
}
|
||||
}
|
||||
|
@ -440,7 +440,7 @@ using namespace place_page;
|
|||
|
||||
#pragma mark - Getters
|
||||
|
||||
- (storage::TCountryId const &)countryId { return m_info.m_countryId; }
|
||||
- (storage::TCountryId const &)countryId { return m_info.GetCountryId(); }
|
||||
- (FeatureID const &)featureId { return m_info.GetID(); }
|
||||
- (NSString *)title { return @(m_info.GetTitle().c_str()); }
|
||||
- (NSString *)subtitle { return @(m_info.GetSubtitle().c_str()); }
|
||||
|
@ -620,34 +620,27 @@ using namespace place_page;
|
|||
|
||||
- (NSString *)externalTitle
|
||||
{
|
||||
if (m_info.IsBookmark() && m_info.m_bookmarkTitle != m_info.GetTitle())
|
||||
return @(m_info.m_bookmarkTitle.c_str());
|
||||
|
||||
auto const secondaryTitle = m_info.GetSecondaryTitle();
|
||||
if (!secondaryTitle.empty())
|
||||
return @(secondaryTitle.c_str());
|
||||
|
||||
return nil;
|
||||
return m_info.GetSecondaryTitle().empty() ? nil : @(m_info.GetSecondaryTitle().c_str());
|
||||
}
|
||||
|
||||
- (NSString *)bookmarkColor
|
||||
{
|
||||
return m_info.IsBookmark() ? @(m_info.m_bookmarkColorName.c_str()) : nil;
|
||||
return m_info.IsBookmark() ? @(m_info.GetBookmarkData().GetType().c_str()) : nil;
|
||||
}
|
||||
|
||||
- (NSString *)bookmarkDescription
|
||||
{
|
||||
return m_info.IsBookmark() ? @(m_info.m_bookmarkDescription.c_str()) : nil;
|
||||
return m_info.IsBookmark() ? @(m_info.GetBookmarkData().GetDescription().c_str()) : nil;
|
||||
}
|
||||
|
||||
- (NSString *)bookmarkCategory
|
||||
{
|
||||
return m_info.IsBookmark() ? @(m_info.m_bookmarkCategoryName.c_str()) : nil;
|
||||
return m_info.IsBookmark() ? @(m_info.GetBookmarkCategoryName().c_str()) : nil;
|
||||
}
|
||||
|
||||
- (BookmarkAndCategory)bac;
|
||||
{
|
||||
return m_info.IsBookmark() ? m_info.m_bac : BookmarkAndCategory();
|
||||
return m_info.IsBookmark() ? m_info.GetBookmarkAndCategory() : BookmarkAndCategory();
|
||||
}
|
||||
|
||||
#pragma mark - Local Ads
|
||||
|
@ -677,8 +670,8 @@ using namespace place_page;
|
|||
|
||||
#pragma mark - Getters
|
||||
|
||||
- (RouteMarkType)routeMarkType { return m_info.m_routeMarkType; }
|
||||
- (int8_t)intermediateIndex { return m_info.m_intermediateIndex; }
|
||||
- (RouteMarkType)routeMarkType { return m_info.GetRouteMarkType(); }
|
||||
- (int8_t)intermediateIndex { return m_info.GetIntermediateIndex(); }
|
||||
- (NSString *)address { return @(m_info.GetAddress().c_str()); }
|
||||
- (NSString *)apiURL { return @(m_info.GetApiUrl().c_str()); }
|
||||
- (std::vector<Sections> const &)sections { return m_sections; }
|
||||
|
@ -722,12 +715,12 @@ using namespace place_page;
|
|||
- (NSString *)phoneNumber { return @(m_info.GetPhone().c_str()); }
|
||||
- (BOOL)isBookmark { return m_info.IsBookmark(); }
|
||||
- (BOOL)isApi { return m_info.HasApiUrl(); }
|
||||
- (BOOL)isBooking { return m_info.m_sponsoredType == SponsoredType::Booking; }
|
||||
- (BOOL)isOpentable { return m_info.m_sponsoredType == SponsoredType::Opentable; }
|
||||
- (BOOL)isViator { return m_info.m_sponsoredType == SponsoredType::Viator; }
|
||||
- (BOOL)isBooking { return m_info.GetSponsoredType() == SponsoredType::Booking; }
|
||||
- (BOOL)isOpentable { return m_info.GetSponsoredType() == SponsoredType::Opentable; }
|
||||
- (BOOL)isViator { return m_info.GetSponsoredType() == SponsoredType::Viator; }
|
||||
- (BOOL)isBookingSearch { return !m_info.GetBookingSearchUrl().empty(); }
|
||||
- (BOOL)isMyPosition { return m_info.IsMyPosition(); }
|
||||
- (BOOL)isHTMLDescription { return strings::IsHTML(m_info.m_bookmarkDescription); }
|
||||
- (BOOL)isHTMLDescription { return strings::IsHTML(m_info.GetBookmarkData().GetDescription()); }
|
||||
- (BOOL)isRoutePoint { return m_info.IsRoutePoint(); }
|
||||
|
||||
#pragma mark - Coordinates
|
||||
|
|
|
@ -179,7 +179,7 @@ array<Class, 8> const kPreviewCells = {{[_MWMPPPTitle class], [_MWMPPPExternalTi
|
|||
self.lastCellIsBanner = NO;
|
||||
self.lastCellIndexPath = [NSIndexPath indexPathForRow:previewRows.size() - 1 inSection:0];
|
||||
|
||||
if (data.isMyPosition)
|
||||
if (data.isMyPosition || previewRows.size() == 1)
|
||||
{
|
||||
self.distanceRow = 0;
|
||||
}
|
||||
|
|
|
@ -816,15 +816,12 @@ bool Framework::DeleteBmCategory(size_t index)
|
|||
|
||||
void Framework::FillBookmarkInfo(Bookmark const & bmk, BookmarkAndCategory const & bac, place_page::Info & info) const
|
||||
{
|
||||
FillPointInfo(bmk.GetPivot(), string(), info);
|
||||
|
||||
info.m_bac = bac;
|
||||
info.SetBac(bac);
|
||||
BookmarkCategory * cat = GetBmCategory(bac.m_categoryIndex);
|
||||
info.m_bookmarkCategoryName = cat->GetName();
|
||||
info.SetBookmarkCategoryName(cat->GetName());
|
||||
BookmarkData const & data = static_cast<Bookmark const *>(cat->GetUserMark(bac.m_bookmarkIndex))->GetData();
|
||||
info.m_bookmarkTitle = data.GetName();
|
||||
info.m_bookmarkColorName = data.GetType();
|
||||
info.m_bookmarkDescription = data.GetDescription();
|
||||
info.SetBookmarkData(data);
|
||||
FillPointInfo(bmk.GetPivot(), {} /* customTitle */, info);
|
||||
}
|
||||
|
||||
void Framework::FillFeatureInfo(FeatureID const & fid, place_page::Info & info) const
|
||||
|
@ -859,10 +856,13 @@ void Framework::FillFeatureInfo(FeatureID const & fid, place_page::Info & info)
|
|||
{
|
||||
size_t const level = isState ? 1 : 0;
|
||||
TCountriesVec countries;
|
||||
info.m_countryId = m_infoGetter->GetRegionCountryId(info.GetMercator());
|
||||
GetStorage().GetTopmostNodesFor(info.m_countryId, countries, level);
|
||||
TCountryId countryId = m_infoGetter->GetRegionCountryId(info.GetMercator());
|
||||
GetStorage().GetTopmostNodesFor(countryId, countries, level);
|
||||
if (countries.size() == 1)
|
||||
info.m_countryId = countries.front();
|
||||
countryId = countries.front();
|
||||
|
||||
info.SetCountryId(countryId);
|
||||
info.SetTopmostCountryIds(countries);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -875,8 +875,10 @@ void Framework::FillPointInfo(m2::PointD const & mercator, string const & custom
|
|||
}
|
||||
else
|
||||
{
|
||||
info.m_customName = customTitle.empty() ? m_stringsBundle.GetString("placepage_unknown_place") : customTitle;
|
||||
info.m_canEditOrAdd = CanEditMap();
|
||||
auto const customName =
|
||||
customTitle.empty() ? m_stringsBundle.GetString("placepage_unknown_place") : customTitle;
|
||||
info.SetCustomName(customName);
|
||||
info.SetCanEditOrAdd(CanEditMap());
|
||||
}
|
||||
|
||||
// This line overwrites mercator center from area feature which can be far away.
|
||||
|
@ -896,81 +898,82 @@ void Framework::FillInfoFromFeatureType(FeatureType const & ft, place_page::Info
|
|||
feature::TypesHolder buildingHolder;
|
||||
buildingHolder.Assign(classif().GetTypeByPath({"building"}));
|
||||
|
||||
info.SetFromFeatureType(ft);
|
||||
info.SetLocalizedWifiString(m_stringsBundle.GetString("wifi"));
|
||||
info.SetLocalizedRatingString(m_stringsBundle.GetString("place_page_booking_rating"));
|
||||
|
||||
if (ftypes::IsAddressObjectChecker::Instance()(ft))
|
||||
info.m_address = GetAddressInfoAtPoint(feature::GetCenter(ft)).FormatHouseAndStreet();
|
||||
info.SetAddress(GetAddressInfoAtPoint(feature::GetCenter(ft)).FormatHouseAndStreet());
|
||||
|
||||
info.SetFromFeatureType(ft);
|
||||
|
||||
if (ftypes::IsBookingChecker::Instance()(ft))
|
||||
{
|
||||
ASSERT(m_bookingApi, ());
|
||||
info.m_sponsoredType = SponsoredType::Booking;
|
||||
info.SetSponsoredType(SponsoredType::Booking);
|
||||
auto const & baseUrl = info.GetMetadata().Get(feature::Metadata::FMD_WEBSITE);
|
||||
auto const & hotelId = info.GetMetadata().Get(feature::Metadata::FMD_SPONSORED_ID);
|
||||
info.m_sponsoredUrl = m_bookingApi->GetBookHotelUrl(baseUrl);
|
||||
info.m_sponsoredDescriptionUrl = m_bookingApi->GetDescriptionUrl(baseUrl);
|
||||
info.m_sponsoredReviewUrl = m_bookingApi->GetHotelReviewsUrl(hotelId, baseUrl);
|
||||
info.SetSponsoredUrl(m_bookingApi->GetBookHotelUrl(baseUrl));
|
||||
info.SetSponsoredDescriptionUrl(m_bookingApi->GetDescriptionUrl(baseUrl));
|
||||
info.SetSponsoredReviewUrl(m_bookingApi->GetHotelReviewsUrl(hotelId, baseUrl));
|
||||
}
|
||||
else if (ftypes::IsOpentableChecker::Instance()(ft))
|
||||
{
|
||||
info.m_sponsoredType = SponsoredType::Opentable;
|
||||
info.SetSponsoredType(SponsoredType::Opentable);
|
||||
auto const & sponsoredId = info.GetMetadata().Get(feature::Metadata::FMD_SPONSORED_ID);
|
||||
auto const & url = opentable::Api::GetBookTableUrl(sponsoredId);
|
||||
info.m_sponsoredUrl = url;
|
||||
info.m_sponsoredDescriptionUrl = url;
|
||||
info.SetSponsoredUrl(url);
|
||||
info.SetSponsoredDescriptionUrl(url);
|
||||
}
|
||||
else if (ftypes::IsViatorChecker::Instance()(ft))
|
||||
{
|
||||
info.m_sponsoredType = SponsoredType::Viator;
|
||||
info.SetSponsoredType(SponsoredType::Viator);
|
||||
auto const & sponsoredId = info.GetMetadata().Get(feature::Metadata::FMD_SPONSORED_ID);
|
||||
info.m_sponsoredUrl = viator::Api::GetCityUrl(sponsoredId);
|
||||
info.m_isPreviewExtended = true;
|
||||
info.SetSponsoredDescriptionUrl(viator::Api::GetCityUrl(sponsoredId));
|
||||
}
|
||||
else if (ftypes::IsHotelChecker::Instance()(ft))
|
||||
{
|
||||
info.m_bookingSearchUrl = MakeSearchBookingUrl(*m_bookingApi, *m_cityFinder, ft);
|
||||
LOG(LINFO, (info.m_bookingSearchUrl));
|
||||
auto const url = MakeSearchBookingUrl(*m_bookingApi, *m_cityFinder, ft);
|
||||
info.SetBookingSearchUrl(url);
|
||||
LOG(LINFO, (url));
|
||||
}
|
||||
else if (cian::Api::IsCitySupported(city) &&
|
||||
(buildingHolder.Equals({ft}) || ftypes::IsPublicTransportStopChecker::Instance()(ft)))
|
||||
{
|
||||
info.m_sponsoredType = SponsoredType::Cian;
|
||||
info.m_isPreviewExtended = true;
|
||||
info.SetSponsoredType(SponsoredType::Cian);
|
||||
}
|
||||
|
||||
auto const mwmInfo = ft.GetID().m_mwmId.GetInfo();
|
||||
bool const isMapVersionEditable = mwmInfo && mwmInfo->m_version.IsEditableMap();
|
||||
info.m_canEditOrAdd = featureStatus != osm::Editor::FeatureStatus::Obsolete && CanEditMap() &&
|
||||
!info.IsNotEditableSponsored() && isMapVersionEditable;
|
||||
|
||||
info.m_localizedWifiString = m_stringsBundle.GetString("wifi");
|
||||
info.m_localizedRatingString = m_stringsBundle.GetString("place_page_booking_rating");
|
||||
bool const canEditOrAdd = featureStatus != osm::Editor::FeatureStatus::Obsolete && CanEditMap() &&
|
||||
!info.IsNotEditableSponsored() && isMapVersionEditable;
|
||||
info.SetCanEditOrAdd(canEditOrAdd);
|
||||
|
||||
if (m_localAdsManager.IsSupportedType(info.GetTypes()))
|
||||
{
|
||||
info.m_localAdsUrl = m_localAdsManager.GetCompanyUrl(ft.GetID());
|
||||
info.m_localAdsStatus = m_localAdsManager.Contains(ft.GetID())
|
||||
? place_page::LocalAdsStatus::Customer
|
||||
: place_page::LocalAdsStatus::Candidate;
|
||||
info.SetLocalAdsUrl(m_localAdsManager.GetCompanyUrl(ft.GetID()));
|
||||
auto const status = m_localAdsManager.Contains(ft.GetID())
|
||||
? place_page::LocalAdsStatus::Customer
|
||||
: place_page::LocalAdsStatus::Candidate;
|
||||
info.SetLocalAdsStatus(status);
|
||||
}
|
||||
else
|
||||
{
|
||||
info.m_localAdsStatus = place_page::LocalAdsStatus::NotAvailable;
|
||||
info.SetLocalAdsStatus(place_page::LocalAdsStatus::NotAvailable);
|
||||
}
|
||||
|
||||
auto const latlon = MercatorBounds::ToLatLon(feature::GetCenter(ft));
|
||||
ASSERT(m_taxiEngine, ());
|
||||
info.m_reachableByProviders = m_taxiEngine->GetProvidersAtPos(latlon);
|
||||
info.SetReachableByTaxiProviders(m_taxiEngine->GetProvidersAtPos(latlon));
|
||||
}
|
||||
|
||||
void Framework::FillApiMarkInfo(ApiMarkPoint const & api, place_page::Info & info) const
|
||||
{
|
||||
FillPointInfo(api.GetPivot(), "", info);
|
||||
FillPointInfo(api.GetPivot(), {} /* customTitle */, info);
|
||||
string const & name = api.GetName();
|
||||
if (!name.empty())
|
||||
info.m_customName = name;
|
||||
info.m_apiId = api.GetID();
|
||||
info.m_apiUrl = GenerateApiBackUrl(api);
|
||||
info.SetCustomName(name);
|
||||
info.SetApiId(api.GetID());
|
||||
info.SetApiUrl(GenerateApiBackUrl(api));
|
||||
}
|
||||
|
||||
void Framework::FillSearchResultInfo(SearchMarkPoint const & smp, place_page::Info & info) const
|
||||
|
@ -986,25 +989,25 @@ void Framework::FillMyPositionInfo(place_page::Info & info, m2::PointD const & p
|
|||
double lat, lon;
|
||||
VERIFY(GetCurrentPosition(lat, lon), ());
|
||||
info.SetMercator(MercatorBounds::FromLatLon(lat, lon));
|
||||
info.m_isMyPosition = true;
|
||||
info.m_customName = m_stringsBundle.GetString("my_position");
|
||||
info.SetIsMyPosition();
|
||||
info.SetCustomName(m_stringsBundle.GetString("my_position"));
|
||||
|
||||
UserMark const * mark = FindUserMarkInTapPosition(pt);
|
||||
if (mark != nullptr && mark->GetMarkType() == UserMark::Type::ROUTING)
|
||||
{
|
||||
RouteMarkPoint const * routingMark = static_cast<RouteMarkPoint const *>(mark);
|
||||
info.m_isRoutePoint = true;
|
||||
info.m_routeMarkType = routingMark->GetRoutePointType();
|
||||
info.m_intermediateIndex = routingMark->GetIntermediateIndex();
|
||||
info.SetIsRoutePoint();
|
||||
info.SetRouteMarkType(routingMark->GetRoutePointType());
|
||||
info.SetIntermediateIndex(routingMark->GetIntermediateIndex());
|
||||
}
|
||||
}
|
||||
|
||||
void Framework::FillRouteMarkInfo(RouteMarkPoint const & rmp, place_page::Info & info) const
|
||||
{
|
||||
FillPointInfo(rmp.GetPivot(), "", info);
|
||||
info.m_isRoutePoint = true;
|
||||
info.m_routeMarkType = rmp.GetRoutePointType();
|
||||
info.m_intermediateIndex = rmp.GetIntermediateIndex();
|
||||
FillPointInfo(rmp.GetPivot(), {} /* customTitle */, info);
|
||||
info.SetIsRoutePoint();
|
||||
info.SetRouteMarkType(rmp.GetRoutePointType());
|
||||
info.SetIntermediateIndex(rmp.GetIntermediateIndex());
|
||||
}
|
||||
|
||||
void Framework::ShowBookmark(BookmarkAndCategory const & bnc)
|
||||
|
@ -2361,8 +2364,12 @@ void Framework::UpdatePlacePageInfoForCurrentSelection()
|
|||
place_page::Info info;
|
||||
|
||||
df::SelectionShape::ESelectedObject const obj = OnTapEventImpl(*m_lastTapEvent, info);
|
||||
info.m_countryId = m_infoGetter->GetRegionCountryId(info.GetMercator());
|
||||
GetStorage().GetTopmostNodesFor(info.m_countryId, info.m_topmostCountryIds);
|
||||
TCountryId const countryId = m_infoGetter->GetRegionCountryId(info.GetMercator());
|
||||
TCountriesVec countries;
|
||||
GetStorage().GetTopmostNodesFor(countryId, countries);
|
||||
|
||||
info.SetCountryId(countryId);
|
||||
info.SetTopmostCountryIds(countries);
|
||||
if (obj != df::SelectionShape::OBJECT_EMPTY)
|
||||
ActivateMapSelection(false, obj, info);
|
||||
}
|
||||
|
@ -2409,13 +2416,16 @@ void Framework::OnTapEvent(TapEvent const & tapEvent)
|
|||
// Older version of statistics used "$GetUserMark" event.
|
||||
alohalytics::Stats::Instance().LogEvent("$SelectMapObject", kv, alohalytics::Location::FromLatLon(ll.lat, ll.lon));
|
||||
|
||||
if (info.m_sponsoredType == SponsoredType::Booking)
|
||||
if (info.GetSponsoredType() == SponsoredType::Booking)
|
||||
GetPlatform().GetMarketingService().SendMarketingEvent(marketing::kPlacepageHotelBook, {{"provider", "booking.com"}});
|
||||
}
|
||||
|
||||
if (info.m_countryId.empty())
|
||||
info.m_countryId = m_infoGetter->GetRegionCountryId(info.GetMercator());
|
||||
GetStorage().GetTopmostNodesFor(info.m_countryId, info.m_topmostCountryIds);
|
||||
if (info.GetCountryId().empty())
|
||||
info.SetCountryId(m_infoGetter->GetRegionCountryId(info.GetMercator()));
|
||||
|
||||
TCountriesVec countries;
|
||||
GetStorage().GetTopmostNodesFor(info.GetCountryId(), countries);
|
||||
info.SetTopmostCountryIds(countries);
|
||||
|
||||
ActivateMapSelection(true, selection, info);
|
||||
}
|
||||
|
@ -2479,7 +2489,7 @@ df::SelectionShape::ESelectedObject Framework::OnTapEventImpl(TapEvent const & t
|
|||
return df::SelectionShape::OBJECT_MY_POSITION;
|
||||
}
|
||||
|
||||
outInfo.m_adsEngine = m_adsEngine.get();
|
||||
outInfo.SetAdsEngine(m_adsEngine.get());
|
||||
|
||||
UserMark const * mark = FindUserMarkInTapPosition(pxPoint2d);
|
||||
if (mark)
|
||||
|
@ -2517,7 +2527,7 @@ df::SelectionShape::ESelectedObject Framework::OnTapEventImpl(TapEvent const & t
|
|||
}
|
||||
else if (tapInfo.m_isLong || tapEvent.m_source == TapEvent::Source::Search)
|
||||
{
|
||||
FillPointInfo(m_currentModelView.PtoG(pxPoint2d), "", outInfo);
|
||||
FillPointInfo(m_currentModelView.PtoG(pxPoint2d), {} /* customTitle */, outInfo);
|
||||
showMapSelection = true;
|
||||
}
|
||||
|
||||
|
|
|
@ -20,20 +20,135 @@ char const * const Info::kEmptyRatingSymbol = "-";
|
|||
char const * const Info::kPricingSymbol = "$";
|
||||
char const * const kWheelchairSymbol = u8"\u267F";
|
||||
|
||||
bool Info::IsFeature() const { return m_featureID.IsValid(); }
|
||||
bool Info::IsBookmark() const { return m_bac.IsValid(); }
|
||||
bool Info::IsMyPosition() const { return m_isMyPosition; }
|
||||
bool Info::IsRoutePoint() const { return m_isRoutePoint; }
|
||||
bool Info::IsSponsored() const { return m_sponsoredType != SponsoredType::None; }
|
||||
bool Info::IsNotEditableSponsored() const { return m_sponsoredType == SponsoredType::Booking; }
|
||||
|
||||
bool Info::ShouldShowAddPlace() const
|
||||
{
|
||||
auto const isPointOrBuilding = IsPointType() || IsBuilding();
|
||||
return m_canEditOrAdd && !(IsFeature() && isPointOrBuilding);
|
||||
}
|
||||
|
||||
bool Info::ShouldShowAddBusiness() const { return m_canEditOrAdd && IsBuilding(); }
|
||||
void Info::SetFromFeatureType(FeatureType const & ft)
|
||||
{
|
||||
MapObject::SetFromFeatureType(ft);
|
||||
std::string primaryName;
|
||||
std::string secondaryName;
|
||||
GetPrefferedNames(primaryName, secondaryName);
|
||||
if (IsBookmark())
|
||||
{
|
||||
m_uiTitle = m_bookmarkData.GetName();
|
||||
|
||||
std::string secondary;
|
||||
if (m_customName.empty())
|
||||
secondary = primaryName.empty() ? secondaryName : primaryName;
|
||||
else
|
||||
secondary = m_customName;
|
||||
|
||||
if (m_uiTitle != secondary)
|
||||
m_uiSecondaryTitle = secondary;
|
||||
|
||||
m_uiSubtitle = FormatSubtitle(true /* withType */);
|
||||
m_uiAddress = m_address;
|
||||
}
|
||||
else if (!primaryName.empty())
|
||||
{
|
||||
m_uiTitle = primaryName;
|
||||
m_uiSecondaryTitle = secondaryName;
|
||||
m_uiSubtitle = FormatSubtitle(true /* withType */);
|
||||
m_uiAddress = m_address;
|
||||
}
|
||||
else if (!secondaryName.empty())
|
||||
{
|
||||
m_uiTitle = secondaryName;
|
||||
m_uiSubtitle = FormatSubtitle(true /* withType */);
|
||||
m_uiAddress = m_address;
|
||||
}
|
||||
else if (IsBuilding())
|
||||
{
|
||||
bool const isAddressEmpty = m_address.empty();
|
||||
m_uiTitle = isAddressEmpty ? GetLocalizedType() : m_address;
|
||||
m_uiSubtitle = FormatSubtitle(!isAddressEmpty /* withType */);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_uiTitle = GetLocalizedType();
|
||||
m_uiSubtitle = FormatSubtitle(false /* withType */);
|
||||
m_uiAddress = m_address;
|
||||
}
|
||||
}
|
||||
|
||||
string Info::FormatSubtitle(bool withType) const
|
||||
{
|
||||
std::vector<std::string> subtitle;
|
||||
|
||||
if (IsBookmark())
|
||||
subtitle.push_back(m_bookmarkCategoryName);
|
||||
|
||||
if (withType)
|
||||
subtitle.push_back(GetLocalizedType());
|
||||
// Flats.
|
||||
string const flats = GetFlats();
|
||||
if (!flats.empty())
|
||||
subtitle.push_back(flats);
|
||||
|
||||
// Cuisines.
|
||||
for (string const & cuisine : GetLocalizedCuisines())
|
||||
subtitle.push_back(cuisine);
|
||||
|
||||
// Stars.
|
||||
string const stars = FormatStars();
|
||||
if (!stars.empty())
|
||||
subtitle.push_back(stars);
|
||||
|
||||
// Operator.
|
||||
string const op = GetOperator();
|
||||
if (!op.empty())
|
||||
subtitle.push_back(op);
|
||||
|
||||
// Elevation.
|
||||
string const eleStr = GetElevationFormatted();
|
||||
if (!eleStr.empty())
|
||||
subtitle.push_back(kMountainSymbol + eleStr);
|
||||
if (HasWifi())
|
||||
subtitle.push_back(m_localizedWifiString);
|
||||
|
||||
// Wheelchair
|
||||
if (GetWheelchairType() == ftraits::WheelchairAvailability::Yes)
|
||||
subtitle.push_back(kWheelchairSymbol);
|
||||
|
||||
return strings::JoinStrings(subtitle, kSubtitleSeparator);
|
||||
}
|
||||
|
||||
void Info::GetPrefferedNames(std::string & primaryName, std::string & secondaryName) const
|
||||
{
|
||||
auto const mwmInfo = GetID().m_mwmId.GetInfo();
|
||||
if (mwmInfo)
|
||||
{
|
||||
auto const deviceLang = StringUtf8Multilang::GetLangIndex(languages::GetCurrentNorm());
|
||||
feature::GetPreferredNames(mwmInfo->GetRegionData(), m_name, deviceLang,
|
||||
true /* allowTranslit */, primaryName, secondaryName);
|
||||
}
|
||||
}
|
||||
|
||||
void Info::SetCustomName(std::string const & name)
|
||||
{
|
||||
if (IsBookmark())
|
||||
{
|
||||
m_uiTitle = GetBookmarkData().GetName();
|
||||
m_uiSubtitle = m_bookmarkCategoryName;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_uiTitle = name;
|
||||
}
|
||||
|
||||
m_customName = name;
|
||||
}
|
||||
|
||||
void Info::SetBac(BookmarkAndCategory const & bac)
|
||||
{
|
||||
m_bac = bac;
|
||||
if (!bac.IsValid())
|
||||
m_uiSubtitle = FormatSubtitle(true /* withType */);
|
||||
}
|
||||
|
||||
bool Info::ShouldShowEditPlace() const
|
||||
{
|
||||
|
@ -42,13 +157,6 @@ bool Info::ShouldShowEditPlace() const
|
|||
!IsMyPosition() && IsFeature();
|
||||
}
|
||||
|
||||
bool Info::ShouldShowUGC() const { return ftraits::UGC::IsUGCAvailable(m_types); }
|
||||
bool Info::ShouldShowUGCRating() const { return ftraits::UGC::IsRatingAvailable(m_types); }
|
||||
bool Info::ShouldShowUGCReviews() const { return ftraits::UGC::IsReviewsAvailable(m_types); }
|
||||
bool Info::ShouldShowUGCDetails() const { return ftraits::UGC::IsDetailsAvailable(m_types); }
|
||||
bool Info::HasApiUrl() const { return !m_apiUrl.empty(); }
|
||||
bool Info::HasWifi() const { return GetInternet() == osm::Internet::Wlan; }
|
||||
|
||||
string Info::FormatNewBookmarkName() const
|
||||
{
|
||||
string const title = GetTitle();
|
||||
|
@ -57,88 +165,6 @@ string Info::FormatNewBookmarkName() const
|
|||
return title;
|
||||
}
|
||||
|
||||
string Info::GetTitle() const
|
||||
{
|
||||
if (!m_customName.empty())
|
||||
return m_customName;
|
||||
|
||||
auto const mwmInfo = GetID().m_mwmId.GetInfo();
|
||||
|
||||
string primaryName;
|
||||
if (mwmInfo)
|
||||
{
|
||||
auto const deviceLang = StringUtf8Multilang::GetLangIndex(languages::GetCurrentNorm());
|
||||
string secondaryName;
|
||||
feature::GetPreferredNames(mwmInfo->GetRegionData(), m_name, deviceLang, true /* allowTranslit */, primaryName, secondaryName);
|
||||
}
|
||||
return primaryName;
|
||||
}
|
||||
|
||||
string Info::GetSecondaryTitle() const
|
||||
{
|
||||
auto const mwmInfo = GetID().m_mwmId.GetInfo();
|
||||
|
||||
string secondaryName;
|
||||
if (mwmInfo)
|
||||
{
|
||||
auto const deviceLang = StringUtf8Multilang::GetLangIndex(languages::GetCurrentNorm());
|
||||
string primaryName;
|
||||
feature::GetPreferredNames(mwmInfo->GetRegionData(), m_name, deviceLang, true /* allowTranslit */, primaryName, secondaryName);
|
||||
}
|
||||
return secondaryName;
|
||||
}
|
||||
|
||||
string Info::GetSubtitle() const
|
||||
{
|
||||
if (!IsFeature())
|
||||
{
|
||||
if (IsBookmark())
|
||||
return m_bookmarkCategoryName;
|
||||
return {};
|
||||
}
|
||||
|
||||
vector<string> values;
|
||||
|
||||
// Bookmark category.
|
||||
if (IsBookmark())
|
||||
values.push_back(m_bookmarkCategoryName);
|
||||
|
||||
// Type.
|
||||
values.push_back(GetLocalizedType());
|
||||
|
||||
// Flats.
|
||||
string const flats = GetFlats();
|
||||
if (!flats.empty())
|
||||
values.push_back(flats);
|
||||
|
||||
// Cuisines.
|
||||
for (string const & cuisine : GetLocalizedCuisines())
|
||||
values.push_back(cuisine);
|
||||
|
||||
// Stars.
|
||||
string const stars = FormatStars();
|
||||
if (!stars.empty())
|
||||
values.push_back(stars);
|
||||
|
||||
// Operator.
|
||||
string const op = GetOperator();
|
||||
if (!op.empty())
|
||||
values.push_back(op);
|
||||
|
||||
// Elevation.
|
||||
string const eleStr = GetElevationFormatted();
|
||||
if (!eleStr.empty())
|
||||
values.push_back(kMountainSymbol + eleStr);
|
||||
if (HasWifi())
|
||||
values.push_back(m_localizedWifiString);
|
||||
|
||||
// Wheelchair
|
||||
if (GetWheelchairType() == ftraits::WheelchairAvailability::Yes)
|
||||
values.push_back(kWheelchairSymbol);
|
||||
|
||||
return strings::JoinStrings(values, kSubtitleSeparator);
|
||||
}
|
||||
|
||||
string Info::FormatStars() const
|
||||
{
|
||||
string stars;
|
||||
|
@ -154,14 +180,6 @@ string Info::GetFormattedCoordinate(bool isDMS) const
|
|||
: measurement_utils::FormatLatLonAsDMS(ll.lat, ll.lon, 2);
|
||||
}
|
||||
|
||||
string Info::GetCustomName() const { return m_customName; }
|
||||
BookmarkAndCategory Info::GetBookmarkAndCategory() const { return m_bac; }
|
||||
string Info::GetBookmarkCategoryName() const { return m_bookmarkCategoryName; }
|
||||
string const & Info::GetApiUrl() const { return m_apiUrl; }
|
||||
string const & Info::GetSponsoredUrl() const { return m_sponsoredUrl; }
|
||||
string const & Info::GetSponsoredDescriptionUrl() const { return m_sponsoredDescriptionUrl; }
|
||||
string const & Info::GetSponsoredReviewUrl() const { return m_sponsoredReviewUrl; }
|
||||
|
||||
string Info::GetRatingFormatted() const
|
||||
{
|
||||
if (!IsSponsored())
|
||||
|
@ -218,16 +236,4 @@ vector<ads::Banner> Info::GetBanners() const
|
|||
|
||||
return m_adsEngine->GetBanners(m_types, m_topmostCountryIds, languages::GetCurrentNorm());
|
||||
}
|
||||
|
||||
std::vector<taxi::Provider::Type> const & Info::ReachableByTaxiProviders() const
|
||||
{
|
||||
return m_reachableByProviders;
|
||||
}
|
||||
|
||||
void Info::SetMercator(m2::PointD const & mercator) { m_mercator = mercator; }
|
||||
vector<string> Info::GetRawTypes() const { return m_types.ToObjectNames(); }
|
||||
string const & Info::GetBookingSearchUrl() const { return m_bookingSearchUrl; }
|
||||
LocalAdsStatus Info::GetLocalAdsStatus() const { return m_localAdsStatus; }
|
||||
string const & Info::GetLocalAdsUrl() const { return m_localAdsUrl; }
|
||||
bool Info::IsPreviewExtended() const { return m_isPreviewExtended; }
|
||||
} // namespace place_page
|
||||
|
|
|
@ -16,9 +16,9 @@
|
|||
#include "geometry/mercator.hpp"
|
||||
#include "geometry/point2d.hpp"
|
||||
|
||||
#include "std/string.hpp"
|
||||
#include "std/unique_ptr.hpp"
|
||||
#include "std/vector.hpp"
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace ads
|
||||
{
|
||||
|
@ -54,135 +54,190 @@ public:
|
|||
static char const * const kEmptyRatingSymbol;
|
||||
static char const * const kPricingSymbol;
|
||||
|
||||
bool IsFeature() const;
|
||||
bool IsBookmark() const;
|
||||
bool IsMyPosition() const;
|
||||
bool IsSponsored() const;
|
||||
bool IsNotEditableSponsored() const;
|
||||
bool IsRoutePoint() const;
|
||||
/// Place traits
|
||||
bool IsFeature() const { return m_featureID.IsValid(); }
|
||||
bool IsBookmark() const { return m_bac.IsValid(); }
|
||||
bool IsMyPosition() const { return m_isMyPosition; }
|
||||
bool IsRoutePoint() const { return m_isRoutePoint; }
|
||||
|
||||
/// Edit and add
|
||||
bool ShouldShowAddPlace() const;
|
||||
bool ShouldShowAddBusiness() const;
|
||||
bool ShouldShowAddBusiness() const { return m_canEditOrAdd && IsBuilding(); }
|
||||
bool ShouldShowEditPlace() const;
|
||||
|
||||
bool ShouldShowUGC() const;
|
||||
bool ShouldShowUGCRating() const;
|
||||
bool ShouldShowUGCReviews() const;
|
||||
bool ShouldShowUGCDetails() const;
|
||||
/// UGC
|
||||
bool ShouldShowUGC() const { return ftraits::UGC::IsUGCAvailable(m_types); }
|
||||
bool ShouldShowUGCRating() const { return ftraits::UGC::IsRatingAvailable(m_types); }
|
||||
bool ShouldShowUGCReviews() const { return ftraits::UGC::IsReviewsAvailable(m_types); }
|
||||
bool ShouldShowUGCDetails() const { return ftraits::UGC::IsDetailsAvailable(m_types); }
|
||||
|
||||
/// @returns true if Back API button should be displayed.
|
||||
bool HasApiUrl() const;
|
||||
|
||||
bool HasApiUrl() const { return !m_apiUrl.empty(); }
|
||||
/// TODO: Support all possible Internet types in UI. @See MapObject::GetInternet().
|
||||
bool HasWifi() const;
|
||||
|
||||
string GetAddress() const { return m_address; }
|
||||
|
||||
bool HasWifi() const { return GetInternet() == osm::Internet::Wlan; }
|
||||
/// Should be used by UI code to generate cool name for new bookmarks.
|
||||
// TODO: Tune new bookmark name. May be add address or some other data.
|
||||
string FormatNewBookmarkName() const;
|
||||
std::string FormatNewBookmarkName() const;
|
||||
|
||||
/// Convenient wrapper for feature's name and custom name.
|
||||
string GetTitle() const;
|
||||
/// For showing in UI
|
||||
std::string const & GetTitle() const { return m_uiTitle; };
|
||||
/// Convenient wrapper for secondary feature name.
|
||||
string GetSecondaryTitle() const;
|
||||
std::string const & GetSecondaryTitle() const { return m_uiSecondaryTitle; };
|
||||
/// Convenient wrapper for type, cuisines, elevation, stars, wifi etc.
|
||||
string GetSubtitle() const;
|
||||
/// @returns empty string or GetStars() count of ★ symbol.
|
||||
string FormatStars() const;
|
||||
|
||||
std::string const & GetSubtitle() const { return m_uiSubtitle; };
|
||||
std::string const & GetAddress() const { return m_uiAddress; }
|
||||
/// @returns coordinate in DMS format if isDMS is true
|
||||
string GetFormattedCoordinate(bool isDMS) const;
|
||||
|
||||
string GetCustomName() const;
|
||||
BookmarkAndCategory GetBookmarkAndCategory() const;
|
||||
string GetBookmarkCategoryName() const;
|
||||
string const & GetApiUrl() const;
|
||||
|
||||
string const & GetSponsoredUrl() const;
|
||||
string const & GetSponsoredDescriptionUrl() const;
|
||||
string const & GetSponsoredReviewUrl() const;
|
||||
|
||||
std::string GetFormattedCoordinate(bool isDMS) const;
|
||||
/// @returns formatted rating string for booking object, or empty if it isn't booking object
|
||||
string GetRatingFormatted() const;
|
||||
/// @returns string with |kPricingSymbol| signs or empty string if it isn't booking object
|
||||
string GetApproximatePricing() const;
|
||||
std::string GetRatingFormatted() const;
|
||||
/// @returns string with |kPricingSymbol| signs or empty std::string if it isn't booking object
|
||||
std::string GetApproximatePricing() const;
|
||||
|
||||
/// UI setters
|
||||
void SetCustomName(std::string const & name);
|
||||
void SetAddress(std::string const & address) { m_address = address; }
|
||||
void SetIsMyPosition() { m_isMyPosition = true; }
|
||||
void SetCanEditOrAdd(bool canEditOrAdd) { m_canEditOrAdd = canEditOrAdd; }
|
||||
void SetLocalizedWifiString(std::string const & str) { m_localizedWifiString = str; }
|
||||
void SetLocalizedRatingString(std::string const & str) { m_localizedRatingString = str; }
|
||||
|
||||
/// Bookmark
|
||||
BookmarkAndCategory const & GetBookmarkAndCategory() const { return m_bac; }
|
||||
std::string const & GetBookmarkCategoryName() const { return m_bookmarkCategoryName; }
|
||||
void SetBac(BookmarkAndCategory const & bac);
|
||||
void SetBookmarkCategoryName(std::string const & name) { m_bookmarkCategoryName = name; }
|
||||
void SetBookmarkData(BookmarkData const & data) { m_bookmarkData = data; }
|
||||
BookmarkData const & GetBookmarkData() const { return m_bookmarkData; }
|
||||
|
||||
/// Api
|
||||
void SetApiId(std::string const & apiId) { m_apiId = apiId; }
|
||||
void SetApiUrl(std::string const & url) { m_apiUrl = url; }
|
||||
std::string const & GetApiUrl() const { return m_apiUrl; }
|
||||
|
||||
/// Sponsored
|
||||
bool IsSponsored() const { return m_sponsoredType != SponsoredType::None; }
|
||||
bool IsNotEditableSponsored() const { return m_sponsoredType == SponsoredType::Booking; }
|
||||
void SetBookingSearchUrl(std::string const & url) { m_bookingSearchUrl = url; }
|
||||
std::string const & GetBookingSearchUrl() const { return m_bookingSearchUrl; }
|
||||
void SetSponsoredUrl(std::string const & url) { m_sponsoredUrl = url; }
|
||||
std::string const & GetSponsoredUrl() const { return m_sponsoredUrl; }
|
||||
void SetSponsoredDescriptionUrl(std::string const & url) { m_sponsoredDescriptionUrl = url; }
|
||||
std::string const & GetSponsoredDescriptionUrl() const { return m_sponsoredDescriptionUrl; }
|
||||
void SetSponsoredReviewUrl(std::string const & url) { m_sponsoredReviewUrl = url; }
|
||||
std::string const & GetSponsoredReviewUrl() const { return m_sponsoredReviewUrl; }
|
||||
void SetSponsoredType(SponsoredType type) { m_sponsoredType = type; }
|
||||
SponsoredType GetSponsoredType() const { return m_sponsoredType; }
|
||||
|
||||
/// Banner
|
||||
bool HasBanner() const;
|
||||
vector<ads::Banner> GetBanners() const;
|
||||
std::vector<ads::Banner> GetBanners() const;
|
||||
|
||||
std::vector<taxi::Provider::Type> const & ReachableByTaxiProviders() const;
|
||||
/// Taxi
|
||||
void SetReachableByTaxiProviders(std::vector<taxi::Provider::Type> const & providers)
|
||||
{
|
||||
m_reachableByProviders = providers;
|
||||
}
|
||||
|
||||
void SetMercator(m2::PointD const & mercator);
|
||||
std::vector<taxi::Provider::Type> const & ReachableByTaxiProviders() const
|
||||
{
|
||||
return m_reachableByProviders;
|
||||
}
|
||||
|
||||
vector<string> GetRawTypes() const;
|
||||
/// Local ads
|
||||
void SetLocalAdsStatus(LocalAdsStatus status) { m_localAdsStatus = status; }
|
||||
LocalAdsStatus GetLocalAdsStatus() const { return m_localAdsStatus; }
|
||||
void SetLocalAdsUrl(std::string const & url) { m_localAdsUrl = url; }
|
||||
std::string const & GetLocalAdsUrl() const { return m_localAdsUrl; }
|
||||
void SetAdsEngine(ads::Engine * const engine) { m_adsEngine = engine; }
|
||||
|
||||
string const & GetBookingSearchUrl() const;
|
||||
|
||||
LocalAdsStatus GetLocalAdsStatus() const;
|
||||
|
||||
string const & GetLocalAdsUrl() const;
|
||||
|
||||
bool IsPreviewExtended() const;
|
||||
|
||||
/// Comes from API, shared links etc.
|
||||
string m_customName;
|
||||
/// If not empty, bookmark is bound to this place page.
|
||||
BookmarkAndCategory m_bac;
|
||||
/// Bookmark category name. Empty, if it's not bookmark;
|
||||
string m_bookmarkCategoryName;
|
||||
/// Bookmark title. Empty, if it's not bookmark;
|
||||
string m_bookmarkTitle;
|
||||
/// Bookmark color name. Empty, if it's not bookmark;
|
||||
string m_bookmarkColorName;
|
||||
/// Bookmark description. Empty, if it's not bookmark;
|
||||
string m_bookmarkDescription;
|
||||
/// Api ID passed for the selected object. It's automatically included in api url below.
|
||||
string m_apiId;
|
||||
/// [Deep] link to open when "Back" button is pressed in a Place Page.
|
||||
string m_apiUrl;
|
||||
/// Formatted feature address.
|
||||
string m_address;
|
||||
/// Sponsored type or None.
|
||||
SponsoredType m_sponsoredType = SponsoredType::None;
|
||||
|
||||
/// Sponsored feature urls.
|
||||
string m_sponsoredUrl;
|
||||
string m_sponsoredDescriptionUrl;
|
||||
string m_sponsoredReviewUrl;
|
||||
/// Routing
|
||||
void SetRouteMarkType(RouteMarkType type) { m_routeMarkType = type; }
|
||||
RouteMarkType GetRouteMarkType() const { return m_routeMarkType; }
|
||||
void SetIntermediateIndex(int8_t index) { m_intermediateIndex = index; }
|
||||
int8_t GetIntermediateIndex() const { return m_intermediateIndex; }
|
||||
void SetIsRoutePoint() { m_isRoutePoint = true; }
|
||||
|
||||
/// CountryId
|
||||
/// Which mwm this MapObject is in.
|
||||
/// Exception: for a country-name point it will be set to the topmost node for the mwm.
|
||||
/// TODO(@a): use m_topmostCountryIds in exceptional case.
|
||||
void SetCountryId(storage::TCountryId const & countryId) { m_countryId = countryId; }
|
||||
storage::TCountryId const & GetCountryId() const { return m_countryId; }
|
||||
void SetTopmostCountryIds(storage::TCountriesVec const & ids) { m_topmostCountryIds = ids; }
|
||||
|
||||
/// MapObject
|
||||
void SetFromFeatureType(FeatureType const & ft);
|
||||
|
||||
void SetMercator(m2::PointD const & mercator) { m_mercator = mercator; }
|
||||
std::vector<std::string> GetRawTypes() const { return m_types.ToObjectNames(); }
|
||||
|
||||
private:
|
||||
std::string FormatSubtitle(bool withType) const;
|
||||
void GetPrefferedNames(std::string & primaryName, std::string & secondaryName) const;
|
||||
/// @returns empty string or GetStars() count of ★ symbol.
|
||||
std::string FormatStars() const;
|
||||
|
||||
/// UI
|
||||
std::string m_uiTitle;
|
||||
std::string m_uiSubtitle;
|
||||
std::string m_uiSecondaryTitle;
|
||||
std::string m_uiAddress;
|
||||
// TODO(AlexZ): Temporary solution. It's better to use a wifi icon in UI instead of text.
|
||||
std::string m_localizedWifiString;
|
||||
/// Booking rating string
|
||||
std::string m_localizedRatingString;
|
||||
|
||||
/// CountryId
|
||||
storage::TCountryId m_countryId = storage::kInvalidCountryId;
|
||||
/// The topmost downloader nodes this MapObject is in, i.e.
|
||||
/// the country name for an object whose mwm represents only
|
||||
/// one part of the country (or several countries for disputed territories).
|
||||
storage::TCountriesVec m_topmostCountryIds;
|
||||
|
||||
bool m_isRoutePoint = false;
|
||||
/// Comes from API, shared links etc.
|
||||
std::string m_customName;
|
||||
|
||||
/// Bookmarks
|
||||
/// If not empty, bookmark is bound to this place page.
|
||||
BookmarkAndCategory m_bac;
|
||||
/// Bookmark category name. Empty, if it's not bookmark;
|
||||
std::string m_bookmarkCategoryName;
|
||||
BookmarkData m_bookmarkData;
|
||||
|
||||
/// Api ID passed for the selected object. It's automatically included in api url below.
|
||||
std::string m_apiId;
|
||||
/// [Deep] link to open when "Back" button is pressed in a Place Page.
|
||||
std::string m_apiUrl;
|
||||
/// Formatted feature address for inner using.
|
||||
std::string m_address;
|
||||
|
||||
/// Routing
|
||||
RouteMarkType m_routeMarkType;
|
||||
int8_t m_intermediateIndex = 0;
|
||||
bool m_isRoutePoint = false;
|
||||
|
||||
bool m_isMyPosition = false;
|
||||
|
||||
/// Editor
|
||||
/// True if editing of a selected point is allowed by basic logic.
|
||||
/// See initialization in framework.
|
||||
bool m_canEditOrAdd = false;
|
||||
|
||||
// TODO(AlexZ): Temporary solution. It's better to use a wifi icon in UI instead of text.
|
||||
string m_localizedWifiString;
|
||||
/// Booking rating string
|
||||
string m_localizedRatingString;
|
||||
|
||||
string m_bookingSearchUrl;
|
||||
/// Ads
|
||||
std::vector<taxi::Provider::Type> m_reachableByProviders;
|
||||
std::string m_localAdsUrl;
|
||||
LocalAdsStatus m_localAdsStatus = LocalAdsStatus::NotAvailable;
|
||||
/// Ads source.
|
||||
ads::Engine * m_adsEngine = nullptr;
|
||||
/// Sponsored type or None.
|
||||
SponsoredType m_sponsoredType = SponsoredType::None;
|
||||
|
||||
LocalAdsStatus m_localAdsStatus = LocalAdsStatus::NotAvailable;
|
||||
string m_localAdsUrl;
|
||||
/// Sponsored feature urls.
|
||||
std::string m_sponsoredUrl;
|
||||
std::string m_sponsoredDescriptionUrl;
|
||||
std::string m_sponsoredReviewUrl;
|
||||
|
||||
std::vector<taxi::Provider::Type> m_reachableByProviders;
|
||||
|
||||
bool m_isPreviewExtended;
|
||||
/// Booking
|
||||
std::string m_bookingSearchUrl;
|
||||
};
|
||||
} // namespace place_page
|
||||
|
|
|
@ -36,7 +36,7 @@ PlacePageDialog::PlacePageDialog(QWidget * parent, place_page::Info const & info
|
|||
}
|
||||
{
|
||||
grid->addWidget(new QLabel("CountryId"), row, 0);
|
||||
QLabel * label = new QLabel(QString::fromStdString(info.m_countryId));
|
||||
QLabel * label = new QLabel(QString::fromStdString(info.GetCountryId()));
|
||||
label->setTextInteractionFlags(Qt::TextSelectableByMouse);
|
||||
grid->addWidget(label, row++, 1);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue