show coordinates with geo url to open in other mapping app

pull/259/head
goga 2021-03-16 10:04:01 +05:00
rodzic 53745ca9f5
commit 452bf6f6cb
5 zmienionych plików z 25 dodań i 17 usunięć

Wyświetl plik

@ -1235,7 +1235,7 @@ class MeshService : Service(), Logging {
MyNodeInfo( MyNodeInfo(
myNodeNum, myNodeNum,
hasGps, hasGps,
hwModel, hwModelDeprecated,
firmwareVersion, firmwareVersion,
firmwareUpdateFilename != null, firmwareUpdateFilename != null,
isBluetoothInterface && SoftwareUpdateService.shouldUpdate( isBluetoothInterface && SoftwareUpdateService.shouldUpdate(
@ -1545,10 +1545,10 @@ class MeshService : Service(), Logging {
*/ */
private fun setFirmwareUpdateFilename(info: MeshProtos.MyNodeInfo) { private fun setFirmwareUpdateFilename(info: MeshProtos.MyNodeInfo) {
firmwareUpdateFilename = try { firmwareUpdateFilename = try {
if (info.region != null && info.firmwareVersion != null && info.hwModel != null) if (info.region != null && info.firmwareVersion != null && info.hwModelDeprecated != null)
SoftwareUpdateService.getUpdateFilename( SoftwareUpdateService.getUpdateFilename(
this, this,
info.hwModel info.hwModelDeprecated
) )
else else
null null

Wyświetl plik

@ -160,7 +160,7 @@ class MockInterface(private val service: RadioInterfaceService) : Logging, IRadi
MeshProtos.FromRadio.newBuilder().apply { MeshProtos.FromRadio.newBuilder().apply {
myInfo = MeshProtos.MyNodeInfo.newBuilder().apply { myInfo = MeshProtos.MyNodeInfo.newBuilder().apply {
myNodeNum = MY_NODE myNodeNum = MY_NODE
hwModel = "Sim" hwModelDeprecated = "Sim"
messageTimeoutMsec = 5 * 60 * 1000 messageTimeoutMsec = 5 * 60 * 1000
firmwareVersion = service.getString(R.string.cur_firmware_version) firmwareVersion = service.getString(R.string.cur_firmware_version)
numBands = 13 numBands = 13

Wyświetl plik

@ -80,7 +80,7 @@ class MapFragment : ScreenFragment("Map"), Logging {
) )
) )
node.user?.let { node.user?.let {
f.addStringProperty("name", it.longName + " " + formatAgo(node.lastSeen)) f.addStringProperty("name", it.longName + " " + formatAgo(p.time))
} }
f f
} }
@ -94,7 +94,8 @@ class MapFragment : ScreenFragment("Map"), Logging {
} }
fun zoomToNodes(map: MapboxMap) { 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()) { if (nodesWithPosition != null && nodesWithPosition.isNotEmpty()) {
val update = if (nodesWithPosition.size >= 2) { val update = if (nodesWithPosition.size >= 2) {
// Multiple nodes, make them all fit on the map view // 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 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 = BitmapFactory.decodeResource(context.resources, R.drawable.ic_twotone_person_pin_24)
val markerIcon = 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 -> map.setStyle(Style.OUTDOORS) { style ->
style.addSource(nodePositions) style.addSource(nodePositions)
@ -177,7 +181,7 @@ class MapFragment : ScreenFragment("Map"), Logging {
// Any times nodes change update our map // Any times nodes change update our map
model.nodeDB.nodes.observe(viewLifecycleOwner, Observer { nodes -> model.nodeDB.nodes.observe(viewLifecycleOwner, Observer { nodes ->
if(isViewVisible) if (isViewVisible)
onNodesChanged(map, nodes.values) onNodesChanged(map, nodes.values)
}) })
zoomToNodes(map) zoomToNodes(map)

Wyświetl plik

@ -2,11 +2,13 @@ package com.geeksville.mesh.ui
import android.os.Bundle 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.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import androidx.core.content.ContextCompat import androidx.core.content.ContextCompat
import androidx.core.text.HtmlCompat
import androidx.fragment.app.activityViewModels import androidx.fragment.app.activityViewModels
import androidx.lifecycle.Observer import androidx.lifecycle.Observer
import androidx.recyclerview.widget.LinearLayoutManager 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.databinding.NodelistFragmentBinding
import com.geeksville.mesh.model.UIViewModel import com.geeksville.mesh.model.UIViewModel
import com.geeksville.util.formatAgo import com.geeksville.util.formatAgo
import java.text.ParseException
import java.util.*
class UsersFragment : ScreenFragment("Users"), Logging { class UsersFragment : ScreenFragment("Users"), Logging {
@ -36,7 +36,7 @@ class UsersFragment : ScreenFragment("Users"), Logging {
class ViewHolder(itemView: AdapterNodeLayoutBinding) : RecyclerView.ViewHolder(itemView.root) { class ViewHolder(itemView: AdapterNodeLayoutBinding) : RecyclerView.ViewHolder(itemView.root) {
val nodeNameView = itemView.nodeNameView val nodeNameView = itemView.nodeNameView
val distanceView = itemView.distanceView val distanceView = itemView.distanceView
val coordsview = itemView.coordsView val coordsView = itemView.coordsView
val batteryPctView = itemView.batteryPercentageView val batteryPctView = itemView.batteryPercentageView
val lastTime = itemView.lastConnectionView val lastTime = itemView.lastConnectionView
val powerIcon = itemView.batteryIcon val powerIcon = itemView.batteryIcon
@ -111,12 +111,15 @@ class UsersFragment : ScreenFragment("Users"), Logging {
holder.nodeNameView.text = n.user?.longName ?: n.user?.id ?: "Unknown node" holder.nodeNameView.text = n.user?.longName ?: n.user?.id ?: "Unknown node"
val ourNodeInfo = model.nodeDB.ourNodeInfo val ourNodeInfo = model.nodeDB.ourNodeInfo
val pos = ourNodeInfo?.position; val pos = ourNodeInfo?.validPosition;
if (pos != null) { if (pos != null) {
holder.coordsview.text = pos.latitude.toString() + " " + pos.longitude val html =
holder.coordsview.visibility = View.VISIBLE "<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 { } else {
holder.coordsview.visibility = View.INVISIBLE holder.coordsView.visibility = View.INVISIBLE
} }
val distance = ourNodeInfo?.distanceStr(n) val distance = ourNodeInfo?.distanceStr(n)
if (distance != null) { if (distance != null) {

Wyświetl plik

@ -55,10 +55,11 @@
android:id="@+id/coords_view" android:id="@+id/coords_view"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="76dp" android:layout_marginStart="140dp"
android:layout_marginTop="8dp" android:layout_marginTop="8dp"
android:layout_marginBottom="8dp" android:layout_marginBottom="8dp"
android:text="@string/sample_coords" android:text="@string/sample_coords"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/imageView" app:layout_constraintTop_toBottomOf="@+id/imageView"