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
Original file line number Diff line number Diff line change
Expand Up @@ -625,7 +625,9 @@ class CallActivity : SimpleActivity() {
callSimId.text = sim.id.toString()
callSimId.beVisible()
callSimImage.beVisible()
callSimImage.applyColorFilter(sim.color.adjustSimColorForBackground(getProperBackgroundColor()))
val simColor = sim.color.adjustForContrast(getProperBackgroundColor())
callSimId.setTextColor(simColor.getContrastColor())
callSimImage.applyColorFilter(simColor)
}

val acceptDrawableId = when (index) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ class RecentCallsAdapter(
private var durationPadding = resources.getDimension(R.dimen.normal_margin).toInt()
private var phoneNumberUtilInstance: PhoneNumberUtil = PhoneNumberUtil.getInstance()
private var phoneNumberOfflineGeocoderInstance: PhoneNumberOfflineGeocoder = PhoneNumberOfflineGeocoder.getInstance()
private val cachedSimColors = HashMap<Pair<Int,Int>, Int>()

init {
initDrawables()
Expand Down Expand Up @@ -537,8 +538,9 @@ class RecentCallsAdapter(
itemRecentsSimImage.beVisibleIf(areMultipleSIMsAvailable && call.simID != -1)
itemRecentsSimId.beVisibleIf(areMultipleSIMsAvailable && call.simID != -1)
if (areMultipleSIMsAvailable && call.simID != -1) {
itemRecentsSimImage.applyColorFilter(call.simColor.adjustSimColorForBackground(backgroundColor))
itemRecentsSimId.setTextColor(backgroundColor)
val simColor = getAdjustedSimColor(call.simColor)
itemRecentsSimImage.applyColorFilter(simColor)
itemRecentsSimId.setTextColor(simColor.getContrastColor())
itemRecentsSimId.text = call.simID.toString()
}

Expand Down Expand Up @@ -583,6 +585,12 @@ class RecentCallsAdapter(
}
}

private fun getAdjustedSimColor(simColor: Int): Int {
return cachedSimColors.getOrPut(simColor to backgroundColor) {
simColor.adjustForContrast(backgroundColor)
}
}

private inner class RecentCallDateViewHolder(val binding: ItemRecentsDateBinding) : ViewHolder(binding.root) {
fun bind(date: CallLogItem.Date) {
binding.dateTextView.apply {
Expand Down
16 changes: 12 additions & 4 deletions app/src/main/kotlin/org/fossify/phone/extensions/Context.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ val Context.powerManager: PowerManager get() = getSystemService(Context.POWER_SE

@SuppressLint("MissingPermission")
fun Context.getAvailableSIMCardLabels(): List<SIMAccount> {
val SIMAccounts = mutableListOf<SIMAccount>()
val simAccounts = mutableListOf<SIMAccount>()
try {
telecomManager.callCapablePhoneAccounts.forEachIndexed { index, account ->
val phoneAccount = telecomManager.getPhoneAccount(account)
Expand All @@ -29,12 +29,20 @@ fun Context.getAvailableSIMCardLabels(): List<SIMAccount> {
label += " ($address)"
}

val SIM = SIMAccount(index + 1, phoneAccount.accountHandle, label, address.substringAfter("tel:"), phoneAccount.highlightColor)
SIMAccounts.add(SIM)
simAccounts.add(
SIMAccount(
id = index + 1,
handle = phoneAccount.accountHandle,
label = label,
phoneNumber = address.substringAfter("tel:"),
color = phoneAccount.highlightColor
)
)
}
} catch (ignored: Exception) {
}
return SIMAccounts

return simAccounts
}

@SuppressLint("MissingPermission")
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/layout/item_recent_call.xml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@
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
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ detekt = "1.23.8"
#Eventbus
eventbus = "3.3.1"
#Fossify
commons = "3.0.1"
commons = "3.0.3"
#Gradle
gradlePlugins-agp = "8.10.1"
#Other
Expand Down
Loading