[android] [bookmarks] Add predicates to check compilations visibility. MAPSME-15104

This commit is contained in:
Anatoliy Tomilov 2020-10-19 17:16:19 +05:00 committed by Maria Velichko
parent fde771280f
commit 8469c959c7
4 changed files with 63 additions and 1 deletions

View file

@ -1022,6 +1022,22 @@ Java_com_mapswithme_maps_bookmarks_data_BookmarkManager_nativeSetChildCategories
static_cast<bool>(visible));
}
JNIEXPORT jboolean JNICALL
Java_com_mapswithme_maps_bookmarks_data_BookmarkManager_nativeAreAllCompilationsInvisible(
JNIEnv * env, jobject thiz, jlong categoryId, jint compilationType)
{
return static_cast<jboolean>(frm()->GetBookmarkManager().AreAllCompilationsInvisible(static_cast<kml::MarkGroupId>(categoryId),
static_cast<kml::CompilationType>(compilationType)));
}
JNIEXPORT jboolean JNICALL
Java_com_mapswithme_maps_bookmarks_data_BookmarkManager_nativeAreAllCompilationsVisible(
JNIEnv * env, jobject thiz, jlong categoryId, jint compilationType)
{
return static_cast<jboolean>(frm()->GetBookmarkManager().AreAllCompilationsVisible(static_cast<kml::MarkGroupId>(categoryId),
static_cast<kml::CompilationType>(compilationType)));
}
JNIEXPORT jint JNICALL
Java_com_mapswithme_maps_bookmarks_data_BookmarkManager_nativeGetKmlFilesCountForConversion(
JNIEnv * env, jobject thiz)

View file

@ -709,6 +709,16 @@ public enum BookmarkManager
nativeSetAllCategoriesVisibility(visible, type.ordinal());
}
public boolean areAllCompilationsVisible(long catId, @CompilationType int compilationType)
{
return nativeAreAllCompilationsVisible(catId, compilationType);
}
public boolean areAllCompilationsInvisible(long catId, @CompilationType int compilationType)
{
return nativeAreAllCompilationsInvisible(catId, compilationType);
}
public void setChildCategoriesVisibility(long catId, @CompilationType int compilationType, boolean visible)
{
nativeSetChildCategoriesVisibility(catId, compilationType, visible);
@ -1124,8 +1134,12 @@ public enum BookmarkManager
private static native boolean nativeAreAllCategoriesInvisible(int type);
private static native void nativeSetAllCategoriesVisibility(boolean visible, int type);
private static native boolean nativeAreAllCompilationsVisible(long catId, @CompilationType int compilationType);
private static native boolean nativeAreAllCompilationsInvisible(long catId, @CompilationType int compilationType);
private static native void nativeSetChildCategoriesVisibility(long catId, int compilationType, boolean visible);
private static native void nativeSetChildCategoriesVisibility(long catId, @CompilationType int compilationType, boolean visible);
private static native int nativeGetKmlFilesCountForConversion();

View file

@ -3373,6 +3373,35 @@ void BookmarkManager::SetAllCategoriesVisibility(CategoryFilterType const filter
}
}
bool BookmarkManager::AreAllCompilationsVisible(kml::MarkGroupId categoryId, kml::CompilationType compilationType) const
{
return CheckCompilationsVisibility(categoryId, compilationType, true);
}
bool BookmarkManager::AreAllCompilationsInvisible(kml::MarkGroupId categoryId, kml::CompilationType compilationType) const
{
return CheckCompilationsVisibility(categoryId, compilationType, false);
}
bool BookmarkManager::CheckCompilationsVisibility(kml::MarkGroupId categoryId, kml::CompilationType compilationType, bool isVisible) const
{
CHECK_THREAD_CHECKER(m_threadChecker, ());
auto const categoryIt = m_categories.find(categoryId);
CHECK(categoryIt != m_categories.end(), ());
auto & category = *categoryIt->second;
for (kml::MarkGroupId const compilationId : category.GetCategoryData().m_compilationIds)
{
auto const compilationIt = m_compilations.find(compilationId);
CHECK(compilationIt != m_compilations.cend(), ());
auto & compilation = *compilationIt->second;
if (compilation.GetCategoryData().m_type != compilationType)
continue;
if (compilation.IsVisible() != isVisible)
return false;
}
return true;
}
void BookmarkManager::SetChildCategoriesVisibility(kml::MarkGroupId categoryId, kml::CompilationType compilationType,
bool visible)
{

View file

@ -371,6 +371,8 @@ public:
bool AreAllCategoriesVisible(CategoryFilterType const filter) const;
bool AreAllCategoriesInvisible(CategoryFilterType const filter) const;
void SetAllCategoriesVisibility(CategoryFilterType const filter, bool visible);
bool AreAllCompilationsVisible(kml::MarkGroupId categoryId, kml::CompilationType compilationType) const;
bool AreAllCompilationsInvisible(kml::MarkGroupId categoryId, kml::CompilationType compilationType) const;
void SetChildCategoriesVisibility(kml::MarkGroupId categoryId, kml::CompilationType compilationType,
bool visible);
@ -736,6 +738,7 @@ private:
template <typename UniquityChecker>
void SetUniqueName(kml::CategoryData & data, UniquityChecker checker);
bool CheckVisibility(CategoryFilterType const filter, bool isVisible) const;
bool CheckCompilationsVisibility(kml::MarkGroupId categoryId, kml::CompilationType compilationType, bool isVisible) const;
struct SortBookmarkData
{