- all user interface unrelated data is now kept in baresip service

allowing proper recovery in case Android kills other activities
- many other improvements and bug fixes
This commit is contained in:
Juha Heinanen
2018-11-23 10:35:48 +02:00
parent 0a9108f846
commit 18478c3436
23 changed files with 872 additions and 679 deletions
@@ -1,7 +1,38 @@
package com.tutpro.baresip
import java.io.Serializable
import java.io.*
import java.util.ArrayList
class Message(val aor: String, val peerUri: String, var direction: Int, val message: String,
val timeStamp: Long, var new: Boolean): Serializable {
companion object {
val MESSAGE_HISTORY_SIZE = 100
fun messages(): ArrayList<Message> {
return BaresipService.messages
}
fun messages(messages: ArrayList<Message>) {
BaresipService.messages = messages
}
fun add(message: Message) {
BaresipService.messages.add(message)
var count = 0
var firstIndex = -1
for (i in BaresipService.messages.indices)
if (BaresipService.messages[i].aor == message.aor) {
if (count == 0) firstIndex = i
count++
if (count > MESSAGE_HISTORY_SIZE) {
break
}
}
if (count > MESSAGE_HISTORY_SIZE)
BaresipService.messages.removeAt(firstIndex)
}
}
}