Correct how sms length is calculated (@tswistak)

This commit is contained in:
Spitap 2022-03-11 13:14:55 +01:00
parent 277b16762c
commit baf9c4a832
No known key found for this signature in database
GPG Key ID: 66DC115FB72EDC69

View File

@ -12,6 +12,7 @@ import android.os.Bundle
import android.os.Handler import android.os.Handler
import android.provider.ContactsContract import android.provider.ContactsContract
import android.provider.Telephony import android.provider.Telephony
import android.telephony.SmsMessage
import android.telephony.SubscriptionManager import android.telephony.SubscriptionManager
import android.text.TextUtils import android.text.TextUtils
import android.util.TypedValue import android.util.TypedValue
@ -352,7 +353,6 @@ class ThreadActivity : SimpleActivity() {
val adjustedPrimaryColor = getAdjustedPrimaryColor() val adjustedPrimaryColor = getAdjustedPrimaryColor()
thread_messages_fastscroller.updateColors(adjustedPrimaryColor) thread_messages_fastscroller.updateColors(adjustedPrimaryColor)
thread_character_counter.beVisibleIf(config.showCharacterCounter) thread_character_counter.beVisibleIf(config.showCharacterCounter)
thread_character_counter.setTextSize(TypedValue.COMPLEX_UNIT_PX, getTextSize()) thread_character_counter.setTextSize(TypedValue.COMPLEX_UNIT_PX, getTextSize())
@ -364,10 +364,9 @@ class ThreadActivity : SimpleActivity() {
thread_send_message.isClickable = false thread_send_message.isClickable = false
thread_type_message.onTextChangeListener { thread_type_message.onTextChangeListener {
checkSendMessageAvailability() checkSendMessageAvailability()
val messageLength = it.length val messageLength = SmsMessage.calculateLength(it, config.useSimpleCharacters)
val messageCounter: Int = messageLength / 160
@SuppressLint("SetTextI18n") @SuppressLint("SetTextI18n")
thread_character_counter.text = (160 - messageLength % 160).toString() + "/" + messageCounter.toString() thread_character_counter.text = messageLength[2].toString() + "/" + messageLength[0].toString()
} }
confirm_manage_contacts.setOnClickListener { confirm_manage_contacts.setOnClickListener {