Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions app/src/main/kotlin/org/fossify/phone/activities/CallActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}

Expand Down Expand Up @@ -614,19 +614,19 @@ class RecentCallsDiffCallback : DiffUtil.ItemCallback<CallLogItem>() {
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
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ fun Context.getAvailableSIMCardLabels(): List<SIMAccount> {
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) {
Expand Down
10 changes: 6 additions & 4 deletions app/src/main/kotlin/org/fossify/phone/helpers/RecentsHelper.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -138,9 +139,9 @@ class RecentsHelper(private val context: Context) {
Calls.PHONE_ACCOUNT_ID
)

val accountIdToSimIDMap = HashMap<String, Int>()
val accountIdToSimAccountMap = HashMap<String, SIMAccount>()
context.getAvailableSIMCardLabels().forEach {
accountIdToSimIDMap[it.handle.id] = it.id
accountIdToSimAccountMap[it.handle.id] = it
}

val cursor = if (isNougatPlus()) {
Expand Down Expand Up @@ -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 = ""

Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions app/src/main/kotlin/org/fossify/phone/models/RecentCall.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
8 changes: 7 additions & 1 deletion app/src/main/kotlin/org/fossify/phone/models/SIMAccount.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
1 change: 1 addition & 0 deletions app/src/main/res/layout/item_recent_call.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Loading