From afa8a9002691c37dcf459fdfae2f65b7257c0ecc Mon Sep 17 00:00:00 2001 From: Arsentiy Milchakov Date: Tue, 5 Feb 2019 20:56:48 +0300 Subject: [PATCH] [android][ios][notification] refactoring to support address in notifications --- android/jni/com/mapswithme/maps/Framework.cpp | 30 +++--- .../com/mapswithme/maps/LightFramework.cpp | 27 ++--- .../src/com/mapswithme/maps/Framework.java | 2 +- .../src/com/mapswithme/maps/MwmActivity.java | 18 ++-- .../background/NotificationCandidate.java | 100 +++++------------- .../maps/background/NotificationService.java | 4 +- .../mapswithme/maps/background/Notifier.java | 16 ++- iphone/Maps/Classes/MapsAppDelegate.mm | 7 +- map/framework.cpp | 24 +++-- map/framework.hpp | 8 +- map/notifications/notification_manager.cpp | 1 - .../notification_manager_delegate.cpp | 2 +- map/notifications/notification_queue.cpp | 61 ++++++++++- map/notifications/notification_queue.hpp | 7 ++ map/utils.cpp | 2 +- xcode/map/map.xcodeproj/project.pbxproj | 12 +++ 16 files changed, 179 insertions(+), 142 deletions(-) diff --git a/android/jni/com/mapswithme/maps/Framework.cpp b/android/jni/com/mapswithme/maps/Framework.cpp index c416bdc008..287e527ecc 100644 --- a/android/jni/com/mapswithme/maps/Framework.cpp +++ b/android/jni/com/mapswithme/maps/Framework.cpp @@ -7,6 +7,7 @@ #include "map/chart_generator.hpp" #include "map/everywhere_search_params.hpp" +#include "map/notifications/notification_queue.hpp" #include "map/user_mark.hpp" #include "partners_api/ads_engine.hpp" @@ -55,6 +56,7 @@ using namespace std; using namespace std::placeholders; +using namespace notifications; unique_ptr g_framework; @@ -1933,34 +1935,34 @@ Java_com_mapswithme_maps_Framework_nativeGetAccessToken(JNIEnv * env, jclass) JNIEXPORT jobject JNICALL Java_com_mapswithme_maps_Framework_nativeGetMapObject(JNIEnv * env, jclass, - jobject notificationMapObject) + jobject notificationCandidate) { - eye::MapObject mapObject; + NotificationCandidate notification(NotificationCandidate::Type::UgcReview); auto const getBestTypeId = - jni::GetMethodID(env, notificationMapObject, "getBestType", "()Ljava/lang/String;"); + jni::GetMethodID(env, notificationCandidate, "getFeatureBestType", "()Ljava/lang/String;"); auto const bestType = - static_cast(env->CallObjectMethod(notificationMapObject, getBestTypeId)); - mapObject.SetBestType(jni::ToNativeString(env, bestType)); + static_cast(env->CallObjectMethod(notificationCandidate, getBestTypeId)); + notification.SetBestFeatureType(jni::ToNativeString(env, bestType)); auto const getMercatorPosXId = - jni::GetMethodID(env, notificationMapObject, "getMercatorPosX", "()D"); + jni::GetMethodID(env, notificationCandidate, "getMercatorPosX", "()D"); auto const getMercatorPosYId = - jni::GetMethodID(env, notificationMapObject, "getMercatorPosY", "()D"); + jni::GetMethodID(env, notificationCandidate, "getMercatorPosY", "()D"); auto const posX = - static_cast(env->CallDoubleMethod(notificationMapObject, getMercatorPosXId)); + static_cast(env->CallDoubleMethod(notificationCandidate, getMercatorPosXId)); auto const posY = - static_cast(env->CallDoubleMethod(notificationMapObject, getMercatorPosYId)); - mapObject.SetPos({posX, posY}); + static_cast(env->CallDoubleMethod(notificationCandidate, getMercatorPosYId)); + notification.SetPos({posX, posY}); auto const getDefaultNameId = - jni::GetMethodID(env, notificationMapObject, "getDefaultName", "()Ljava/lang/String;"); + jni::GetMethodID(env, notificationCandidate, "getDefaultName", "()Ljava/lang/String;"); auto const defaultName = - static_cast(env->CallObjectMethod(notificationMapObject, getDefaultNameId)); - mapObject.SetDefaultName(jni::ToNativeString(env, defaultName)); + static_cast(env->CallObjectMethod(notificationCandidate, getDefaultNameId)); + notification.SetDefaultName(jni::ToNativeString(env, defaultName)); place_page::Info info; - if (frm()->MakePlacePageInfo(mapObject, info)) + if (frm()->MakePlacePageInfo(notification, info)) return usermark_helper::CreateMapObject(env, info); return nullptr; diff --git a/android/jni/com/mapswithme/maps/LightFramework.cpp b/android/jni/com/mapswithme/maps/LightFramework.cpp index 220135b290..0b716ae21a 100644 --- a/android/jni/com/mapswithme/maps/LightFramework.cpp +++ b/android/jni/com/mapswithme/maps/LightFramework.cpp @@ -98,26 +98,21 @@ Java_com_mapswithme_maps_LightFramework_nativeGetNotification(JNIEnv * env, jcla if (!notification) return nullptr; + auto const & n = notification.get(); // Type::UgcReview is only supported. - CHECK_EQUAL(notification.get().m_type, notifications::NotificationCandidate::Type::UgcReview, ()); + CHECK_EQUAL(n.GetType(), notifications::NotificationCandidate::Type::UgcReview, ()); static jclass const candidateId = - jni::GetGlobalClassRef(env, "com/mapswithme/maps/background/NotificationCandidate"); - static jclass const mapObjectId = - jni::GetGlobalClassRef(env, "com/mapswithme/maps/background/NotificationCandidate$MapObject"); + jni::GetGlobalClassRef(env, "com/mapswithme/maps/background/NotificationCandidate$UgcReview"); static jmethodID const candidateCtor = jni::GetConstructorID( - env, candidateId, "(ILcom/mapswithme/maps/background/NotificationCandidate$MapObject;)V"); - static jmethodID const mapObjectCtor = jni::GetConstructorID( - env, mapObjectId, "(DDLjava/lang/String;Ljava/lang/String;Ljava/lang/String;)V"); + env, candidateId, + "(DDLjava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V"); - auto const & srcObject = notification.get().m_mapObject; - ASSERT(srcObject, ()); - auto const readableName = jni::ToJavaString(env, srcObject->GetReadableName()); - auto const defaultName = jni::ToJavaString(env, srcObject->GetDefaultName()); - auto const type = jni::ToJavaString(env, srcObject->GetBestType()); - auto const mapObject = env->NewObject(mapObjectId, mapObjectCtor, srcObject->GetPos().x, - srcObject->GetPos().y, readableName, defaultName, type); - return env->NewObject(candidateId, candidateCtor, static_cast(notification.get().m_type), - mapObject); + auto const readableName = jni::ToJavaString(env, n.GetReadableName()); + auto const defaultName = jni::ToJavaString(env, n.GetDefaultName()); + auto const type = jni::ToJavaString(env, n.GetBestFeatureType()); + auto const address = jni::ToJavaString(env, n.GetAddress()); + return env->NewObject(candidateId, candidateCtor, n.GetPos().x, n.GetPos().y, readableName, + defaultName, type, address); } } // extern "C" diff --git a/android/src/com/mapswithme/maps/Framework.java b/android/src/com/mapswithme/maps/Framework.java index fd4684c558..15bb70c21c 100644 --- a/android/src/com/mapswithme/maps/Framework.java +++ b/android/src/com/mapswithme/maps/Framework.java @@ -514,7 +514,7 @@ public class Framework @Nullable public static native MapObject nativeGetMapObject( - @NonNull NotificationCandidate.MapObject mapObject); + @NonNull NotificationCandidate notificationCandidate); public static native void nativeSetPowerManagerFacility(int facilityType, boolean state); public static native int nativeGetPowerManagerScheme(); diff --git a/android/src/com/mapswithme/maps/MwmActivity.java b/android/src/com/mapswithme/maps/MwmActivity.java index 1896e2e908..4b3f78dc50 100644 --- a/android/src/com/mapswithme/maps/MwmActivity.java +++ b/android/src/com/mapswithme/maps/MwmActivity.java @@ -355,12 +355,12 @@ public class MwmActivity extends BaseMwmFragmentActivity @NonNull public static Intent createLeaveReviewIntent(@NonNull Context context, - @NonNull NotificationCandidate.MapObject mapObject) + @NonNull NotificationCandidate.UgcReview nc) { return new Intent(context, MwmActivity.class) .addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION) .addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP) - .putExtra(MwmActivity.EXTRA_TASK, new MwmActivity.ShowUGCEditorTask(mapObject)); + .putExtra(MwmActivity.EXTRA_TASK, new MwmActivity.ShowUGCEditorTask(nc)); } @Override @@ -2687,18 +2687,22 @@ public class MwmActivity extends BaseMwmFragmentActivity public static class ShowUGCEditorTask implements MapTask { private static final long serialVersionUID = 1636712824900113568L; - @NonNull - private final NotificationCandidate.MapObject mMapObject; + // Nullable because of possible serialization from previous incompatible version of class. + @Nullable + private final NotificationCandidate.UgcReview mNotificationCandidate; - ShowUGCEditorTask(@NonNull NotificationCandidate.MapObject mapObject) + ShowUGCEditorTask(@Nullable NotificationCandidate.UgcReview notificationCandidate) { - mMapObject = mapObject; + mNotificationCandidate = notificationCandidate; } @Override public boolean run(@NonNull MwmActivity target) { - MapObject mapObject = Framework.nativeGetMapObject(mMapObject); + if (mNotificationCandidate == null) + return false; + + MapObject mapObject = Framework.nativeGetMapObject(mNotificationCandidate); if (mapObject == null) return false; diff --git a/android/src/com/mapswithme/maps/background/NotificationCandidate.java b/android/src/com/mapswithme/maps/background/NotificationCandidate.java index af776b236c..13bc755cb2 100644 --- a/android/src/com/mapswithme/maps/background/NotificationCandidate.java +++ b/android/src/com/mapswithme/maps/background/NotificationCandidate.java @@ -1,17 +1,16 @@ package com.mapswithme.maps.background; -import android.os.Parcel; -import android.os.Parcelable; import android.support.annotation.IntDef; import android.support.annotation.NonNull; -import android.support.annotation.Nullable; import java.io.Serializable; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; -public class NotificationCandidate +public class NotificationCandidate implements Serializable { + private static final long serialVersionUID = -7020549752940235436L; + // This constants should be compatible with notifications::NotificationCandidate::Type enum // from c++ side. static final int TYPE_UGC_AUTH = 0; @@ -19,11 +18,14 @@ public class NotificationCandidate @Retention(RetentionPolicy.SOURCE) @IntDef({ TYPE_UGC_AUTH, TYPE_UGC_REVIEW }) - @interface NotificationType {} - - public static class MapObject implements Parcelable, Serializable + @interface NotificationType { - private static final long serialVersionUID = -7443680760782198916L; + } + + public static class UgcReview extends NotificationCandidate + { + private static final long serialVersionUID = 5469867251355445859L; + private final double mMercatorPosX; private final double mMercatorPosY; @NonNull @@ -31,57 +33,22 @@ public class NotificationCandidate @NonNull private final String mDefaultName; @NonNull - private final String mBestType; - - public static final Creator CREATOR = new Creator() - { - @Override - public MapObject createFromParcel(Parcel in) - { - return new MapObject(in); - } - - @Override - public MapObject[] newArray(int size) - { - return new MapObject[size]; - } - }; + private final String mFeatureBestType; + @NonNull + private final String mAddress; @SuppressWarnings("unused") - MapObject(double posX, double posY, @NonNull String readableName, @NonNull String defaultName, - @NonNull String bestType) + UgcReview(double posX, double posY, @NonNull String readableName, @NonNull String defaultName, + @NonNull String bestType, @NonNull String address) { + super(TYPE_UGC_REVIEW); + mMercatorPosX = posX; mMercatorPosY = posY; mReadableName = readableName; mDefaultName = defaultName; - mBestType = bestType; - } - - protected MapObject(Parcel in) - { - mMercatorPosX = in.readDouble(); - mMercatorPosY = in.readDouble(); - mReadableName = in.readString(); - mDefaultName = in.readString(); - mBestType = in.readString(); - } - - @Override - public void writeToParcel(Parcel dest, int flags) - { - dest.writeDouble(mMercatorPosX); - dest.writeDouble(mMercatorPosY); - dest.writeString(mReadableName); - dest.writeString(mDefaultName); - dest.writeString(mBestType); - } - - @Override - public int describeContents() - { - return 0; + mFeatureBestType = bestType; + mAddress = address; } @SuppressWarnings("unused") @@ -110,39 +77,28 @@ public class NotificationCandidate @NonNull @SuppressWarnings("unused") - public String getBestType() + public String getFeatureBestType() { - return mBestType; + return mFeatureBestType; + } + + @NonNull + public String getAddress() + { + return mAddress; } } @NotificationType private final int mType; - @Nullable - private MapObject mMapObject; - - @SuppressWarnings("unused") - NotificationCandidate(@NotificationType int type) + private NotificationCandidate(@NotificationType int type) { mType = type; } - @SuppressWarnings("unused") - NotificationCandidate(@NotificationType int type, @Nullable MapObject mapObject) - { - this(type); - mMapObject = mapObject; - } - public int getType() { return mType; } - - @Nullable - public MapObject getMapObject() - { - return mMapObject; - } } diff --git a/android/src/com/mapswithme/maps/background/NotificationService.java b/android/src/com/mapswithme/maps/background/NotificationService.java index 4b70888ff7..684b5d5733 100644 --- a/android/src/com/mapswithme/maps/background/NotificationService.java +++ b/android/src/com/mapswithme/maps/background/NotificationService.java @@ -79,13 +79,13 @@ public class NotificationService extends JobIntentService NotificationCandidate candidate = LightFramework.nativeGetNotification(); - if (candidate == null || candidate.getMapObject() == null) + if (candidate == null) return false; if (candidate.getType() == NotificationCandidate.TYPE_UGC_REVIEW) { Notifier notifier = Notifier.from(getApplication()); - notifier.notifyLeaveReview(candidate.getMapObject()); + notifier.notifyLeaveReview((NotificationCandidate.UgcReview) candidate); return true; } diff --git a/android/src/com/mapswithme/maps/background/Notifier.java b/android/src/com/mapswithme/maps/background/Notifier.java index 5a5c423b83..d503d2d051 100644 --- a/android/src/com/mapswithme/maps/background/Notifier.java +++ b/android/src/com/mapswithme/maps/background/Notifier.java @@ -32,7 +32,7 @@ public final class Notifier private final Application mContext; @Retention(RetentionPolicy.SOURCE) - @IntDef({ ID_NONE, ID_DOWNLOAD_FAILED, ID_IS_NOT_AUTHENTICATED }) + @IntDef({ ID_NONE, ID_DOWNLOAD_FAILED, ID_IS_NOT_AUTHENTICATED, ID_LEAVE_REVIEW }) public @interface NotificationId { } @@ -80,9 +80,9 @@ public final class Notifier Statistics.INSTANCE.trackEvent(Statistics.EventName.UGC_NOT_AUTH_NOTIFICATION_SHOWN); } - void notifyLeaveReview(@NonNull NotificationCandidate.MapObject mapObject) + void notifyLeaveReview(@NonNull NotificationCandidate.UgcReview source) { - Intent reviewIntent = MwmActivity.createLeaveReviewIntent(mContext, mapObject); + Intent reviewIntent = MwmActivity.createLeaveReviewIntent(mContext, source); reviewIntent.putExtra(EXTRA_CANCEL_NOTIFICATION, Notifier.ID_LEAVE_REVIEW); reviewIntent.putExtra(EXTRA_NOTIFICATION_CLICKED, Statistics.EventName.UGC_REVIEW_NOTIFICATION_CLICKED); @@ -93,12 +93,10 @@ public final class Notifier String channel = NotificationChannelFactory.createProvider(mContext).getUGCChannel(); NotificationCompat.Builder builder = getBuilder(mContext.getString(R.string.notification_leave_review_title, - mapObject.getReadableName()), - mContext.getString(R.string.notification_leave_review_content, - mapObject.getReadableName()), - pi, channel); - - builder.addAction(0, mContext.getString(R.string.leave_a_review), pi); + source.getReadableName()), + mContext.getString(R.string.notification_leave_review_content), + pi, channel) + .addAction(0, mContext.getString(R.string.leave_a_review), pi); getNotificationManager().notify(ID_LEAVE_REVIEW, builder.build()); diff --git a/iphone/Maps/Classes/MapsAppDelegate.mm b/iphone/Maps/Classes/MapsAppDelegate.mm index 0ee1732b07..c23bdc3fc0 100644 --- a/iphone/Maps/Classes/MapsAppDelegate.mm +++ b/iphone/Maps/Classes/MapsAppDelegate.mm @@ -458,15 +458,14 @@ using namespace osm_auth_ios; if (notificationCandidate) { auto const notification = notificationCandidate.get(); - if (notification.m_type == notifications::NotificationCandidate::Type::UgcReview && - notification.m_mapObject) + if (notification.GetType() == notifications::NotificationCandidate::Type::UgcReview) { [LocalNotificationManager.sharedManager - showReviewNotificationForPlace:@(notification.m_mapObject->GetReadableName().c_str()) + showReviewNotificationForPlace:@(notification.GetReadableName().c_str()) onTap:^{ [Statistics logEvent:kStatUGCReviewNotificationClicked]; place_page::Info info; - if (GetFramework().MakePlacePageInfo(*notification.m_mapObject, info)) + if (GetFramework().MakePlacePageInfo(notification, info)) [[MapViewController sharedController].controlsManager showPlacePageReview:info]; }]; } diff --git a/map/framework.cpp b/map/framework.cpp index e716160c06..3708395742 100644 --- a/map/framework.cpp +++ b/map/framework.cpp @@ -7,6 +7,7 @@ #include "map/geourl_process.hpp" #include "map/gps_tracker.hpp" #include "map/notifications/notification_manager_delegate.hpp" +#include "map/notifications/notification_queue.hpp" #include "map/taxi_delegate.hpp" #include "map/user_mark.hpp" #include "map/utils.hpp" @@ -115,6 +116,7 @@ using namespace storage; using namespace routing; using namespace location; +using namespace notifications; using platform::CountryFile; using platform::LocalCountryFile; @@ -382,8 +384,8 @@ void Framework::Migrate(bool keepDownloaded) InitTaxiEngine(); RegisterAllMaps(); m_notificationManager.SetDelegate( - std::make_unique(m_model.GetDataSource(), - *m_cityFinder, *m_ugcApi)); + std::make_unique(m_model.GetDataSource(), *m_cityFinder, + *m_ugcApi)); m_trafficManager.SetCurrentDataVersion(GetStorage().GetCurrentDataVersion()); if (m_drapeEngine && m_isRenderingEnabled) @@ -551,8 +553,8 @@ Framework::Framework(FrameworkParams const & params) LOG(LDEBUG, ("Transliterators initialized")); m_notificationManager.SetDelegate( - std::make_unique(m_model.GetDataSource(), - *m_cityFinder, *m_ugcApi)); + std::make_unique(m_model.GetDataSource(), *m_cityFinder, + *m_ugcApi)); m_notificationManager.Load(); m_notificationManager.TrimExpired(); @@ -3814,18 +3816,22 @@ double Framework::GetLastBackgroundTime() const return m_startBackgroundTime; } -bool Framework::MakePlacePageInfo(eye::MapObject const & mapObject, place_page::Info & info) const +bool Framework::MakePlacePageInfo(NotificationCandidate const & notification, + place_page::Info & info) const { - m2::RectD rect = MercatorBounds::RectByCenterXYAndOffset(mapObject.GetPos(), kMwmPointAccuracy); + if (notification.GetType() != NotificationCandidate::Type::UgcReview) + return false; + + m2::RectD rect = MercatorBounds::RectByCenterXYAndOffset(notification.GetPos(), kMwmPointAccuracy); bool found = false; - m_model.GetDataSource().ForEachInRect([this, &info, &mapObject, &found](FeatureType & ft) + m_model.GetDataSource().ForEachInRect([this, &info, ¬ification, &found](FeatureType & ft) { - if (found || !feature::GetCenter(ft).EqualDxDy(mapObject.GetPos(), kMwmPointAccuracy)) + if (found || !feature::GetCenter(ft).EqualDxDy(notification.GetPos(), kMwmPointAccuracy)) return; auto const foundMapObject = utils::MakeEyeMapObject(ft); - if (!foundMapObject.IsEmpty() && mapObject.AlmostEquals(foundMapObject)) + if (!foundMapObject.IsEmpty() && notification.IsSameMapObject(foundMapObject)) { FillInfoFromFeatureType(ft, info); found = true; diff --git a/map/framework.hpp b/map/framework.hpp index 3e5dc98c6c..60a8bcfcaf 100644 --- a/map/framework.hpp +++ b/map/framework.hpp @@ -126,6 +126,11 @@ namespace descriptions class Loader; } +namespace notifications +{ +class NotificationCandidate; +} + /// Uncomment line to make fixed position settings and /// build version for screenshots. //#define FIXED_LOCATION @@ -903,7 +908,8 @@ public: bool HaveTransit(m2::PointD const & pt) const override; double GetLastBackgroundTime() const override; - bool MakePlacePageInfo(eye::MapObject const & mapObject, place_page::Info & info) const; + bool MakePlacePageInfo(notifications::NotificationCandidate const & notification, + place_page::Info & info) const; power_management::PowerManager & GetPowerManager() { return m_powerManager; } diff --git a/map/notifications/notification_manager.cpp b/map/notifications/notification_manager.cpp index c0d1c6a9b9..25a64963c7 100644 --- a/map/notifications/notification_manager.cpp +++ b/map/notifications/notification_manager.cpp @@ -104,7 +104,6 @@ bool CheckPlannedTripTrigger(eye::MapObject const & poi) namespace notifications { - void NotificationManager::SetDelegate(std::unique_ptr delegate) { m_delegate = std::move(delegate); diff --git a/map/notifications/notification_manager_delegate.cpp b/map/notifications/notification_manager_delegate.cpp index 8af7de69ee..52d16ab5fe 100644 --- a/map/notifications/notification_manager_delegate.cpp +++ b/map/notifications/notification_manager_delegate.cpp @@ -38,6 +38,6 @@ string NotificationManagerDelegate::GetAddress(m2::PointD const & pt) if (city.empty()) return address; - return city + " ," + address; + return address + ", " + city; } } // namespace notifications diff --git a/map/notifications/notification_queue.cpp b/map/notifications/notification_queue.cpp index 9d8a88576f..e7b5c842c0 100644 --- a/map/notifications/notification_queue.cpp +++ b/map/notifications/notification_queue.cpp @@ -4,12 +4,18 @@ namespace notifications { +NotificationCandidate::NotificationCandidate(Type type) + : m_type(NotificationCandidate::Type::UgcReview) + , m_created(Clock::now()) +{ +} + NotificationCandidate::NotificationCandidate(eye::MapObject const & poi, std::string const & address) -: m_type(NotificationCandidate::Type::UgcReview) -, m_created(Clock::now()) -, m_mapObject(std::make_shared(poi)) -, m_address(address) + : m_type(NotificationCandidate::Type::UgcReview) + , m_created(Clock::now()) + , m_mapObject(std::make_shared(poi)) + , m_address(address) { CHECK(!poi.IsEmpty(), ()); @@ -84,4 +90,51 @@ std::string const & NotificationCandidate::GetAddress() const return m_address; } + +void NotificationCandidate::SetBestFeatureType(std::string const & bestFeatureType) +{ + CHECK_EQUAL(m_type, NotificationCandidate::Type::UgcReview, ()); + + if (!m_mapObject) + m_mapObject = std::make_shared(); + + m_mapObject->SetBestType(bestFeatureType); +} + +void NotificationCandidate::SetPos(m2::PointD const & pt) +{ + CHECK_EQUAL(m_type, NotificationCandidate::Type::UgcReview, ()); + + if (!m_mapObject) + m_mapObject = std::make_shared(); + + m_mapObject->SetPos(pt); +} + +void NotificationCandidate::SetDefaultName(std::string const & name) +{ + CHECK_EQUAL(m_type, NotificationCandidate::Type::UgcReview, ()); + + if (!m_mapObject) + m_mapObject = std::make_shared(); + + m_mapObject->SetDefaultName(name); +} + +void NotificationCandidate::SetReadableName(std::string const & name) +{ + CHECK_EQUAL(m_type, NotificationCandidate::Type::UgcReview, ()); + + if (!m_mapObject) + m_mapObject = std::make_shared(); + + m_mapObject->SetReadableName(name); +} + +void NotificationCandidate::SetAddress(std::string const & address) +{ + CHECK_EQUAL(m_type, NotificationCandidate::Type::UgcReview, ()); + + m_address = address; +} } // namespace notifications diff --git a/map/notifications/notification_queue.hpp b/map/notifications/notification_queue.hpp index 6165e8edc2..e4715bb9bd 100644 --- a/map/notifications/notification_queue.hpp +++ b/map/notifications/notification_queue.hpp @@ -27,6 +27,7 @@ public: visitor(m_address, std::string(""), "address")); NotificationCandidate() = default; + NotificationCandidate(Type type); // Constructs candidate with type Type::UgcReview. NotificationCandidate(eye::MapObject const & poi, std::string const & address); @@ -46,6 +47,12 @@ public: std::string const & GetReadableName() const; std::string const & GetAddress() const; + void SetBestFeatureType(std::string const & bestFeatureType); + void SetPos(m2::PointD const & pt); + void SetDefaultName(std::string const & name); + void SetReadableName(std::string const & name); + void SetAddress(std::string const & address); + private: Type m_type; Time m_created; diff --git a/map/utils.cpp b/map/utils.cpp index 010ae2d087..69bf4650d8 100644 --- a/map/utils.cpp +++ b/map/utils.cpp @@ -3,8 +3,8 @@ #include "map/place_page_info.hpp" #include "indexer/feature.hpp" -#include "indexer/feature_decl.hpp" #include "indexer/feature_algo.hpp" +#include "indexer/feature_decl.hpp" namespace utils { diff --git a/xcode/map/map.xcodeproj/project.pbxproj b/xcode/map/map.xcodeproj/project.pbxproj index bf7d3b398f..373ef1d939 100644 --- a/xcode/map/map.xcodeproj/project.pbxproj +++ b/xcode/map/map.xcodeproj/project.pbxproj @@ -87,6 +87,9 @@ 3DD1166C21888AAD007A2ED4 /* notification_queue_serdes.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 3DD1166521888AAC007A2ED4 /* notification_queue_serdes.hpp */; }; 3DD122BB2135708900EDFB53 /* libmetrics_tests_support.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 3DD122BA2135708900EDFB53 /* libmetrics_tests_support.a */; }; 3DD122BD2135708900EDFB53 /* libmetrics.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 3DD122BC2135708900EDFB53 /* libmetrics.a */; }; + 3DD692AD2209E253001C3C62 /* notification_queue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3DD692AC2209E253001C3C62 /* notification_queue.cpp */; }; + 3DD692B02209E272001C3C62 /* notification_manager_delegate.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 3DD692AE2209E272001C3C62 /* notification_manager_delegate.hpp */; }; + 3DD692B12209E272001C3C62 /* notification_manager_delegate.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3DD692AF2209E272001C3C62 /* notification_manager_delegate.cpp */; }; 3DEE1ADE21EE03B400054A91 /* power_management_schemas.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 3DEE1ADA21EE03B400054A91 /* power_management_schemas.hpp */; }; 3DEE1ADF21EE03B400054A91 /* power_manager.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 3DEE1ADB21EE03B400054A91 /* power_manager.hpp */; }; 3DEE1AE021EE03B400054A91 /* power_manager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3DEE1ADC21EE03B400054A91 /* power_manager.cpp */; }; @@ -326,6 +329,9 @@ 3DD1166521888AAC007A2ED4 /* notification_queue_serdes.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = notification_queue_serdes.hpp; sourceTree = ""; }; 3DD122BA2135708900EDFB53 /* libmetrics_tests_support.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; path = libmetrics_tests_support.a; sourceTree = BUILT_PRODUCTS_DIR; }; 3DD122BC2135708900EDFB53 /* libmetrics.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; path = libmetrics.a; sourceTree = BUILT_PRODUCTS_DIR; }; + 3DD692AC2209E253001C3C62 /* notification_queue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = notification_queue.cpp; sourceTree = ""; }; + 3DD692AE2209E272001C3C62 /* notification_manager_delegate.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = notification_manager_delegate.hpp; sourceTree = ""; }; + 3DD692AF2209E272001C3C62 /* notification_manager_delegate.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = notification_manager_delegate.cpp; sourceTree = ""; }; 3DEE1ADA21EE03B400054A91 /* power_management_schemas.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = power_management_schemas.hpp; sourceTree = ""; }; 3DEE1ADB21EE03B400054A91 /* power_manager.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = power_manager.hpp; sourceTree = ""; }; 3DEE1ADC21EE03B400054A91 /* power_manager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = power_manager.cpp; sourceTree = ""; }; @@ -652,6 +658,9 @@ 3DD1165E21888AAC007A2ED4 /* notifications */ = { isa = PBXGroup; children = ( + 3DD692AF2209E272001C3C62 /* notification_manager_delegate.cpp */, + 3DD692AE2209E272001C3C62 /* notification_manager_delegate.hpp */, + 3DD692AC2209E253001C3C62 /* notification_queue.cpp */, 3DD1165F21888AAC007A2ED4 /* notification_queue_serdes.cpp */, 3DD1166021888AAC007A2ED4 /* notification_queue.hpp */, 3DD1166121888AAC007A2ED4 /* notification_queue_storage.hpp */, @@ -973,6 +982,7 @@ F6FC3CB71FC323430001D929 /* discovery_manager.hpp in Headers */, 6753469C1A4054E800A0A8C3 /* track.hpp in Headers */, 675346651A4054E800A0A8C3 /* framework.hpp in Headers */, + 3DD692B02209E272001C3C62 /* notification_manager_delegate.hpp in Headers */, BBA014B120754997007402E4 /* user_mark_id_storage.hpp in Headers */, 674A2A381B2715FB001A525C /* osm_opening_hours.hpp in Headers */, 3DEE1ADF21EE03B400054A91 /* power_manager.hpp in Headers */, @@ -1151,6 +1161,7 @@ F6B283091C1B03320081957A /* gps_track.cpp in Sources */, 34583BCF1C88556800F94664 /* place_page_info.cpp in Sources */, 3DD1166921888AAC007A2ED4 /* notification_manager.cpp in Sources */, + 3DD692AD2209E253001C3C62 /* notification_queue.cpp in Sources */, F6B283031C1B03320081957A /* gps_track_collection.cpp in Sources */, 3D4E99A31FB4A6410025B48C /* booking_filter_cache.cpp in Sources */, 6753469B1A4054E800A0A8C3 /* track.cpp in Sources */, @@ -1189,6 +1200,7 @@ 45580ABE1E2CBD5E00CD535D /* benchmark_tools.cpp in Sources */, 3DF54F80219DD21000D12E37 /* utils.cpp in Sources */, 3DA5723220C195ED007BDE27 /* everywhere_search_callback.cpp in Sources */, + 3DD692B12209E272001C3C62 /* notification_manager_delegate.cpp in Sources */, 3DEE1AE121EE03B400054A91 /* power_management_schemas.cpp in Sources */, BBD9E2C61EE9D01900DF189A /* routing_mark.cpp in Sources */, );