mirror of
https://codeberg.org/comaps/comaps
synced 2025-12-20 05:13:58 +00:00
[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:
@@ -124,6 +124,7 @@ dependencies {
|
||||
implementation libs.androidx.lifecycle.process
|
||||
implementation libs.androidx.media
|
||||
implementation libs.androidx.recyclerview
|
||||
implementation libs.androidx.preference
|
||||
implementation libs.android.material
|
||||
|
||||
testImplementation libs.junit
|
||||
|
||||
@@ -42,16 +42,16 @@ using namespace std::placeholders;
|
||||
|
||||
namespace
|
||||
{
|
||||
std::unique_ptr<MapFilesDownloader> & LegacyDownloader()
|
||||
{
|
||||
static auto downloader = storage::GetDownloader();
|
||||
return downloader;
|
||||
}
|
||||
std::unique_ptr<MapFilesDownloader> & LegacyDownloader()
|
||||
{
|
||||
static auto downloader = storage::GetDownloader();
|
||||
return downloader;
|
||||
}
|
||||
|
||||
static std::vector<platform::CountryFile> g_filesToDownload;
|
||||
static int g_totalDownloadedBytes;
|
||||
static int g_totalBytesToDownload;
|
||||
static std::shared_ptr<HttpRequest> g_currentRequest;
|
||||
static std::vector<platform::CountryFile> g_filesToDownload;
|
||||
static int g_totalDownloadedBytes;
|
||||
static int g_totalBytesToDownload;
|
||||
static std::shared_ptr<HttpRequest> g_currentRequest;
|
||||
} // namespace
|
||||
|
||||
extern "C"
|
||||
|
||||
@@ -356,14 +356,16 @@ public class Framework
|
||||
|
||||
public static void applyCustomMapDownloadUrl(@NonNull Context context, @Nullable String url)
|
||||
{
|
||||
String normalizedUrl = url != null ? url.trim() : "";
|
||||
|
||||
// Normalize
|
||||
if (!normalizedUrl.isEmpty() && !normalizedUrl.endsWith("/"))
|
||||
normalizedUrl = normalizedUrl + "/";
|
||||
|
||||
nativeSetCustomMapDownloadUrl(normalizedUrl);
|
||||
nativeSetCustomMapDownloadUrl(normalizeServerUrl(url));
|
||||
// Reset the legacy downloader too (world/coasts).
|
||||
app.organicmaps.sdk.DownloadResourcesLegacyActivity.nativeResetMetaConfig();
|
||||
}
|
||||
|
||||
public static String normalizeServerUrl(@Nullable String url)
|
||||
{
|
||||
String out = url != null ? url.trim() : "";
|
||||
if (!out.isEmpty() && !out.endsWith("/"))
|
||||
out = out + "/";
|
||||
return out;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,12 +2,13 @@ package app.organicmaps.sdk;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.preference.PreferenceManager;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.lifecycle.DefaultLifecycleObserver;
|
||||
import androidx.lifecycle.LifecycleOwner;
|
||||
import androidx.lifecycle.ProcessLifecycleOwner;
|
||||
import androidx.preference.PreferenceManager;
|
||||
|
||||
import app.organicmaps.sdk.bookmarks.data.BookmarkManager;
|
||||
import app.organicmaps.sdk.bookmarks.data.Icon;
|
||||
import app.organicmaps.sdk.downloader.Android7RootCertificateWorkaround;
|
||||
@@ -27,6 +28,7 @@ import app.organicmaps.sdk.util.SharedPropertiesUtils;
|
||||
import app.organicmaps.sdk.util.StorageUtils;
|
||||
import app.organicmaps.sdk.util.log.Logger;
|
||||
import app.organicmaps.sdk.util.log.LogsManager;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public final class OrganicMaps implements DefaultLifecycleObserver
|
||||
|
||||
Reference in New Issue
Block a user