diff --git a/android/jni/com/mapswithme/maps/editor/Editor.cpp b/android/jni/com/mapswithme/maps/editor/Editor.cpp index 7a6b075c1e..41782818bd 100644 --- a/android/jni/com/mapswithme/maps/editor/Editor.cpp +++ b/android/jni/com/mapswithme/maps/editor/Editor.cpp @@ -304,9 +304,9 @@ Java_com_mapswithme_maps_editor_Editor_nativeIsBuilding(JNIEnv * env, jclass cla } JNIEXPORT jobject JNICALL -Java_com_mapswithme_maps_editor_Editor_nativeGetNamesDataSource(JNIEnv * env, jclass) +Java_com_mapswithme_maps_editor_Editor_nativeGetNamesDataSource(JNIEnv * env, jclass, jboolean needFakes) { - auto const namesDataSource = g_editableMapObject.GetNamesDataSource(); + auto const namesDataSource = g_editableMapObject.GetNamesDataSource(needFakes); jobjectArray names = jni::ToJavaArray(env, g_localNameClazz, namesDataSource.names, ToJavaName); jint mandatoryNamesCount = namesDataSource.mandatoryNamesCount; diff --git a/android/src/com/mapswithme/maps/editor/Editor.java b/android/src/com/mapswithme/maps/editor/Editor.java index 274895485c..715f1d381a 100644 --- a/android/src/com/mapswithme/maps/editor/Editor.java +++ b/android/src/com/mapswithme/maps/editor/Editor.java @@ -102,7 +102,7 @@ public final class Editor public static native boolean nativeIsNameEditable(); public static native boolean nativeIsBuilding(); - public static native NamesDataSource nativeGetNamesDataSource(); + public static native NamesDataSource nativeGetNamesDataSource(boolean needFakes); public static native String nativeGetDefaultName(); public static native void nativeEnableNamesAdvancedMode(); public static native void nativeSetNames(@NonNull LocalizedName[] names); diff --git a/android/src/com/mapswithme/maps/editor/EditorHostFragment.java b/android/src/com/mapswithme/maps/editor/EditorHostFragment.java index 1355a78d6f..9808d0ea86 100644 --- a/android/src/com/mapswithme/maps/editor/EditorHostFragment.java +++ b/android/src/com/mapswithme/maps/editor/EditorHostFragment.java @@ -103,6 +103,14 @@ public class EditorHostFragment extends BaseMwmToolbarFragment mMandatoryNamesCount = mandatoryNamesCount; } + private void fillNames(boolean needFakes) + { + NamesDataSource namesDataSource = Editor.nativeGetNamesDataSource(needFakes); + setNames(namesDataSource.getNames()); + setMandatoryNamesCount(namesDataSource.getMandatoryNamesCount()); + editMapObject(); + } + @Nullable @Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) @@ -128,10 +136,7 @@ public class EditorHostFragment extends BaseMwmToolbarFragment mIsNewObject = getArguments().getBoolean(EditorActivity.EXTRA_NEW_OBJECT, false); mToolbarController.setTitle(getTitle()); - NamesDataSource namesDataSource = Editor.nativeGetNamesDataSource(); - setNames(namesDataSource.getNames()); - setMandatoryNamesCount(namesDataSource.getMandatoryNamesCount()); - editMapObject(); + fillNames(true /* addFakes */); } @StringRes @@ -373,6 +378,7 @@ public class EditorHostFragment extends BaseMwmToolbarFragment String name = ""; if (lang.code.equals(Language.DEFAULT_LANG_CODE)) { + fillNames(false /* addFakes */); name = Editor.nativeGetDefaultName(); Editor.nativeEnableNamesAdvancedMode(); } diff --git a/indexer/editable_map_object.cpp b/indexer/editable_map_object.cpp index 3c0c5d8992..3f982ab72f 100644 --- a/indexer/editable_map_object.cpp +++ b/indexer/editable_map_object.cpp @@ -212,7 +212,7 @@ vector const & EditableMapObject::GetEditableFields() StringUtf8Multilang const & EditableMapObject::GetName() const { return m_name; } -NamesDataSource EditableMapObject::GetNamesDataSource() +NamesDataSource EditableMapObject::GetNamesDataSource(bool needFakes /* = true */) { auto const mwmInfo = GetID().m_mwmId.GetInfo(); @@ -224,13 +224,20 @@ NamesDataSource EditableMapObject::GetNamesDataSource() auto const userLangCode = StringUtf8Multilang::GetLangIndex(languages::GetCurrentNorm()); - StringUtf8Multilang fakeSource; - m_fakeNames = MakeFakeSource(m_name, mwmLanguages, fakeSource); - - if (m_fakeNames.m_names.empty()) - return GetNamesDataSource(m_name, mwmLanguages, userLangCode); + if (needFakes) + { + StringUtf8Multilang fakeSource; + m_fakeNames = MakeFakeSource(m_name, mwmLanguages, fakeSource); - return GetNamesDataSource(fakeSource, mwmLanguages, userLangCode); + if (!m_fakeNames.m_names.empty()) + return GetNamesDataSource(fakeSource, mwmLanguages, userLangCode); + } + else + { + RemoveFakeNames(m_fakeNames, m_name); + } + + return GetNamesDataSource(m_name, mwmLanguages, userLangCode); } // static diff --git a/indexer/editable_map_object.hpp b/indexer/editable_map_object.hpp index feaefc4619..fdf9570a24 100644 --- a/indexer/editable_map_object.hpp +++ b/indexer/editable_map_object.hpp @@ -103,7 +103,7 @@ public: StringUtf8Multilang const & GetName() const; /// See comment for NamesDataSource class. - NamesDataSource GetNamesDataSource(); + NamesDataSource GetNamesDataSource(bool addFakes = true); LocalizedStreet const & GetStreet() const; vector const & GetNearbyStreets() const; string const & GetHouseNumber() const; diff --git a/iphone/Maps/UI/Editor/MWMEditorViewController.mm b/iphone/Maps/UI/Editor/MWMEditorViewController.mm index 28348937dc..d0dcd19b88 100644 --- a/iphone/Maps/UI/Editor/MWMEditorViewController.mm +++ b/iphone/Maps/UI/Editor/MWMEditorViewController.mm @@ -538,7 +538,11 @@ void registerCellsForTableView(vector const & cells, UITab MWMEditorAdditionalNameTableViewCell * tCell = static_cast(cell); - auto const & localizedNames = m_mapObject.GetNamesDataSource().names; + // When default name is added - remove fake names from datasource. + auto const it = std::find(m_newAdditionalLanguages.begin(), m_newAdditionalLanguages.end(), + StringUtf8Multilang::kDefaultCode); + auto const needFakes = it == m_newAdditionalLanguages.end(); + auto const & localizedNames = m_mapObject.GetNamesDataSource(needFakes).names; if (indexPath.row < localizedNames.size()) {