diff --git a/app/src/main/kotlin/org/fossify/phone/activities/CallActivity.kt b/app/src/main/kotlin/org/fossify/phone/activities/CallActivity.kt index a78457b37..ab076ddaf 100644 --- a/app/src/main/kotlin/org/fossify/phone/activities/CallActivity.kt +++ b/app/src/main/kotlin/org/fossify/phone/activities/CallActivity.kt @@ -617,14 +617,15 @@ class CallActivity : SimpleActivity() { @SuppressLint("MissingPermission") private fun checkCalledSIMCard() { try { - val accounts = telecomManager.callCapablePhoneAccounts - if (accounts.size > 1) { - accounts.forEachIndexed { index, account -> - if (account == CallManager.getPrimaryCall()?.details?.accountHandle) { + val simLabels = getAvailableSIMCardLabels() + if (simLabels.size > 1) { + simLabels.forEachIndexed { index, sim -> + if (sim.handle == CallManager.getPrimaryCall()?.details?.accountHandle) { binding.apply { - callSimId.text = "${index + 1}" + callSimId.text = sim.id.toString() callSimId.beVisible() callSimImage.beVisible() + callSimImage.applyColorFilter(sim.color.adjustSimColorForBackground(getProperBackgroundColor())) } val acceptDrawableId = when (index) { diff --git a/app/src/main/kotlin/org/fossify/phone/adapters/RecentCallsAdapter.kt b/app/src/main/kotlin/org/fossify/phone/adapters/RecentCallsAdapter.kt index e7aae993c..92a58f0e8 100644 --- a/app/src/main/kotlin/org/fossify/phone/adapters/RecentCallsAdapter.kt +++ b/app/src/main/kotlin/org/fossify/phone/adapters/RecentCallsAdapter.kt @@ -529,16 +529,16 @@ class RecentCallsAdapter( setTextSize(TypedValue.COMPLEX_UNIT_PX, currentFontSize * 0.8f) beVisibleIf( phoneNumber != null - && phoneNumber.countryCodeSource != Phonenumber.PhoneNumber.CountryCodeSource.FROM_DEFAULT_COUNTRY - && (location != locale.displayCountry || matchingContact == null) + && phoneNumber.countryCodeSource != Phonenumber.PhoneNumber.CountryCodeSource.FROM_DEFAULT_COUNTRY + && (location != locale.displayCountry || matchingContact == null) ) } itemRecentsSimImage.beVisibleIf(areMultipleSIMsAvailable && call.simID != -1) itemRecentsSimId.beVisibleIf(areMultipleSIMsAvailable && call.simID != -1) if (areMultipleSIMsAvailable && call.simID != -1) { - itemRecentsSimImage.applyColorFilter(textColor) - itemRecentsSimId.setTextColor(textColor.getContrastColor()) + itemRecentsSimImage.applyColorFilter(call.simColor.adjustSimColorForBackground(backgroundColor)) + itemRecentsSimId.setTextColor(backgroundColor) itemRecentsSimId.text = call.simID.toString() } @@ -614,19 +614,19 @@ class RecentCallsDiffCallback : DiffUtil.ItemCallback() { oldItem is CallLogItem.Date && newItem is CallLogItem.Date -> oldItem.timestamp == newItem.timestamp && oldItem.dayCode == newItem.dayCode oldItem is RecentCall && newItem is RecentCall -> { oldItem.phoneNumber == newItem.phoneNumber && - oldItem.name == newItem.name && - oldItem.photoUri == newItem.photoUri && - oldItem.startTS == newItem.startTS && - oldItem.duration == newItem.duration && - oldItem.type == newItem.type && - oldItem.simID == newItem.simID && - oldItem.specificNumber == newItem.specificNumber && - oldItem.specificType == newItem.specificType && - oldItem.isUnknownNumber == newItem.isUnknownNumber && - oldItem.groupedCalls?.size == newItem.groupedCalls?.size + oldItem.name == newItem.name && + oldItem.photoUri == newItem.photoUri && + oldItem.startTS == newItem.startTS && + oldItem.duration == newItem.duration && + oldItem.type == newItem.type && + oldItem.simID == newItem.simID && + oldItem.specificNumber == newItem.specificNumber && + oldItem.specificType == newItem.specificType && + oldItem.isUnknownNumber == newItem.isUnknownNumber && + oldItem.groupedCalls?.size == newItem.groupedCalls?.size } else -> false } } -} +} \ No newline at end of file diff --git a/app/src/main/kotlin/org/fossify/phone/extensions/Context.kt b/app/src/main/kotlin/org/fossify/phone/extensions/Context.kt index 72a9fac93..dbbf84128 100644 --- a/app/src/main/kotlin/org/fossify/phone/extensions/Context.kt +++ b/app/src/main/kotlin/org/fossify/phone/extensions/Context.kt @@ -29,7 +29,7 @@ fun Context.getAvailableSIMCardLabels(): List { label += " ($address)" } - val SIM = SIMAccount(index + 1, phoneAccount.accountHandle, label, address.substringAfter("tel:")) + val SIM = SIMAccount(index + 1, phoneAccount.accountHandle, label, address.substringAfter("tel:"), phoneAccount.highlightColor) SIMAccounts.add(SIM) } } catch (ignored: Exception) { diff --git a/app/src/main/kotlin/org/fossify/phone/helpers/RecentsHelper.kt b/app/src/main/kotlin/org/fossify/phone/helpers/RecentsHelper.kt index 2857e25d9..7d7d63d44 100644 --- a/app/src/main/kotlin/org/fossify/phone/helpers/RecentsHelper.kt +++ b/app/src/main/kotlin/org/fossify/phone/helpers/RecentsHelper.kt @@ -12,6 +12,7 @@ import org.fossify.phone.R import org.fossify.phone.activities.SimpleActivity import org.fossify.phone.extensions.getAvailableSIMCardLabels import org.fossify.phone.models.RecentCall +import org.fossify.phone.models.SIMAccount class RecentsHelper(private val context: Context) { companion object { @@ -138,9 +139,9 @@ class RecentsHelper(private val context: Context) { Calls.PHONE_ACCOUNT_ID ) - val accountIdToSimIDMap = HashMap() + val accountIdToSimAccountMap = HashMap() context.getAvailableSIMCardLabels().forEach { - accountIdToSimIDMap[it.handle.id] = it.id + accountIdToSimAccountMap[it.handle.id] = it } val cursor = if (isNougatPlus()) { @@ -232,7 +233,7 @@ class RecentsHelper(private val context: Context) { val duration = cursor.getIntValue(Calls.DURATION) val type = cursor.getIntValue(Calls.TYPE) val accountId = cursor.getStringValue(Calls.PHONE_ACCOUNT_ID) - val simID = accountIdToSimIDMap[accountId] ?: -1 + val simAccount = accountIdToSimAccountMap[accountId] var specificNumber = "" var specificType = "" @@ -255,7 +256,8 @@ class RecentsHelper(private val context: Context) { startTS = startTS, duration = duration, type = type, - simID = simID, + simID = simAccount?.id ?: -1, + simColor = simAccount?.color ?: -1, specificNumber = specificNumber, specificType = specificType, isUnknownNumber = isUnknownNumber diff --git a/app/src/main/kotlin/org/fossify/phone/models/RecentCall.kt b/app/src/main/kotlin/org/fossify/phone/models/RecentCall.kt index 3a599b490..53b3707c0 100644 --- a/app/src/main/kotlin/org/fossify/phone/models/RecentCall.kt +++ b/app/src/main/kotlin/org/fossify/phone/models/RecentCall.kt @@ -18,6 +18,7 @@ data class RecentCall( val duration: Int, val type: Int, val simID: Int, + val simColor: Int, val specificNumber: String, val specificType: String, val isUnknownNumber: Boolean, diff --git a/app/src/main/kotlin/org/fossify/phone/models/SIMAccount.kt b/app/src/main/kotlin/org/fossify/phone/models/SIMAccount.kt index 47dd7d3a4..f004e64a1 100644 --- a/app/src/main/kotlin/org/fossify/phone/models/SIMAccount.kt +++ b/app/src/main/kotlin/org/fossify/phone/models/SIMAccount.kt @@ -2,4 +2,10 @@ package org.fossify.phone.models import android.telecom.PhoneAccountHandle -data class SIMAccount(val id: Int, val handle: PhoneAccountHandle, val label: String, val phoneNumber: String) +data class SIMAccount( + val id: Int, + val handle: PhoneAccountHandle, + val label: String, + val phoneNumber: String, + val color: Int, +) diff --git a/app/src/main/res/layout/item_recent_call.xml b/app/src/main/res/layout/item_recent_call.xml index 66ed64209..7455d02dc 100644 --- a/app/src/main/res/layout/item_recent_call.xml +++ b/app/src/main/res/layout/item_recent_call.xml @@ -63,6 +63,7 @@ android:gravity="center" android:textColor="@color/md_grey_black" android:textSize="@dimen/small_text_size" + android:textStyle="bold" android:visibility="gone" app:layout_constraintBottom_toBottomOf="@+id/item_recents_sim_image" app:layout_constraintEnd_toEndOf="@+id/item_recents_sim_image"