Added JNI for bookmark’s author

This commit is contained in:
r.kuznetsov 2018-05-17 17:48:03 +03:00 committed by Aleksandr Zatsepin
parent 28f3fa0b36
commit 4af9502827
4 changed files with 38 additions and 4 deletions

View file

@ -373,7 +373,17 @@ JNIEXPORT jstring JNICALL
Java_com_mapswithme_maps_bookmarks_data_BookmarkManager_nativeGetCategoryName(
JNIEnv * env, jobject thiz, jlong catId)
{
return ToJavaString(env, frm()->GetBookmarkManager().GetCategoryName(static_cast<kml::MarkGroupId>(catId)));
return ToJavaString(env, frm()->GetBookmarkManager().GetCategoryName(
static_cast<kml::MarkGroupId>(catId)));
}
JNIEXPORT jstring JNICALL
Java_com_mapswithme_maps_bookmarks_data_BookmarkManager_nativeGetCategoryAuthor(
JNIEnv * env, jobject thiz, jlong catId)
{
auto const & data = frm()->GetBookmarkManager().GetCategoryData(
static_cast<kml::MarkGroupId>(catId));
return ToJavaString(env, data.m_authorName);
}
JNIEXPORT jint JNICALL

View file

@ -450,6 +450,12 @@ public enum BookmarkManager
return nativeIsCategoryFromCatalog(catId);
}
@NonNull
private String getCategoryAuthor(long catId)
{
return nativeGetCategoryAuthor(catId);
}
private native int nativeGetCategoriesCount();
private native int nativeGetCategoryPositionById(long catId);
@ -479,6 +485,9 @@ public enum BookmarkManager
private native void nativeSetCategoryName(long catId, @NonNull String n);
@NonNull
private native String nativeGetCategoryAuthor(long catId);
private static native void nativeLoadBookmarks();
private native boolean nativeDeleteCategory(long catId);

View file

@ -760,19 +760,33 @@ void BookmarkManager::ClearGroup(kml::MarkGroupId groupId)
std::string BookmarkManager::GetCategoryName(kml::MarkGroupId categoryId) const
{
CHECK_THREAD_CHECKER(m_threadChecker, ());
return GetBmCategory(categoryId)->GetName();
auto const category = GetBmCategory(categoryId);
CHECK(category != nullptr, ());
return category->GetName();
}
void BookmarkManager::SetCategoryName(kml::MarkGroupId categoryId, std::string const & name)
{
CHECK_THREAD_CHECKER(m_threadChecker, ());
GetBmCategory(categoryId)->SetName(name);
auto category = GetBmCategory(categoryId);
CHECK(category != nullptr, ());
category->SetName(name);
}
std::string BookmarkManager::GetCategoryFileName(kml::MarkGroupId categoryId) const
{
CHECK_THREAD_CHECKER(m_threadChecker, ());
return GetBmCategory(categoryId)->GetFileName();
auto const category = GetBmCategory(categoryId);
CHECK(category != nullptr, ());
return category->GetFileName();
}
kml::CategoryData const & BookmarkManager::GetCategoryData(kml::MarkGroupId categoryId) const
{
CHECK_THREAD_CHECKER(m_threadChecker, ());
auto const category = GetBmCategory(categoryId);
CHECK(category != nullptr, ());
return category->GetCategoryData();
}
kml::MarkGroupId BookmarkManager::GetCategoryId(std::string const & name) const

View file

@ -172,6 +172,7 @@ public:
std::string GetCategoryName(kml::MarkGroupId categoryId) const;
std::string GetCategoryFileName(kml::MarkGroupId categoryId) const;
kml::CategoryData const & GetCategoryData(kml::MarkGroupId categoryId) const;
kml::MarkGroupId GetCategoryId(std::string const & name) const;