- fixed callee completion from contacts

- moved restoring of call and message history from baresip service to
  main activity
- small cleanups
This commit is contained in:
Juha Heinanen
2018-10-26 12:04:48 +03:00
parent 6772497d14
commit 289faa0793
10 changed files with 97 additions and 101 deletions
@@ -91,30 +91,30 @@ class ContactsActivity : AppCompatActivity() {
var contacts = ArrayList<Contact>()
fun generateContacts(path: String) {
val content = Utils.getFileContents(File(path))
contacts_remove()
fun saveContacts() {
var contents = ""
for (c in contacts)
contents += "\"${c.name}\" ${c.uri}\n"
val path = MainActivity.filesPath + "/contacts"
Utils.putFileContents(File(path), contents)
Log.d("Baresip", "Saved contacts '${contents}' to '$path")
}
fun restoreContacts(path: String) {
val content = Utils.getFileContents(File(path + "/contacts"))
Api.contacts_remove()
contacts.clear()
content.lines().forEach {
val parts = it.split("\"")
if (parts.size == 3) {
val name = parts[1]
val uri = parts[2].trim()
contact_add("\"$name\" $uri")
Api.contact_add("\"$name\" $uri")
contacts.add(Contact(name, uri))
}
}
}
fun saveContacts() {
var contents = ""
for (c in contacts)
contents += "\"${c.name}\" ${c.uri}\n"
val path = MainActivity.filesPath + "/contacts"
Utils.putFileContents(File(path), contents)
Log.d("Baresip", "Saved contacts '${contents}' to '$path")
}
fun findContactURI(name: String): String {
for (c in contacts)
if (c.name == name)
@@ -137,10 +137,5 @@ class ContactsActivity : AppCompatActivity() {
return c.name
return uri
}
external fun contacts_remove()
external fun contact_add(contact: String)
}
}