refresh the messages text color if it changes

This commit is contained in:
tibbi 2020-04-03 16:43:35 +02:00
parent 960b16c99b
commit 10bda77c50
2 changed files with 20 additions and 1 deletions

View File

@ -16,10 +16,12 @@ import com.simplemobiletools.commons.models.FAQItem
import com.simplemobiletools.smsmessenger.BuildConfig
import com.simplemobiletools.smsmessenger.R
import com.simplemobiletools.smsmessenger.adapters.MessagesAdapter
import com.simplemobiletools.smsmessenger.extensions.config
import com.simplemobiletools.smsmessenger.models.Message
import kotlinx.android.synthetic.main.activity_main.*
class MainActivity : SimpleActivity() {
private var storedTextColor = 0
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
@ -42,6 +44,18 @@ class MainActivity : SimpleActivity() {
}
}
override fun onResume() {
super.onResume()
if (storedTextColor != config.textColor) {
(messages_list.adapter as? MessagesAdapter)?.updateTextColor(config.textColor)
}
}
override fun onPause() {
super.onPause()
storeStateVariables()
}
override fun onCreateOptionsMenu(menu: Menu): Boolean {
menuInflater.inflate(R.menu.menu, menu)
return true
@ -56,7 +70,12 @@ class MainActivity : SimpleActivity() {
return true
}
private fun storeStateVariables() {
storedTextColor = config.textColor
}
private fun initMessenger() {
storeStateVariables()
val messages = getMessages()
MessagesAdapter(this, messages, messages_list, messages_fastscroller) {

View File

@ -75,7 +75,7 @@ class MessagesAdapter(
message_body_short.alpha = 1f
}
arrayListOf<TextView>(message_address, message_body_short).forEach {
arrayListOf<TextView>(message_address, message_body_short, message_date).forEach {
it.setTextColor(textColor)
}
}