Moving right along

pull/489/head
PWRxPSYCHO 2022-10-06 17:08:35 -04:00
rodzic 63bee8a3d8
commit b1291e28a7
3 zmienionych plików z 69 dodań i 19 usunięć

Wyświetl plik

@ -0,0 +1,44 @@
package com.geeksville.mesh.model.map
import android.content.Context
import android.view.MotionEvent
import org.osmdroid.tileprovider.MapTileProviderBase
import org.osmdroid.views.MapView
import org.osmdroid.views.overlay.DefaultOverlayManager
import org.osmdroid.views.overlay.TilesOverlay
class CustomOverlayManager
/**
* Default constructor
*/
(tilesOverlay: TilesOverlay?) : DefaultOverlayManager(tilesOverlay) {
/**
* Override event & do nothing
*/
override fun onDoubleTap(e: MotionEvent?, pMapView: MapView?): Boolean {
return true
}
/**
* Override event & do nothing
*/
override fun onDoubleTapEvent(e: MotionEvent?, pMapView: MapView?): Boolean {
return true
}
companion object {
/**
* Create MyOverlayManager
*/
fun create(mapView: MapView, context: Context?): CustomOverlayManager {
val mTileProvider: MapTileProviderBase = mapView.tileProvider
val tilesOverlay = TilesOverlay(mTileProvider, context)
mapView.tileProvider
mapView.overlayManager = CustomOverlayManager(tilesOverlay)
//mapView.overlayManager.overlays().add(overlay)
mapView.invalidate()
return CustomOverlayManager(tilesOverlay)
}
}
}

Wyświetl plik

@ -20,6 +20,7 @@ import com.geeksville.mesh.android.Logging
import com.geeksville.mesh.database.entity.Packet import com.geeksville.mesh.database.entity.Packet
import com.geeksville.mesh.databinding.MapViewBinding import com.geeksville.mesh.databinding.MapViewBinding
import com.geeksville.mesh.model.UIViewModel import com.geeksville.mesh.model.UIViewModel
import com.geeksville.mesh.model.map.CustomOverlayManager
import com.geeksville.mesh.model.map.CustomTileSource import com.geeksville.mesh.model.map.CustomTileSource
import com.geeksville.mesh.util.formatAgo import com.geeksville.mesh.util.formatAgo
import com.google.android.material.dialog.MaterialAlertDialogBuilder import com.google.android.material.dialog.MaterialAlertDialogBuilder
@ -177,7 +178,7 @@ class MapFragment : ScreenFragment("Map"), Logging, View.OnClickListener {
} }
private fun clearCache() { private fun clearCache() {
map.canZoomIn()
} }
@ -213,6 +214,8 @@ class MapFragment : ScreenFragment("Map"), Logging, View.OnClickListener {
private fun downloadJobAlert() { private fun downloadJobAlert() {
//prompt for input params . //prompt for input params .
map.overlayManager = CustomOverlayManager.create(map, context)
binding.downloadButton.hide()
binding.cacheLayout.visibility = View.VISIBLE binding.cacheLayout.visibility = View.VISIBLE
val builder = AlertDialog.Builder(activity) val builder = AlertDialog.Builder(activity)
fiveMileButton = binding.box5miles fiveMileButton = binding.box5miles
@ -225,11 +228,12 @@ class MapFragment : ScreenFragment("Map"), Logging, View.OnClickListener {
generateBoxOverlay(zoomLevelLowest) generateBoxOverlay(zoomLevelLowest)
executeJob = binding.executeJob executeJob = binding.executeJob
executeJob.setOnClickListener(this) executeJob.setOnClickListener(this)
//cancelDownload = binding.cacheLayout.findViewById(R.id.cancelDownload) binding.cancelDownload.setOnClickListener {
builder.setOnCancelListener {
cacheEstimate.text = "" cacheEstimate.text = ""
drawOverlays() drawOverlays()
binding.downloadButton.show()
binding.cacheLayout.visibility = View.GONE binding.cacheLayout.visibility = View.GONE
setupMapProperties()
} }
builder.setCancelable(true) builder.setCancelable(true)
} }
@ -248,7 +252,6 @@ class MapFragment : ScreenFragment("Map"), Logging, View.OnClickListener {
val polygon = Polygon() val polygon = Polygon()
polygon.points = Polygon.pointsAsRect(downloadRegionBoundingBox) as MutableList<GeoPoint> polygon.points = Polygon.pointsAsRect(downloadRegionBoundingBox) as MutableList<GeoPoint>
map.overlayManager.add(polygon) map.overlayManager.add(polygon)
map.invalidate()
mapController.setZoom(zoomLevel - 1.0) mapController.setZoom(zoomLevel - 1.0)
cacheManager = CacheManager(map) cacheManager = CacheManager(map)
val tilecount: Int = val tilecount: Int =

Wyświetl plik

@ -26,8 +26,11 @@
<androidx.constraintlayout.widget.ConstraintLayout <androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/cache_layout" android:id="@+id/cache_layout"
android:layout_width="match_parent" android:layout_width="wrap_content"
android:layout_height="match_parent"> android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent">
<TextView <TextView
android:layout_width="match_parent" android:layout_width="match_parent"
@ -36,14 +39,16 @@
android:text="Select download region" android:text="Select download region"
android:textAppearance="?android:attr/textAppearanceLarge" android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="@color/colourGrey" android:textColor="@color/colourGrey"
app:layout_constraintBottom_toTopOf="@id/toggleButton" /> app:layout_constraintBottom_toTopOf="@id/toggleButton"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
<com.google.android.material.button.MaterialButtonToggleGroup <com.google.android.material.button.MaterialButtonToggleGroup
android:id="@+id/toggleButton" android:id="@+id/toggleButton"
style="?attr/materialButtonToggleGroupStyle"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:gravity="center" android:gravity="center"
style="?attr/materialButtonToggleGroupStyle"
app:layout_constraintBottom_toTopOf="@id/cache_estimate"> app:layout_constraintBottom_toTopOf="@id/cache_estimate">
<Button <Button
@ -81,8 +86,8 @@
android:text="Tile download estimate:" android:text="Tile download estimate:"
android:textColor="@color/colourGrey" android:textColor="@color/colourGrey"
app:layout_constraintBottom_toTopOf="@id/executeJob" app:layout_constraintBottom_toTopOf="@id/executeJob"
app:layout_constraintEnd_toEndOf="@id/executeJob" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="@id/executeJob" /> app:layout_constraintStart_toStartOf="parent" />
<Button <Button
android:id="@+id/executeJob" android:id="@+id/executeJob"
@ -90,17 +95,15 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="Start Download" android:text="Start Download"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" /> app:layout_constraintStart_toStartOf="parent" />
<!-- <Button--> <Button
<!-- android:id="@+id/cancelDownload"--> android:id="@+id/cancelDownload"
<!-- android:layout_width="wrap_content"--> android:layout_width="wrap_content"
<!-- android:layout_height="wrap_content"--> android:layout_height="wrap_content"
<!-- android:text="Cancel"--> android:text="Cancel"
<!-- app:layout_constraintBottom_toBottomOf="parent"--> app:layout_constraintBottom_toBottomOf="parent"
<!-- app:layout_constraintEnd_toEndOf="parent"--> app:layout_constraintEnd_toEndOf="parent" />
<!-- />-->
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>
<com.google.android.material.floatingactionbutton.FloatingActionButton <com.google.android.material.floatingactionbutton.FloatingActionButton