kopia lustrzana https://github.com/meshtastic/Meshtastic-Android
Moving right along
rodzic
63bee8a3d8
commit
b1291e28a7
|
@ -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)
|
||||
}
|
||||
}
|
||||
}
|
|
@ -20,6 +20,7 @@ import com.geeksville.mesh.android.Logging
|
|||
import com.geeksville.mesh.database.entity.Packet
|
||||
import com.geeksville.mesh.databinding.MapViewBinding
|
||||
import com.geeksville.mesh.model.UIViewModel
|
||||
import com.geeksville.mesh.model.map.CustomOverlayManager
|
||||
import com.geeksville.mesh.model.map.CustomTileSource
|
||||
import com.geeksville.mesh.util.formatAgo
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||
|
@ -177,7 +178,7 @@ class MapFragment : ScreenFragment("Map"), Logging, View.OnClickListener {
|
|||
}
|
||||
|
||||
private fun clearCache() {
|
||||
|
||||
map.canZoomIn()
|
||||
}
|
||||
|
||||
|
||||
|
@ -213,6 +214,8 @@ class MapFragment : ScreenFragment("Map"), Logging, View.OnClickListener {
|
|||
|
||||
private fun downloadJobAlert() {
|
||||
//prompt for input params .
|
||||
map.overlayManager = CustomOverlayManager.create(map, context)
|
||||
binding.downloadButton.hide()
|
||||
binding.cacheLayout.visibility = View.VISIBLE
|
||||
val builder = AlertDialog.Builder(activity)
|
||||
fiveMileButton = binding.box5miles
|
||||
|
@ -225,11 +228,12 @@ class MapFragment : ScreenFragment("Map"), Logging, View.OnClickListener {
|
|||
generateBoxOverlay(zoomLevelLowest)
|
||||
executeJob = binding.executeJob
|
||||
executeJob.setOnClickListener(this)
|
||||
//cancelDownload = binding.cacheLayout.findViewById(R.id.cancelDownload)
|
||||
builder.setOnCancelListener {
|
||||
binding.cancelDownload.setOnClickListener {
|
||||
cacheEstimate.text = ""
|
||||
drawOverlays()
|
||||
binding.downloadButton.show()
|
||||
binding.cacheLayout.visibility = View.GONE
|
||||
setupMapProperties()
|
||||
}
|
||||
builder.setCancelable(true)
|
||||
}
|
||||
|
@ -248,7 +252,6 @@ class MapFragment : ScreenFragment("Map"), Logging, View.OnClickListener {
|
|||
val polygon = Polygon()
|
||||
polygon.points = Polygon.pointsAsRect(downloadRegionBoundingBox) as MutableList<GeoPoint>
|
||||
map.overlayManager.add(polygon)
|
||||
map.invalidate()
|
||||
mapController.setZoom(zoomLevel - 1.0)
|
||||
cacheManager = CacheManager(map)
|
||||
val tilecount: Int =
|
||||
|
|
|
@ -26,8 +26,11 @@
|
|||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/cache_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent">
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
|
@ -36,14 +39,16 @@
|
|||
android:text="Select download region"
|
||||
android:textAppearance="?android:attr/textAppearanceLarge"
|
||||
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
|
||||
android:id="@+id/toggleButton"
|
||||
style="?attr/materialButtonToggleGroupStyle"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
style="?attr/materialButtonToggleGroupStyle"
|
||||
app:layout_constraintBottom_toTopOf="@id/cache_estimate">
|
||||
|
||||
<Button
|
||||
|
@ -81,8 +86,8 @@
|
|||
android:text="Tile download estimate:"
|
||||
android:textColor="@color/colourGrey"
|
||||
app:layout_constraintBottom_toTopOf="@id/executeJob"
|
||||
app:layout_constraintEnd_toEndOf="@id/executeJob"
|
||||
app:layout_constraintStart_toStartOf="@id/executeJob" />
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/executeJob"
|
||||
|
@ -90,17 +95,15 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:text="Start Download"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent" />
|
||||
|
||||
<!-- <Button-->
|
||||
<!-- android:id="@+id/cancelDownload"-->
|
||||
<!-- android:layout_width="wrap_content"-->
|
||||
<!-- android:layout_height="wrap_content"-->
|
||||
<!-- android:text="Cancel"-->
|
||||
<!-- app:layout_constraintBottom_toBottomOf="parent"-->
|
||||
<!-- app:layout_constraintEnd_toEndOf="parent"-->
|
||||
<!-- />-->
|
||||
<Button
|
||||
android:id="@+id/cancelDownload"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Cancel"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||
|
|
Ładowanie…
Reference in New Issue