mirror of
https://github.com/SimpleMobileTools/Simple-Contacts.git
synced 2025-02-02 17:07:08 +01:00
updating the way view colors are set
This commit is contained in:
parent
20df1db399
commit
49241363a1
@ -59,9 +59,6 @@ class MainActivity : SimpleActivity(), RefreshContactsListener {
|
|||||||
private var isGettingContacts = false
|
private var isGettingContacts = false
|
||||||
private var ignoredExportContactSources = HashSet<String>()
|
private var ignoredExportContactSources = HashSet<String>()
|
||||||
|
|
||||||
private var storedTextColor = 0
|
|
||||||
private var storedBackgroundColor = 0
|
|
||||||
private var storedPrimaryColor = 0
|
|
||||||
private var storedShowContactThumbnails = false
|
private var storedShowContactThumbnails = false
|
||||||
private var storedShowPhoneNumbers = false
|
private var storedShowPhoneNumbers = false
|
||||||
private var storedStartNameWithSurname = false
|
private var storedStartNameWithSurname = false
|
||||||
@ -114,29 +111,14 @@ class MainActivity : SimpleActivity(), RefreshContactsListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val configTextColor = config.textColor
|
val adjustedPrimaryColor = getAdjustedPrimaryColor()
|
||||||
if (storedTextColor != configTextColor) {
|
main_tabs_holder.background = ColorDrawable(config.backgroundColor)
|
||||||
getInactiveTabIndexes(viewpager.currentItem).forEach {
|
main_tabs_holder.setSelectedTabIndicatorColor(adjustedPrimaryColor)
|
||||||
main_tabs_holder.getTabAt(it)?.icon?.applyColorFilter(configTextColor)
|
|
||||||
}
|
|
||||||
getAllFragments().forEach {
|
getAllFragments().forEach {
|
||||||
it?.textColorChanged(configTextColor)
|
it?.setupColors(config.textColor, adjustedPrimaryColor)
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
val configBackgroundColor = config.backgroundColor
|
updateTabColors()
|
||||||
if (storedBackgroundColor != configBackgroundColor) {
|
|
||||||
main_tabs_holder.background = ColorDrawable(configBackgroundColor)
|
|
||||||
}
|
|
||||||
|
|
||||||
val configPrimaryColor = config.primaryColor
|
|
||||||
if (storedPrimaryColor != configPrimaryColor) {
|
|
||||||
main_tabs_holder.setSelectedTabIndicatorColor(getAdjustedPrimaryColor())
|
|
||||||
main_tabs_holder.getTabAt(viewpager.currentItem)?.icon?.applyColorFilter(getAdjustedPrimaryColor())
|
|
||||||
getAllFragments().forEach {
|
|
||||||
it?.primaryColorChanged()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
val configStartNameWithSurname = config.startNameWithSurname
|
val configStartNameWithSurname = config.startNameWithSurname
|
||||||
if (storedStartNameWithSurname != configStartNameWithSurname) {
|
if (storedStartNameWithSurname != configStartNameWithSurname) {
|
||||||
@ -156,17 +138,13 @@ class MainActivity : SimpleActivity(), RefreshContactsListener {
|
|||||||
initFragments()
|
initFragments()
|
||||||
} else {
|
} else {
|
||||||
refreshContacts(ALL_TABS_MASK)
|
refreshContacts(ALL_TABS_MASK)
|
||||||
|
|
||||||
getAllFragments().forEach {
|
|
||||||
it?.onActivityResume()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val dialpadIcon = resources.getColoredDrawableWithColor(R.drawable.ic_dialpad_vector, getFABIconColor())
|
val dialpadIcon = resources.getColoredDrawableWithColor(R.drawable.ic_dialpad_vector, adjustedPrimaryColor.getContrastColor())
|
||||||
main_dialpad_button.apply {
|
main_dialpad_button.apply {
|
||||||
setImageDrawable(dialpadIcon)
|
setImageDrawable(dialpadIcon)
|
||||||
background.applyColorFilter(getAdjustedPrimaryColor())
|
background.applyColorFilter(adjustedPrimaryColor)
|
||||||
beVisibleIf(config.showDialpadButton)
|
beVisibleIf(config.showDialpadButton)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -233,9 +211,6 @@ class MainActivity : SimpleActivity(), RefreshContactsListener {
|
|||||||
|
|
||||||
private fun storeStateVariables() {
|
private fun storeStateVariables() {
|
||||||
config.apply {
|
config.apply {
|
||||||
storedTextColor = textColor
|
|
||||||
storedBackgroundColor = backgroundColor
|
|
||||||
storedPrimaryColor = primaryColor
|
|
||||||
storedShowContactThumbnails = showContactThumbnails
|
storedShowContactThumbnails = showContactThumbnails
|
||||||
storedShowPhoneNumbers = showPhoneNumbers
|
storedShowPhoneNumbers = showPhoneNumbers
|
||||||
storedStartNameWithSurname = startNameWithSurname
|
storedStartNameWithSurname = startNameWithSurname
|
||||||
@ -280,6 +255,13 @@ class MainActivity : SimpleActivity(), RefreshContactsListener {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun updateTabColors() {
|
||||||
|
getInactiveTabIndexes(viewpager.currentItem).forEach {
|
||||||
|
main_tabs_holder.getTabAt(it)?.icon?.applyColorFilter(config.textColor)
|
||||||
|
}
|
||||||
|
main_tabs_holder.getTabAt(viewpager.currentItem)?.icon?.applyColorFilter(getAdjustedPrimaryColor())
|
||||||
|
}
|
||||||
|
|
||||||
private fun getSearchString(): Int {
|
private fun getSearchString(): Int {
|
||||||
return when (getCurrentFragment()) {
|
return when (getCurrentFragment()) {
|
||||||
favorites_fragment -> R.string.search_favorites
|
favorites_fragment -> R.string.search_favorites
|
||||||
@ -567,6 +549,7 @@ class MainActivity : SimpleActivity(), RefreshContactsListener {
|
|||||||
if (viewpager.adapter == null) {
|
if (viewpager.adapter == null) {
|
||||||
viewpager.adapter = ViewPagerAdapter(this, tabsList, config.showTabs)
|
viewpager.adapter = ViewPagerAdapter(this, tabsList, config.showTabs)
|
||||||
viewpager.currentItem = getDefaultTab()
|
viewpager.currentItem = getDefaultTab()
|
||||||
|
updateTabColors()
|
||||||
}
|
}
|
||||||
|
|
||||||
ContactsHelper(this).getContacts { contacts ->
|
ContactsHelper(this).getContacts { contacts ->
|
||||||
|
@ -3,11 +3,13 @@ package com.simplemobiletools.contacts.pro.adapters
|
|||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import androidx.viewpager.widget.PagerAdapter
|
import androidx.viewpager.widget.PagerAdapter
|
||||||
|
import com.simplemobiletools.commons.extensions.getAdjustedPrimaryColor
|
||||||
import com.simplemobiletools.commons.helpers.TAB_CONTACTS
|
import com.simplemobiletools.commons.helpers.TAB_CONTACTS
|
||||||
import com.simplemobiletools.commons.helpers.TAB_FAVORITES
|
import com.simplemobiletools.commons.helpers.TAB_FAVORITES
|
||||||
import com.simplemobiletools.commons.helpers.TAB_GROUPS
|
import com.simplemobiletools.commons.helpers.TAB_GROUPS
|
||||||
import com.simplemobiletools.contacts.pro.R
|
import com.simplemobiletools.contacts.pro.R
|
||||||
import com.simplemobiletools.contacts.pro.activities.SimpleActivity
|
import com.simplemobiletools.contacts.pro.activities.SimpleActivity
|
||||||
|
import com.simplemobiletools.contacts.pro.extensions.config
|
||||||
import com.simplemobiletools.contacts.pro.fragments.MyViewPagerFragment
|
import com.simplemobiletools.contacts.pro.fragments.MyViewPagerFragment
|
||||||
|
|
||||||
class ViewPagerAdapter(val activity: SimpleActivity, val currTabsList: ArrayList<Int>, val showTabs: Int) : PagerAdapter() {
|
class ViewPagerAdapter(val activity: SimpleActivity, val currTabsList: ArrayList<Int>, val showTabs: Int) : PagerAdapter() {
|
||||||
@ -19,6 +21,7 @@ class ViewPagerAdapter(val activity: SimpleActivity, val currTabsList: ArrayList
|
|||||||
|
|
||||||
(view as MyViewPagerFragment).apply {
|
(view as MyViewPagerFragment).apply {
|
||||||
setupFragment(activity)
|
setupFragment(activity)
|
||||||
|
setupColors(activity.config.textColor, activity.getAdjustedPrimaryColor())
|
||||||
}
|
}
|
||||||
|
|
||||||
return view
|
return view
|
||||||
|
@ -2,6 +2,7 @@ package com.simplemobiletools.contacts.pro.dialogs
|
|||||||
|
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import androidx.appcompat.app.AlertDialog
|
import androidx.appcompat.app.AlertDialog
|
||||||
|
import com.simplemobiletools.commons.extensions.getAdjustedPrimaryColor
|
||||||
import com.simplemobiletools.commons.extensions.setupDialogStuff
|
import com.simplemobiletools.commons.extensions.setupDialogStuff
|
||||||
import com.simplemobiletools.commons.views.MyAppCompatCheckbox
|
import com.simplemobiletools.commons.views.MyAppCompatCheckbox
|
||||||
import com.simplemobiletools.contacts.pro.R
|
import com.simplemobiletools.contacts.pro.R
|
||||||
@ -51,11 +52,12 @@ class SelectGroupsDialog(val activity: SimpleActivity, val selectedGroups: Array
|
|||||||
item_checkbox_holder.setOnClickListener {
|
item_checkbox_holder.setOnClickListener {
|
||||||
item_checkbox.toggle()
|
item_checkbox.toggle()
|
||||||
}
|
}
|
||||||
|
|
||||||
item_checkbox.apply {
|
item_checkbox.apply {
|
||||||
isChecked = selectedGroups.contains(group)
|
isChecked = selectedGroups.contains(group)
|
||||||
text = group.title
|
text = group.title
|
||||||
tag = group.id
|
tag = group.id
|
||||||
setColors(config.textColor, config.primaryColor, config.backgroundColor)
|
setColors(config.textColor, activity.getAdjustedPrimaryColor(), config.backgroundColor)
|
||||||
}
|
}
|
||||||
view.dialog_groups_holder.addView(this)
|
view.dialog_groups_holder.addView(this)
|
||||||
}
|
}
|
||||||
|
@ -61,7 +61,6 @@ abstract class MyViewPagerFragment(context: Context, attributeSet: AttributeSet)
|
|||||||
}
|
}
|
||||||
|
|
||||||
fragment_placeholder_2?.underlineText()
|
fragment_placeholder_2?.underlineText()
|
||||||
updateViewStuff()
|
|
||||||
|
|
||||||
when {
|
when {
|
||||||
this is FavoritesFragment -> {
|
this is FavoritesFragment -> {
|
||||||
@ -76,22 +75,24 @@ abstract class MyViewPagerFragment(context: Context, attributeSet: AttributeSet)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun textColorChanged(color: Int) {
|
fun setupColors(textColor: Int, adjustedPrimaryColor: Int) {
|
||||||
when {
|
when {
|
||||||
this is GroupsFragment -> (fragment_list.adapter as GroupsAdapter).updateTextColor(color)
|
this is GroupsFragment -> (fragment_list.adapter as? GroupsAdapter)?.updateTextColor(textColor)
|
||||||
else -> (fragment_list.adapter as? ContactsAdapter)?.apply {
|
else -> (fragment_list.adapter as? ContactsAdapter)?.apply {
|
||||||
updateTextColor(color)
|
updateTextColor(textColor)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
letter_fastscroller?.textColor = color.getColorStateList()
|
letter_fastscroller?.textColor = textColor.getColorStateList()
|
||||||
}
|
|
||||||
|
|
||||||
fun primaryColorChanged() {
|
|
||||||
fragment_fastscroller?.updatePrimaryColor()
|
fragment_fastscroller?.updatePrimaryColor()
|
||||||
fragment_fastscroller?.updateBubblePrimaryColor()
|
fragment_fastscroller?.updateBubblePrimaryColor()
|
||||||
letter_fastscroller_thumb?.thumbColor = config.primaryColor.getColorStateList()
|
|
||||||
letter_fastscroller_thumb?.textColor = config.primaryColor.getContrastColor()
|
letter_fastscroller_thumb?.fontSize = context.getTextSize()
|
||||||
|
letter_fastscroller_thumb?.textColor = adjustedPrimaryColor.getContrastColor()
|
||||||
|
letter_fastscroller_thumb?.thumbColor = adjustedPrimaryColor.getColorStateList()
|
||||||
|
|
||||||
|
context.updateTextColors(fragment_wrapper.parent as ViewGroup)
|
||||||
|
fragment_placeholder_2?.setTextColor(adjustedPrimaryColor)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun startNameWithSurnameChanged(startNameWithSurname: Boolean) {
|
fun startNameWithSurnameChanged(startNameWithSurname: Boolean) {
|
||||||
@ -143,11 +144,8 @@ abstract class MyViewPagerFragment(context: Context, attributeSet: AttributeSet)
|
|||||||
} else {
|
} else {
|
||||||
setupContactsFavoritesAdapter(contacts)
|
setupContactsFavoritesAdapter(contacts)
|
||||||
contactsIgnoringSearch = (fragment_list?.adapter as? ContactsAdapter)?.contactItems ?: ArrayList()
|
contactsIgnoringSearch = (fragment_list?.adapter as? ContactsAdapter)?.contactItems ?: ArrayList()
|
||||||
|
|
||||||
letter_fastscroller.textColor = config.textColor.getColorStateList()
|
|
||||||
setupLetterFastscroller(contacts)
|
setupLetterFastscroller(contacts)
|
||||||
letter_fastscroller_thumb.setupWithFastScroller(letter_fastscroller)
|
letter_fastscroller_thumb.setupWithFastScroller(letter_fastscroller)
|
||||||
letter_fastscroller_thumb.textColor = config.primaryColor.getContrastColor()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -274,10 +272,6 @@ abstract class MyViewPagerFragment(context: Context, attributeSet: AttributeSet)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun onActivityResume() {
|
|
||||||
updateViewStuff()
|
|
||||||
}
|
|
||||||
|
|
||||||
fun finishActMode() {
|
fun finishActMode() {
|
||||||
(fragment_list.adapter as? MyRecyclerViewAdapter)?.finishActMode()
|
(fragment_list.adapter as? MyRecyclerViewAdapter)?.finishActMode()
|
||||||
}
|
}
|
||||||
@ -348,13 +342,6 @@ abstract class MyViewPagerFragment(context: Context, attributeSet: AttributeSet)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updateViewStuff() {
|
|
||||||
context.updateTextColors(fragment_wrapper.parent as ViewGroup)
|
|
||||||
fragment_fastscroller?.updateBubbleColors()
|
|
||||||
fragment_placeholder_2?.setTextColor(context.getAdjustedPrimaryColor())
|
|
||||||
letter_fastscroller_thumb?.fontSize = context.getTextSize()
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun setupViewVisibility(hasItemsToShow: Boolean) {
|
private fun setupViewVisibility(hasItemsToShow: Boolean) {
|
||||||
fragment_placeholder_2?.beVisibleIf(!hasItemsToShow)
|
fragment_placeholder_2?.beVisibleIf(!hasItemsToShow)
|
||||||
fragment_placeholder?.beVisibleIf(!hasItemsToShow)
|
fragment_placeholder?.beVisibleIf(!hasItemsToShow)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user