- Added Call History menu that allows deleting of account's call history
and disabling/enabling production of account's call history.
This commit is contained in:
@@ -20,8 +20,10 @@ class Account(val accp: String) {
|
|||||||
var vmOld = 0
|
var vmOld = 0
|
||||||
var missedCalls = false
|
var missedCalls = false
|
||||||
var unreadMessages = false
|
var unreadMessages = false
|
||||||
|
var callHistory = true
|
||||||
|
|
||||||
init {
|
init {
|
||||||
|
|
||||||
val stunHost = account_stun_host(accp)
|
val stunHost = account_stun_host(accp)
|
||||||
if (stunHost != "") {
|
if (stunHost != "") {
|
||||||
val stunPort = account_stun_port(accp)
|
val stunPort = account_stun_port(accp)
|
||||||
@@ -30,6 +32,7 @@ class Account(val accp: String) {
|
|||||||
else
|
else
|
||||||
stunServer = "$stunHost:$stunPort"
|
stunServer = "$stunHost:$stunPort"
|
||||||
}
|
}
|
||||||
|
|
||||||
var i = 0
|
var i = 0
|
||||||
while (true) {
|
while (true) {
|
||||||
val ob = account_outbound(accp, i)
|
val ob = account_outbound(accp, i)
|
||||||
@@ -40,6 +43,7 @@ class Account(val accp: String) {
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
i = 0
|
i = 0
|
||||||
while (true) {
|
while (true) {
|
||||||
val ac = account_audio_codec(accp, i)
|
val ac = account_audio_codec(accp, i)
|
||||||
@@ -50,8 +54,12 @@ class Account(val accp: String) {
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
answerMode = Utils.paramValue(account_extra(accp),"answer_mode")
|
|
||||||
|
val extra = account_extra(accp)
|
||||||
|
answerMode = Utils.paramValue(extra,"answer_mode")
|
||||||
if (answerMode == "") answerMode = "manual"
|
if (answerMode == "") answerMode = "manual"
|
||||||
|
callHistory = Utils.paramValue(extra,"call_history") == ""
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun print() : String {
|
fun print() : String {
|
||||||
@@ -99,7 +107,16 @@ class Account(val accp: String) {
|
|||||||
res = res + ";vm_uri=\"$vmUri\""
|
res = res + ";vm_uri=\"$vmUri\""
|
||||||
|
|
||||||
res += ";ptime=20;regint=${regint};regq=0.5;pubint=0;call_transfer=yes"
|
res += ";ptime=20;regint=${regint};regq=0.5;pubint=0;call_transfer=yes"
|
||||||
if (answerMode == "auto") res += ";extra=\"answer_mode=auto\""
|
|
||||||
|
var extra = ""
|
||||||
|
if (!callHistory) extra = "call_history=no"
|
||||||
|
if (answerMode == "auto") {
|
||||||
|
if (extra == "")
|
||||||
|
extra = "answer_mode=auto"
|
||||||
|
else
|
||||||
|
extra += ";answer_mode=auto"
|
||||||
|
}
|
||||||
|
res += ";extra=\"$extra\""
|
||||||
|
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -201,8 +201,10 @@ class BaresipService: Service() {
|
|||||||
val aor = call.ua.account.aor
|
val aor = call.ua.account.aor
|
||||||
Log.d(LOG_TAG, "Aor $aor rejected incoming call $callp from $peerUri")
|
Log.d(LOG_TAG, "Aor $aor rejected incoming call $callp from $peerUri")
|
||||||
Api.ua_hangup(call.ua.uap, callp, 486, "Rejected")
|
Api.ua_hangup(call.ua.uap, callp, 486, "Rejected")
|
||||||
CallHistory.add(CallHistory(aor, peerUri, "in", false))
|
if (call.ua.account.callHistory) {
|
||||||
CallHistory.save(filesPath)
|
CallHistory.add(CallHistory(aor, peerUri, "in", false))
|
||||||
|
CallHistory.save(filesPath)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -409,9 +411,11 @@ class BaresipService: Service() {
|
|||||||
if ((Call.calls().size > 0) || (tm.callState != TelephonyManager.CALL_STATE_IDLE)) {
|
if ((Call.calls().size > 0) || (tm.callState != TelephonyManager.CALL_STATE_IDLE)) {
|
||||||
Log.d(LOG_TAG, "Auto-rejecting incoming call $uap/$callp/$peerUri")
|
Log.d(LOG_TAG, "Auto-rejecting incoming call $uap/$callp/$peerUri")
|
||||||
Api.ua_hangup(uap, callp, 486, "Busy Here")
|
Api.ua_hangup(uap, callp, 486, "Busy Here")
|
||||||
CallHistory.add(CallHistory(aor, peerUri, "in", false))
|
if (ua.account.callHistory) {
|
||||||
CallHistory.save(filesPath)
|
CallHistory.add(CallHistory(aor, peerUri, "in", false))
|
||||||
ua.account.missedCalls = true
|
CallHistory.save(filesPath)
|
||||||
|
ua.account.missedCalls = true
|
||||||
|
}
|
||||||
if (!Utils.isVisible())
|
if (!Utils.isVisible())
|
||||||
return
|
return
|
||||||
newEvent = "call rejected"
|
newEvent = "call rejected"
|
||||||
@@ -486,9 +490,11 @@ class BaresipService: Service() {
|
|||||||
Log.d(LOG_TAG, "AoR $aor call $callp established")
|
Log.d(LOG_TAG, "AoR $aor call $callp established")
|
||||||
call.status = "connected"
|
call.status = "connected"
|
||||||
call.onhold = false
|
call.onhold = false
|
||||||
CallHistory.add(CallHistory(aor, call.peerURI, call.dir, true))
|
if (ua.account.callHistory) {
|
||||||
CallHistory.save(filesPath)
|
CallHistory.add(CallHistory(aor, call.peerURI, call.dir, true))
|
||||||
call.hasHistory = true
|
CallHistory.save(filesPath)
|
||||||
|
call.hasHistory = true
|
||||||
|
}
|
||||||
if (call.dir == "in") {
|
if (call.dir == "in") {
|
||||||
stopRinging()
|
stopRinging()
|
||||||
am.mode = AudioManager.MODE_IN_COMMUNICATION
|
am.mode = AudioManager.MODE_IN_COMMUNICATION
|
||||||
@@ -574,7 +580,7 @@ class BaresipService: Service() {
|
|||||||
Log.d(LOG_TAG, "AoR $aor call $callp is closed")
|
Log.d(LOG_TAG, "AoR $aor call $callp is closed")
|
||||||
if (call.status == "incoming") stopRinging()
|
if (call.status == "incoming") stopRinging()
|
||||||
calls.remove(call)
|
calls.remove(call)
|
||||||
if (!call.hasHistory) {
|
if (ua.account.callHistory && !call.hasHistory) {
|
||||||
CallHistory.add(CallHistory(aor, call.peerURI, call.dir, false))
|
CallHistory.add(CallHistory(aor, call.peerURI, call.dir, false))
|
||||||
CallHistory.save(filesPath)
|
CallHistory.save(filesPath)
|
||||||
if (call.dir == "in") ua.account.missedCalls = true
|
if (call.dir == "in") ua.account.missedCalls = true
|
||||||
|
|||||||
@@ -30,12 +30,12 @@ class CallHistory(val aor: String, val peerURI: String, val direction: String,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun clear(aor: String) {
|
||||||
|
BaresipService.history = ArrayList(BaresipService.history.filter{it.aor != aor})
|
||||||
|
}
|
||||||
|
|
||||||
fun aorHistorySize(aor: String): Int {
|
fun aorHistorySize(aor: String): Int {
|
||||||
var size = 0;
|
return BaresipService.history.filter { it.aor == aor }.count()
|
||||||
for (h in BaresipService.history) {
|
|
||||||
if (h.aor == aor) size++
|
|
||||||
}
|
|
||||||
return size
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun aorLatestHistory(aor: String): CallHistory? {
|
fun aorLatestHistory(aor: String): CallHistory? {
|
||||||
@@ -75,6 +75,11 @@ class CallHistory(val aor: String, val peerURI: String, val direction: String,
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun print() {
|
||||||
|
for (h in BaresipService.history)
|
||||||
|
Log.d("Baresip", "[${h.aor}, ${h.peerURI}, ${h.direction}, ${h.connected}]")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import android.content.Intent
|
|||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.support.v7.app.AlertDialog
|
import android.support.v7.app.AlertDialog
|
||||||
import android.support.v7.app.AppCompatActivity
|
import android.support.v7.app.AppCompatActivity
|
||||||
|
import android.view.Menu
|
||||||
import android.view.MenuItem
|
import android.view.MenuItem
|
||||||
import android.widget.AdapterView
|
import android.widget.AdapterView
|
||||||
import android.widget.ListView
|
import android.widget.ListView
|
||||||
@@ -18,6 +19,9 @@ import java.util.GregorianCalendar
|
|||||||
|
|
||||||
class CallsActivity : AppCompatActivity() {
|
class CallsActivity : AppCompatActivity() {
|
||||||
|
|
||||||
|
internal lateinit var account: Account
|
||||||
|
internal lateinit var adapter: CallListAdapter
|
||||||
|
|
||||||
internal var uaHistory = ArrayList<CallRow>()
|
internal var uaHistory = ArrayList<CallRow>()
|
||||||
internal var aor = ""
|
internal var aor = ""
|
||||||
|
|
||||||
@@ -29,6 +33,7 @@ class CallsActivity : AppCompatActivity() {
|
|||||||
aor = intent.getStringExtra("aor")!!
|
aor = intent.getStringExtra("aor")!!
|
||||||
BaresipService.activities.add(0, "calls,$aor")
|
BaresipService.activities.add(0, "calls,$aor")
|
||||||
val ua = Account.findUa(aor)!!
|
val ua = Account.findUa(aor)!!
|
||||||
|
account = ua.account
|
||||||
|
|
||||||
val headerView = findViewById(R.id.account) as TextView
|
val headerView = findViewById(R.id.account) as TextView
|
||||||
val headerText = "${getString(R.string.account)} ${aor.substringAfter(":")}"
|
val headerText = "${getString(R.string.account)} ${aor.substringAfter(":")}"
|
||||||
@@ -36,7 +41,7 @@ class CallsActivity : AppCompatActivity() {
|
|||||||
|
|
||||||
val listView = findViewById(R.id.calls) as ListView
|
val listView = findViewById(R.id.calls) as ListView
|
||||||
aorGenerateHistory(aor)
|
aorGenerateHistory(aor)
|
||||||
val adapter = CallListAdapter(this, uaHistory)
|
adapter = CallListAdapter(this, uaHistory)
|
||||||
listView.adapter = adapter
|
listView.adapter = adapter
|
||||||
listView.isLongClickable = true
|
listView.isLongClickable = true
|
||||||
|
|
||||||
@@ -70,6 +75,7 @@ class CallsActivity : AppCompatActivity() {
|
|||||||
.setPositiveButton(getString(R.string.send_message), dialogClickListener)
|
.setPositiveButton(getString(R.string.send_message), dialogClickListener)
|
||||||
.show()
|
.show()
|
||||||
}
|
}
|
||||||
|
|
||||||
listView.onItemLongClickListener = AdapterView.OnItemLongClickListener { _, _, pos, _ ->
|
listView.onItemLongClickListener = AdapterView.OnItemLongClickListener { _, _, pos, _ ->
|
||||||
val peerUri = uaHistory[pos].peerURI
|
val peerUri = uaHistory[pos].peerURI
|
||||||
val peerName = ContactsActivity.contactName(peerUri)
|
val peerName = ContactsActivity.contactName(peerUri)
|
||||||
@@ -85,11 +91,6 @@ class CallsActivity : AppCompatActivity() {
|
|||||||
}
|
}
|
||||||
DialogInterface.BUTTON_POSITIVE -> {
|
DialogInterface.BUTTON_POSITIVE -> {
|
||||||
removeUaHistoryAt(pos)
|
removeUaHistoryAt(pos)
|
||||||
if (uaHistory.size == 0) {
|
|
||||||
val i = Intent()
|
|
||||||
setResult(Activity.RESULT_CANCELED, i)
|
|
||||||
finish()
|
|
||||||
}
|
|
||||||
adapter.notifyDataSetChanged()
|
adapter.notifyDataSetChanged()
|
||||||
}
|
}
|
||||||
DialogInterface.BUTTON_NEUTRAL -> {
|
DialogInterface.BUTTON_NEUTRAL -> {
|
||||||
@@ -121,6 +122,7 @@ class CallsActivity : AppCompatActivity() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ua.account.missedCalls = false
|
ua.account.missedCalls = false
|
||||||
|
invalidateOptionsMenu()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onPause() {
|
override fun onPause() {
|
||||||
@@ -134,6 +136,19 @@ class CallsActivity : AppCompatActivity() {
|
|||||||
|
|
||||||
when (item.itemId) {
|
when (item.itemId) {
|
||||||
|
|
||||||
|
R.id.delete_history -> {
|
||||||
|
CallHistory.clear(aor)
|
||||||
|
CallHistory.save(applicationContext.filesDir.absolutePath)
|
||||||
|
aorGenerateHistory(aor)
|
||||||
|
adapter.notifyDataSetChanged()
|
||||||
|
}
|
||||||
|
|
||||||
|
R.id.history_on_off -> {
|
||||||
|
account.callHistory = !account.callHistory
|
||||||
|
invalidateOptionsMenu()
|
||||||
|
AccountsActivity.saveAccounts()
|
||||||
|
}
|
||||||
|
|
||||||
android.R.id.home -> {
|
android.R.id.home -> {
|
||||||
BaresipService.activities.removeAt(0)
|
BaresipService.activities.removeAt(0)
|
||||||
val i = Intent()
|
val i = Intent()
|
||||||
@@ -152,6 +167,24 @@ class CallsActivity : AppCompatActivity() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun onPrepareOptionsMenu(menu: Menu): Boolean {
|
||||||
|
|
||||||
|
if (account.callHistory)
|
||||||
|
menu.findItem(R.id.history_on_off).setTitle(getString(R.string.disable_history))
|
||||||
|
else
|
||||||
|
menu.findItem(R.id.history_on_off).setTitle(getString(R.string.enable_history))
|
||||||
|
return super.onPrepareOptionsMenu(menu)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onCreateOptionsMenu(menu: Menu): Boolean {
|
||||||
|
|
||||||
|
menuInflater.inflate(R.menu.calls_menu, menu)
|
||||||
|
return true
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private fun aorGenerateHistory(aor: String) {
|
private fun aorGenerateHistory(aor: String) {
|
||||||
uaHistory.clear()
|
uaHistory.clear()
|
||||||
for (i in CallHistory.history().indices.reversed()) {
|
for (i in CallHistory.history().indices.reversed()) {
|
||||||
|
|||||||
@@ -144,6 +144,9 @@
|
|||||||
%2$s puheluhistoriasta?
|
%2$s puheluhistoriasta?
|
||||||
</string>
|
</string>
|
||||||
<string name="calls_delete_question">Haluatko poistaa \'%1$s\' %2$s puheluhistoriasta?</string>
|
<string name="calls_delete_question">Haluatko poistaa \'%1$s\' %2$s puheluhistoriasta?</string>
|
||||||
|
<string name="delete_history">Tyhjennä</string>
|
||||||
|
<string name="disable_history">Poista käytöstä</string>
|
||||||
|
<string name="enable_history">Ota käyttöön</string>
|
||||||
<!-- Chat Activity -->
|
<!-- Chat Activity -->
|
||||||
<string name="chat">Viestiketju</string>
|
<string name="chat">Viestiketju</string>
|
||||||
<string name="chat_with">Viestiketju %1$s</string>
|
<string name="chat_with">Viestiketju %1$s</string>
|
||||||
|
|||||||
@@ -129,6 +129,9 @@ Check Apps → baresip → Permissions → Storage and that file \'accounts.bs\'
|
|||||||
</string>
|
</string>
|
||||||
<string name="calls_delete_question">Do you want to delete \'%1$s\' %2$s from call history?
|
<string name="calls_delete_question">Do you want to delete \'%1$s\' %2$s from call history?
|
||||||
</string>
|
</string>
|
||||||
|
<string name="delete_history">Delete</string>
|
||||||
|
<string name="disable_history">Disable</string>
|
||||||
|
<string name="enable_history">Enable</string>
|
||||||
|
|
||||||
<!-- Chat Activity -->
|
<!-- Chat Activity -->
|
||||||
<string name="chat">Chat Messages</string>
|
<string name="chat">Chat Messages</string>
|
||||||
|
|||||||
Reference in New Issue
Block a user