collapse history of multiple calls to/from same peer

This commit is contained in:
Juha Heinanen
2018-05-29 16:26:04 +03:00
parent 0c922eb543
commit e4fcb302ee
9 changed files with 86 additions and 50 deletions

View File

@ -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)
}
}
}

View File

@ -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
}

View File

@ -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)
}
}

View File

@ -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)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 521 B

After

Width:  |  Height:  |  Size: 351 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 525 B

After

Width:  |  Height:  |  Size: 305 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 520 B

After

Width:  |  Height:  |  Size: 320 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 521 B

After

Width:  |  Height:  |  Size: 286 B

View File

@ -1,48 +1,57 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/historyRow"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginBottom="0dp"
android:layout_marginTop="0dp"
android:descendantFocusability="blocksDescendants">
android:descendantFocusability="blocksDescendants" >
<ImageView
android:id="@+id/direction"
<LinearLayout
android:id="@+id/directions"
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_centerVertical="true" />
<TextView
android:id="@+id/time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:focusable="false"
android:paddingRight="10dp"
android:layout_alignParentEnd="true"
android:gravity="end"
android:textAlignment="gravity"
android:paddingTop="5dp"
android:paddingBottom="5dp"
android:paddingLeft="10dp"
android:scaleType="centerCrop" />
android:textSize="18sp"
android:maxLines="1"
android:text="" />
<TextView
android:id="@+id/etc"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toEndOf="@id/directions"
android:paddingTop="10dp"
android:text="" />
<TextView
android:id="@+id/peer_uri"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@+id/direction"
android:layout_centerVertical="true"
android:layout_toEndOf="@id/etc"
android:layout_toStartOf="@id/time"
android:focusable="false"
android:paddingStart="5dp"
android:paddingTop="5dp"
android:paddingBottom="5dp"
android:textSize="18sp"
android:text="" />
<TextView
android:id="@+id/time"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_toRightOf="@+id/peer_uri"
android:layout_centerVertical="true"
android:focusable="false"
android:gravity="right"
android:textAlignment="gravity"
android:paddingTop="5dp"
android:paddingBottom="5dp"
android:textSize="18sp"
android:maxLines="1"
android:ellipsize="end"
android:text="" />
</RelativeLayout>