collapse history of multiple calls to/from same peer
This commit is contained in:
@@ -92,28 +92,31 @@ class HistoryActivity : AppCompatActivity() {
|
||||
if (Utils.uriHostPart(peer_uri) == Utils.uriHostPart(aor)) {
|
||||
peer_uri = Utils.uriUserPart(peer_uri)
|
||||
}
|
||||
val time: String
|
||||
if (isToday(h.time)) {
|
||||
val fmt = SimpleDateFormat("HH:mm")
|
||||
time = fmt.format(h.time.time)
|
||||
var direction: Int
|
||||
if (h.direction == "in")
|
||||
if (h.connected)
|
||||
direction = R.drawable.arrow_down_green
|
||||
else
|
||||
direction = R.drawable.arrow_down_red
|
||||
else
|
||||
if (h.connected)
|
||||
direction = R.drawable.arrow_up_green
|
||||
else
|
||||
direction = R.drawable.arrow_up_red
|
||||
if (uaHistory.isNotEmpty() && (uaHistory.last().peerURI == peer_uri)) {
|
||||
uaHistory.last().directions.add(direction)
|
||||
} else {
|
||||
val fmt = SimpleDateFormat("MMM dd")
|
||||
time = fmt.format(h.time.time)
|
||||
}
|
||||
if (h.direction == "in") {
|
||||
if (h.connected) {
|
||||
uaHistory.add(HistoryRow(peer_uri, R.drawable.arrow_down_green, time))
|
||||
val time: String
|
||||
if (isToday(h.time)) {
|
||||
val fmt = SimpleDateFormat("HH:mm")
|
||||
time = fmt.format(h.time.time)
|
||||
} else {
|
||||
uaHistory.add(HistoryRow(peer_uri, R.drawable.arrow_down_red, time))
|
||||
}
|
||||
} else {
|
||||
if (h.connected) {
|
||||
uaHistory.add(HistoryRow(peer_uri, R.drawable.arrow_up_green, time))
|
||||
} else {
|
||||
uaHistory.add(HistoryRow(peer_uri, R.drawable.arrow_up_red, time))
|
||||
val fmt = SimpleDateFormat("dd.MM")
|
||||
time = fmt.format(h.time.time)
|
||||
}
|
||||
uaHistory.add(HistoryRow(peer_uri, direction, time))
|
||||
posAtHistory.add(i)
|
||||
}
|
||||
posAtHistory.add(i)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.ArrayAdapter
|
||||
import android.widget.ImageView
|
||||
import android.widget.LinearLayout
|
||||
import android.widget.TextView
|
||||
import java.util.*
|
||||
|
||||
@@ -16,18 +17,27 @@ class HistoryListAdapter(private val cxt: Context, private val rows: ArrayList<H
|
||||
val row = rows[position]
|
||||
val inflater = context.getSystemService(Context.LAYOUT_INFLATER_SERVICE) as LayoutInflater
|
||||
val rowView = inflater.inflate(R.layout.history_row, parent, false)
|
||||
val directionView = rowView.findViewById(R.id.direction) as ImageView
|
||||
directionView.setImageResource(row.direction)
|
||||
val directions = rowView.findViewById(R.id.directions) as LinearLayout
|
||||
var count = 1
|
||||
for (d in row.directions) {
|
||||
if (count > 3) {
|
||||
val etc = rowView.findViewById(R.id.etc) as TextView
|
||||
etc.text = "..."
|
||||
break
|
||||
}
|
||||
val dirView = ImageView(cxt)
|
||||
val params = LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
|
||||
ViewGroup.LayoutParams.WRAP_CONTENT)
|
||||
dirView.layoutParams = params
|
||||
dirView.setPadding(0, 5, 0, 0)
|
||||
dirView.setImageResource(d)
|
||||
directions.addView(dirView)
|
||||
count++
|
||||
}
|
||||
val peerURIView = rowView.findViewById(R.id.peer_uri) as TextView
|
||||
peerURIView.text = row.peerURI
|
||||
val timeView = rowView.findViewById(R.id.time) as TextView
|
||||
val now = GregorianCalendar()
|
||||
if (row.time.get(Calendar.YEAR).equals(now.get(Calendar.YEAR)) &&
|
||||
row.time.get(Calendar.DAY_OF_YEAR).equals(now.get(Calendar.DAY_OF_YEAR)))
|
||||
timeView.text = String.format("%02d", row.time.get(Calendar.HOUR_OF_DAY)) + ":" +
|
||||
String.format("%02d", row.time.get(Calendar.HOUR_OF_DAY))
|
||||
else
|
||||
timeView.text = row.time
|
||||
timeView.text = row.time
|
||||
return rowView
|
||||
}
|
||||
|
||||
|
||||
@@ -1,3 +1,10 @@
|
||||
package com.tutpro.baresip
|
||||
|
||||
class HistoryRow(val peerURI: String, val direction: Int, val time: String)
|
||||
class HistoryRow(val peerURI: String, val direction: Int, val time: String) {
|
||||
|
||||
val directions = ArrayList<Int>()
|
||||
|
||||
init {
|
||||
directions.add(direction)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,6 +22,13 @@ class UserAgent (val uap: String) {
|
||||
return null
|
||||
}
|
||||
|
||||
fun findAorIndex(uas: ArrayList<UserAgent>, aor: String): Int? {
|
||||
for (i in uas.indices) {
|
||||
if (uas[i].aor == aor) return i
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
fun register(uas: ArrayList<UserAgent>) {
|
||||
for (ua in uas) {
|
||||
if (ua_register(ua.uap) != 0)
|
||||
|
||||
Reference in New Issue
Block a user