properly update colors when they change

This commit is contained in:
tibbi 2017-12-10 19:24:01 +01:00
parent f6de835584
commit 771ecd5ec4
1 changed files with 24 additions and 1 deletions

View File

@ -7,6 +7,7 @@ import android.view.MenuItem
import com.simplemobiletools.commons.extensions.appLaunched
import com.simplemobiletools.commons.extensions.restartActivity
import com.simplemobiletools.commons.extensions.toast
import com.simplemobiletools.commons.extensions.updateTextColors
import com.simplemobiletools.commons.helpers.LICENSE_KOTLIN
import com.simplemobiletools.commons.helpers.LICENSE_MULTISELECT
import com.simplemobiletools.commons.helpers.PERMISSION_WRITE_CONTACTS
@ -22,6 +23,9 @@ import kotlinx.android.synthetic.main.activity_main.*
class MainActivity : SimpleActivity(), RefreshRecyclerViewListener {
private var storedUseEnglish = false
private var storedTextColor = 0
private var storedBackgroundColor = 0
private var storedPrimaryColor = 0
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
@ -47,6 +51,20 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener {
restartActivity()
return
}
if (storedTextColor != config.textColor) {
(contacts_list.adapter as ContactsAdapter).apply {
updateTextColor(config.textColor)
initDrawables()
}
}
if (storedPrimaryColor != config.primaryColor) {
contacts_fastscroller.updatePrimaryColor()
}
contacts_fastscroller.updateBubbleColors()
updateTextColors(contacts_holder)
}
override fun onPause() {
@ -80,7 +98,12 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener {
}
private fun storeStateVariables() {
storedUseEnglish = config.useEnglish
config.apply {
storedUseEnglish = useEnglish
storedTextColor = textColor
storedBackgroundColor = backgroundColor
storedPrimaryColor = primaryColor
}
}
private fun initContacts() {