Suppress warnings from CallHistory
This commit is contained in:
@@ -13,6 +13,7 @@ import android.view.MenuItem
|
|||||||
import android.view.View
|
import android.view.View
|
||||||
import android.widget.AdapterView
|
import android.widget.AdapterView
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
|
import androidx.activity.result.contract.ActivityResultContracts
|
||||||
import com.tutpro.baresip.databinding.ActivityCallsBinding
|
import com.tutpro.baresip.databinding.ActivityCallsBinding
|
||||||
|
|
||||||
import java.util.ArrayList
|
import java.util.ArrayList
|
||||||
@@ -88,6 +89,13 @@ class CallsActivity : AppCompatActivity() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val contactRequest =
|
||||||
|
registerForActivityResult(ActivityResultContracts.StartActivityForResult()) {
|
||||||
|
if (it.resultCode == RESULT_OK) {
|
||||||
|
clAdapter.notifyDataSetChanged()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
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)
|
||||||
@@ -99,7 +107,7 @@ class CallsActivity : AppCompatActivity() {
|
|||||||
b.putBoolean("new", true)
|
b.putBoolean("new", true)
|
||||||
b.putString("uri", peerUri)
|
b.putString("uri", peerUri)
|
||||||
i.putExtras(b)
|
i.putExtras(b)
|
||||||
startActivityForResult(i, MainActivity.CONTACT_CODE)
|
contactRequest.launch(i)
|
||||||
}
|
}
|
||||||
DialogInterface.BUTTON_POSITIVE -> {
|
DialogInterface.BUTTON_POSITIVE -> {
|
||||||
removeUaHistoryAt(pos)
|
removeUaHistoryAt(pos)
|
||||||
@@ -110,11 +118,10 @@ class CallsActivity : AppCompatActivity() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
val callText: String
|
val callText: String = if (uaHistory[pos].directions.size > 1)
|
||||||
if (uaHistory[pos].directions.size > 1)
|
getString(R.string.calls_calls)
|
||||||
callText = getString(R.string.calls_calls)
|
|
||||||
else
|
else
|
||||||
callText = getString(R.string.calls_call)
|
getString(R.string.calls_call)
|
||||||
val builder = AlertDialog.Builder(this@CallsActivity, R.style.Theme_AppCompat)
|
val builder = AlertDialog.Builder(this@CallsActivity, R.style.Theme_AppCompat)
|
||||||
if (peerName.startsWith("sip:"))
|
if (peerName.startsWith("sip:"))
|
||||||
with (builder) {
|
with (builder) {
|
||||||
@@ -140,14 +147,6 @@ class CallsActivity : AppCompatActivity() {
|
|||||||
invalidateOptionsMenu()
|
invalidateOptionsMenu()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
|
||||||
|
|
||||||
super.onActivityResult(requestCode, resultCode, data)
|
|
||||||
|
|
||||||
if (resultCode == RESULT_OK) clAdapter.notifyDataSetChanged()
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||||
|
|
||||||
if (BaresipService.activities.indexOf("calls,$aor") == -1)
|
if (BaresipService.activities.indexOf("calls,$aor") == -1)
|
||||||
@@ -231,26 +230,24 @@ class CallsActivity : AppCompatActivity() {
|
|||||||
for (i in BaresipService.callHistory.indices.reversed()) {
|
for (i in BaresipService.callHistory.indices.reversed()) {
|
||||||
val h = BaresipService.callHistory[i]
|
val h = BaresipService.callHistory[i]
|
||||||
if (h.aor == aor) {
|
if (h.aor == aor) {
|
||||||
var direction: Int
|
val direction: Int = if (h.direction == "in")
|
||||||
if (h.direction == "in")
|
|
||||||
if (h.connected)
|
if (h.connected)
|
||||||
direction = R.drawable.arrow_down_green
|
R.drawable.arrow_down_green
|
||||||
else
|
else
|
||||||
direction = R.drawable.arrow_down_red
|
R.drawable.arrow_down_red
|
||||||
else
|
else
|
||||||
if (h.connected)
|
if (h.connected)
|
||||||
direction = R.drawable.arrow_up_green
|
R.drawable.arrow_up_green
|
||||||
else
|
else
|
||||||
direction = R.drawable.arrow_up_red
|
R.drawable.arrow_up_red
|
||||||
if (uaHistory.isNotEmpty() && (uaHistory.last().peerUri == h.peerUri)) {
|
if (uaHistory.isNotEmpty() && (uaHistory.last().peerUri == h.peerUri)) {
|
||||||
uaHistory.last().directions.add(direction)
|
uaHistory.last().directions.add(direction)
|
||||||
uaHistory.last().indexes.add(i)
|
uaHistory.last().indexes.add(i)
|
||||||
} else {
|
} else {
|
||||||
val fmt: DateFormat
|
val fmt: DateFormat = if (isToday(h.time.timeInMillis))
|
||||||
if (isToday(h.time.timeInMillis))
|
DateFormat.getTimeInstance(DateFormat.SHORT)
|
||||||
fmt = DateFormat.getTimeInstance(DateFormat.SHORT)
|
|
||||||
else
|
else
|
||||||
fmt = DateFormat.getDateInstance(DateFormat.SHORT)
|
DateFormat.getDateInstance(DateFormat.SHORT)
|
||||||
val time = fmt.format(h.time.time)
|
val time = fmt.format(h.time.time)
|
||||||
uaHistory.add(CallRow(h.aor, h.peerUri, direction, time, i))
|
uaHistory.add(CallRow(h.aor, h.peerUri, direction, time, i))
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user