improved showing of history items

This commit is contained in:
Juha Heinanen
2018-03-17 17:21:32 +13:00
parent afb4635af7
commit 0f4ae4ff8b
3 changed files with 26 additions and 13 deletions

View File

@ -35,9 +35,8 @@ class HistoryActivity : AppCompatActivity() {
val adapter = HistoryListAdapter(this, uaHistory)
listview.adapter = adapter
listview.onItemClickListener = AdapterView.OnItemClickListener { _, _, position, _ ->
val row = uaHistory[position]
val i = Intent()
i.putExtra("peer_uri", row.peerURI)
i.putExtra("peer_uri", uaHistory[position].peerURI)
setResult(Activity.RESULT_OK, i)
finish()
}
@ -89,6 +88,10 @@ class HistoryActivity : AppCompatActivity() {
for (i in History.indices.reversed()) {
val h = History[i]
if (h.aor == aor) {
var peer_uri = h.peerURI
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")
@ -99,15 +102,15 @@ class HistoryActivity : AppCompatActivity() {
}
if (h.direction == "in") {
if (h.connected) {
uaHistory.add(HistoryRow(h.peerURI, R.drawable.arrow_down_green, time))
uaHistory.add(HistoryRow(peer_uri, R.drawable.arrow_down_green, time))
} else {
uaHistory.add(HistoryRow(h.peerURI, R.drawable.arrow_down_red, time))
uaHistory.add(HistoryRow(peer_uri, R.drawable.arrow_down_red, time))
}
} else {
if (h.connected) {
uaHistory.add(HistoryRow(h.peerURI, R.drawable.arrow_up_green, time))
uaHistory.add(HistoryRow(peer_uri, R.drawable.arrow_up_green, time))
} else {
uaHistory.add(HistoryRow(h.peerURI, R.drawable.arrow_up_red, time))
uaHistory.add(HistoryRow(peer_uri, R.drawable.arrow_up_red, time))
}
}
posAtHistory.add(i)

View File

@ -650,12 +650,12 @@ class MainActivity : AppCompatActivity() {
internal var In = ArrayList<Call>()
internal var Out = ArrayList<Call>()
private val RECORD_AUDIO_PERMISSION = 1
private val EDIT_ACCOUNTS_CODE = 1
private val EDIT_CONTACTS_CODE = 2
private val EDIT_CONFIG_CODE = 3
private val HISTORY_CODE = 4
private val ABOUT_CODE = 5
const val RECORD_AUDIO_PERMISSION = 1
const val EDIT_ACCOUNTS_CODE = 1
const val EDIT_CONTACTS_CODE = 2
const val EDIT_CONFIG_CODE = 3
const val HISTORY_CODE = 4
const val ABOUT_CODE = 5
external fun contacts_remove()
external fun contact_add(contact: String)

View File

@ -1,7 +1,6 @@
package com.tutpro.baresip
import android.content.Context
import android.content.DialogInterface
import android.support.v7.app.AlertDialog
import android.util.Log
@ -64,4 +63,15 @@ object Utils {
alertDialog.show()
}
fun uriHostPart(uri: String): String {
return uri.substringAfter("@")
.substringBefore(":")
.substringBefore(";")
.substringBefore(">")
}
fun uriUserPart(uri: String): String {
return uri.substringAfter(":").substringBefore("@")
}
}