forked from organicmaps/organicmaps
[android] Supported jni - set category description, modified Category interface
This commit is contained in:
parent
7984be229f
commit
03ea9671da
6 changed files with 42 additions and 14 deletions
|
@ -109,8 +109,9 @@ void PrepareClassRefs(JNIEnv * env)
|
|||
// boolean isMyCategory,
|
||||
// boolean isVisible)
|
||||
g_bookmarkCategoryConstructor =
|
||||
jni::GetConstructorID(env, g_bookmarkCategoryClass, "(JLjava/lang/String;Ljava/lang/String;"
|
||||
"Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;IIZZZ)V");
|
||||
jni::GetConstructorID(env, g_bookmarkCategoryClass,
|
||||
"(JLjava/lang/String;Ljava/lang/String;"
|
||||
"Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;IIZZZI)V");
|
||||
|
||||
g_catalogTagClass =
|
||||
jni::GetGlobalClassRef(env, "com/mapswithme/maps/bookmarks/data/CatalogTag");
|
||||
|
@ -539,6 +540,16 @@ Java_com_mapswithme_maps_bookmarks_data_BookmarkManager_nativeSetCategoryName(
|
|||
jni::ToNativeString(env, name));
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_mapswithme_maps_bookmarks_data_BookmarkManager_nativeSetCategoryDesc(JNIEnv * env,
|
||||
jobject thiz,
|
||||
jlong catId,
|
||||
jstring desc)
|
||||
{
|
||||
frm()->GetBookmarkManager().GetEditSession().SetCategoryDescription(
|
||||
static_cast<kml::MarkGroupId>(catId), jni::ToNativeString(env, desc));
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_mapswithme_maps_bookmarks_data_BookmarkManager_nativeSetCategoryTags(
|
||||
JNIEnv * env, jobject, jlong catId, jobjectArray tagsIds)
|
||||
|
@ -589,15 +600,6 @@ Java_com_mapswithme_maps_bookmarks_data_BookmarkManager_nativeGetCategoryAuthor(
|
|||
return ToJavaString(env, data.m_authorName);
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_com_mapswithme_maps_bookmarks_data_BookmarkManager_nativeGetCategoryAccessRules(
|
||||
JNIEnv * env, jobject thiz, jlong catId)
|
||||
{
|
||||
auto const & data = frm()->GetBookmarkManager().GetCategoryData(
|
||||
static_cast<kml::MarkGroupId>(catId));
|
||||
return static_cast<jint>(data.m_accessRules);
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_com_mapswithme_maps_bookmarks_data_BookmarkManager_nativeGetBookmarksCount(
|
||||
JNIEnv * env, jobject thiz, jlong catId)
|
||||
|
@ -913,6 +915,7 @@ Java_com_mapswithme_maps_bookmarks_data_BookmarkManager_nativeGetBookmarkCategor
|
|||
auto const preferBookmarkStr = GetPreferredBookmarkStr(data.m_name);
|
||||
auto const annotation = GetPreferredBookmarkStr(data.m_annotation);
|
||||
auto const description = GetPreferredBookmarkStr(data.m_description);
|
||||
auto const accessRules = data.m_accessRules;
|
||||
|
||||
jni::TScopedLocalRef preferBookmarkStrRef(env, jni::ToJavaString(env, preferBookmarkStr));
|
||||
jni::TScopedLocalRef authorIdRef(env, jni::ToJavaString(env, data.m_authorId));
|
||||
|
@ -932,7 +935,8 @@ Java_com_mapswithme_maps_bookmarks_data_BookmarkManager_nativeGetBookmarkCategor
|
|||
static_cast<jint>(bookmarksCount),
|
||||
static_cast<jboolean>(isFromCatalog),
|
||||
static_cast<jboolean>(isMyCategory),
|
||||
static_cast<jboolean>(isVisible));
|
||||
static_cast<jboolean>(isVisible),
|
||||
static_cast<jint>(accessRules));
|
||||
};
|
||||
return ToJavaArray(env, g_bookmarkCategoryClass, categories, bookmarkConverter);
|
||||
}
|
||||
|
|
|
@ -340,7 +340,7 @@ public enum BookmarkManager
|
|||
|
||||
public void setCategoryDesc(long id, @NonNull String categoryDesc)
|
||||
{
|
||||
nativeSetCategoryDesc(id, categoryDesc);
|
||||
nativeSetCategoryDescription(id, categoryDesc);
|
||||
}
|
||||
|
||||
public void setAccessRules(long id, @NonNull BookmarkCategory.AccessRules rules)
|
||||
|
@ -658,7 +658,7 @@ public enum BookmarkManager
|
|||
|
||||
private native void nativeSetCategoryName(long catId, @NonNull String n);
|
||||
|
||||
private native void nativeSetCategoryDesc(long catId, @NonNull String n);
|
||||
private native void nativeSetCategoryDescription(long catId, @NonNull String n);
|
||||
|
||||
private native void nativeSetCategoryTags(long catId, @NonNull String[] tagsIds);
|
||||
|
||||
|
|
|
@ -240,6 +240,12 @@ void BookmarkCategory::SetName(std::string const & name)
|
|||
kml::SetDefaultStr(m_data.m_name, name);
|
||||
}
|
||||
|
||||
void BookmarkCategory::SetDescription(std::string const & desc)
|
||||
{
|
||||
SetDirty();
|
||||
kml::SetDefaultStr(m_data.m_description, desc);
|
||||
}
|
||||
|
||||
void BookmarkCategory::SetServerId(std::string const & serverId)
|
||||
{
|
||||
if (m_serverId == serverId)
|
||||
|
|
|
@ -74,6 +74,7 @@ public:
|
|||
|
||||
void SetIsVisible(bool isVisible) override;
|
||||
void SetName(std::string const & name);
|
||||
void SetDescription(std::string const & desc);
|
||||
void SetFileName(std::string const & fileName) { m_file = fileName; }
|
||||
std::string GetName() const;
|
||||
std::string const & GetFileName() const { return m_file; }
|
||||
|
|
|
@ -803,6 +803,14 @@ std::string BookmarkManager::GetCategoryName(kml::MarkGroupId categoryId) const
|
|||
return category->GetName();
|
||||
}
|
||||
|
||||
void BookmarkManager::SetCategoryDescription(kml::MarkGroupId categoryId, std::string const & desc)
|
||||
{
|
||||
CHECK_THREAD_CHECKER(m_threadChecker, ());
|
||||
auto category = GetBmCategory(categoryId);
|
||||
CHECK(category != nullptr, ());
|
||||
category->SetDescription(desc);
|
||||
}
|
||||
|
||||
void BookmarkManager::SetCategoryName(kml::MarkGroupId categoryId, std::string const & name)
|
||||
{
|
||||
CHECK_THREAD_CHECKER(m_threadChecker, ());
|
||||
|
@ -2659,6 +2667,13 @@ void BookmarkManager::EditSession::SetCategoryName(kml::MarkGroupId categoryId,
|
|||
m_bmManager.SetCategoryName(categoryId, name);
|
||||
}
|
||||
|
||||
void BookmarkManager::EditSession::SetCategoryDescription(kml::MarkGroupId categoryId,
|
||||
std::string const & desc)
|
||||
{
|
||||
CHECK(m_bmManager.IsEditableCategory(categoryId), ());
|
||||
m_bmManager.SetCategoryDescription(categoryId, desc);
|
||||
}
|
||||
|
||||
void BookmarkManager::EditSession::SetCategoryTags(kml::MarkGroupId categoryId, std::vector<std::string> const & tags)
|
||||
{
|
||||
CHECK(m_bmManager.IsEditableCategory(categoryId), ());
|
||||
|
|
|
@ -125,6 +125,7 @@ public:
|
|||
void DetachTrack(kml::TrackId trackId, kml::MarkGroupId groupId);
|
||||
|
||||
void SetCategoryName(kml::MarkGroupId categoryId, std::string const & name);
|
||||
void SetCategoryDescription(kml::MarkGroupId categoryId, std::string const & desc);
|
||||
void SetCategoryTags(kml::MarkGroupId categoryId, std::vector<std::string> const & tags);
|
||||
void SetCategoryAccessRules(kml::MarkGroupId categoryId, kml::AccessRules accessRules);
|
||||
void SetCategoryCustomProperty(kml::MarkGroupId categoryId, std::string const & key,
|
||||
|
@ -438,6 +439,7 @@ private:
|
|||
void SetIsVisible(kml::MarkGroupId groupId, bool visible);
|
||||
|
||||
void SetCategoryName(kml::MarkGroupId categoryId, std::string const & name);
|
||||
void SetCategoryDescription(kml::MarkGroupId categoryId, std::string const & desc);
|
||||
void SetCategoryTags(kml::MarkGroupId categoryId, std::vector<std::string> const & tags);
|
||||
void SetCategoryAccessRules(kml::MarkGroupId categoryId, kml::AccessRules accessRules);
|
||||
void SetCategoryCustomProperty(kml::MarkGroupId categoryId, std::string const & key,
|
||||
|
|
Loading…
Add table
Reference in a new issue