Allow exporting of baresip contacts to Android contacts

This commit is contained in:
Juha Heinanen
2021-01-25 09:50:12 +02:00
parent e570620615
commit a262827e3a
8 changed files with 79 additions and 54 deletions
@@ -22,7 +22,7 @@ class Contact(var name: String, var uri: String, var color: Int, val id: Long) {
fun save(): Boolean {
var contents = ""
for (c in BaresipService.contacts) contents +=
"\"${c.name}\" <${c.uri}>;id=${c.id};color=${c.color}\n"
"\"${c.name}\" <${c.uri}>;id=${c.id};color=${c.color};android=${c.androidContact}\n"
return Utils.putFileContents(BaresipService.filesPath + "/contacts",
contents.toByteArray())
}
@@ -49,14 +49,16 @@ class Contact(var name: String, var uri: String, var color: Int, val id: Long) {
color = colorValue.toInt()
else
color = Utils.randomColor()
val androidContact = Utils.paramValue(params, "android" ) == "true"
val idValue = Utils.paramValue(params, "id" )
val id: Long
if (idValue != "")
id = idValue.toLong()
else
id = baseId + contactNo
Log.d("Baresip", "Restoring contact $name, $uri, $color, $id")
Log.d("Baresip", "Restoring contact $name, $uri, $color, $id, $androidContact")
val contact = Contact(name, uri, color, id)
contact.androidContact = androidContact
val avatarFilePath = BaresipService.filesPath + "/$id.png"
if (File(avatarFilePath).exists()) {
try {