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:
authorSergey Magidovich <mgsergio@mapswithme.com>2016-06-10 15:19:29 +0300
committerVladimir Byko-Ianko <v.bykoianko@corp.mail.ru>2016-06-23 19:26:25 +0300
commit82cc6171cc02b73eec0140fddadd8c4f7e026dbd (patch)
treeea29f2bdb6db5c5b45ada8986f4ed9e9a1979c70
parenta9bdcb8f27a8ab84fe3fe2902abe8cff19584291 (diff)
Do not edit old maps. Refactor edit buttos showups.
-rw-r--r--android/jni/com/mapswithme/maps/Framework.cpp12
-rw-r--r--android/jni/com/mapswithme/maps/editor/Editor.cpp16
-rw-r--r--android/src/com/mapswithme/maps/Framework.java2
-rw-r--r--android/src/com/mapswithme/maps/editor/Editor.java4
-rw-r--r--android/src/com/mapswithme/maps/widget/placepage/PlacePageView.java7
-rw-r--r--indexer/osm_editor.cpp2
-rw-r--r--iphone/Maps/Classes/CustomViews/MapViewControls/BottomMenu/MWMBottomMenuViewController.mm2
-rw-r--r--iphone/Maps/Classes/MWMPlacePageEntity.mm8
-rw-r--r--map/framework.cpp18
-rw-r--r--map/framework.hpp4
-rw-r--r--map/place_page_info.cpp22
-rw-r--r--map/place_page_info.hpp15
-rw-r--r--qt/place_page_dialog.cpp2
13 files changed, 62 insertions, 52 deletions
diff --git a/android/jni/com/mapswithme/maps/Framework.cpp b/android/jni/com/mapswithme/maps/Framework.cpp
index f4d8185b54..f2da2a9965 100644
--- a/android/jni/com/mapswithme/maps/Framework.cpp
+++ b/android/jni/com/mapswithme/maps/Framework.cpp
@@ -1048,18 +1048,6 @@ Java_com_mapswithme_maps_Framework_nativeGetActiveObjectFormattedCuisine(JNIEnv
return jni::ToJavaString(env, g_framework->GetPlacePageInfo().FormatCuisines());
}
-JNIEXPORT jboolean JNICALL
-Java_com_mapswithme_maps_Framework_nativeIsActiveObjectABuilding(JNIEnv * env, jclass)
-{
- return g_framework->GetPlacePageInfo().IsBuilding();
-}
-
-JNIEXPORT jboolean JNICALL
-Java_com_mapswithme_maps_Framework_nativeCanAddPlaceFromPlacePage(JNIEnv * env, jclass clazz)
-{
- return g_framework->GetPlacePageInfo().ShouldShowAddPlace();
-}
-
JNIEXPORT jobject JNICALL
Java_com_mapswithme_maps_Framework_nativeGetSponsoredHotelInfo(JNIEnv * env, jclass clazz)
{
diff --git a/android/jni/com/mapswithme/maps/editor/Editor.cpp b/android/jni/com/mapswithme/maps/editor/Editor.cpp
index eafd002a42..b572988e2b 100644
--- a/android/jni/com/mapswithme/maps/editor/Editor.cpp
+++ b/android/jni/com/mapswithme/maps/editor/Editor.cpp
@@ -244,9 +244,21 @@ Java_com_mapswithme_maps_editor_Editor_nativeSaveEditedFeature(JNIEnv *, jclass)
}
JNIEXPORT jboolean JNICALL
-Java_com_mapswithme_maps_editor_Editor_nativeIsFeatureEditable(JNIEnv *, jclass)
+Java_com_mapswithme_maps_editor_Editor_nativeShouldShowEditPlace(JNIEnv *, jclass)
{
- return g_framework->GetPlacePageInfo().IsEditable();
+ return g_framework->GetPlacePageInfo().ShouldShowEditPlace();
+}
+
+JNIEXPORT jboolean JNICALL
+Java_com_mapswithme_maps_editor_Editor_nativeShouldShowAddPlace(JNIEnv *, jclass)
+{
+ return g_framework->GetPlacePageInfo().ShouldShowAddPlace();
+}
+
+JNIEXPORT jboolean JNICALL
+Java_com_mapswithme_maps_editor_Editor_nativeShouldShowAddBusiness(JNIEnv *, jclass)
+{
+ return g_framework->GetPlacePageInfo().ShouldShowAddBusiness();
}
JNIEXPORT jintArray JNICALL
diff --git a/android/src/com/mapswithme/maps/Framework.java b/android/src/com/mapswithme/maps/Framework.java
index 8903ece170..d1de9edec4 100644
--- a/android/src/com/mapswithme/maps/Framework.java
+++ b/android/src/com/mapswithme/maps/Framework.java
@@ -212,7 +212,5 @@ public class Framework
public static native boolean nativeIsInChoosePositionMode();
public static native boolean nativeIsDownloadedMapAtScreenCenter();
public static native String nativeGetActiveObjectFormattedCuisine();
- public static native boolean nativeIsActiveObjectABuilding();
- public static native boolean nativeCanAddPlaceFromPlacePage();
public static native SponsoredHotelInfo nativeGetSponsoredHotelInfo();
}
diff --git a/android/src/com/mapswithme/maps/editor/Editor.java b/android/src/com/mapswithme/maps/editor/Editor.java
index 6ea15cc2ae..2812281bd8 100644
--- a/android/src/com/mapswithme/maps/editor/Editor.java
+++ b/android/src/com/mapswithme/maps/editor/Editor.java
@@ -67,7 +67,9 @@ public final class Editor
BuildConfig.APPLICATION_ID);
}
- public static native boolean nativeIsFeatureEditable();
+ public static native boolean nativeShouldShowEditPlace();
+ public static native boolean nativeShouldShowAddPlace();
+ public static native boolean nativeShouldShowAddBusiness();
@NonNull
public static native int[] nativeGetEditableFields();
diff --git a/android/src/com/mapswithme/maps/widget/placepage/PlacePageView.java b/android/src/com/mapswithme/maps/widget/placepage/PlacePageView.java
index 57234337f8..42fa8ca2f4 100644
--- a/android/src/com/mapswithme/maps/widget/placepage/PlacePageView.java
+++ b/android/src/com/mapswithme/maps/widget/placepage/PlacePageView.java
@@ -696,10 +696,9 @@ public class PlacePageView extends RelativeLayout implements View.OnClickListene
}
else
{
- UiUtils.showIf(Editor.nativeIsFeatureEditable(), mEditPlace);
- UiUtils.showIf(Framework.nativeIsActiveObjectABuilding() &&
- Editor.nativeGetMapObjectStatus() != Editor.OBSOLETE, mAddOrganisation);
- UiUtils.showIf(Framework.nativeCanAddPlaceFromPlacePage(), mAddPlace);
+ UiUtils.showIf(Editor.nativeShouldShowEditPlace(), mEditPlace);
+ UiUtils.showIf(Editor.nativeShouldShowAddBusiness(), mAddOrganisation);
+ UiUtils.showIf(Editor.nativeShouldShowAddPlace(), mAddPlace);
}
UiUtils.showIf(mSponsoredHotelInfo != null, mMoreInfo);
diff --git a/indexer/osm_editor.cpp b/indexer/osm_editor.cpp
index 69a044948e..473218f54c 100644
--- a/indexer/osm_editor.cpp
+++ b/indexer/osm_editor.cpp
@@ -593,7 +593,7 @@ vector<uint32_t> Editor::GetFeaturesByStatus(MwmSet::MwmId const & mwmId, Featur
EditableProperties Editor::GetEditableProperties(FeatureType const & feature) const
{
ASSERT(version::IsSingleMwm(feature.GetID().m_mwmId.GetInfo()->m_version.GetVersion()),
- ("Edit mode should be available only on new datas"));
+ ("Edit mode should be available only on new data"));
ASSERT(GetFeatureStatus(feature.GetID()) != FeatureStatus::Obsolete,
("Edit mode should not be available on obsolete features"));
diff --git a/iphone/Maps/Classes/CustomViews/MapViewControls/BottomMenu/MWMBottomMenuViewController.mm b/iphone/Maps/Classes/CustomViews/MapViewControls/BottomMenu/MWMBottomMenuViewController.mm
index aba5f017fd..0fbae1535e 100644
--- a/iphone/Maps/Classes/CustomViews/MapViewControls/BottomMenu/MWMBottomMenuViewController.mm
+++ b/iphone/Maps/Classes/CustomViews/MapViewControls/BottomMenu/MWMBottomMenuViewController.mm
@@ -197,7 +197,7 @@ typedef NS_ENUM(NSUInteger, MWMBottomMenuViewCell)
case MWMBottomMenuViewCellAddPlace:
{
BOOL const isEnabled = self.controller.controlsManager.navigationState == MWMNavigationDashboardStateHidden &&
- version::IsSingleMwm(GetFramework().Storage().GetCurrentDataVersion());
+ GetFramework().CanEditMap();
[cell configureWithImageName:@"ic_add_place"
label:L(@"placepage_add_place_button")
badgeCount:0
diff --git a/iphone/Maps/Classes/MWMPlacePageEntity.mm b/iphone/Maps/Classes/MWMPlacePageEntity.mm
index 10fbb3a2cf..4ec3ac10f1 100644
--- a/iphone/Maps/Classes/MWMPlacePageEntity.mm
+++ b/iphone/Maps/Classes/MWMPlacePageEntity.mm
@@ -178,7 +178,7 @@ void initFieldsMap()
- (NSString *)getCellValue:(MWMPlacePageCellType)cellType
{
auto const s = MapsAppDelegate.theApp.mapViewController.controlsManager.navigationState;
- BOOL const editOrAddAreAvailable = s == MWMNavigationDashboardStateHidden && m_info.IsEditable();
+ BOOL const navigationIsHidden = s == MWMNavigationDashboardStateHidden;
switch (cellType)
{
case MWMPlacePageCellTypeName:
@@ -186,14 +186,14 @@ void initFieldsMap()
case MWMPlacePageCellTypeCoordinate:
return [self coordinate];
case MWMPlacePageCellTypeAddPlaceButton:
- return editOrAddAreAvailable && m_info.ShouldShowAddPlace() ? @"" : nil;
+ return navigationIsHidden && m_info.ShouldShowAddPlace() ? @"" : nil;
case MWMPlacePageCellTypeBookmark:
return m_info.IsBookmark() ? @"" : nil;
case MWMPlacePageCellTypeEditButton:
// TODO(Vlad): It's a really strange way to "display" cell if returned text is not nil.
- return editOrAddAreAvailable && !m_info.IsMyPosition() && m_info.IsFeature() ? @"": nil;
+ return navigationIsHidden && m_info.ShouldShowEditPlace() ? @"" : nil;
case MWMPlacePageCellTypeAddBusinessButton:
- return editOrAddAreAvailable && m_info.IsBuilding() ? @"" : nil;
+ return navigationIsHidden && m_info.ShouldShowAddBusiness() ? @"" : nil;
case MWMPlacePageCellTypeWebsite:
return m_info.IsSponsoredHotel() ? nil : [self getDefaultField:cellType];
case MWMPlacePageCellTypeBookingMore:
diff --git a/map/framework.cpp b/map/framework.cpp
index cd48c6274a..2b1117b0b8 100644
--- a/map/framework.cpp
+++ b/map/framework.cpp
@@ -725,9 +725,14 @@ void Framework::FillPointInfo(m2::PointD const & mercator, string const & custom
{
auto feature = GetFeatureAtPoint(mercator);
if (feature)
+ {
FillInfoFromFeatureType(*feature, info);
+ }
else
+ {
info.m_customName = customTitle.empty() ? m_stringsBundle.GetString("placepage_unknown_place") : customTitle;
+ info.m_canEditOrAdd = CanEditMap();
+ }
// This line overwrites mercator center from area feature which can be far away.
info.SetMercator(mercator);
@@ -751,9 +756,8 @@ void Framework::FillInfoFromFeatureType(FeatureType const & ft, place_page::Info
info.m_sponsoredDescriptionUrl = GetBookingApi().GetDescriptionUrl(baseUrl);
}
- info.m_isEditable = featureStatus != osm::Editor::FeatureStatus::Obsolete &&
- !info.IsSponsoredHotel();
- info.m_isDataEditable = version::IsSingleMwm(ft.GetID().m_mwmId.GetInfo()->m_version.GetVersion());
+ info.m_canEditOrAdd = featureStatus != osm::Editor::FeatureStatus::Obsolete && CanEditMap() &&
+ !info.IsSponsoredHotel();
info.m_localizedWifiString = m_stringsBundle.GetString("wifi");
info.m_localizedRatingString = m_stringsBundle.GetString("place_page_booking_rating");
@@ -2194,11 +2198,7 @@ void Framework::UpdateSavedDataVersion()
settings::Set("DataVersion", m_storage.GetCurrentDataVersion());
}
-int64_t Framework::GetCurrentDataVersion()
-{
- return m_storage.GetCurrentDataVersion();
-}
-
+int64_t Framework::GetCurrentDataVersion() const { return m_storage.GetCurrentDataVersion(); }
void Framework::BuildRoute(m2::PointD const & finish, uint32_t timeoutSec)
{
ASSERT_THREAD_CHECKER(m_threadChecker, ("BuildRoute"));
@@ -2723,6 +2723,8 @@ void SetHostingBuildingAddress(FeatureID const & hostingBuildingFid, Index const
}
} // namespace
+bool Framework::CanEditMap() const { return version::IsSingleMwm(GetCurrentDataVersion()); }
+
bool Framework::CreateMapObject(m2::PointD const & mercator, uint32_t const featureType,
osm::EditableMapObject & emo) const
{
diff --git a/map/framework.hpp b/map/framework.hpp
index 49486afe6c..7c87293bd5 100644
--- a/map/framework.hpp
+++ b/map/framework.hpp
@@ -579,7 +579,7 @@ public:
//@{
bool IsDataVersionUpdated();
void UpdateSavedDataVersion();
- int64_t GetCurrentDataVersion();
+ int64_t GetCurrentDataVersion() const;
//@}
public:
@@ -655,6 +655,8 @@ public:
//@{
/// Initializes feature for Create Object UI.
/// @returns false in case when coordinate is in the ocean or mwm is not downloaded.
+ bool CanEditMap() const;
+
bool CreateMapObject(m2::PointD const & mercator, uint32_t const featureType, osm::EditableMapObject & emo) const;
/// @returns false if feature is invalid or can't be edited.
bool GetEditableMapObject(FeatureID const & fid, osm:: EditableMapObject & emo) const;
diff --git a/map/place_page_info.cpp b/map/place_page_info.cpp
index 79ae971a90..52edfff5c8 100644
--- a/map/place_page_info.cpp
+++ b/map/place_page_info.cpp
@@ -15,19 +15,25 @@ char const * const Info::kPricingSymbol = "$";
bool Info::IsFeature() const { return m_featureID.IsValid(); }
bool Info::IsBookmark() const { return m_bac != MakeEmptyBookmarkAndCategory(); }
bool Info::IsMyPosition() const { return m_isMyPosition; }
-bool Info::HasApiUrl() const { return !m_apiUrl.empty(); }
-bool Info::IsEditable() const { return m_isEditable && m_isDataEditable; }
-bool Info::IsDataEditable() const { return m_isDataEditable; }
-bool Info::HasWifi() const { return GetInternet() == osm::Internet::Wlan; }
+bool Info::IsSponsoredHotel() const { return m_isSponsoredHotel; }
bool Info::ShouldShowAddPlace() const
{
- return !IsSponsoredHotel() &&
- (!IsFeature() || (!IsPointType() && !IsBuilding())) &&
- m_isDataEditable;
+ auto const isPointOrBuilding = IsPointType() || IsBuilding();
+ return m_canEditOrAdd && !(IsFeature() && isPointOrBuilding);
}
-bool Info::IsSponsoredHotel() const { return m_isSponsoredHotel; }
+bool Info::ShouldShowAddBusiness() const { return m_canEditOrAdd && IsBuilding(); }
+
+bool Info::ShouldShowEditPlace() const
+{
+ return m_canEditOrAdd &&
+ // TODO(mgsergio): Does IsFeature() imply !IsMyPosition()?
+ !IsMyPosition() && IsFeature();
+}
+
+bool Info::HasApiUrl() const { return !m_apiUrl.empty(); }
+bool Info::HasWifi() const { return GetInternet() == osm::Internet::Wlan; }
string Info::FormatNewBookmarkName() const
{
diff --git a/map/place_page_info.hpp b/map/place_page_info.hpp
index c1cedfb34a..cd308c2c8d 100644
--- a/map/place_page_info.hpp
+++ b/map/place_page_info.hpp
@@ -28,14 +28,14 @@ public:
bool IsFeature() const;
bool IsBookmark() const;
bool IsMyPosition() const;
- bool ShouldShowAddPlace() const;
bool IsSponsoredHotel() const;
+
+ bool ShouldShowAddPlace() const;
+ bool ShouldShowAddBusiness() const;
+ bool ShouldShowEditPlace() const;
+
/// @returns true if Back API button should be displayed.
bool HasApiUrl() const;
- /// @returns true if Edit Place button should be displayed.
- bool IsEditable() const;
- /// @returns true if PlacePage was opened on a single mwm (see version::IsSingleMwm).
- bool IsDataEditable() const;
/// TODO: Support all possible Internet types in UI. @See MapObject::GetInternet().
bool HasWifi() const;
@@ -91,8 +91,9 @@ public:
storage::TCountryId m_countryId = storage::kInvalidCountryId;
bool m_isMyPosition = false;
- bool m_isEditable = false;
- bool m_isDataEditable = false;
+ /// 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;
diff --git a/qt/place_page_dialog.cpp b/qt/place_page_dialog.cpp
index 4162fb4a54..fef2ca432b 100644
--- a/qt/place_page_dialog.cpp
+++ b/qt/place_page_dialog.cpp
@@ -165,7 +165,7 @@ PlacePageDialog::PlacePageDialog(QWidget * parent, place_page::Info const & info
connect(closeButton, SIGNAL(clicked()), this, SLOT(OnClose()));
dbb->addButton(closeButton, QDialogButtonBox::RejectRole);
- if (info.IsEditable())
+ if (info.ShouldShowEditPlace())
{
QPushButton * editButton = new QPushButton("Edit Place");
connect(editButton, SIGNAL(clicked()), this, SLOT(OnEdit()));