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

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArsentiy Milchakov <milcars@mapswithme.com>2020-02-14 16:49:02 +0300
committerDaria Volvenkova <dvolvenkova@gmail.com>2020-02-20 17:01:36 +0300
commite01e37614d0e236153c99d59783c81fa25298865 (patch)
treee26ccffacc1e01754f4dc90c259b69fbb03737ae
parentf19700744f3363f18880ed8c92c7162124c71802 (diff)
[core][android] Showing place page by feature id is added. Showing place page by mercator is removed because of incorrect behavior (building was shown instead of poi).
-rw-r--r--android/jni/CMakeLists.txt1
-rw-r--r--android/jni/com/mapswithme/core/jni_helper.hpp4
-rw-r--r--android/jni/com/mapswithme/maps/Framework.cpp17
-rw-r--r--android/jni/com/mapswithme/maps/Framework.hpp7
-rw-r--r--android/jni/com/mapswithme/maps/isolines/IsolinesManager.cpp2
-rw-r--r--android/jni/com/mapswithme/maps/ugc/UGC.cpp46
-rw-r--r--android/jni/com/mapswithme/util/FeatureIdBuilder.hpp36
-rw-r--r--android/src/com/mapswithme/maps/Framework.java3
-rw-r--r--android/src/com/mapswithme/maps/MwmActivity.java2
-rw-r--r--android/src/com/mapswithme/maps/discovery/DiscoveryFragment.java2
-rw-r--r--android/src/com/mapswithme/maps/gallery/Items.java10
-rw-r--r--map/framework.cpp19
-rw-r--r--map/framework.hpp2
13 files changed, 85 insertions, 66 deletions
diff --git a/android/jni/CMakeLists.txt b/android/jni/CMakeLists.txt
index aa4018ec8d..a88edad20d 100644
--- a/android/jni/CMakeLists.txt
+++ b/android/jni/CMakeLists.txt
@@ -22,6 +22,7 @@ set(
SRC
# JNI headers
../../private.h
+ com/mapswithme/util/FeatureIdBuilder.hpp
com/mapswithme/core/jni_helper.hpp
com/mapswithme/core/logging.hpp
com/mapswithme/core/ScopedEnv.hpp
diff --git a/android/jni/com/mapswithme/core/jni_helper.hpp b/android/jni/com/mapswithme/core/jni_helper.hpp
index 5fbac92a56..dbe8c9d87c 100644
--- a/android/jni/com/mapswithme/core/jni_helper.hpp
+++ b/android/jni/com/mapswithme/core/jni_helper.hpp
@@ -4,11 +4,11 @@
#include "ScopedLocalRef.hpp"
+#include "geometry/point2d.hpp"
+
#include "base/buffer_vector.hpp"
#include "base/logging.hpp"
-#include "geometry/point2d.hpp"
-
#include <iterator>
#include <memory>
#include <string>
diff --git a/android/jni/com/mapswithme/maps/Framework.cpp b/android/jni/com/mapswithme/maps/Framework.cpp
index 76d8697d75..f0fb3c055e 100644
--- a/android/jni/com/mapswithme/maps/Framework.cpp
+++ b/android/jni/com/mapswithme/maps/Framework.cpp
@@ -4,6 +4,7 @@
#include "com/mapswithme/opengl/androidoglcontextfactory.hpp"
#include "com/mapswithme/platform/Platform.hpp"
#include "com/mapswithme/util/NetworkPolicy.hpp"
+#include "com/mapswithme/util/FeatureIdBuilder.hpp"
#include "com/mapswithme/vulkan/android_vulkan_context_factory.hpp"
#include "map/chart_generator.hpp"
@@ -878,6 +879,13 @@ void Framework::OnPowerSchemeChanged(power_management::Scheme const actualScheme
// Dummy
// TODO: provide information for UI Properties.
}
+
+FeatureID Framework::BuildFeatureId(JNIEnv * env, jobject featureId)
+{
+ static FeatureIdBuilder const builder(env);
+
+ return builder.Build(env, featureId);
+}
} // namespace android
//============ GLUE CODE for com.mapswithme.maps.Framework class =============//
@@ -1967,7 +1975,6 @@ Java_com_mapswithme_maps_Framework_nativeGetPhoneAuthUrl(JNIEnv * env, jclass, j
JNIEXPORT jobjectArray JNICALL
Java_com_mapswithme_maps_Framework_nativeGetDefaultAuthHeaders(JNIEnv * env, jobject)
{
- auto const & bm = frm()->GetBookmarkManager();
return jni::ToKeyValueArray(env, web_api::GetDefaultAuthHeaders());
}
@@ -1984,10 +1991,12 @@ Java_com_mapswithme_maps_Framework_nativeGetTermsOfUseLink(JNIEnv * env, jclass)
}
JNIEXPORT void JNICALL
-Java_com_mapswithme_maps_Framework_nativeShowFeatureByLatLon(JNIEnv * env, jclass,
- jdouble lat, jdouble lon)
+Java_com_mapswithme_maps_Framework_nativeShowFeature(JNIEnv * env, jclass, jobject featureId)
{
- frm()->ShowFeatureByMercator(mercator::FromLatLon(ms::LatLon(lat, lon)));
+ auto const f = g_framework->BuildFeatureId(env, featureId);
+
+ if (f.IsValid())
+ frm()->ShowFeature(f);
}
JNIEXPORT void JNICALL
diff --git a/android/jni/com/mapswithme/maps/Framework.hpp b/android/jni/com/mapswithme/maps/Framework.hpp
index 0681222a9c..d8cf004809 100644
--- a/android/jni/com/mapswithme/maps/Framework.hpp
+++ b/android/jni/com/mapswithme/maps/Framework.hpp
@@ -22,6 +22,9 @@
#include "partners_api/promo_api.hpp"
#include "partners_api/utm.hpp"
+#include "indexer/feature_decl.hpp"
+#include "indexer/map_style.hpp"
+
#include "platform/country_defines.hpp"
#include "platform/location.hpp"
@@ -29,8 +32,6 @@
#include "base/timer.hpp"
-#include "indexer/map_style.hpp"
-
#include <cstdint>
#include <map>
#include <memory>
@@ -228,6 +229,8 @@ namespace android
// PowerManager::Subscriber overrides:
void OnPowerFacilityChanged(power_management::Facility const facility, bool enabled) override;
void OnPowerSchemeChanged(power_management::Scheme const actualScheme) override;
+
+ FeatureID BuildFeatureId(JNIEnv * env, jobject featureId);
};
}
diff --git a/android/jni/com/mapswithme/maps/isolines/IsolinesManager.cpp b/android/jni/com/mapswithme/maps/isolines/IsolinesManager.cpp
index 836a0a7512..9ff68dd9cf 100644
--- a/android/jni/com/mapswithme/maps/isolines/IsolinesManager.cpp
+++ b/android/jni/com/mapswithme/maps/isolines/IsolinesManager.cpp
@@ -1,5 +1,5 @@
#include <jni.h>
-#include <android/jni/com/mapswithme/maps/Framework.hpp>
+#include "com/mapswithme/maps/Framework.hpp"
#include "com/mapswithme/core/jni_helper.hpp"
#include "com/mapswithme/platform/Platform.hpp"
diff --git a/android/jni/com/mapswithme/maps/ugc/UGC.cpp b/android/jni/com/mapswithme/maps/ugc/UGC.cpp
index 8e4bf90994..eb3068ffb0 100644
--- a/android/jni/com/mapswithme/maps/ugc/UGC.cpp
+++ b/android/jni/com/mapswithme/maps/ugc/UGC.cpp
@@ -18,48 +18,6 @@
namespace
{
-class FeatureIdBuilder
-{
-public:
- FeatureID Build(JNIEnv * env, jobject obj)
- {
- Init(env);
-
- jstring jcountryName = static_cast<jstring>(env->GetObjectField(obj, m_countryName));
- jlong jversion = env->GetLongField(obj, m_version);
- jint jindex = env->GetIntField(obj, m_index);
-
- auto const countryName = jni::ToNativeString(env, jcountryName);
- auto const version = static_cast<int64_t>(jversion);
- auto const index = static_cast<uint32_t>(jindex);
-
- auto const & ds = g_framework->GetDataSource();
- auto const id = ds.GetMwmIdByCountryFile(platform::CountryFile(countryName));
- return FeatureID(id, index);
- }
-
-private:
- void Init(JNIEnv * env)
- {
- if (m_initialized)
- return;
-
- m_class = jni::GetGlobalClassRef(env, "com/mapswithme/maps/bookmarks/data/FeatureId");
- m_countryName = env->GetFieldID(m_class, "mMwmName", "Ljava/lang/String;");
- m_version = env->GetFieldID(m_class, "mMwmVersion", "J");
- m_index = env->GetFieldID(m_class, "mFeatureIndex", "I");
-
- m_initialized = true;
- }
-
- bool m_initialized = false;
-
- jclass m_class;
- jfieldID m_countryName;
- jfieldID m_version;
- jfieldID m_index;
-} g_builder;
-
class JavaBridge
{
public:
@@ -272,7 +230,7 @@ JNIEXPORT
void JNICALL Java_com_mapswithme_maps_ugc_UGC_nativeRequestUGC(JNIEnv * env, jclass /* clazz */,
jobject featureId)
{
- auto const fid = g_builder.Build(env, featureId);
+ auto const fid = g_framework->BuildFeatureId(env, featureId);
g_framework->RequestUGC(fid, [](ugc::UGC const & ugc, ugc::UGCUpdate const & update) {
g_bridge.OnUGCReceived(jni::GetEnv(), ugc, update);
});
@@ -283,7 +241,7 @@ void JNICALL Java_com_mapswithme_maps_ugc_UGC_nativeSetUGCUpdate(JNIEnv * env, j
jobject featureId,
jobject ugcUpdate)
{
- auto const fid = g_builder.Build(env, featureId);
+ auto const fid = g_framework->BuildFeatureId(env, featureId);
ugc::UGCUpdate update = g_bridge.ToNativeUGCUpdate(env, ugcUpdate);
g_framework->SetUGCUpdate(fid, update, [](ugc::Storage::SettingResult const & result) {
g_bridge.OnUGCSaved(jni::GetEnv(), result);
diff --git a/android/jni/com/mapswithme/util/FeatureIdBuilder.hpp b/android/jni/com/mapswithme/util/FeatureIdBuilder.hpp
new file mode 100644
index 0000000000..e35b0e3b04
--- /dev/null
+++ b/android/jni/com/mapswithme/util/FeatureIdBuilder.hpp
@@ -0,0 +1,36 @@
+#pragma once
+
+#include "com/mapswithme/core/jni_helper.hpp"
+
+#include "indexer/feature_decl.hpp"
+
+class FeatureIdBuilder
+{
+public:
+ FeatureIdBuilder(JNIEnv * env)
+ {
+ m_class = jni::GetGlobalClassRef(env, "com/mapswithme/maps/bookmarks/data/FeatureId");
+ m_countryName = env->GetFieldID(m_class, "mMwmName", "Ljava/lang/String;");
+ m_version = env->GetFieldID(m_class, "mMwmVersion", "J");
+ m_index = env->GetFieldID(m_class, "mFeatureIndex", "I");
+ }
+
+ FeatureID Build(JNIEnv * env, jobject obj) const
+ {
+ jstring jcountryName = static_cast<jstring>(env->GetObjectField(obj, m_countryName));
+ jint jindex = env->GetIntField(obj, m_index);
+
+ auto const countryName = jni::ToNativeString(env, jcountryName);
+ auto const index = static_cast<uint32_t>(jindex);
+
+ auto const & ds = g_framework->GetDataSource();
+ auto const id = ds.GetMwmIdByCountryFile(platform::CountryFile(countryName));
+ return FeatureID(id, index);
+ }
+
+private:
+ jclass m_class;
+ jfieldID m_countryName;
+ jfieldID m_version;
+ jfieldID m_index;
+};
diff --git a/android/src/com/mapswithme/maps/Framework.java b/android/src/com/mapswithme/maps/Framework.java
index c8a1c334bd..f50022e57e 100644
--- a/android/src/com/mapswithme/maps/Framework.java
+++ b/android/src/com/mapswithme/maps/Framework.java
@@ -18,6 +18,7 @@ import com.mapswithme.maps.api.ParsedUrlMwmRequest;
import com.mapswithme.maps.auth.AuthorizationListener;
import com.mapswithme.maps.background.NotificationCandidate;
import com.mapswithme.maps.bookmarks.data.DistanceAndAzimut;
+import com.mapswithme.maps.bookmarks.data.FeatureId;
import com.mapswithme.maps.bookmarks.data.MapObject;
import com.mapswithme.maps.downloader.DownloaderPromoBanner;
import com.mapswithme.maps.gdpr.UserBindingListener;
@@ -493,7 +494,7 @@ public class Framework
@NonNull
public static native String nativeGetTermsOfUseLink();
- public static native void nativeShowFeatureByLatLon(double lat, double lon);
+ public static native void nativeShowFeature(@NonNull FeatureId featureId);
public static native void nativeShowBookmarkCategory(long cat);
private static native int nativeGetFilterRating(float rawRating);
diff --git a/android/src/com/mapswithme/maps/MwmActivity.java b/android/src/com/mapswithme/maps/MwmActivity.java
index 4011706396..54d6720c8e 100644
--- a/android/src/com/mapswithme/maps/MwmActivity.java
+++ b/android/src/com/mapswithme/maps/MwmActivity.java
@@ -1158,7 +1158,7 @@ public class MwmActivity extends BaseMwmFragmentActivity
@Override
public boolean run(@NonNull MwmActivity target)
{
- Framework.nativeShowFeatureByLatLon(object.getLat(), object.getLon());
+ Framework.nativeShowFeature(object.getFeatureId());
return false;
}
});
diff --git a/android/src/com/mapswithme/maps/discovery/DiscoveryFragment.java b/android/src/com/mapswithme/maps/discovery/DiscoveryFragment.java
index ee6b15ba03..eb34eabd3f 100644
--- a/android/src/com/mapswithme/maps/discovery/DiscoveryFragment.java
+++ b/android/src/com/mapswithme/maps/discovery/DiscoveryFragment.java
@@ -399,7 +399,7 @@ public class DiscoveryFragment extends BaseMwmToolbarFragment implements Discove
String title = TextUtils.isEmpty(item.getTitle()) ? subtitle : item.getTitle();
- return MapObject.createMapObject(FeatureId.EMPTY, MapObject.SEARCH, title, subtitle,
+ return MapObject.createMapObject(item.getFeatureId(), MapObject.SEARCH, title, subtitle,
item.getLat(), item.getLon());
}
diff --git a/android/src/com/mapswithme/maps/gallery/Items.java b/android/src/com/mapswithme/maps/gallery/Items.java
index 54e78e3065..128a8a5a3e 100644
--- a/android/src/com/mapswithme/maps/gallery/Items.java
+++ b/android/src/com/mapswithme/maps/gallery/Items.java
@@ -5,6 +5,7 @@ import androidx.annotation.Nullable;
import com.mapswithme.maps.MwmApplication;
import com.mapswithme.maps.R;
+import com.mapswithme.maps.bookmarks.data.FeatureId;
import com.mapswithme.maps.search.Popularity;
import com.mapswithme.maps.search.SearchResult;
@@ -136,6 +137,15 @@ public class Items
}
@NonNull
+ public FeatureId getFeatureId()
+ {
+ if (mResult.description == null)
+ return FeatureId.EMPTY;
+
+ return mResult.description.featureId == null ? FeatureId.EMPTY : mResult.description.featureId;
+ }
+
+ @NonNull
public Popularity getPopularity()
{
return mResult.getPopularity();
diff --git a/map/framework.cpp b/map/framework.cpp
index ae8e8aa441..1653d68734 100644
--- a/map/framework.cpp
+++ b/map/framework.cpp
@@ -1148,17 +1148,20 @@ void Framework::ShowBookmarkCategory(kml::MarkGroupId categoryId, bool animation
ShowRect(rect, -1 /* maxScale */, animation);
}
-void Framework::ShowFeatureByMercator(m2::PointD const & pt)
+void Framework::ShowFeature(FeatureID const & featureId)
{
StopLocationFollow();
place_page::BuildInfo info;
- info.m_mercator = pt;
+ info.m_featureId = featureId;
+ info.m_match = place_page::BuildInfo::Match::FeatureOnly;
m_currentPlacePageInfo = BuildPlacePageInfo(info);
+
if (m_drapeEngine != nullptr)
{
- m_drapeEngine->SetModelViewCenter(pt, scales::GetUpperComfortScale(), true /* isAnim */,
- true /* trackVisibleViewport */);
+ auto const pt = m_currentPlacePageInfo->GetMercator();
+ auto const scale = scales::GetUpperComfortScale();
+ m_drapeEngine->SetModelViewCenter(pt, scale, true /* isAnim */, true /* trackVisibleViewport */);
}
ActivateMapSelection(m_currentPlacePageInfo);
}
@@ -3176,20 +3179,18 @@ bool Framework::ParseEditorDebugCommand(search::SearchParams const & params)
auto const features = FindFeaturesByIndex(index);
for (auto const & fid : features)
{
- FeaturesLoaderGuard guard(m_featuresFetcher.GetDataSource(), fid.m_mwmId);
- auto ft = guard.GetFeatureByIndex(fid.m_index);
- if (!ft)
+ if (!fid.IsValid())
continue;
// Show the first feature on the map.
if (!isShown)
{
- ShowFeatureByMercator(feature::GetCenter(*ft));
+ ShowFeature(fid);
isShown = true;
}
// Log found features.
- LOG(LINFO, ("Feature found:", fid, mercator::ToLatLon(feature::GetCenter(*ft))));
+ LOG(LINFO, ("Feature found:", fid));
}
}
return true;
diff --git a/map/framework.hpp b/map/framework.hpp
index 5f0568af1f..0605234037 100644
--- a/map/framework.hpp
+++ b/map/framework.hpp
@@ -355,7 +355,7 @@ public:
void ShowBookmark(kml::MarkId id);
void ShowBookmark(Bookmark const * bookmark);
void ShowTrack(kml::TrackId trackId);
- void ShowFeatureByMercator(m2::PointD const & pt);
+ void ShowFeature(FeatureID const & featureId);
void ShowBookmarkCategory(kml::MarkGroupId categoryId, bool animation = true);
void AddBookmarksFile(std::string const & filePath, bool isTemporaryFile);