diff --git a/app/src/main/kotlin/com/tutpro/baresip/BaresipService.kt b/app/src/main/kotlin/com/tutpro/baresip/BaresipService.kt index 9ed9138a..97b85bc0 100644 --- a/app/src/main/kotlin/com/tutpro/baresip/BaresipService.kt +++ b/app/src/main/kotlin/com/tutpro/baresip/BaresipService.kt @@ -997,8 +997,7 @@ class BaresipService: Service() { val timeStamp = System.currentTimeMillis() val timeStampString = timeStamp.toString() Log.d(TAG, "Message event for $uap from $peerUri at $timeStampString") - Message(ua.account.aor, peerUri, text, timeStamp, - R.drawable.arrow_down_green, 0, "", true).add() + Message(ua.account.aor, peerUri, text, timeStamp, MESSAGE_DOWN, 0, "", true).add() Message.save() ua.account.unreadMessages = true if (!Utils.isVisible()) { @@ -1068,9 +1067,9 @@ class BaresipService: Service() { for (m in messages.reversed()) if (m.timeStamp == timeStamp) { if (responseCode < 300) { - m.direction = R.drawable.arrow_up_green + m.direction = MESSAGE_UP } else { - m.direction = R.drawable.arrow_up_red + m.direction = MESSAGE_UP_FAIL m.responseCode = responseCode m.responseReason = responseReason } diff --git a/app/src/main/kotlin/com/tutpro/baresip/ChatActivity.kt b/app/src/main/kotlin/com/tutpro/baresip/ChatActivity.kt index 27752aa6..dd7c0682 100644 --- a/app/src/main/kotlin/com/tutpro/baresip/ChatActivity.kt +++ b/app/src/main/kotlin/com/tutpro/baresip/ChatActivity.kt @@ -118,8 +118,7 @@ class ChatActivity : AppCompatActivity() { if (msgText.isNotEmpty()) { imm.hideSoftInputFromWindow(newMessage.windowToken, 0) val time = System.currentTimeMillis() - val msg = Message(aor, peerUri, msgText, time, R.drawable.arrow_up_yellow, - 0, "", true) + val msg = Message(aor, peerUri, msgText, time, MESSAGE_UP_WAIT, 0, "", true) msg.add() var msgUri = "" chatMessages.add(msg) @@ -137,7 +136,7 @@ class ChatActivity : AppCompatActivity() { if (Api.message_send(ua.uap, msgUri, msgText, time.toString()) != 0) { Toast.makeText(applicationContext, "${getString(R.string.message_failed)}!", Toast.LENGTH_SHORT).show() - msg.direction = R.drawable.arrow_up_red + msg.direction = MESSAGE_UP_FAIL msg.responseReason = getString(R.string.message_failed) } else { newMessage.text.clear() diff --git a/app/src/main/kotlin/com/tutpro/baresip/ChatListAdapter.kt b/app/src/main/kotlin/com/tutpro/baresip/ChatListAdapter.kt index bd973a1e..08e9047f 100644 --- a/app/src/main/kotlin/com/tutpro/baresip/ChatListAdapter.kt +++ b/app/src/main/kotlin/com/tutpro/baresip/ChatListAdapter.kt @@ -51,8 +51,7 @@ class ChatListAdapter(private val ctx: Context, private val account: Account, pr else message.peerUri) - if ((message.direction == R.drawable.arrow_down_green) || - (message.direction == R.drawable.arrow_down_red)) + if (message.direction == MESSAGE_DOWN) viewHolder.layoutView.setBackgroundResource(R.drawable.message_in_bg) else viewHolder.layoutView.setBackgroundResource(R.drawable.message_out_bg) @@ -64,7 +63,7 @@ class ChatListAdapter(private val ctx: Context, private val account: Account, pr else DateFormat.getDateInstance(DateFormat.SHORT) viewHolder.infoView.text = fmt.format(cal.time) - if (message.direction == R.drawable.arrow_up_red) { + if (message.direction == MESSAGE_UP_FAIL) { val info: String = if (message.responseCode != 0) "${viewHolder.infoView.text} - ${ctx.getString(R.string.message_failed)}: " + "${message.responseCode} ${message.responseReason}" diff --git a/app/src/main/kotlin/com/tutpro/baresip/Constants.kt b/app/src/main/kotlin/com/tutpro/baresip/Constants.kt index 3521a99a..6fe896bd 100644 --- a/app/src/main/kotlin/com/tutpro/baresip/Constants.kt +++ b/app/src/main/kotlin/com/tutpro/baresip/Constants.kt @@ -29,3 +29,12 @@ const val DELETE_REQ_CODE = 11 const val REGISTRATION_INTERVAL = 900 const val NO_AUTH_PASS = "t%Qa?~?J8,~6" + +const val MESSAGE_DOWN = 2131165304 +const val MESSAGE_UP = 2131165306 +const val MESSAGE_UP_FAIL = 2131165307 +const val MESSAGE_UP_WAIT = 2131165308 + + + + diff --git a/app/src/main/kotlin/com/tutpro/baresip/MessageListAdapter.kt b/app/src/main/kotlin/com/tutpro/baresip/MessageListAdapter.kt index 8f7417b8..ef43070d 100644 --- a/app/src/main/kotlin/com/tutpro/baresip/MessageListAdapter.kt +++ b/app/src/main/kotlin/com/tutpro/baresip/MessageListAdapter.kt @@ -94,8 +94,7 @@ class MessageListAdapter(private val ctx: Context, private val peerUri: String, val message = rows[position] - val down = (message.direction == R.drawable.arrow_down_green) || - (message.direction == R.drawable.arrow_down_red) + val down = message.direction == MESSAGE_DOWN val lp = viewHolder.layoutView.layoutParams as LinearLayout.LayoutParams val peer: String = if (down) { lp.setMargins(0, 10, 75, 10) @@ -123,7 +122,7 @@ class MessageListAdapter(private val ctx: Context, private val peerUri: String, info = fmt.format(cal.time) if (info.length < 6) info = "${ctx.getString(R.string.today)} $info" info = "$info - $peer" - if (message.direction == R.drawable.arrow_up_red) { + if (message.direction == MESSAGE_UP_FAIL) { info = if (message.responseCode != 0) "$info - ${ctx.getString(R.string.message_failed)}: " + "${message.responseCode} ${message.responseReason}" else diff --git a/app/src/main/res/drawable/arrow_down_green.png b/app/src/main/res/drawable/arrow_down_green.png deleted file mode 100644 index b20c9a26..00000000 Binary files a/app/src/main/res/drawable/arrow_down_green.png and /dev/null differ diff --git a/app/src/main/res/drawable/arrow_down_red.png b/app/src/main/res/drawable/arrow_down_red.png deleted file mode 100644 index 04460b1a..00000000 Binary files a/app/src/main/res/drawable/arrow_down_red.png and /dev/null differ diff --git a/app/src/main/res/drawable/arrow_up_green.png b/app/src/main/res/drawable/arrow_up_green.png deleted file mode 100644 index 84131c86..00000000 Binary files a/app/src/main/res/drawable/arrow_up_green.png and /dev/null differ diff --git a/app/src/main/res/drawable/arrow_up_red.png b/app/src/main/res/drawable/arrow_up_red.png deleted file mode 100644 index bab5da03..00000000 Binary files a/app/src/main/res/drawable/arrow_up_red.png and /dev/null differ diff --git a/app/src/main/res/drawable/arrow_up_yellow.png b/app/src/main/res/drawable/arrow_up_yellow.png deleted file mode 100644 index 977cd974..00000000 Binary files a/app/src/main/res/drawable/arrow_up_yellow.png and /dev/null differ