kopia lustrzana https://github.com/meshtastic/Meshtastic-Android
show coordinates with geo url to open in other mapping app
rodzic
53745ca9f5
commit
452bf6f6cb
|
@ -1235,7 +1235,7 @@ class MeshService : Service(), Logging {
|
|||
MyNodeInfo(
|
||||
myNodeNum,
|
||||
hasGps,
|
||||
hwModel,
|
||||
hwModelDeprecated,
|
||||
firmwareVersion,
|
||||
firmwareUpdateFilename != null,
|
||||
isBluetoothInterface && SoftwareUpdateService.shouldUpdate(
|
||||
|
@ -1545,10 +1545,10 @@ class MeshService : Service(), Logging {
|
|||
*/
|
||||
private fun setFirmwareUpdateFilename(info: MeshProtos.MyNodeInfo) {
|
||||
firmwareUpdateFilename = try {
|
||||
if (info.region != null && info.firmwareVersion != null && info.hwModel != null)
|
||||
if (info.region != null && info.firmwareVersion != null && info.hwModelDeprecated != null)
|
||||
SoftwareUpdateService.getUpdateFilename(
|
||||
this,
|
||||
info.hwModel
|
||||
info.hwModelDeprecated
|
||||
)
|
||||
else
|
||||
null
|
||||
|
|
|
@ -160,7 +160,7 @@ class MockInterface(private val service: RadioInterfaceService) : Logging, IRadi
|
|||
MeshProtos.FromRadio.newBuilder().apply {
|
||||
myInfo = MeshProtos.MyNodeInfo.newBuilder().apply {
|
||||
myNodeNum = MY_NODE
|
||||
hwModel = "Sim"
|
||||
hwModelDeprecated = "Sim"
|
||||
messageTimeoutMsec = 5 * 60 * 1000
|
||||
firmwareVersion = service.getString(R.string.cur_firmware_version)
|
||||
numBands = 13
|
||||
|
|
|
@ -80,7 +80,7 @@ class MapFragment : ScreenFragment("Map"), Logging {
|
|||
)
|
||||
)
|
||||
node.user?.let {
|
||||
f.addStringProperty("name", it.longName + " " + formatAgo(node.lastSeen))
|
||||
f.addStringProperty("name", it.longName + " " + formatAgo(p.time))
|
||||
}
|
||||
f
|
||||
}
|
||||
|
@ -94,7 +94,8 @@ class MapFragment : ScreenFragment("Map"), Logging {
|
|||
}
|
||||
|
||||
fun zoomToNodes(map: MapboxMap) {
|
||||
val nodesWithPosition = model.nodeDB.nodes.value?.values?.filter { it.validPosition != null }
|
||||
val nodesWithPosition =
|
||||
model.nodeDB.nodes.value?.values?.filter { it.validPosition != null }
|
||||
if (nodesWithPosition != null && nodesWithPosition.isNotEmpty()) {
|
||||
val update = if (nodesWithPosition.size >= 2) {
|
||||
// Multiple nodes, make them all fit on the map view
|
||||
|
@ -159,7 +160,10 @@ class MapFragment : ScreenFragment("Map"), Logging {
|
|||
if (view != null) { // it might have gone away by now
|
||||
// val markerIcon = BitmapFactory.decodeResource(context.resources, R.drawable.ic_twotone_person_pin_24)
|
||||
val markerIcon =
|
||||
ContextCompat.getDrawable(requireActivity(), R.drawable.ic_twotone_person_pin_24)!!
|
||||
ContextCompat.getDrawable(
|
||||
requireActivity(),
|
||||
R.drawable.ic_twotone_person_pin_24
|
||||
)!!
|
||||
|
||||
map.setStyle(Style.OUTDOORS) { style ->
|
||||
style.addSource(nodePositions)
|
||||
|
@ -177,7 +181,7 @@ class MapFragment : ScreenFragment("Map"), Logging {
|
|||
|
||||
// Any times nodes change update our map
|
||||
model.nodeDB.nodes.observe(viewLifecycleOwner, Observer { nodes ->
|
||||
if(isViewVisible)
|
||||
if (isViewVisible)
|
||||
onNodesChanged(map, nodes.values)
|
||||
})
|
||||
zoomToNodes(map)
|
||||
|
|
|
@ -2,11 +2,13 @@ package com.geeksville.mesh.ui
|
|||
|
||||
|
||||
import android.os.Bundle
|
||||
import android.text.format.DateFormat
|
||||
import android.text.Html
|
||||
import android.text.method.LinkMovementMethod
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.core.text.HtmlCompat
|
||||
import androidx.fragment.app.activityViewModels
|
||||
import androidx.lifecycle.Observer
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
|
@ -18,8 +20,6 @@ import com.geeksville.mesh.databinding.AdapterNodeLayoutBinding
|
|||
import com.geeksville.mesh.databinding.NodelistFragmentBinding
|
||||
import com.geeksville.mesh.model.UIViewModel
|
||||
import com.geeksville.util.formatAgo
|
||||
import java.text.ParseException
|
||||
import java.util.*
|
||||
|
||||
|
||||
class UsersFragment : ScreenFragment("Users"), Logging {
|
||||
|
@ -36,7 +36,7 @@ class UsersFragment : ScreenFragment("Users"), Logging {
|
|||
class ViewHolder(itemView: AdapterNodeLayoutBinding) : RecyclerView.ViewHolder(itemView.root) {
|
||||
val nodeNameView = itemView.nodeNameView
|
||||
val distanceView = itemView.distanceView
|
||||
val coordsview = itemView.coordsView
|
||||
val coordsView = itemView.coordsView
|
||||
val batteryPctView = itemView.batteryPercentageView
|
||||
val lastTime = itemView.lastConnectionView
|
||||
val powerIcon = itemView.batteryIcon
|
||||
|
@ -111,12 +111,15 @@ class UsersFragment : ScreenFragment("Users"), Logging {
|
|||
holder.nodeNameView.text = n.user?.longName ?: n.user?.id ?: "Unknown node"
|
||||
|
||||
val ourNodeInfo = model.nodeDB.ourNodeInfo
|
||||
val pos = ourNodeInfo?.position;
|
||||
val pos = ourNodeInfo?.validPosition;
|
||||
if (pos != null) {
|
||||
holder.coordsview.text = pos.latitude.toString() + " " + pos.longitude
|
||||
holder.coordsview.visibility = View.VISIBLE
|
||||
val html =
|
||||
"<a href='geo:${pos.latitude},${pos.longitude}'>${pos.latitude.toString()} ${pos.longitude}</a>"
|
||||
holder.coordsView.text = HtmlCompat.fromHtml(html, Html.FROM_HTML_MODE_LEGACY)
|
||||
holder.coordsView.movementMethod = LinkMovementMethod.getInstance()
|
||||
holder.coordsView.visibility = View.VISIBLE
|
||||
} else {
|
||||
holder.coordsview.visibility = View.INVISIBLE
|
||||
holder.coordsView.visibility = View.INVISIBLE
|
||||
}
|
||||
val distance = ourNodeInfo?.distanceStr(n)
|
||||
if (distance != null) {
|
||||
|
|
|
@ -55,10 +55,11 @@
|
|||
android:id="@+id/coords_view"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="76dp"
|
||||
android:layout_marginStart="140dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:text="@string/sample_coords"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Small"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/imageView"
|
||||
|
|
Ładowanie…
Reference in New Issue