@@ -57,6 +57,7 @@ class RecentCallsAdapter(
5757 private var durationPadding = resources.getDimension(R .dimen.normal_margin).toInt()
5858 private var phoneNumberUtilInstance: PhoneNumberUtil = PhoneNumberUtil .getInstance()
5959 private var phoneNumberOfflineGeocoderInstance: PhoneNumberOfflineGeocoder = PhoneNumberOfflineGeocoder .getInstance()
60+ private val cachedSimColors = HashMap <Pair <Int ,Int >, Int > ()
6061
6162 init {
6263 initDrawables()
@@ -537,8 +538,9 @@ class RecentCallsAdapter(
537538 itemRecentsSimImage.beVisibleIf(areMultipleSIMsAvailable && call.simID != - 1 )
538539 itemRecentsSimId.beVisibleIf(areMultipleSIMsAvailable && call.simID != - 1 )
539540 if (areMultipleSIMsAvailable && call.simID != - 1 ) {
540- itemRecentsSimImage.applyColorFilter(call.simColor.adjustSimColorForBackground(backgroundColor))
541- itemRecentsSimId.setTextColor(backgroundColor)
541+ val simColor = getAdjustedSimColor(call.simColor)
542+ itemRecentsSimImage.applyColorFilter(simColor)
543+ itemRecentsSimId.setTextColor(simColor.getContrastColor())
542544 itemRecentsSimId.text = call.simID.toString()
543545 }
544546
@@ -583,6 +585,12 @@ class RecentCallsAdapter(
583585 }
584586 }
585587
588+ private fun getAdjustedSimColor (simColor : Int ): Int {
589+ return cachedSimColors.getOrPut(simColor to backgroundColor) {
590+ simColor.adjustForContrast(backgroundColor)
591+ }
592+ }
593+
586594 private inner class RecentCallDateViewHolder (val binding : ItemRecentsDateBinding ) : ViewHolder(binding.root) {
587595 fun bind (date : CallLogItem .Date ) {
588596 binding.dateTextView.apply {
0 commit comments