[android] Unify custom map server dialog logic and UI

- Add setting icon for custom map server download option.
- Extract shared custom map server dialog helper.
- Clean up based on reviewers' feedback.

Signed-off-by: NoelClick <dev@noel.click>
This commit is contained in:
NoelClick
2025-12-03 12:18:12 -08:00
committed by jeanbaptisteC
parent 76ecd8209e
commit 2b630964d0
15 changed files with 147 additions and 170 deletions

View File

@@ -156,24 +156,16 @@ std::string GetAcceptLanguage()
MetaConfig MapFilesDownloader::LoadMetaConfig()
{
Platform & pl = GetPlatform();
std::optional<MetaConfig> metaConfig;
// If user sets a custom download server, skip metaserver entirely.
std::string const customServer = pl.CustomMapServerUrl();
if (!customServer.empty())
{
LOG(LINFO, ("Using custom map server URL:", customServer));
// Reuse default meta settings (timeouts, other endpoints) and override servers
metaConfig = downloader::ParseMetaConfig(pl.DefaultUrlsJSON());
CHECK(metaConfig, ());
metaConfig->m_serversList.clear();
metaConfig->m_serversList.push_back(customServer);
LOG(LINFO, ("Got servers list (custom server):", metaConfig->m_serversList));
CHECK(!metaConfig->m_serversList.empty(), ());
return *metaConfig;
MetaConfig metaConfig;
metaConfig.m_serversList = {customServer};
return metaConfig;
}
std::string const metaServerUrl = pl.MetaServerUrl();
@@ -190,7 +182,7 @@ MetaConfig MapFilesDownloader::LoadMetaConfig()
request.RunHttpRequest(httpResult);
}
metaConfig = downloader::ParseMetaConfig(httpResult);
auto metaConfig = downloader::ParseMetaConfig(httpResult);
if (!metaConfig)
{
metaConfig = downloader::ParseMetaConfig(pl.DefaultUrlsJSON());
@@ -201,6 +193,7 @@ MetaConfig MapFilesDownloader::LoadMetaConfig()
{
LOG(LINFO, ("Got servers list:", metaConfig->m_serversList));
}
CHECK(!metaConfig->m_serversList.empty(), ());
return *metaConfig;
}