From 2810fbbbbfbd0c4adf54158866596638b86a41c8 Mon Sep 17 00:00:00 2001 From: Jm Casler Date: Wed, 2 Mar 2022 18:49:44 -0800 Subject: [PATCH 1/4] updating proto submodule to latest --- app/src/main/proto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/proto b/app/src/main/proto index 7c49bdad9..f6ba3722b 160000 --- a/app/src/main/proto +++ b/app/src/main/proto @@ -1 +1 @@ -Subproject commit 7c49bdad99f53332d17796188fc89fd5c29e0ce3 +Subproject commit f6ba3722be8a51c3c0c1446bb08e730a0be568e0 From cc295d0fb374f5087249d489282e729294a3cf44 Mon Sep 17 00:00:00 2001 From: PWRxPSYCHO Date: Mon, 7 Mar 2022 08:10:06 -0500 Subject: [PATCH 2/4] Simplified some logic --- .../com/geeksville/mesh/ui/MapFragment.kt | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/com/geeksville/mesh/ui/MapFragment.kt b/app/src/main/java/com/geeksville/mesh/ui/MapFragment.kt index 91bf4424f..4dba12fe2 100644 --- a/app/src/main/java/com/geeksville/mesh/ui/MapFragment.kt +++ b/app/src/main/java/com/geeksville/mesh/ui/MapFragment.kt @@ -622,17 +622,19 @@ class MapFragment : ScreenFragment("Map"), Logging { // Save URI userStyleURI = uri.text.toString() uri.setText("") // clear text + + downloadOfflineRegion(userStyleURI!!) + dialog.dismiss() + } else { + Toast.makeText( + requireContext(), + "Style URI cannot be empty", + Toast.LENGTH_SHORT + ).show() } - } - if (uri.isVisible && (this.userStyleURI != null)) { - downloadOfflineRegion(userStyleURI!!) - dialog.dismiss() } else { - Toast.makeText( - requireContext(), - "Style URI cannot be empty", - Toast.LENGTH_SHORT - ).show() + downloadOfflineRegion() + dialog.dismiss() } } } From 3fde01588c629d948b2416ef2052981cb175372a Mon Sep 17 00:00:00 2001 From: PWRxPSYCHO Date: Mon, 7 Mar 2022 09:44:29 -0500 Subject: [PATCH 3/4] Working on "view region" flow --- app/src/main/java/com/geeksville/mesh/ui/MapFragment.kt | 4 +++- app/src/main/res/layout/map_view.xml | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/geeksville/mesh/ui/MapFragment.kt b/app/src/main/java/com/geeksville/mesh/ui/MapFragment.kt index 4dba12fe2..f925615c4 100644 --- a/app/src/main/java/com/geeksville/mesh/ui/MapFragment.kt +++ b/app/src/main/java/com/geeksville/mesh/ui/MapFragment.kt @@ -592,7 +592,9 @@ class MapFragment : ScreenFragment("Map"), Logging { if (userStyleURI != null) { it?.loadStyleUri(userStyleURI.toString()) } else { - it?.loadStyleUri(mapView?.getMapboxMap()?.getStyle()?.styleURI.toString()) + it?.getStyle().also { style -> + style?.removeStyleImage(userPointImageId) + } } } } diff --git a/app/src/main/res/layout/map_view.xml b/app/src/main/res/layout/map_view.xml index 7a3ba9f60..0f4498c2b 100644 --- a/app/src/main/res/layout/map_view.xml +++ b/app/src/main/res/layout/map_view.xml @@ -53,6 +53,7 @@ android:layout_margin="16dp" android:backgroundTint="@color/buttonColor" android:contentDescription="@string/download_region" + android:visibility="invisible" android:src="@drawable/baseline_download_white_24dp" tools:background="@color/buttonColor" /> From 71724a6fd22d2b648d9873247c9ffa6092e07fbd Mon Sep 17 00:00:00 2001 From: PWRxPSYCHO Date: Tue, 8 Mar 2022 13:49:22 -0500 Subject: [PATCH 4/4] Cleaning up some code --- .../java/com/geeksville/mesh/ui/MapFragment.kt | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/com/geeksville/mesh/ui/MapFragment.kt b/app/src/main/java/com/geeksville/mesh/ui/MapFragment.kt index f925615c4..e18943566 100644 --- a/app/src/main/java/com/geeksville/mesh/ui/MapFragment.kt +++ b/app/src/main/java/com/geeksville/mesh/ui/MapFragment.kt @@ -1,7 +1,6 @@ package com.geeksville.mesh.ui import android.app.AlertDialog -import android.content.DialogInterface import android.graphics.Color import android.os.Bundle import android.os.Handler @@ -39,7 +38,6 @@ import com.mapbox.maps.extension.style.sources.generated.GeoJsonSource import com.mapbox.maps.extension.style.sources.generated.geoJsonSource import com.mapbox.maps.plugin.animation.MapAnimationOptions import com.mapbox.maps.plugin.animation.flyTo -import com.mapbox.maps.plugin.gestures.OnMapClickListener import com.mapbox.maps.plugin.gestures.OnMapLongClickListener import com.mapbox.maps.plugin.gestures.gestures import dagger.hilt.android.AndroidEntryPoint @@ -248,7 +246,6 @@ class MapFragment : ScreenFragment("Map"), Logging { // Note this will not remove the downloaded style pack, instead, it will just mark the resources // not a part of the existing style pack. The resources still exists as disk cache. offlineManager.removeStylePack(mapView?.getMapboxMap()?.getStyle()?.styleURI.toString()) - MapboxMap.clearData(resourceOptions) { it.error?.let { error -> debug(error) @@ -454,10 +451,12 @@ class MapFragment : ScreenFragment("Map"), Logging { 5 miles NE,NW,SE,SW from user center point. 25 Sq Mile Region */ + //____________________________________________________________________________________________ val topRight = calculateCoordinate(45.0, point?.latitude()!!, point?.longitude()!!) val topLeft = calculateCoordinate(135.0, point?.latitude()!!, point?.longitude()!!) val bottomLeft = calculateCoordinate(225.0, point?.latitude()!!, point?.longitude()!!) val bottomRight = calculateCoordinate(315.0, point?.latitude()!!, point?.longitude()!!) + //____________________________________________________________________________________________ val pointList = listOf(topRight, topLeft, bottomLeft, bottomRight, topRight) @@ -505,18 +504,18 @@ class MapFragment : ScreenFragment("Map"), Logging { /** * Find's coordinates (Lat,Lon) a specified distance from given (lat,lon) using degrees to determine direction - * @param degrees Angle - * @param lat latitude position - * @param long longitude position + * @param degrees degree of desired position from current position. (center point is 0,0 and desired point, top right corner, is 45 degrees from 0,0) + * @param lat latitude position (current position lat) + * @param lon longitude position (current position lon) * @return Point */ - private fun calculateCoordinate(degrees: Double, lat: Double, long: Double): Point { + private fun calculateCoordinate(degrees: Double, lat: Double, lon: Double): Point { val deg = Math.toRadians(degrees) val distancesInMeters = 1609.344 * 5 // 1609.344 is 1 mile in meters -> multiplier will be user specified up to a max of 10 val radiusOfEarthInMeters = 6378137 val x = - long + (180 / Math.PI) * (distancesInMeters / radiusOfEarthInMeters) * cos( + lon + (180 / Math.PI) * (distancesInMeters / radiusOfEarthInMeters) * cos( deg ) val y = @@ -591,6 +590,9 @@ class MapFragment : ScreenFragment("Map"), Logging { .build(), MapAnimationOptions.mapAnimationOptions { duration(1000) }) if (userStyleURI != null) { it?.loadStyleUri(userStyleURI.toString()) + it?.getStyle().also { style -> + //TODO: Add box for downloaded region + } } else { it?.getStyle().also { style -> style?.removeStyleImage(userPointImageId)