Handle message rerponse already in baresip service
This commit is contained in:
@@ -960,12 +960,26 @@ class BaresipService: Service() {
|
|||||||
@Suppress("UNUSED")
|
@Suppress("UNUSED")
|
||||||
fun messageResponse(responseCode: Int, responseReason: String, time: String) {
|
fun messageResponse(responseCode: Int, responseReason: String, time: String) {
|
||||||
Log.d(TAG, "Message response '$responseCode $responseReason' at $time")
|
Log.d(TAG, "Message response '$responseCode $responseReason' at $time")
|
||||||
|
val timeStamp = time.toLong()
|
||||||
|
for (m in messages.reversed())
|
||||||
|
if (m.timeStamp == timeStamp) {
|
||||||
|
if (responseCode < 300) {
|
||||||
|
m.direction = R.drawable.arrow_up_green
|
||||||
|
} else {
|
||||||
|
m.direction = R.drawable.arrow_up_red
|
||||||
|
m.responseCode = responseCode
|
||||||
|
m.responseReason = responseReason
|
||||||
|
}
|
||||||
|
break
|
||||||
|
}
|
||||||
|
if (Utils.isVisible()) {
|
||||||
val intent = Intent("message response")
|
val intent = Intent("message response")
|
||||||
intent.putExtra("response code", responseCode)
|
intent.putExtra("response code", responseCode)
|
||||||
intent.putExtra("response reason", responseReason)
|
intent.putExtra("response reason", responseReason)
|
||||||
intent.putExtra("time", time)
|
intent.putExtra("time", time)
|
||||||
LocalBroadcastManager.getInstance(this).sendBroadcast(intent)
|
LocalBroadcastManager.getInstance(this).sendBroadcast(intent)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Keep
|
@Keep
|
||||||
fun getPassword(aor: String): String {
|
fun getPassword(aor: String): String {
|
||||||
|
|||||||
@@ -161,9 +161,7 @@ class ChatActivity : AppCompatActivity() {
|
|||||||
|
|
||||||
messageResponseReceiver = object : BroadcastReceiver() {
|
messageResponseReceiver = object : BroadcastReceiver() {
|
||||||
override fun onReceive(context: Context, intent: Intent) {
|
override fun onReceive(context: Context, intent: Intent) {
|
||||||
handleMessageResponse(intent.getIntExtra("response code", 0),
|
mlAdapter.notifyDataSetChanged()
|
||||||
intent.getStringExtra("response reason")!!,
|
|
||||||
intent.getStringExtra("time")!!)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -274,20 +272,4 @@ class ChatActivity : AppCompatActivity() {
|
|||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun handleMessageResponse(responseCode: Int, responseReason: String, time: String) {
|
|
||||||
val timeStamp = time.toLong()
|
|
||||||
for (m in chatMessages.reversed())
|
|
||||||
if (m.timeStamp == timeStamp) {
|
|
||||||
if (responseCode < 300) {
|
|
||||||
m.direction = R.drawable.arrow_up_green
|
|
||||||
} else {
|
|
||||||
m.direction = R.drawable.arrow_up_red
|
|
||||||
m.responseCode = responseCode
|
|
||||||
m.responseReason = responseReason
|
|
||||||
}
|
|
||||||
mlAdapter.notifyDataSetChanged()
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user