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

pull/100/head
geeksville 2020-07-14 22:05:46 -07:00
commit 0a38b70682
4 zmienionych plików z 39 dodań i 6 usunięć

Wyświetl plik

@ -57,7 +57,7 @@ data class Position(
fun bearing(o: Position) = bearing(latitude, longitude, o.latitude, o.longitude)
override fun toString(): String {
return "Position(lat=${latitude.anonymize}, lon=${longitude.anonymize}, alt=${altitude.anonymize}, time=${time})"
return "Position(lat=${latitude.anonymize}, lon=${longitude.anonymize}, alt=${altitude.anonymize}, time=${time}, batteryPctLevel=${batteryPctLevel})"
}
}

Wyświetl plik

@ -1,6 +1,7 @@
package com.geeksville.mesh.ui
import android.os.Bundle
import android.text.format.DateFormat
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
@ -21,7 +22,6 @@ import com.geeksville.mesh.service.MeshService
import com.google.android.material.chip.Chip
import kotlinx.android.synthetic.main.adapter_message_layout.view.*
import kotlinx.android.synthetic.main.messages_fragment.*
import java.text.SimpleDateFormat
import java.util.*
// Allows usage like email.on(EditorInfo.IME_ACTION_NEXT, { confirm() })
@ -40,6 +40,8 @@ class MessagesFragment : ScreenFragment("Messages"), Logging {
private val model: UIViewModel by activityViewModels()
private lateinit var dateTimeFormat : java.text.DateFormat
// Provide a direct reference to each of the views within a data item
// Used to cache the views within the item layout for fast access
class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
@ -131,7 +133,7 @@ class MessagesFragment : ScreenFragment("Messages"), Logging {
holder.messageText.text = msg.text
}
holder.messageTime.text = dateFormat.format(Date(msg.time))
holder.messageTime.text = dateTimeFormat.format(Date(msg.time))
val icon = when (msg.status) {
MessageStatus.QUEUED -> R.drawable.ic_twotone_cloud_upload_24
@ -171,6 +173,7 @@ class MessagesFragment : ScreenFragment("Messages"), Logging {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
dateTimeFormat = DateFormat.getTimeFormat(context)
messageInputText.on(EditorInfo.IME_ACTION_DONE) {
debug("did IME action")
@ -206,6 +209,5 @@ class MessagesFragment : ScreenFragment("Messages"), Logging {
})
}
private val dateFormat = SimpleDateFormat("h:mm a")
}

Wyświetl plik

@ -2,6 +2,7 @@ package com.geeksville.mesh.ui
import android.os.Bundle
import android.text.format.DateFormat
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
@ -15,6 +16,8 @@ import com.geeksville.mesh.R
import com.geeksville.mesh.model.UIViewModel
import kotlinx.android.synthetic.main.adapter_node_layout.view.*
import kotlinx.android.synthetic.main.nodelist_fragment.*
import java.text.ParseException
import java.util.*
class UsersFragment : ScreenFragment("Users"), Logging {
@ -27,6 +30,7 @@ class UsersFragment : ScreenFragment("Users"), Logging {
val nodeNameView = itemView.nodeNameView
val distance_view = itemView.distance_view
val batteryPctView = itemView.batteryPercentageView
val lastTime = itemView.lastConnectionView
}
private val nodesAdapter = object : RecyclerView.Adapter<ViewHolder>() {
@ -117,6 +121,8 @@ class UsersFragment : ScreenFragment("Users"), Logging {
{
holder.batteryPctView.text = "?"
}
holder.lastTime.text = getLastTimeValue(n)
}
private var nodes = arrayOf<NodeInfo>()
@ -128,6 +134,31 @@ class UsersFragment : ScreenFragment("Users"), Logging {
}
}
private fun getLastTimeValue(n: NodeInfo): String {
var lastTimeText: String = "?"
val currentTime = (System.currentTimeMillis()/1000).toInt()
val threeDaysLong = 3 * 60*60*24
//if the lastSeen is too old
if((n.lastSeen<currentTime-threeDaysLong))
return lastTimeText
try {
val toLong: Long = n.lastSeen.toLong()
val long1000 = toLong * 1000L
val date = Date(long1000)
val timeFormat = DateFormat.getTimeFormat(context)
lastTimeText = timeFormat.format(date)
} catch (e: ParseException) {
//
}
return lastTimeText
}
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?

Wyświetl plik

@ -77,7 +77,7 @@
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
android:visibility="invisible"
android:visibility="visible"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/lastConnectionView"
app:srcCompat="@drawable/ic_antenna_24" />
@ -88,7 +88,7 @@
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:text="06/14 15h01 (13 min ago)"
android:visibility="invisible"
android:visibility="visible"
app:layout_constraintBottom_toBottomOf="@+id/lastCommIcon"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="@+id/lastCommIcon" />