diff --git a/android/jni/com/mapswithme/maps/bookmarks/data/Bookmark.cpp b/android/jni/com/mapswithme/maps/bookmarks/data/Bookmark.cpp index 25ec5b775f..8a4e4327fd 100644 --- a/android/jni/com/mapswithme/maps/bookmarks/data/Bookmark.cpp +++ b/android/jni/com/mapswithme/maps/bookmarks/data/Bookmark.cpp @@ -74,14 +74,17 @@ extern "C" JNIEXPORT void JNICALL Java_com_mapswithme_maps_bookmarks_data_Bookmark_changeBookmark( - JNIEnv * env, jobject thiz, jdouble x, jdouble y, jstring cat, jstring name, jstring type) + JNIEnv * env, jobject thiz, jdouble x, jdouble y, + jstring cat, jstring name, jstring type, jstring descr) { // get existing bookmark under point BookmarkAndCategory bac = frm()->GetBookmark(frm()->GtoP(m2::PointD(x, y))); // initialize new bookmark Bookmark bm(m2::PointD(x, y), jni::ToNativeString(env, name), jni::ToNativeString(env, type)); - if (IsValid(bac)) + if (descr != 0) + bm.SetDescription(jni::ToNativeString(env, descr)); + else if (IsValid(bac)) bm.SetDescription(getBookmark(bac.first, bac.second)->GetDescription()); // add new bookmark diff --git a/android/src/com/mapswithme/maps/bookmarks/BookmarkActivity.java b/android/src/com/mapswithme/maps/bookmarks/BookmarkActivity.java index 13032e4001..108ccf5272 100644 --- a/android/src/com/mapswithme/maps/bookmarks/BookmarkActivity.java +++ b/android/src/com/mapswithme/maps/bookmarks/BookmarkActivity.java @@ -136,18 +136,7 @@ public class BookmarkActivity extends AbstractBookmarkActivity private void assignPinParams() { if (mPin != null) - { - String s = mName.getText().toString(); - if (!s.equals(mPin.getName())) - mPin.setName(s); - - s = mDescr.getText().toString(); - if (!s.equals(mPin.getBookmarkDescription())) - mPin.setDescription(s); - - if (m_icon != null && m_icon != mPin.getIcon()) - mPin.setIcon(m_icon); - } + mPin.setParams(mName.getText().toString(), m_icon, mDescr.getText().toString()); } @Override diff --git a/android/src/com/mapswithme/maps/bookmarks/data/Bookmark.java b/android/src/com/mapswithme/maps/bookmarks/data/Bookmark.java index 5e333adfe3..8d79772468 100644 --- a/android/src/com/mapswithme/maps/bookmarks/data/Bookmark.java +++ b/android/src/com/mapswithme/maps/bookmarks/data/Bookmark.java @@ -83,7 +83,7 @@ public class Bookmark private native String getName(int c, long b); private native String getIconPos(double px, double py); private native String getIcon(int c, long b); - private native void changeBookmark(double x, double y, String category, String name, String type); + private native void changeBookmark(double x, double y, String category, String name, String type, String descr); private native String getBookmarkDescription(int categoryId, long bookmark); private native void setBookmarkDescription(int categoryId, long bookmark, String newDescr); private native String getBookmarkDescriptionPos(int categoryId, int bookmark); @@ -176,9 +176,18 @@ public class Bookmark mBookmark = BookmarkManager.getBookmarkManager(mContext).getCategoryById(mCategoryId).getSize() - 1; } + public void setParams(String name, Icon icon, String descr) + { + if (icon == null) + icon = mIcon; + + if (!name.equals(getName()) || icon != mIcon || !descr.equals(getBookmarkDescription())) + changeBookmark(mMercatorX, mMercatorY, getCategoryName(), name, icon.getType(), descr); + } + private void changeBookmark(String category, String name, String type) { - changeBookmark(mMercatorX, mMercatorY, category, name, type); + changeBookmark(mMercatorX, mMercatorY, category, name, type, null); } public int getCategoryId()