mirror of
https://codeberg.org/comaps/comaps
synced 2025-12-19 13:03:36 +00:00
[android] Fix colors order
Signed-off-by: Andrei Shkrob <github@shkrob.dev>
This commit is contained in:
committed by
Konstantin Pastbin
parent
6c4503b0db
commit
d0bb8c1c49
@@ -9,9 +9,10 @@ extern "C"
|
|||||||
JNIEXPORT jintArray JNICALL
|
JNIEXPORT jintArray JNICALL
|
||||||
Java_app_organicmaps_sdk_bookmarks_data_PredefinedColors_nativeGetPredefinedColors(JNIEnv * env, jclass)
|
Java_app_organicmaps_sdk_bookmarks_data_PredefinedColors_nativeGetPredefinedColors(JNIEnv * env, jclass)
|
||||||
{
|
{
|
||||||
std::array<jint, static_cast<size_t>(kml::PredefinedColor::Count)> colors{};
|
using kml::kOrderedPredefinedColors;
|
||||||
for (size_t i = 0; i < static_cast<size_t>(kml::PredefinedColor::Count); ++i)
|
std::array<jint, kOrderedPredefinedColors.size()> colors;
|
||||||
colors[i] = static_cast<jint>(kml::ColorFromPredefinedColor(static_cast<kml::PredefinedColor>(i)).GetARGB());
|
for (size_t i = 0; i < kOrderedPredefinedColors.size(); ++i)
|
||||||
|
colors[i] = static_cast<jint>(kml::ColorFromPredefinedColor(kOrderedPredefinedColors[i]).GetARGB());
|
||||||
|
|
||||||
jintArray jColors = env->NewIntArray(colors.size());
|
jintArray jColors = env->NewIntArray(colors.size());
|
||||||
env->SetIntArrayRegion(jColors, 0, static_cast<jsize>(colors.size()), colors.data());
|
env->SetIntArrayRegion(jColors, 0, static_cast<jsize>(colors.size()), colors.data());
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
#include <concepts>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <initializer_list>
|
#include <initializer_list>
|
||||||
#include <iterator>
|
#include <iterator>
|
||||||
#include <memory>
|
#include <ranges>
|
||||||
#include <tuple>
|
#include <tuple>
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
@@ -496,4 +497,12 @@ struct RetrieveSecond
|
|||||||
return pair.second;
|
return pair.second;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template <std::ranges::random_access_range Container>
|
||||||
|
requires std::totally_ordered<std::ranges::range_value_t<Container>>
|
||||||
|
consteval bool HasUniqueElements(Container container)
|
||||||
|
{
|
||||||
|
std::sort(container.begin(), container.end());
|
||||||
|
return std::adjacent_find(container.begin(), container.end()) == container.end();
|
||||||
|
}
|
||||||
} // namespace base
|
} // namespace base
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
|
|
||||||
#include "base/assert.hpp"
|
#include "base/assert.hpp"
|
||||||
#include "base/internal/message.hpp" // DebugPrint(Timestamp)
|
#include "base/internal/message.hpp" // DebugPrint(Timestamp)
|
||||||
|
#include "base/stl_helpers.hpp"
|
||||||
#include "base/visitor.hpp"
|
#include "base/visitor.hpp"
|
||||||
|
|
||||||
#include "drape/color.hpp"
|
#include "drape/color.hpp"
|
||||||
@@ -40,6 +41,31 @@ enum class PredefinedColor : uint8_t
|
|||||||
Count
|
Count
|
||||||
};
|
};
|
||||||
|
|
||||||
|
std::array constexpr kOrderedPredefinedColors = {
|
||||||
|
// clang-format off
|
||||||
|
PredefinedColor::None,
|
||||||
|
PredefinedColor::Red,
|
||||||
|
PredefinedColor::Pink,
|
||||||
|
PredefinedColor::Purple,
|
||||||
|
PredefinedColor::DeepPurple,
|
||||||
|
PredefinedColor::Blue,
|
||||||
|
PredefinedColor::LightBlue,
|
||||||
|
PredefinedColor::Cyan,
|
||||||
|
PredefinedColor::Teal,
|
||||||
|
PredefinedColor::Green,
|
||||||
|
PredefinedColor::Lime,
|
||||||
|
PredefinedColor::Yellow,
|
||||||
|
PredefinedColor::Orange,
|
||||||
|
PredefinedColor::DeepOrange,
|
||||||
|
PredefinedColor::Brown,
|
||||||
|
PredefinedColor::Gray,
|
||||||
|
PredefinedColor::BlueGray
|
||||||
|
// clang-format on
|
||||||
|
};
|
||||||
|
static_assert(kOrderedPredefinedColors.size() == static_cast<size_t>(PredefinedColor::Count),
|
||||||
|
"kOrderedPredefinedColors size must match PredefinedColor::Count");
|
||||||
|
static_assert(base::HasUniqueElements(kOrderedPredefinedColors), "All values must be unique");
|
||||||
|
|
||||||
inline std::string DebugPrint(PredefinedColor color)
|
inline std::string DebugPrint(PredefinedColor color)
|
||||||
{
|
{
|
||||||
switch (color)
|
switch (color)
|
||||||
|
|||||||
Reference in New Issue
Block a user