Merge remote-tracking branch 'root/master' into dev

pull/81/head
geeksville 2020-07-02 10:12:44 -07:00
commit 36949b83e5
6 zmienionych plików z 88 dodań i 5 usunięć

Wyświetl plik

@ -28,7 +28,8 @@ data class Position(
val latitude: Double,
val longitude: Double,
val altitude: Int,
val time: Int = currentTime() // default to current time in secs
val time: Int = currentTime(), // default to current time in secs
val batteryPctLevel: Int
) : Parcelable {
companion object {
/// Convert to a double representation of degrees
@ -45,7 +46,8 @@ data class Position(
degD(p.latitudeI),
degD(p.longitudeI),
p.altitude,
if (p.time != 0) p.time else defaultTime
if (p.time != 0) p.time else defaultTime,
p.batteryLevel
)
/// @return distance in meters to some other node (or null if unknown)
@ -71,6 +73,8 @@ data class NodeInfo(
/// Return the last time we've seen this node in secs since 1970
val lastSeen get() = position?.time ?: 0
val batteryPctLevel get() = position?.batteryPctLevel
/**
* true if the device was heard from recently
*

Wyświetl plik

@ -10,12 +10,14 @@ import com.geeksville.mesh.Position
/// NodeDB lives inside the UIViewModel, but it needs a backpointer to reach the service
class NodeDB(private val ui: UIViewModel) {
private val testPositions = arrayOf(
Position(32.776665, -96.796989, 35), // dallas
Position(32.960758, -96.733521, 35), // richardson
Position(32.776665, -96.796989, 35, 123, 40), // dallas
Position(32.960758, -96.733521, 35, 456, 50), // richardson
Position(
32.912901,
-96.781776,
35
35,
789,
60
) // north dallas
)

Wyświetl plik

@ -26,6 +26,7 @@ class UsersFragment : ScreenFragment("Users"), Logging {
class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
val nodeNameView = itemView.nodeNameView
val distance_view = itemView.distance_view
val batteryPctView = itemView.batteryPercentageView
}
private val nodesAdapter = object : RecyclerView.Adapter<ViewHolder>() {
@ -106,6 +107,16 @@ class UsersFragment : ScreenFragment("Users"), Logging {
} else {
holder.distance_view.visibility = View.INVISIBLE
}
val battery = n.batteryPctLevel
if (battery != null)
{
holder.batteryPctView.text = "$battery%"
}
else
{
holder.batteryPctView.text = "?"
}
}
private var nodes = arrayOf<NodeInfo>()

Wyświetl plik

@ -0,0 +1,12 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:height="24dp"
android:width="24dp"
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="@android:color/white"
android:pathData="M12 7.5C12.69 7.5 13.27 7.73 13.76 8.2S14.5 9.27 14.5 10C14.5 11.05 14 11.81 13 12.28V21H11V12.28C10 11.81 9.5 11.05 9.5 10C9.5 9.27 9.76 8.67 10.24 8.2S11.31 7.5 12 7.5M16.69 5.3C17.94 6.55 18.61 8.11 18.7 10C18.7 11.8 18.03 13.38 16.69 14.72L15.5 13.5C16.5 12.59 17 11.42 17 10C17 8.67 16.5 7.5 15.5 6.5L16.69 5.3M6.09 4.08C4.5 5.67 3.7 7.64 3.7 10S4.5 14.3 6.09 15.89L4.92 17.11C3 15.08 2 12.7 2 10C2 7.3 3 4.94 4.92 2.91L6.09 4.08M19.08 2.91C21 4.94 22 7.3 22 10C22 12.8 21 15.17 19.08 17.11L17.91 15.89C19.5 14.3 20.3 12.33 20.3 10S19.5 5.67 17.91 4.08L19.08 2.91M7.31 5.3L8.5 6.5C7.5 7.42 7 8.58 7 10C7 11.33 7.5 12.5 8.5 13.5L7.31 14.72C5.97 13.38 5.3 11.8 5.3 10C5.3 8.2 5.97 6.64 7.31 5.3Z"
android:fillAlpha=".5"
/>
</vector>

Wyświetl plik

@ -0,0 +1,11 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:height="24dp"
android:width="24dp"
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="@android:color/white"
android:pathData="M16 20H8V6H16M16.67 4H15V2H9V4H7.33C6.6 4 6 4.6 6 5.33V20.67C6 21.4 6.6 22 7.33 22H16.67C17.41 22 18 21.41 18 20.67V5.33C18 4.6 17.4 4 16.67 4M15 16H9V19H15V16M15 7H9V10H15V7M15 11.5H9V14.5H15V11.5Z"
android:fillAlpha=".5"/>
</vector>

Wyświetl plik

@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clipToPadding="false">
@ -49,6 +50,48 @@
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/imageView" />
<ImageView
android:id="@+id/batteryIcon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
app:layout_constraintEnd_toStartOf="@+id/batteryPercentageView"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/ic_battery_full_24" />
<TextView
android:id="@+id/batteryPercentageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:text="100%"
app:layout_constraintBottom_toBottomOf="@+id/batteryIcon"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="@+id/batteryIcon" />
<ImageView
android:id="@+id/lastCommIcon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
android:visibility="invisible"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/lastConnectionView"
app:srcCompat="@drawable/ic_antenna_24" />
<TextView
android:id="@+id/lastConnectionView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:text="06/14 15h01 (13 min ago)"
android:visibility="invisible"
app:layout_constraintBottom_toBottomOf="@+id/lastCommIcon"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="@+id/lastCommIcon" />
</androidx.constraintlayout.widget.ConstraintLayout>
</com.google.android.material.card.MaterialCardView>
</LinearLayout>