Preparation skeleton for Offline maps implementation
This commit is contained in:
@@ -46,6 +46,7 @@ dependencies {
|
||||
implementation(libs.constraintlayout)
|
||||
implementation(libs.viewpager2)
|
||||
|
||||
implementation("androidx.core:core-ktx:1.17.0")
|
||||
implementation("org.osmdroid:osmdroid-android:6.1.20")
|
||||
implementation("org.maplibre.gl:android-sdk:11.13.0")
|
||||
implementation("com.github.mapsforge.vtm:vtm:0.27.0")
|
||||
@@ -61,7 +62,6 @@ dependencies {
|
||||
implementation("com.squareup.okhttp3:okhttp:4.12.0")
|
||||
implementation("com.fasterxml.jackson.core:jackson-databind:2.15.0")
|
||||
implementation("org.apache.commons:commons-lang3:3.14.0")
|
||||
implementation(libs.core.ktx)
|
||||
|
||||
testImplementation(libs.junit)
|
||||
androidTestImplementation(libs.ext.junit)
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
package eu.konggdev.strikemaps.map.offline;
|
||||
|
||||
import java.io.IOException;
|
||||
public final class OfflineTileResolver {
|
||||
public byte[] resolve(String url) throws IOException {
|
||||
|
||||
//byte[] data = getOfflineTile();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package eu.konggdev.strikemaps.map.offline.download;
|
||||
|
||||
import eu.konggdev.strikemaps.map.source.MapSource;
|
||||
|
||||
import java.net.URI;
|
||||
|
||||
public final class OfflineDownloader {
|
||||
|
||||
public static String[] fetchAvailableExports(MapSource source) {
|
||||
URI uri = URI.create(source.url);
|
||||
String host = uri.getHost();
|
||||
return new String[0];
|
||||
}
|
||||
|
||||
public static void download(MapSource source, String export) {
|
||||
|
||||
}
|
||||
|
||||
public static void download(MapSource source, int[] bounds) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -12,6 +12,7 @@ import eu.konggdev.strikemaps.ui.element.region.content.MainContentRegion;
|
||||
import eu.konggdev.strikemaps.ui.element.region.UIRegion;
|
||||
import eu.konggdev.strikemaps.ui.fragment.layout.FragmentLayoutControls;
|
||||
import eu.konggdev.strikemaps.ui.fragment.layout.FragmentLayoutSearch;
|
||||
import eu.konggdev.strikemaps.ui.fragment.layout.content.main.FragmentLayoutContentOfflineMaps;
|
||||
import eu.konggdev.strikemaps.ui.fragment.layout.content.main.FragmentLayoutContentSettings;
|
||||
import eu.konggdev.strikemaps.ui.screen.Screen;
|
||||
import eu.konggdev.strikemaps.ui.screen.definition.DefinedScreen;
|
||||
@@ -51,6 +52,13 @@ public class UIComponent implements Component {
|
||||
Map.of(
|
||||
R.id.mainContentView, new MainContentRegion(new FragmentLayoutContentSettings(app), R.id.mainContentView)
|
||||
)
|
||||
),
|
||||
//Offline maps screen
|
||||
DefinedScreen.OFFLINE, new Screen(
|
||||
app,
|
||||
Map.of(
|
||||
R.id.mainContentView, new MainContentRegion(new FragmentLayoutContentOfflineMaps(app), R.id.mainContentView)
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -4,33 +4,36 @@ import android.graphics.Bitmap;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import eu.konggdev.strikemaps.ui.UIComponent;
|
||||
import org.maplibre.geojson.Feature;
|
||||
|
||||
import eu.konggdev.strikemaps.R;
|
||||
public class PreviewItem implements UIItem {
|
||||
public String name;
|
||||
public String type;
|
||||
@NonNull public String name;
|
||||
public String details;
|
||||
public Bitmap image;
|
||||
boolean hasImage;
|
||||
public PreviewItem(String refName, String refType) {
|
||||
this.name = refName;
|
||||
this.type = refType;
|
||||
this.details = refType;
|
||||
hasImage = false;
|
||||
}
|
||||
public PreviewItem(String refName, String refType, Bitmap refImage) {
|
||||
this.name = refName;
|
||||
this.type = refType;
|
||||
this.details = refType;
|
||||
this.image = refImage;
|
||||
hasImage = true;
|
||||
}
|
||||
|
||||
public static PreviewItem fromFeature(Feature feature) {
|
||||
return new PreviewItem(feature.getStringProperty("name"), feature.getStringProperty("class"));
|
||||
}
|
||||
public View makeView(UIComponent spawner) {
|
||||
View view = spawner.inflateUi(R.layout.item_preview);
|
||||
((TextView) view.findViewById(R.id.choiceName)).setText(name);
|
||||
((TextView) view.findViewById(R.id.type)).setText(type);
|
||||
if (details != null)
|
||||
((TextView) view.findViewById(R.id.details)).setText(details);
|
||||
return view;
|
||||
}
|
||||
public View makeView(UIComponent spawner, View.OnClickListener onClick) {
|
||||
|
||||
@@ -12,5 +12,4 @@ public interface UIItem {
|
||||
}
|
||||
|
||||
default View.OnLongClickListener longClick(Runnable action) { return v -> { action.run(); return true; };}
|
||||
|
||||
}
|
||||
|
||||
+39
-3
@@ -1,6 +1,5 @@
|
||||
package eu.konggdev.strikemaps.ui.fragment.layout;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.os.Bundle;
|
||||
@@ -10,7 +9,6 @@ import android.view.ViewGroup;
|
||||
import android.widget.PopupWindow;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import android.widget.PopupMenu;
|
||||
|
||||
import eu.konggdev.strikemaps.R;
|
||||
import eu.konggdev.strikemaps.app.AppController;
|
||||
@@ -41,9 +39,11 @@ public class FragmentLayoutSearch extends Fragment implements Layout {
|
||||
public void onViewCreated(@NonNull View view, Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
|
||||
|
||||
|
||||
setupButton(view, R.id.hamburgerButton, click(() -> {
|
||||
|
||||
View menuView = getLayoutInflater().inflate(R.layout.menu_dropdown, null);
|
||||
View menuView = getLayoutInflater().inflate(R.layout.dropdown_main, null);
|
||||
|
||||
PopupWindow popupWindow = new PopupWindow(
|
||||
menuView,
|
||||
@@ -85,5 +85,41 @@ public class FragmentLayoutSearch extends Fragment implements Layout {
|
||||
});
|
||||
|
||||
}));
|
||||
|
||||
setupButton(view, R.id.offlineMapsButton, click(() -> {
|
||||
View offlineMapsPopupView = getLayoutInflater().inflate(R.layout.dropdown_offline, null);
|
||||
|
||||
PopupWindow popupWindow = new PopupWindow(
|
||||
offlineMapsPopupView,
|
||||
ViewGroup.LayoutParams.WRAP_CONTENT,
|
||||
ViewGroup.LayoutParams.WRAP_CONTENT,
|
||||
true
|
||||
);
|
||||
|
||||
popupWindow.setOutsideTouchable(true);
|
||||
popupWindow.setFocusable(true);
|
||||
popupWindow.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
|
||||
|
||||
View anchor = view.findViewById(R.id.searchContainer);
|
||||
|
||||
setupButton(offlineMapsPopupView, R.id.offlineMaps, click(() -> {
|
||||
popupWindow.dismiss();
|
||||
app.getUi().swapScreen(DefinedScreen.OFFLINE);
|
||||
}));
|
||||
|
||||
anchor.post(() -> {
|
||||
|
||||
offlineMapsPopupView.measure(
|
||||
View.MeasureSpec.UNSPECIFIED,
|
||||
View.MeasureSpec.UNSPECIFIED
|
||||
);
|
||||
|
||||
int popupWidth = offlineMapsPopupView.getMeasuredWidth();
|
||||
int containerWidth = anchor.getWidth();
|
||||
|
||||
int xOffset = containerWidth - popupWidth;
|
||||
popupWindow.showAsDropDown(anchor, xOffset, 1);
|
||||
});
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
+58
@@ -0,0 +1,58 @@
|
||||
package eu.konggdev.strikemaps.ui.fragment.layout.content.main;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.LinearLayout;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import eu.konggdev.strikemaps.R;
|
||||
import eu.konggdev.strikemaps.app.AppController;
|
||||
import eu.konggdev.strikemaps.data.helper.FileHelper;
|
||||
import eu.konggdev.strikemaps.map.source.MapSource;
|
||||
import eu.konggdev.strikemaps.map.style.MapStyle;
|
||||
import eu.konggdev.strikemaps.ui.element.item.GenericItem;
|
||||
import eu.konggdev.strikemaps.ui.element.item.PreviewItem;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
public class FragmentLayoutContentOfflineMaps extends Fragment implements MainContentLayout {
|
||||
@NonNull AppController app;
|
||||
|
||||
public FragmentLayoutContentOfflineMaps(AppController app) {
|
||||
super(R.layout.fragment_offline_maps);
|
||||
this.app = app;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Fragment toFragment() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewCreated(@NonNull View view, Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
|
||||
List<MapSource> sources = new ArrayList<>();
|
||||
|
||||
List<String> stylePaths = new ArrayList<>();
|
||||
stylePaths.addAll(Arrays.asList(FileHelper.getAssetFiles("bundled/style", ".style.json", app)));
|
||||
stylePaths.addAll(Arrays.asList(FileHelper.getUserFiles("style", ".style.json", app)));
|
||||
/* Parsing an entire MapStyle is absolutely unnecessary and resource wasteful
|
||||
TODO: A method should be implemented to parse a List<MapSource> directly from the JSON */
|
||||
for (String stylePath : stylePaths) {
|
||||
MapStyle parsedStyle = MapStyle.fromFile(stylePath, app);
|
||||
sources.addAll(parsedStyle.sources.values());
|
||||
}
|
||||
|
||||
LinearLayout sourcesLayout = view.findViewById(R.id.llDownloadContainer);
|
||||
for (MapSource source : sources) {
|
||||
if (!Objects.equals(source.type, "raster"))
|
||||
sourcesLayout.addView(new PreviewItem(source.url, "").makeView(app.getUi()));
|
||||
else
|
||||
sourcesLayout.addView(new PreviewItem(source.tiles.toString(), "").makeView(app.getUi()));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package eu.konggdev.strikemaps.ui.screen.definition;
|
||||
public enum DefinedScreen {
|
||||
MAIN,
|
||||
SETTINGS
|
||||
SETTINGS,
|
||||
OFFLINE
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24"
|
||||
android:tint="?attr/colorControlNormal">
|
||||
<path
|
||||
android:fillColor="#FFFFFF"
|
||||
android:pathData="M12,4l-1.41,1.41L16.17,11H4v2h12.17l-5.58,5.59L12,20l8,-8z" />
|
||||
</vector>
|
||||
@@ -0,0 +1,5 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:height="24dp" android:tint="#000000" android:viewportHeight="24" android:viewportWidth="24" android:width="24dp">
|
||||
|
||||
<path android:fillColor="@android:color/white" android:pathData="M12,2C6.49,2 2,6.49 2,12s4.49,10 10,10s10,-4.49 10,-10S17.51,2 12,2zM11,10V6h2v4h3l-4,4l-4,-4H11zM17,17H7v-2h10V17z"/>
|
||||
|
||||
</vector>
|
||||
@@ -0,0 +1,34 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<com.google.android.material.card.MaterialCardView
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="200dp"
|
||||
android:layout_height="wrap_content"
|
||||
app:cardCornerRadius="12dp"
|
||||
app:cardElevation="12dp"
|
||||
app:cardBackgroundColor="#000000">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:padding="8dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/offlineMaps"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="12dp"
|
||||
android:text="Offline Maps"
|
||||
android:textColor="#FFFFFF"
|
||||
android:background="?android:attr/selectableItemBackground"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</com.google.android.material.card.MaterialCardView>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
@@ -2,5 +2,4 @@
|
||||
<android.widget.LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
</android.widget.LinearLayout>
|
||||
@@ -0,0 +1,41 @@
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="#000000">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvDownloadLabel"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Download for source:"
|
||||
android:textColor="#FFFFFF"
|
||||
android:textSize="18sp"
|
||||
android:includeFontPadding="true"
|
||||
android:paddingBottom="4dp"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginStart="16dp" />
|
||||
|
||||
<androidx.core.widget.NestedScrollView
|
||||
android:id="@+id/scrollDownloadContainer"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
app:layout_constraintTop_toBottomOf="@id/tvDownloadLabel"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
android:layout_marginTop="8dp"
|
||||
android:fillViewport="true">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/llDownloadContainer"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical" />
|
||||
|
||||
</androidx.core.widget.NestedScrollView>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
@@ -4,7 +4,7 @@
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:padding="6dp">
|
||||
android:padding="12dp">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/searchContainer"
|
||||
@@ -26,6 +26,17 @@
|
||||
android:queryHint="Search..."
|
||||
android:background="@android:color/transparent" />
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/offlineMapsButton"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@android:color/transparent"
|
||||
android:contentDescription="Offline Maps"
|
||||
android:src="@drawable/ic_offline"
|
||||
android:padding="6dp"
|
||||
android:scaleType="fitCenter"
|
||||
app:tint="#B0B0B0" />
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/hamburgerButton"
|
||||
android:layout_width="wrap_content"
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="#0E0000"
|
||||
android:background="#000000"
|
||||
android:foregroundTint="#FFFFFF">
|
||||
|
||||
<TextView
|
||||
@@ -16,7 +15,7 @@
|
||||
android:layout_marginEnd="12dp"
|
||||
android:text="Choice Item"
|
||||
android:textColor="#FFFFFF"
|
||||
android:textSize="24sp"
|
||||
android:textSize="20sp"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="1"
|
||||
android:scrollHorizontally="false"
|
||||
@@ -24,12 +23,12 @@
|
||||
android:autoSizeMinTextSize="12sp"
|
||||
android:autoSizeMaxTextSize="24sp"
|
||||
android:autoSizeStepGranularity="1sp"
|
||||
app:layout_constraintStart_toEndOf="@+id/poiIcon"
|
||||
app:layout_constraintStart_toEndOf="@+id/icon"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/poiIcon"
|
||||
android:id="@+id/icon"
|
||||
android:layout_width="55dp"
|
||||
android:layout_height="55dp"
|
||||
android:layout_marginStart="7dp"
|
||||
@@ -39,19 +38,18 @@
|
||||
app:srcCompat="@drawable/maplibre_info_bg_selector" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/type"
|
||||
android:id="@+id/details"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="7dp"
|
||||
android:layout_marginEnd="12dp"
|
||||
android:layout_marginBottom="12dp"
|
||||
android:text="Type"
|
||||
android:textColor="#FFFFFF"
|
||||
android:textSize="16sp"
|
||||
android:textStyle="bold"
|
||||
android:ellipsize="end"
|
||||
android:singleLine="true"
|
||||
app:layout_constraintStart_toEndOf="@id/poiIcon"
|
||||
app:layout_constraintStart_toEndOf="@id/icon"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/choiceName"
|
||||
app:layout_constraintBottom_toBottomOf="parent"/>
|
||||
|
||||
@@ -10,7 +10,6 @@ constraintlayout = "2.1.4"
|
||||
playServicesMaps = "19.0.0"
|
||||
viewpager2 = "1.1.0"
|
||||
kotlin = "2.3.10"
|
||||
coreKtx = "1.18.0"
|
||||
|
||||
[libraries]
|
||||
junit = { group = "junit", name = "junit", version.ref = "junit" }
|
||||
@@ -20,9 +19,7 @@ appcompat = { group = "androidx.appcompat", name = "appcompat", version.ref = "a
|
||||
material = { group = "com.google.android.material", name = "material", version.ref = "material" }
|
||||
activity = { group = "androidx.activity", name = "activity", version.ref = "activity" }
|
||||
constraintlayout = { group = "androidx.constraintlayout", name = "constraintlayout", version.ref = "constraintlayout" }
|
||||
play-services-maps = { group = "com.google.android.gms", name = "play-services-maps", version.ref = "playServicesMaps" }
|
||||
viewpager2 = { group = "androidx.viewpager2", name = "viewpager2", version.ref = "viewpager2" }
|
||||
core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "coreKtx" }
|
||||
|
||||
[plugins]
|
||||
android-application = { id = "com.android.application", version.ref = "agp" }
|
||||
|
||||
Reference in New Issue
Block a user