Added removing diacritics (#29)
This commit is contained in:
parent
72833f6f16
commit
b212aa49b3
28 changed files with 75 additions and 2 deletions
|
|
@ -40,6 +40,7 @@ class SettingsActivity : SimpleActivity() {
|
|||
setupChangeDateTimeFormat()
|
||||
setupFontSize()
|
||||
setupShowCharacterCounter()
|
||||
setupUseSimpleCharacters()
|
||||
setupEnableDeliveryReports()
|
||||
setupLockScreenVisibility()
|
||||
updateTextColors(settings_scrollview)
|
||||
|
|
@ -131,6 +132,13 @@ class SettingsActivity : SimpleActivity() {
|
|||
config.showCharacterCounter = settings_show_character_counter.isChecked
|
||||
}
|
||||
}
|
||||
private fun setupUseSimpleCharacters() {
|
||||
settings_use_simple_characters.isChecked = config.useSimpleCharacters
|
||||
settings_use_simple_characters_holder.setOnClickListener {
|
||||
settings_use_simple_characters.toggle()
|
||||
config.useSimpleCharacters = settings_use_simple_characters.isChecked
|
||||
}
|
||||
}
|
||||
|
||||
private fun setupEnableDeliveryReports() {
|
||||
settings_enable_delivery_reports.isChecked = config.enableDeliveryReports
|
||||
|
|
|
|||
|
|
@ -646,11 +646,13 @@ class ThreadActivity : SimpleActivity() {
|
|||
}
|
||||
|
||||
private fun sendMessage() {
|
||||
val msg = thread_type_message.value
|
||||
var msg = thread_type_message.value
|
||||
if (msg.isEmpty() && attachmentUris.isEmpty()) {
|
||||
return
|
||||
}
|
||||
|
||||
msg = removeDiacriticsIfNeeded(msg)
|
||||
|
||||
val numbers = ArrayList<String>()
|
||||
participants.forEach {
|
||||
it.phoneNumbers.forEach {
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@ import com.simplemobiletools.smsmessenger.receivers.MarkAsReadReceiver
|
|||
import java.util.*
|
||||
import kotlin.collections.ArrayList
|
||||
import me.leolin.shortcutbadger.ShortcutBadger
|
||||
import java.text.Normalizer
|
||||
|
||||
val Context.config: Config get() = Config.newInstance(applicationContext)
|
||||
|
||||
|
|
@ -764,3 +765,13 @@ fun Context.getLockScreenVisibilityText(type: Int) = getString(
|
|||
else -> R.string.nothing
|
||||
}
|
||||
)
|
||||
|
||||
fun Context.removeDiacriticsIfNeeded(text: String): String {
|
||||
var msg = text
|
||||
if (config.useSimpleCharacters) {
|
||||
msg = Normalizer.normalize(msg, Normalizer.Form.NFD)
|
||||
msg = msg.replace("\\p{InCombiningDiacriticalMarks}+".toRegex(), "")
|
||||
}
|
||||
|
||||
return msg
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,6 +18,10 @@ class Config(context: Context) : BaseConfig(context) {
|
|||
get() = prefs.getBoolean(SHOW_CHARACTER_COUNTER, false)
|
||||
set(showCharacterCounter) = prefs.edit().putBoolean(SHOW_CHARACTER_COUNTER, showCharacterCounter).apply()
|
||||
|
||||
var useSimpleCharacters: Boolean
|
||||
get() = prefs.getBoolean(USE_SIMPLE_CHARACTERS, false)
|
||||
set(useSimpleCharacters) = prefs.edit().putBoolean(USE_SIMPLE_CHARACTERS, useSimpleCharacters).apply()
|
||||
|
||||
var enableDeliveryReports: Boolean
|
||||
get() = prefs.getBoolean(ENABLE_DELIVERY_REPORTS, true)
|
||||
set(enableDeliveryReports) = prefs.edit().putBoolean(ENABLE_DELIVERY_REPORTS, enableDeliveryReports).apply()
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ const val SEARCHED_MESSAGE_ID = "searched_message_id"
|
|||
const val USE_SIM_ID_PREFIX = "use_sim_id_"
|
||||
const val NOTIFICATION_CHANNEL = "simple_sms_messenger"
|
||||
const val SHOW_CHARACTER_COUNTER = "show_character_counter"
|
||||
const val USE_SIMPLE_CHARACTERS = "use_simple_characters"
|
||||
const val LOCK_SCREEN_VISIBILITY = "lock_screen_visibility"
|
||||
const val ENABLE_DELIVERY_REPORTS = "enable_delivery_reports"
|
||||
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ import com.simplemobiletools.commons.extensions.showErrorToast
|
|||
import com.simplemobiletools.commons.helpers.ensureBackgroundThread
|
||||
import com.simplemobiletools.smsmessenger.extensions.conversationsDB
|
||||
import com.simplemobiletools.smsmessenger.extensions.markThreadMessagesRead
|
||||
import com.simplemobiletools.smsmessenger.extensions.removeDiacriticsIfNeeded
|
||||
import com.simplemobiletools.smsmessenger.helpers.REPLY
|
||||
import com.simplemobiletools.smsmessenger.helpers.THREAD_ID
|
||||
import com.simplemobiletools.smsmessenger.helpers.THREAD_NUMBER
|
||||
|
|
@ -19,7 +20,9 @@ class DirectReplyReceiver : BroadcastReceiver() {
|
|||
override fun onReceive(context: Context, intent: Intent) {
|
||||
val address = intent.getStringExtra(THREAD_NUMBER)
|
||||
val threadId = intent.getLongExtra(THREAD_ID, 0L)
|
||||
val msg = RemoteInput.getResultsFromIntent(intent).getCharSequence(REPLY)?.toString() ?: return
|
||||
var msg = RemoteInput.getResultsFromIntent(intent).getCharSequence(REPLY)?.toString() ?: return
|
||||
|
||||
msg = context.removeDiacriticsIfNeeded(msg)
|
||||
|
||||
val settings = Settings()
|
||||
settings.useSystemSending = true
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue